Line -... |
Line 1... |
- |
|
1 |
/*
|
- |
|
2 |
* Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
|
- |
|
3 |
* All rights reserved.
|
- |
|
4 |
*
|
- |
|
5 |
* Redistribution and use in source and binary forms, with or without
|
- |
|
6 |
* modification, are permitted provided that the following conditions are met:
|
- |
|
7 |
*
|
- |
|
8 |
* 1. Redistributions of source code must retain the above copyright notice,
|
- |
|
9 |
* this list of conditions and the following disclaimer.
|
- |
|
10 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
- |
|
11 |
* this list of conditions and the following disclaimer in the documentation
|
- |
|
12 |
* and/or other materials provided with the distribution.
|
- |
|
13 |
* 3. Neither the name of The TenDRA Project nor the names of its contributors
|
- |
|
14 |
* may be used to endorse or promote products derived from this software
|
- |
|
15 |
* without specific, prior written permission.
|
- |
|
16 |
*
|
- |
|
17 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
|
- |
|
18 |
* IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
- |
|
19 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
- |
|
20 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
|
- |
|
21 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
- |
|
22 |
* EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
- |
|
23 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
- |
|
24 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
- |
|
25 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
- |
|
26 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
- |
|
27 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
- |
|
28 |
*
|
- |
|
29 |
* $Id$
|
- |
|
30 |
*/
|
1 |
/*
|
31 |
/*
|
2 |
Crown Copyright (c) 1997
|
32 |
Crown Copyright (c) 1997
|
3 |
|
33 |
|
4 |
This TenDRA(r) Computer Program is subject to Copyright
|
34 |
This TenDRA(r) Computer Program is subject to Copyright
|
5 |
owned by the United Kingdom Secretary of State for Defence
|
35 |
owned by the United Kingdom Secretary of State for Defence
|
6 |
acting through the Defence Evaluation and Research Agency
|
36 |
acting through the Defence Evaluation and Research Agency
|
7 |
(DERA). It is made available to Recipients with a
|
37 |
(DERA). It is made available to Recipients with a
|
8 |
royalty-free licence for its use, reproduction, transfer
|
38 |
royalty-free licence for its use, reproduction, transfer
|
9 |
to other parties and amendment for any purpose not excluding
|
39 |
to other parties and amendment for any purpose not excluding
|
10 |
product development provided that any such use et cetera
|
40 |
product development provided that any such use et cetera
|
11 |
shall be deemed to be acceptance of the following conditions:-
|
41 |
shall be deemed to be acceptance of the following conditions:-
|
12 |
|
42 |
|
13 |
(1) Its Recipients shall ensure that this Notice is
|
43 |
(1) Its Recipients shall ensure that this Notice is
|
14 |
reproduced upon any copies or amended versions of it;
|
44 |
reproduced upon any copies or amended versions of it;
|
15 |
|
45 |
|
16 |
(2) Any amended version of it shall be clearly marked to
|
46 |
(2) Any amended version of it shall be clearly marked to
|
17 |
show both the nature of and the organisation responsible
|
47 |
show both the nature of and the organisation responsible
|
18 |
for the relevant amendment or amendments;
|
48 |
for the relevant amendment or amendments;
|
19 |
|
49 |
|
20 |
(3) Its onward transfer from a recipient to another
|
50 |
(3) Its onward transfer from a recipient to another
|
21 |
party shall be deemed to be that party's acceptance of
|
51 |
party shall be deemed to be that party's acceptance of
|
22 |
these conditions;
|
52 |
these conditions;
|
23 |
|
53 |
|
24 |
(4) DERA gives no warranty or assurance as to its
|
54 |
(4) DERA gives no warranty or assurance as to its
|
25 |
quality or suitability for any purpose and DERA accepts
|
55 |
quality or suitability for any purpose and DERA accepts
|
26 |
no liability whatsoever in relation to any use to which
|
56 |
no liability whatsoever in relation to any use to which
|
27 |
it may be put.
|
57 |
it may be put.
|
28 |
*/
|
58 |
*/
|
Line 49... |
Line 79... |
49 |
* This is the bit vector type.
|
79 |
* This is the bit vector type.
|
50 |
*
|
80 |
*
|
51 |
***=== FUNCTIONS ============================================================
|
81 |
***=== FUNCTIONS ============================================================
|
52 |
*
|
82 |
*
|
53 |
** Function: void bitvec_set_size
|
83 |
** Function: void bitvec_set_size
|
54 |
* PROTO_S ((unsigned size))
|
84 |
* (unsigned size)
|
55 |
** Exceptions:
|
85 |
** Exceptions:
|
56 |
*
|
86 |
*
|
57 |
* This function should be called once, before any bit vectors are
|
87 |
* This function should be called once, before any bit vectors are
|
58 |
* initialised. Its argument should specify the number of bits in a bit
|
88 |
* initialised. Its argument should specify the number of bits in a bit
|
59 |
* vector. The bits will be numbered from zero to one less than the number
|
89 |
* vector. The bits will be numbered from zero to one less than the number
|
60 |
* specified.
|
90 |
* specified.
|
61 |
*
|
91 |
*
|
62 |
** Function: void bitvec_init
|
92 |
** Function: void bitvec_init
|
63 |
* PROTO_S ((BitVecP bitvec))
|
93 |
* (BitVecP bitvec)
|
64 |
** Exceptions: XX_dalloc_no_memory
|
94 |
** Exceptions: XX_dalloc_no_memory
|
65 |
*
|
95 |
*
|
66 |
* This function initialises the specified bit vector. Initially, all bits
|
96 |
* This function initialises the specified bit vector. Initially, all bits
|
67 |
* are zero.
|
97 |
* are zero.
|
68 |
*
|
98 |
*
|
69 |
** Function: void bitvec_copy
|
99 |
** Function: void bitvec_copy
|
70 |
* PROTO_S ((BitVecP to, BitVecP from))
|
100 |
* (BitVecP to, BitVecP from)
|
71 |
** Exceptions: XX_dalloc_no_memory
|
101 |
** Exceptions: XX_dalloc_no_memory
|
72 |
*
|
102 |
*
|
73 |
* This function initialises the to bit vector from the from bit vector. It
|
103 |
* This function initialises the to bit vector from the from bit vector. It
|
74 |
* is not necessary to have initialised the to bit vector with the
|
104 |
* is not necessary to have initialised the to bit vector with the
|
75 |
* `bitvec_init' function previously.
|
105 |
* `bitvec_init' function previously.
|
76 |
*
|
106 |
*
|
77 |
** Function: void bitvec_replace
|
107 |
** Function: void bitvec_replace
|
78 |
* PROTO_S ((BitVecP to, BitVecP from))
|
108 |
* (BitVecP to, BitVecP from)
|
79 |
** Exceptions:
|
109 |
** Exceptions:
|
80 |
*
|
110 |
*
|
81 |
* This function copies the from bit vector into the to bit vector. The to
|
111 |
* This function copies the from bit vector into the to bit vector. The to
|
82 |
* bit vector must have been initialised previously.
|
112 |
* bit vector must have been initialised previously.
|
83 |
*
|
113 |
*
|
84 |
** Function: void bitvec_empty
|
114 |
** Function: void bitvec_empty
|
85 |
* PROTO_S ((BitVecP bitvec))
|
115 |
* (BitVecP bitvec)
|
86 |
** Exceptions:
|
116 |
** Exceptions:
|
87 |
*
|
117 |
*
|
88 |
* This function sets all of the bits in the specified bit vector to zero.
|
118 |
* This function sets all of the bits in the specified bit vector to zero.
|
89 |
*
|
119 |
*
|
90 |
** Function: BoolT bitvec_is_empty
|
120 |
** Function: BoolT bitvec_is_empty
|
91 |
* PROTO_S ((BitVecP bitvec))
|
121 |
* (BitVecP bitvec)
|
92 |
** Exceptions:
|
122 |
** Exceptions:
|
93 |
*
|
123 |
*
|
94 |
* This function returns true if all of the bits in the specified bit vector
|
124 |
* This function returns true if all of the bits in the specified bit vector
|
95 |
* are zero, and false otherwise.
|
125 |
* are zero, and false otherwise.
|
96 |
*
|
126 |
*
|
97 |
** Function: BoolT bitvec_is_full
|
127 |
** Function: BoolT bitvec_is_full
|
98 |
* PROTO_S ((BitVecP bitvec))
|
128 |
* (BitVecP bitvec)
|
99 |
** Exceptions:
|
129 |
** Exceptions:
|
100 |
*
|
130 |
*
|
101 |
* This function returns true if all of the bits in the specified bit vector
|
131 |
* This function returns true if all of the bits in the specified bit vector
|
102 |
* are set, and false otherwise.
|
132 |
* are set, and false otherwise.
|
103 |
*
|
133 |
*
|
104 |
** Function: void bitvec_set
|
134 |
** Function: void bitvec_set
|
105 |
* PROTO_S ((BitVecP bitvec, unsigned bit))
|
135 |
* (BitVecP bitvec, unsigned bit)
|
106 |
** Exceptions:
|
136 |
** Exceptions:
|
107 |
*
|
137 |
*
|
108 |
* This function sets the specified bit in the specified bit vector to one.
|
138 |
* This function sets the specified bit in the specified bit vector to one.
|
109 |
* Bits are numbered from zero. If the bit is out of range, then the effect
|
139 |
* Bits are numbered from zero. If the bit is out of range, then the effect
|
110 |
* of this function is undefined.
|
140 |
* of this function is undefined.
|
111 |
*
|
141 |
*
|
112 |
** Function: BoolT bitvec_is_set
|
142 |
** Function: BoolT bitvec_is_set
|
113 |
* PROTO_S ((BitVecP bitvec, unsigned bit))
|
143 |
* (BitVecP bitvec, unsigned bit)
|
114 |
** Exceptions:
|
144 |
** Exceptions:
|
115 |
*
|
145 |
*
|
116 |
* This function returns true if the specified bit in the specified bit vector
|
146 |
* This function returns true if the specified bit in the specified bit vector
|
117 |
* is set to one, and false otherwise. Bits are numbered from zero. If the
|
147 |
* is set to one, and false otherwise. Bits are numbered from zero. If the
|
118 |
* bit is out of range, the effect of this function is undefined.
|
148 |
* bit is out of range, the effect of this function is undefined.
|
119 |
*
|
149 |
*
|
120 |
** Function: void bitvec_or
|
150 |
** Function: void bitvec_or
|
121 |
* PROTO_S ((BitVecP to, BitVecP from))
|
151 |
* (BitVecP to, BitVecP from)
|
122 |
** Exceptions:
|
152 |
** Exceptions:
|
123 |
*
|
153 |
*
|
124 |
* This function performs an in-place bitwise or of the to bit vector and the
|
154 |
* This function performs an in-place bitwise or of the to bit vector and the
|
125 |
* from bit vector, leaving the result in the to bit vector.
|
155 |
* from bit vector, leaving the result in the to bit vector.
|
126 |
*
|
156 |
*
|
127 |
** Function: void bitvec_and
|
157 |
** Function: void bitvec_and
|
128 |
* PROTO_S ((BitVecP to, BitVecPfrom))
|
158 |
* (BitVecP to, BitVecPfrom)
|
129 |
** Exceptions:
|
159 |
** Exceptions:
|
130 |
*
|
160 |
*
|
131 |
* This function performs an in-place bitwise and of the to bit vector and the
|
161 |
* This function performs an in-place bitwise and of the to bit vector and the
|
132 |
* from bit vector, leaving the result in the to bit vector.
|
162 |
* from bit vector, leaving the result in the to bit vector.
|
133 |
*
|
163 |
*
|
134 |
** Function: void bitvec_not
|
164 |
** Function: void bitvec_not
|
135 |
* PROTO_S ((BitVecP to))
|
165 |
* (BitVecP to)
|
136 |
** Exceptions:
|
166 |
** Exceptions:
|
137 |
*
|
167 |
*
|
138 |
* This function performs an in-place bitwise negation of the to bit vector.
|
168 |
* This function performs an in-place bitwise negation of the to bit vector.
|
139 |
*
|
169 |
*
|
140 |
** Function: BoolT bitvec_equal
|
170 |
** Function: BoolT bitvec_equal
|
141 |
* PROTO_S ((BitVecP bitvec1, BitVecP bitvec2))
|
171 |
* (BitVecP bitvec1, BitVecP bitvec2)
|
142 |
** Exceptions:
|
172 |
** Exceptions:
|
143 |
*
|
173 |
*
|
144 |
* This function returns true if both of the specified bit vectors are equal,
|
174 |
* This function returns true if both of the specified bit vectors are equal,
|
145 |
* and false otherwise.
|
175 |
* and false otherwise.
|
146 |
*
|
176 |
*
|
147 |
** Function: BoolT bitvec_intersects
|
177 |
** Function: BoolT bitvec_intersects
|
148 |
* PROTO_S ((BitVecP bitvec1, BitVecP bitvec2))
|
178 |
* (BitVecP bitvec1, BitVecP bitvec2)
|
149 |
** Exceptions:
|
179 |
** Exceptions:
|
150 |
*
|
180 |
*
|
151 |
* This function returns true if the bitwise and of the specified bit vectors
|
181 |
* This function returns true if the bitwise and of the specified bit vectors
|
152 |
* contains at least one bit that is set to one, and false otherwise.
|
182 |
* contains at least one bit that is set to one, and false otherwise.
|
153 |
*
|
183 |
*
|
154 |
** Function: unsigned bitvec_num_bits
|
184 |
** Function: unsigned bitvec_num_bits
|
155 |
* PROTO_S ((BitVecP bitvec))
|
185 |
* (BitVecP bitvec)
|
156 |
** Exceptions:
|
186 |
** Exceptions:
|
157 |
*
|
187 |
*
|
158 |
* This function returns the number of bits in the bit vector that are set to
|
188 |
* This function returns the number of bits in the bit vector that are set to
|
159 |
* one.
|
189 |
* one.
|
160 |
*
|
190 |
*
|
161 |
** Function: unsigned bitvec_first_bit
|
191 |
** Function: unsigned bitvec_first_bit
|
162 |
* PROTO_S ((BitVecP bitvec))
|
192 |
* (BitVecP bitvec)
|
163 |
** Exceptions:
|
193 |
** Exceptions:
|
164 |
*
|
194 |
*
|
165 |
* This function returns the index of the first bit in the specified bit
|
195 |
* This function returns the index of the first bit in the specified bit
|
166 |
* vector that is set to one.
|
196 |
* vector that is set to one.
|
167 |
*
|
197 |
*
|
168 |
** Function: BoolT bitvec_next_bit
|
198 |
** Function: BoolT bitvec_next_bit
|
169 |
* PROTO_S ((BitVecP bitvec, unsigned *next_ref))
|
199 |
* (BitVecP bitvec, unsigned *next_ref)
|
170 |
** Exceptions:
|
200 |
** Exceptions:
|
171 |
*
|
201 |
*
|
172 |
* This function looks for the first bit set to one in the specified bit
|
202 |
* This function looks for the first bit set to one in the specified bit
|
173 |
* vector with a higher index than that specified in the number pointed to by
|
203 |
* vector with a higher index than that specified in the number pointed to by
|
174 |
* next_ref. If such a bit is found, then the index of that bit is written
|
204 |
* next_ref. If such a bit is found, then the index of that bit is written
|
175 |
* back into next_ref, and the function returns true. If no such bit is
|
205 |
* back into next_ref, and the function returns true. If no such bit is
|
176 |
* found, then the function returns false.
|
206 |
* found, then the function returns false.
|
177 |
*
|
207 |
*
|
178 |
** Function: void bitvec_destroy
|
208 |
** Function: void bitvec_destroy
|
179 |
* PROTO_S ((BitVecP bitvec))
|
209 |
* (BitVecP bitvec)
|
180 |
** Exceptions:
|
210 |
** Exceptions:
|
181 |
*
|
211 |
*
|
182 |
* This function destroys the specified bit vector. After this, it should be
|
212 |
* This function destroys the specified bit vector. After this, it should be
|
183 |
* reinitialised before it is used.
|
213 |
* reinitialised before it is used.
|
184 |
*
|
214 |
*
|
185 |
** Function: void write_bitvec_indices
|
215 |
** Function: void write_bitvec_indices
|
186 |
* PROTO_S ((OStreamP ostream, BitVecP bitvec))
|
216 |
* (OStreamP ostream, BitVecP bitvec)
|
187 |
** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
|
217 |
** Exceptions: XX_dalloc_no_memory, XX_ostream_write_error
|
188 |
*
|
218 |
*
|
189 |
* This function writes out to the specified ostream the indices of all bits
|
219 |
* This function writes out to the specified ostream the indices of all bits
|
190 |
* in the specified bit vector that are set to one.
|
220 |
* in the specified bit vector that are set to one.
|
191 |
*
|
221 |
*
|
Line 218... |
Line 248... |
218 |
ByteP bits;
|
248 |
ByteP bits;
|
219 |
} BitVecT, *BitVecP;
|
249 |
} BitVecT, *BitVecP;
|
220 |
|
250 |
|
221 |
/*--------------------------------------------------------------------------*/
|
251 |
/*--------------------------------------------------------------------------*/
|
222 |
|
252 |
|
223 |
extern void bitvec_set_size
|
253 |
extern void bitvec_set_size(unsigned);
|
224 |
PROTO_S ((unsigned));
|
- |
|
225 |
extern void bitvec_init
|
254 |
extern void bitvec_init(BitVecP);
|
226 |
PROTO_S ((BitVecP));
|
- |
|
227 |
extern void bitvec_copy
|
255 |
extern void bitvec_copy(BitVecP, BitVecP);
|
228 |
PROTO_S ((BitVecP, BitVecP));
|
- |
|
229 |
extern void bitvec_replace
|
256 |
extern void bitvec_replace(BitVecP, BitVecP);
|
230 |
PROTO_S ((BitVecP, BitVecP));
|
- |
|
231 |
extern void bitvec_empty
|
257 |
extern void bitvec_empty(BitVecP);
|
232 |
PROTO_S ((BitVecP));
|
- |
|
233 |
extern BoolT bitvec_is_empty
|
258 |
extern BoolT bitvec_is_empty(BitVecP);
|
234 |
PROTO_S ((BitVecP));
|
- |
|
235 |
extern BoolT bitvec_is_full
|
259 |
extern BoolT bitvec_is_full(BitVecP);
|
236 |
PROTO_S ((BitVecP));
|
- |
|
237 |
extern void bitvec_set
|
- |
|
238 |
PROTO_S ((BitVecP, unsigned));
|
260 |
extern void bitvec_set(BitVecP, unsigned);
|
239 |
extern BoolT bitvec_is_set
|
261 |
extern BoolT bitvec_is_set(BitVecP, unsigned);
|
240 |
PROTO_S ((BitVecP, unsigned));
|
- |
|
241 |
extern void bitvec_or
|
- |
|
242 |
PROTO_S ((BitVecP, BitVecP));
|
262 |
extern void bitvec_or(BitVecP, BitVecP);
|
243 |
extern void bitvec_and
|
263 |
extern void bitvec_and(BitVecP, BitVecP);
|
244 |
PROTO_S ((BitVecP, BitVecP));
|
- |
|
245 |
extern void bitvec_not
|
264 |
extern void bitvec_not(BitVecP);
|
246 |
PROTO_S ((BitVecP));
|
- |
|
247 |
extern BoolT bitvec_equal
|
265 |
extern BoolT bitvec_equal(BitVecP, BitVecP);
|
248 |
PROTO_S ((BitVecP, BitVecP));
|
- |
|
249 |
extern BoolT bitvec_intersects
|
266 |
extern BoolT bitvec_intersects(BitVecP, BitVecP);
|
250 |
PROTO_S ((BitVecP, BitVecP));
|
- |
|
251 |
extern unsigned bitvec_num_bits
|
267 |
extern unsigned bitvec_num_bits(BitVecP);
|
252 |
PROTO_S ((BitVecP));
|
- |
|
253 |
extern unsigned bitvec_first_bit
|
268 |
extern unsigned bitvec_first_bit(BitVecP);
|
254 |
PROTO_S ((BitVecP));
|
- |
|
255 |
extern BoolT bitvec_next_bit
|
269 |
extern BoolT bitvec_next_bit(BitVecP, unsigned *);
|
256 |
PROTO_S ((BitVecP, unsigned *));
|
- |
|
257 |
extern void bitvec_destroy
|
270 |
extern void bitvec_destroy(BitVecP);
|
258 |
PROTO_S ((BitVecP));
|
- |
|
259 |
|
271 |
|
260 |
extern void write_bitvec_indices
|
272 |
extern void write_bitvec_indices(OStreamP, BitVecP);
|
261 |
PROTO_S ((OStreamP, BitVecP));
|
- |
|
262 |
|
273 |
|
263 |
#endif /* !defined (H_BITVEC) */
|
274 |
#endif /* !defined (H_BITVEC) */
|
264 |
|
275 |
|
265 |
/*
|
276 |
/*
|
266 |
* Local variables(smf):
|
277 |
* Local variables(smf):
|