1 /* PSPP - computes sample statistics.
2 Copyright (C) 2007 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 /* Bitmap, implemented as a balanced binary tree.
21 Each operation has O(lg N) cost, where N is the number of
22 contiguous regions of 1-bits in the bitmap. Also, a cache
23 reduces the second and subsequent containment tests within a
24 single contiguous region to O(1). */
26 #ifndef LIBPSPP_RANGE_SET_H
27 #define LIBPSPP_RANGE_SET_H
33 struct range_set *range_set_create (void);
34 struct range_set *range_set_create_pool (struct pool *);
35 void range_set_destroy (struct range_set *);
37 void range_set_insert (struct range_set *,
38 unsigned long int start, unsigned long int width);
39 void range_set_delete (struct range_set *,
40 unsigned long int start, unsigned long int width);
41 bool range_set_allocate (struct range_set *, unsigned long int request,
42 unsigned long int *start, unsigned long int *width);
43 bool range_set_contains (const struct range_set *, unsigned long int position);
45 bool range_set_is_empty (const struct range_set *);
47 const struct range_set_node *range_set_first (const struct range_set *);
48 const struct range_set_node *range_set_next (const struct range_set *,
49 const struct range_set_node *);
50 unsigned long int range_set_node_get_start (const struct range_set_node *);
51 unsigned long int range_set_node_get_end (const struct range_set_node *);
52 unsigned long int range_set_node_get_width (const struct range_set_node *);
54 #endif /* libpspp/range-set.h */