Lely core libraries  2.3.4
bitset.h
Go to the documentation of this file.
1 
22 #ifndef LELY_UTIL_BITSET_H_
23 #define LELY_UTIL_BITSET_H_
24 
25 #include <lely/util/util.h>
26 
28 struct bitset {
30  int size;
32  unsigned int *bits;
33 };
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
51 int bitset_init(struct bitset *set, int size);
52 
54 void bitset_fini(struct bitset *set);
55 
57 int bitset_size(const struct bitset *set);
58 
69 int bitset_resize(struct bitset *set, int size);
70 
72 int bitset_test(const struct bitset *set, int n);
73 
75 void bitset_set(struct bitset *set, int n);
76 
78 void bitset_set_all(struct bitset *set);
79 
81 void bitset_clr(struct bitset *set, int n);
82 
84 void bitset_clr_all(struct bitset *set);
85 
87 void bitset_compl(struct bitset *set);
88 
93 int bitset_ffs(const struct bitset *set);
94 
99 int bitset_ffz(const struct bitset *set);
100 
105 int bitset_fns(const struct bitset *set, int n);
106 
111 int bitset_fnz(const struct bitset *set, int n);
112 
113 #ifdef __cplusplus
114 }
115 #endif
116 
117 #endif // !LELY_UTIL_BITSET_H_
bitset_init
int bitset_init(struct bitset *set, int size)
Initializes a bitset.
Definition: bitset.c:39
util.h
bitset_compl
void bitset_compl(struct bitset *set)
Flip all bits in set.
Definition: bitset.c:140
bitset_fini
void bitset_fini(struct bitset *set)
Finalizes a bitset.
Definition: bitset.c:60
bitset_clr
void bitset_clr(struct bitset *set, int n)
Clears bit n in set.
Definition: bitset.c:125
bitset_clr_all
void bitset_clr_all(struct bitset *set)
Clears all bits in set.
Definition: bitset.c:133
bitset_resize
int bitset_resize(struct bitset *set, int size)
Resizes a bitset.
Definition: bitset.c:76
bitset_set
void bitset_set(struct bitset *set, int n)
Sets bit n in set.
Definition: bitset.c:110
bitset_test
int bitset_test(const struct bitset *set, int n)
Returns 1 if bit n in set is set, and 0 otherwise.
Definition: bitset.c:102
bitset::size
int size
The number of integers in bits.
Definition: bitset.h:30
bitset_fnz
int bitset_fnz(const struct bitset *set, int n)
Returns the index (starting from one) of the first zero bit higher or equal to n in set,...
Definition: bitset.c:202
bitset_size
int bitset_size(const struct bitset *set)
Returns the size (in number of bits) of set.
Definition: bitset.c:70
bitset
A variable-sized bitset.
Definition: bitset.h:28
bitset_ffz
int bitset_ffz(const struct bitset *set)
Returns the index (starting from one) of the first zero bit in set, or 0 if all bits are set.
Definition: bitset.c:161
bitset_fns
int bitset_fns(const struct bitset *set, int n)
Returns the index (starting from one) of the first set bit higher or equal to n in set,...
Definition: bitset.c:175
bitset_set_all
void bitset_set_all(struct bitset *set)
Sets all bits in set.
Definition: bitset.c:118
bitset_ffs
int bitset_ffs(const struct bitset *set)
Returns the index (starting from one) of the first set bit in set, or 0 if all bits are zero.
Definition: bitset.c:147
bitset::bits
unsigned int * bits
An array of size integers.
Definition: bitset.h:32