+struct bbitset_struct
+{
+ const struct bitset_vtable *vtable;
+ bitset_windex cindex; /* Cache word index. */
+ bitset_windex csize; /* Cache size in words. */
+ bitset_word *cdata; /* Cache data pointer. */
+ bitset_bindex n_bits; /* Number of bits. */
+ /* Perhaps we could sacrifice another word to indicate
+ that the bitset is known to be zero, that a bit has been set
+ in the cache, and that a bit has been cleared in the cache.
+ This would speed up some of the searches but slightly slow down
+ bit set/reset operations of cached bits. */
+};
+
+
+typedef union bitset_union *bitset;
+
+
+/* Private accessor macros to bitset structure. */
+#define BITSET_VTABLE_(SRC) (SRC)->b.vtable
+#define BITSET_CINDEX_(SRC) (SRC)->b.cindex
+#define BITSET_CDATA_(SRC) (SRC)->b.cdata
+#define BITSET_CSIZE_(SRC) (SRC)->b.csize
+#define BITSET_NBITS_(SRC) (SRC)->b.n_bits
+
+
+/* The contents of this structure should be considered private. */
+struct bitset_vtable
+{
+ void (*set) (bitset, bitset_bindex);
+ void (*reset) (bitset, bitset_bindex);
+ bool (*toggle) (bitset, bitset_bindex);
+ bool (*test) (bitset, bitset_bindex);
+ bitset_bindex (*resize) (bitset, bitset_bindex);
+ bitset_bindex (*size) (bitset);
+ bitset_bindex (*count) (bitset);
+
+ bool (*empty_p) (bitset);
+ void (*ones) (bitset);
+ void (*zero) (bitset);
+
+ void (*copy) (bitset, bitset);
+ bool (*disjoint_p) (bitset, bitset);
+ bool (*equal_p) (bitset, bitset);
+ void (*not) (bitset, bitset);
+ bool (*subset_p) (bitset, bitset);
+
+ void (*and) (bitset, bitset, bitset);
+ bool (*and_cmp) (bitset, bitset, bitset);
+ void (*andn) (bitset, bitset, bitset);
+ bool (*andn_cmp) (bitset, bitset, bitset);
+ void (*or) (bitset, bitset, bitset);
+ bool (*or_cmp) (bitset, bitset, bitset);
+ void (*xor) (bitset, bitset, bitset);
+ bool (*xor_cmp) (bitset, bitset, bitset);
+
+ void (*and_or) (bitset, bitset, bitset, bitset);
+ bool (*and_or_cmp) (bitset, bitset, bitset, bitset);
+ void (*andn_or) (bitset, bitset, bitset, bitset);
+ bool (*andn_or_cmp) (bitset, bitset, bitset, bitset);
+ void (*or_and) (bitset, bitset, bitset, bitset);
+ bool (*or_and_cmp) (bitset, bitset, bitset, bitset);
+
+ bitset_bindex (*list) (bitset, bitset_bindex *, bitset_bindex,
+ bitset_bindex *);
+ bitset_bindex (*list_reverse) (bitset, bitset_bindex *, bitset_bindex,
+ bitset_bindex *);
+ void (*free) (bitset);
+ enum bitset_type type;
+};
+
+#define BITSET_COMPATIBLE_(BSET1, BSET2) \
+((BSET1)->b.vtable == (BSET2)->b.vtable)
+
+#define BITSET_CHECK2_(DST, SRC) \
+if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();
+
+#define BITSET_CHECK3_(DST, SRC1, SRC2) \
+if (!BITSET_COMPATIBLE_ (DST, SRC1) \
+ || !BITSET_COMPATIBLE_ (DST, SRC2)) abort ();
+
+#define BITSET_CHECK4_(DST, SRC1, SRC2, SRC3) \
+if (!BITSET_COMPATIBLE_ (DST, SRC1) || !BITSET_COMPATIBLE_ (DST, SRC2) \
+ || !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();
+
+
+/* Redefine number of bits in bitset DST. */
+#define BITSET_RESIZE_(DST, SIZE) (DST)->b.vtable->resize (DST, SIZE)
+