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_
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
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
int bitset_size(const struct bitset *set)
Returns the size (in number of bits) of set.
Definition: bitset.c:70
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
int bitset_resize(struct bitset *set, int size)
Resizes a bitset.
Definition: bitset.c:76
void bitset_set(struct bitset *set, int n)
Sets bit n in set.
Definition: bitset.c:110
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
void bitset_compl(struct bitset *set)
Flip all bits in set.
Definition: bitset.c:140
void bitset_clr_all(struct bitset *set)
Clears all bits in set.
Definition: bitset.c:133
void bitset_clr(struct bitset *set, int n)
Clears bit n in set.
Definition: bitset.c:125
void bitset_fini(struct bitset *set)
Finalizes a bitset.
Definition: bitset.c:60
int bitset_init(struct bitset *set, int size)
Initializes a bitset.
Definition: bitset.c:39
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
void bitset_set_all(struct bitset *set)
Sets all bits in set.
Definition: bitset.c:118
This is the public header file of the utilities library.
A variable-sized bitset.
Definition: bitset.h:28
unsigned int * bits
An array of size integers.
Definition: bitset.h:32
int size
The number of integers in bits.
Definition: bitset.h:30