1 |
/* |
/**< |
2 |
* Bit lists |
* Bit lists |
3 |
* by Tom Epperly |
* by Tom Epperly |
4 |
* Version: $Revision: 1.7 $ |
* Version: $Revision: 1.7 $ |
32 |
* Bits are numbered 0 .. (BLength(list)-1) |
* Bits are numbered 0 .. (BLength(list)-1) |
33 |
*/ |
*/ |
34 |
|
|
35 |
/* |
/**< |
36 |
* When #including bit.h, make sure these files are #included first: |
* When #including bit.h, make sure these files are #included first: |
37 |
* #include "compiler.h" |
* #include "compiler.h" |
38 |
*/ |
*/ |
47 |
}; |
}; |
48 |
|
|
49 |
extern struct BitList *CreateBList(unsigned long); |
extern struct BitList *CreateBList(unsigned long); |
50 |
/* |
/**< |
51 |
* struct BitList *CreateBList(len) |
* struct BitList *CreateBList(len) |
52 |
* unsigned long len; |
* unsigned long len; |
53 |
* Create a bit list with len elements. The elements are all initialized to |
* Create a bit list with len elements. The elements are all initialized to |
55 |
*/ |
*/ |
56 |
|
|
57 |
extern struct BitList *CreateFBList(unsigned long); |
extern struct BitList *CreateFBList(unsigned long); |
58 |
/* |
/**< |
59 |
* struct BitList *CreateFBList(len) |
* struct BitList *CreateFBList(len) |
60 |
* unsigned long len; |
* unsigned long len; |
61 |
* Create a bit list with len elements. The elements are all initialized to |
* Create a bit list with len elements. The elements are all initialized to |
63 |
*/ |
*/ |
64 |
|
|
65 |
extern struct BitList *ExpandBList(struct BitList *,unsigned long); |
extern struct BitList *ExpandBList(struct BitList *,unsigned long); |
66 |
/* |
/**< |
67 |
* struct BitList *ExpandBList(bl,len) |
* struct BitList *ExpandBList(bl,len) |
68 |
* struct BitList *bl; |
* struct BitList *bl; |
69 |
* unsigned long len; |
* unsigned long len; |
74 |
*/ |
*/ |
75 |
|
|
76 |
extern struct BitList *ExpandFBList(struct BitList *,unsigned long); |
extern struct BitList *ExpandFBList(struct BitList *,unsigned long); |
77 |
/* |
/**< |
78 |
* struct BitList *ExpandBList(bl,len) |
* struct BitList *ExpandBList(bl,len) |
79 |
* struct BitList *bl; |
* struct BitList *bl; |
80 |
* unsigned long len; |
* unsigned long len; |
85 |
*/ |
*/ |
86 |
|
|
87 |
extern void DestroyBList(struct BitList *); |
extern void DestroyBList(struct BitList *); |
88 |
/* |
/**< |
89 |
* void DestroyBList(bl) |
* void DestroyBList(bl) |
90 |
* struct BitList *bl; |
* struct BitList *bl; |
91 |
* Deallocate the memory for bl. |
* Deallocate the memory for bl. |
92 |
*/ |
*/ |
93 |
|
|
94 |
extern struct BitList *CopyBList(CONST struct BitList *); |
extern struct BitList *CopyBList(CONST struct BitList *); |
95 |
/* |
/**< |
96 |
* struct BitList *CopyBList(bl) |
* struct BitList *CopyBList(bl) |
97 |
* struct BitList *bl; |
* struct BitList *bl; |
98 |
* Make a copy of bl and return it. The length of the copy equals that of bl, |
* Make a copy of bl and return it. The length of the copy equals that of bl, |
101 |
*/ |
*/ |
102 |
|
|
103 |
extern void OverwriteBList(CONST struct BitList *, struct BitList *); |
extern void OverwriteBList(CONST struct BitList *, struct BitList *); |
104 |
/* |
/**< |
105 |
* struct BitList *OverwriteBList(src,target) |
* struct BitList *OverwriteBList(src,target) |
106 |
* struct BitList *src, *target; |
* struct BitList *src, *target; |
107 |
* src and target must be the same length or this function will not return. |
* src and target must be the same length or this function will not return. |
111 |
*/ |
*/ |
112 |
|
|
113 |
extern unsigned long BitListBytes(CONST struct BitList *); |
extern unsigned long BitListBytes(CONST struct BitList *); |
114 |
/* |
/**< |
115 |
* unsigned long BitListBytes(bl) |
* unsigned long BitListBytes(bl) |
116 |
* struct BitList *bl; |
* struct BitList *bl; |
117 |
* unsigned long bytes; |
* unsigned long bytes; |
119 |
*/ |
*/ |
120 |
|
|
121 |
extern void SetBit(struct BitList *,unsigned long); |
extern void SetBit(struct BitList *,unsigned long); |
122 |
/* |
/**< |
123 |
* void SetBit(bl,pos) |
* void SetBit(bl,pos) |
124 |
* struct BitList *bl; |
* struct BitList *bl; |
125 |
* unsigned long pos; |
* unsigned long pos; |
127 |
*/ |
*/ |
128 |
|
|
129 |
extern void ClearBit(struct BitList *,unsigned long); |
extern void ClearBit(struct BitList *,unsigned long); |
130 |
/* |
/**< |
131 |
* void ClearBit(bl,pos) |
* void ClearBit(bl,pos) |
132 |
* struct BitList *bl; |
* struct BitList *bl; |
133 |
* unsigned long pos; |
* unsigned long pos; |
135 |
*/ |
*/ |
136 |
|
|
137 |
extern void CondSetBit(struct BitList *,unsigned long,int); |
extern void CondSetBit(struct BitList *,unsigned long,int); |
138 |
/* |
/**< |
139 |
* void CondSetBit(bl,pos,cond) |
* void CondSetBit(bl,pos,cond) |
140 |
* struct BitList *bl; |
* struct BitList *bl; |
141 |
* unsigned long pos; |
* unsigned long pos; |
144 |
*/ |
*/ |
145 |
|
|
146 |
extern int ReadBit(CONST struct BitList *,unsigned long); |
extern int ReadBit(CONST struct BitList *,unsigned long); |
147 |
/* |
/**< |
148 |
* int ReadBit(bl,pos) |
* int ReadBit(bl,pos) |
149 |
* struct BitList *bl; |
* struct BitList *bl; |
150 |
* unsigned long pos; |
* unsigned long pos; |
152 |
*/ |
*/ |
153 |
|
|
154 |
extern void IntersectBLists(struct BitList *,CONST struct BitList *); |
extern void IntersectBLists(struct BitList *,CONST struct BitList *); |
155 |
/* |
/**< |
156 |
* void IntersectBList(bl1,bl2) |
* void IntersectBList(bl1,bl2) |
157 |
* struct BitList *bl1; |
* struct BitList *bl1; |
158 |
* const struct BitList *bl2; |
* const struct BitList *bl2; |
161 |
*/ |
*/ |
162 |
|
|
163 |
extern void UnionBLists(struct BitList *,CONST struct BitList *); |
extern void UnionBLists(struct BitList *,CONST struct BitList *); |
164 |
/* |
/**< |
165 |
* void UnionBLists(bl1,bl2) |
* void UnionBLists(bl1,bl2) |
166 |
* struct BitList *bl1; |
* struct BitList *bl1; |
167 |
* const struct BitList *bl2; |
* const struct BitList *bl2; |
175 |
#define BLength(bl) BLengthF(bl) |
#define BLength(bl) BLengthF(bl) |
176 |
#endif |
#endif |
177 |
extern unsigned long BLengthF(CONST struct BitList *); |
extern unsigned long BLengthF(CONST struct BitList *); |
178 |
/* |
/**< |
179 |
* macro BLength(bl) |
* macro BLength(bl) |
180 |
* unsigned long BLengthF(bl) |
* unsigned long BLengthF(bl) |
181 |
* const struct BitList *bl; |
* const struct BitList *bl; |
183 |
*/ |
*/ |
184 |
|
|
185 |
extern int BitListEmpty(CONST struct BitList *); |
extern int BitListEmpty(CONST struct BitList *); |
186 |
/* |
/**< |
187 |
* int BitListEmpty(bl) |
* int BitListEmpty(bl) |
188 |
* const struct BitList *bl; |
* const struct BitList *bl; |
189 |
* Return a true value if bl is empty; otherwise, it returns a false value. |
* Return a true value if bl is empty; otherwise, it returns a false value. |
191 |
|
|
192 |
|
|
193 |
extern int CompBList(struct BitList *,struct BitList *); |
extern int CompBList(struct BitList *,struct BitList *); |
194 |
/* |
/**< |
195 |
* int CompBList(bl,b2) |
* int CompBList(bl,b2) |
196 |
* const struct BitList *bl; |
* const struct BitList *bl; |
197 |
* const struct BitList *b2; |
* const struct BitList *b2; |
199 |
*/ |
*/ |
200 |
|
|
201 |
extern unsigned long FirstNonZeroBit(CONST struct BitList *); |
extern unsigned long FirstNonZeroBit(CONST struct BitList *); |
202 |
/* |
/**< |
203 |
* unsigned long FirstNonZeroBit(bl) |
* unsigned long FirstNonZeroBit(bl) |
204 |
* const struct BitList *bl; |
* const struct BitList *bl; |
205 |
* Return the first non-zero bit. If it is unable to find a non-zero |
* Return the first non-zero bit. If it is unable to find a non-zero |
206 |
* it will return a number greater than BLength(bl). |
* it will return a number greater than BLength(bl). |
207 |
*/ |
*/ |
208 |
#endif /* __BIT_H_SEEN__ */ |
#endif /**< __BIT_H_SEEN__ */ |