1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2007 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Bitmap, implemented as a balanced binary tree.
19 Each operation has O(lg N) cost, where N is the number of
20 contiguous regions of 1-bits in the bitmap. Also, a cache
21 reduces the second and subsequent containment tests within a
22 single contiguous region to O(1). */
24 #ifndef LIBPSPP_RANGE_SET_H
25 #define LIBPSPP_RANGE_SET_H
31 struct range_set *range_set_create (void);
32 struct range_set *range_set_create_pool (struct pool *);
33 struct range_set *range_set_clone (const struct range_set *, struct pool *);
34 void range_set_destroy (struct range_set *);
36 void range_set_insert (struct range_set *,
37 unsigned long int start, unsigned long int width);
38 void range_set_delete (struct range_set *,
39 unsigned long int start, unsigned long int width);
40 bool range_set_allocate (struct range_set *, unsigned long int request,
41 unsigned long int *start, unsigned long int *width);
42 bool range_set_contains (const struct range_set *, unsigned long int position);
44 bool range_set_is_empty (const struct range_set *);
46 const struct range_set_node *range_set_first (const struct range_set *);
47 const struct range_set_node *range_set_next (const struct range_set *,
48 const struct range_set_node *);
49 unsigned long int range_set_node_get_start (const struct range_set_node *);
50 unsigned long int range_set_node_get_end (const struct range_set_node *);
51 unsigned long int range_set_node_get_width (const struct range_set_node *);
53 #endif /* libpspp/range-set.h */