/[bison]/bison/lib/bbitset.h
ViewVC logotype

Diff of /bison/lib/bbitset.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.12 by eggert, Sat May 24 19:16:02 2003 UTC revision 1.13 by eggert, Tue Jun 17 07:19:50 2003 UTC
# Line 24  Foundation, Inc., 59 Temple Place - Suit Line 24  Foundation, Inc., 59 Temple Place - Suit
24  #include <stdbool.h>  #include <stdbool.h>
25  #include <limits.h>  #include <limits.h>
26    
27  /* Currently we support three flavours of bitsets:  /* Currently we support five flavours of bitsets:
28     BITSET_ARRAY:  Array of bits (fixed size, fast for dense bitsets).     BITSET_ARRAY:  Array of bits (fixed size, fast for dense bitsets).
29     BITSET_LIST:   Linked list of array of bits (variable size, least storage                    Memory for bit array and bitset structure allocated
30                      contiguously.
31       BITSET_LIST:   Linked list of arrays of bits (variable size, least storage
32                    for large very sparse sets).                    for large very sparse sets).
33     BITSET_TABLE:  Expandable table of pointers to array of bits     BITSET_TABLE:  Expandable table of pointers to arrays of bits
34                    (variable size, less storage for large sparse sets).                    (variable size, less storage for large sparse sets).
35                      Faster than BITSET_LIST for random access.
36     BITSET_STATS:  Wrapper bitset for internal use only.     BITSET_VARRAY: Variable array of bits (variable size, fast for
37                      dense bitsets).
38       BITSET_STATS:  Wrapper bitset for internal use only.  Used for gathering
39                      statistics and/or better run-time checking.
40  */  */
41  enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_TYPE_NUM,  enum bitset_type {BITSET_ARRAY, BITSET_LIST, BITSET_TABLE, BITSET_VARRAY,
42                    BITSET_STATS};                    BITSET_TYPE_NUM, BITSET_STATS};
43  #define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset"}  #define BITSET_TYPE_NAMES {"abitset", "lbitset", "ebitset", "vbitset"}
44    
45  extern const char * const bitset_type_names[];  extern const char * const bitset_type_names[];
46    
# Line 78  enum bitset_ops {BITSET_OP_ZERO, BITSET_ Line 83  enum bitset_ops {BITSET_OP_ZERO, BITSET_
83    
84  struct bbitset_struct  struct bbitset_struct
85  {  {
86    const struct bitset_vtable * vtable;    const struct bitset_vtable *vtable;
87    bitset_windex cindex;         /* Cache word index.  */    bitset_windex cindex;         /* Cache word index.  */
88    bitset_windex csize;          /* Cache size in words.  */    bitset_windex csize;          /* Cache size in words.  */
89    bitset_word *cdata;           /* Cache data pointer.  */    bitset_word *cdata;           /* Cache data pointer.  */
90      bitset_bindex n_bits;         /* Number of bits.  */
91    /* Perhaps we could sacrifice another word to indicate    /* Perhaps we could sacrifice another word to indicate
92       that the bitset is known to be zero, that a bit has been set       that the bitset is known to be zero, that a bit has been set
93       in the cache, and that a bit has been cleared in the cache.       in the cache, and that a bit has been cleared in the cache.
# Line 93  struct bbitset_struct Line 99  struct bbitset_struct
99  typedef union bitset_union *bitset;  typedef union bitset_union *bitset;
100    
101    
102    /* Private accessor macros to bitset structure.  */
103    #define BITSET_VTABLE_(SRC) (SRC)->b.vtable
104    #define BITSET_CINDEX_(SRC) (SRC)->b.cindex
105    #define BITSET_CDATA_(SRC) (SRC)->b.cdata
106    #define BITSET_CSIZE_(SRC) (SRC)->b.csize
107    #define BITSET_NBITS_(SRC) (SRC)->b.n_bits
108    
109    
110  /* The contents of this structure should be considered private.  */  /* The contents of this structure should be considered private.  */
111  struct bitset_vtable  struct bitset_vtable
112  {  {
# Line 100  struct bitset_vtable Line 114  struct bitset_vtable
114    void (*reset) PARAMS ((bitset, bitset_bindex));    void (*reset) PARAMS ((bitset, bitset_bindex));
115    bool (*toggle) PARAMS ((bitset, bitset_bindex));    bool (*toggle) PARAMS ((bitset, bitset_bindex));
116    bool (*test) PARAMS ((bitset, bitset_bindex));    bool (*test) PARAMS ((bitset, bitset_bindex));
117      bitset_bindex (*resize) PARAMS ((bitset, bitset_bindex));
118    bitset_bindex (*size) PARAMS ((bitset));    bitset_bindex (*size) PARAMS ((bitset));
119    bitset_bindex (*count) PARAMS ((bitset));    bitset_bindex (*count) PARAMS ((bitset));
120    
# Line 138  struct bitset_vtable Line 153  struct bitset_vtable
153    enum bitset_type type;    enum bitset_type type;
154  };  };
155    
156  #define BITSET_COMPATIBLE_(BSET1, BSET2) ((BSET1)->b.vtable == (BSET2)->b.vtable)  #define BITSET_COMPATIBLE_(BSET1, BSET2) \
157    ((BSET1)->b.vtable == (BSET2)->b.vtable)
158    
159  #define BITSET_CHECK2_(DST, SRC) \  #define BITSET_CHECK2_(DST, SRC) \
160  if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();  if (!BITSET_COMPATIBLE_ (DST, SRC)) abort ();
# Line 152  if (!BITSET_COMPATIBLE_ (DST, SRC1) || ! Line 168  if (!BITSET_COMPATIBLE_ (DST, SRC1) || !
168      || !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();      || !BITSET_COMPATIBLE_ (DST, SRC3)) abort ();
169    
170    
171    /* Redefine number of bits in bitset DST.  */
172    #define BITSET_RESIZE_(DST, SIZE) (DST)->b.vtable->resize (DST, SIZE)
173    
174  /* Return size in bits of bitset SRC.  */  /* Return size in bits of bitset SRC.  */
175  #define BITSET_SIZE_(SRC) (SRC)->b.vtable->size (SRC)  #define BITSET_SIZE_(SRC) (SRC)->b.vtable->size (SRC)
176    
# Line 264  extern bool bitset_toggle_ PARAMS ((bits Line 283  extern bool bitset_toggle_ PARAMS ((bits
283    
284  extern bitset_bindex bitset_count_ PARAMS ((bitset));  extern bitset_bindex bitset_count_ PARAMS ((bitset));
285    
286    extern bitset_bindex bitset_size_ PARAMS ((bitset));
287    
288  extern bool bitset_copy_ PARAMS ((bitset, bitset));  extern bool bitset_copy_ PARAMS ((bitset, bitset));
289    
290  extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));  extern void bitset_and_or_ PARAMS ((bitset, bitset, bitset, bitset));

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26