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 struct range_set *range_set_clone (const struct range_set *, struct pool *);
36 void range_set_destroy (struct range_set *);
38 void range_set_insert (struct range_set *,
39 unsigned long int start, unsigned long int width);
40 void range_set_delete (struct range_set *,
41 unsigned long int start, unsigned long int width);
42 bool range_set_allocate (struct range_set *, unsigned long int request,
43 unsigned long int *start, unsigned long int *width);
44 bool range_set_contains (const struct range_set *, unsigned long int position);
46 bool range_set_is_empty (const struct range_set *);
48 const struct range_set_node *range_set_first (const struct range_set *);
49 const struct range_set_node *range_set_next (const struct range_set *,
50 const struct range_set_node *);
51 unsigned long int range_set_node_get_start (const struct range_set_node *);
52 unsigned long int range_set_node_get_end (const struct range_set_node *);
53 unsigned long int range_set_node_get_width (const struct range_set_node *);
55 #endif /* libpspp/range-set.h */