X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Frange-set.h;h=636fba8166c1b146cb1ed246352cdba1f30a9d24;hb=5cc8d996ceb67400912b46199ae658cdfbfea180;hp=ee7dac23137d3c39b392b13cb11c7d560c71fc79;hpb=07db00919d6f067fd5dd6c6c1c2c2fba4f42cf21;p=pspp diff --git a/src/libpspp/range-set.h b/src/libpspp/range-set.h index ee7dac2313..636fba8166 100644 --- a/src/libpspp/range-set.h +++ b/src/libpspp/range-set.h @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -25,8 +25,8 @@ #define LIBPSPP_RANGE_SET_H #include -#include -#include +#include "libpspp/bt.h" +#include "libpspp/cast.h" /* A set of ranges. */ struct range_set @@ -53,10 +53,10 @@ struct range_set *range_set_create_pool (struct pool *); struct range_set *range_set_clone (const struct range_set *, struct pool *); void range_set_destroy (struct range_set *); -void range_set_insert (struct range_set *, - unsigned long int start, unsigned long int width); -void range_set_delete (struct range_set *, - unsigned long int start, unsigned long int width); +void range_set_set1 (struct range_set *, + unsigned long int start, unsigned long int width); +void range_set_set0 (struct range_set *, + unsigned long int start, unsigned long int width); bool range_set_allocate (struct range_set *, unsigned long int request, unsigned long int *start, unsigned long int *width); bool range_set_allocate_fully (struct range_set *, unsigned long int request, @@ -67,6 +67,11 @@ unsigned long int range_set_scan (const struct range_set *, static inline bool range_set_is_empty (const struct range_set *); +#define RANGE_SET_FOR_EACH(NODE, RANGE_SET) \ + for ((NODE) = range_set_first (RANGE_SET); \ + (NODE) != NULL; \ + (NODE) = range_set_next (RANGE_SET, NODE)) + static inline const struct range_set_node *range_set_first ( const struct range_set *); static inline const struct range_set_node *range_set_next ( @@ -104,7 +109,7 @@ range_set_is_empty (const struct range_set *rs) /* Returns the node representing the first contiguous region of 1-bits in RS, or a null pointer if RS is empty. - Any call to range_set_insert, range_set_delete, or + Any call to range_set_set1, range_set_set0, or range_set_allocate invalidates the returned node. */ static inline const struct range_set_node * range_set_first (const struct range_set *rs) @@ -117,7 +122,7 @@ range_set_first (const struct range_set *rs) pointer if NODE is the last region in RS. If NODE is null, returns the first region in RS, as for range_set_first. - Any call to range_set_insert, range_set_delete, or + Any call to range_set_set1, range_set_set0, or range_set_allocate invalidates the returned node. */ static inline const struct range_set_node * range_set_next (const struct range_set *rs, const struct range_set_node *node) @@ -129,7 +134,7 @@ range_set_next (const struct range_set *rs, const struct range_set_node *node) /* Returns the node representing the last contiguous region of 1-bits in RS, or a null pointer if RS is empty. - Any call to range_set_insert, range_set_delete, or + Any call to range_set_set1, range_set_set0, or range_set_allocate invalidates the returned node. */ static inline const struct range_set_node * range_set_last (const struct range_set *rs) @@ -142,7 +147,7 @@ range_set_last (const struct range_set *rs) pointer if NODE is the first region in RS. If NODE is null, returns the last region in RS, as for range_set_last. - Any call to range_set_insert, range_set_delete, or + Any call to range_set_set1, range_set_set0, or range_set_allocate invalidates the returned node. */ static inline const struct range_set_node * range_set_prev (const struct range_set *rs, const struct range_set_node *node) @@ -180,7 +185,7 @@ range_set_node_get_width (const struct range_set_node *node) static inline struct range_set_node * range_set_node_from_bt__ (const struct bt_node *bt_node) { - return bt_node ? bt_data (bt_node, struct range_set_node, bt_node) : NULL; + return bt_node ? BT_DATA (bt_node, struct range_set_node, bt_node) : NULL; } /* Returns the next range_set_node in RS after NODE,