- MIN, executing CODE. */
-#define BITSET_REVERSE_EXECUTE(BSET, MIN, N, CODE) \
-do { \
- bitset_bindex _list[BITSET_LIST_SIZE]; \
- bitset_bindex _next = (MIN); \
- int _num; \
- \
- while ((_num = bitset_reverse_list ((BSET), _list, \
- BITSET_LIST_SIZE, &_next))) \
- { \
- int _i; \
- \
- for (_i = 0; _i < _num; _i++) \
- { \
- (N) = _list[_i]; \
- CODE; \
- } \
- if (_num < BITSET_LIST_SIZE) \
- break; \
- } \
-} while (0)
-
-
-/* Define set operations in terms of bit operations. */
-
-#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
-
-#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
-
-#define bitset_union(DST, SRC1, SRC2) bitset_or (DST, SRC1, SRC2)
+ MIN, setting INDEX to the index of each set bit. For example, the
+ following will print the bits set in a bitset in reverse order:
+
+ bitset_bindex i;
+ bitset_iterator iter;
+
+ BITSET_FOR_EACH_REVERSE (iter, src, i, 0)
+ {
+ printf ("%lu ", (unsigned long int) i);
+ };
+*/
+#define BITSET_FOR_EACH_REVERSE(ITER, BSET, INDEX, MIN) \
+ for (ITER.next = (MIN), ITER.num = BITSET_LIST_SIZE; \
+ (ITER.num == BITSET_LIST_SIZE) \
+ && (ITER.num = bitset_list_reverse (BSET, ITER.list, \
+ BITSET_LIST_SIZE, &ITER.next));) \
+ for (ITER.i = 0; \
+ ITER.i < ITER.num && ((INDEX) = ITER.list[ITER.i], 1); \
+ ITER.i++)
+
+
+/* Define set operations in terms of logical operations. */
+
+#define bitset_diff(DST, SRC1, SRC2) bitset_andn (DST, SRC1, SRC2)
+#define bitset_diff_cmp(DST, SRC1, SRC2) bitset_andn_cmp (DST, SRC1, SRC2)
+
+#define bitset_intersection(DST, SRC1, SRC2) bitset_and (DST, SRC1, SRC2)
+#define bitset_intersection_cmp(DST, SRC1, SRC2) bitset_and_cmp (DST, SRC1, SRC2)