TaPAS  0.2
ccl-bittable.h
Go to the documentation of this file.
1 /*
2  * ccl-bittable.h -- Implementation of vectors of bits
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2010 CNRS UMR 5800 & Université Bordeaux I (see AUTHORS file).
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the AltaRica Public License that comes with this
10  * package.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  */
16 
22 #ifndef __CCL_BITTABLE_H__
23 # define __CCL_BITTABLE_H__
24 
25 # include <ccl/ccl-common.h>
26 # include <ccl/ccl-log.h>
27 # include <ccl/ccl-iterator.h>
28 
29 BEGIN_C_DECLS
30 
34 typedef struct ccl_bittable_st ccl_bittable;
35 
42 extern ccl_bittable *
43 ccl_bittable_create (int size);
44 
45 extern ccl_bittable *
46 ccl_bittable_add_reference (ccl_bittable *bt);
47 
53 #define ccl_bittable_delete ccl_bittable_del_reference
54 
55 extern void
56 ccl_bittable_del_reference (ccl_bittable *bt);
57 
63 extern int
65 
74 extern int
75 ccl_bittable_has (const ccl_bittable *bt, int index);
76 
88 extern void
89 ccl_bittable_set (ccl_bittable *bt, int index);
90 
91 extern void
92 ccl_bittable_set_array (ccl_bittable *bt, int size, int *array);
93 
105 extern void
106 ccl_bittable_unset (ccl_bittable *bt, int index);
107 
116 extern int
118 
131 extern int
132 ccl_bittable_get_next (const ccl_bittable *bt, int prev);
133 
140 extern void
142 
149 extern unsigned int
150 ccl_bittable_hash (const ccl_bittable *bt);
151 
163 extern int
164 ccl_bittable_equals (const ccl_bittable *bt1, const ccl_bittable *bt2);
165 
166 extern int
167 ccl_bittable_compare (const ccl_bittable *bt1, const ccl_bittable *bt2);
168 
175 extern ccl_bittable *
176 ccl_bittable_dup (const ccl_bittable *bt);
177 
184 extern int
186 
197 extern ccl_int_iterator *
199 
212 extern ccl_bittable *
213 ccl_bittable_resize (ccl_bittable *bt, int newsize);
214 
222 extern ccl_bittable *
223 ccl_bittable_union (const ccl_bittable *bt1, const ccl_bittable *bt2);
224 
225 extern void
226 ccl_bittable_assign_union (ccl_bittable *bt1, const ccl_bittable *bt2);
227 
237 extern ccl_bittable *
238 ccl_bittable_nary_union (ccl_bittable **bts, int nb_bts);
239 
247 extern ccl_bittable *
248 ccl_bittable_intersection (const ccl_bittable *bt1, const ccl_bittable *bt2);
249 
257 extern ccl_bittable *
258 ccl_bittable_sub (const ccl_bittable *bt1, const ccl_bittable *bt2);
259 
266 extern ccl_bittable *
268 
287 extern void
288 ccl_bittable_window_union (ccl_bittable *bt_dst, int dst,
289  const ccl_bittable *bt_src, int src, int w);
290 
305 extern int
307  const ccl_bittable *bt_src, int src,
308  int w);
309 
318 extern int
319 ccl_bittable_is_included_in (const ccl_bittable *bt1, const ccl_bittable *bt2);
320 
327 extern void
329 
330 END_C_DECLS
331 
332 #endif /* ! __CCL_BITTABLE_H__ */
int ccl_bittable_get_size(const ccl_bittable *bt)
Returns the number of bits of the table.
unsigned int ccl_bittable_hash(const ccl_bittable *bt)
Computes an hashed value of the content of bt.
ccl_bittable * ccl_bittable_resize(ccl_bittable *bt, int newsize)
Resize the table of bits bt for newsize bits.
int ccl_bittable_get_nb_one(const ccl_bittable *bt)
Returns the number of bits set to 1 in bt/.
ccl_int_iterator * ccl_bittable_get_ones(ccl_bittable *bt)
Returns an iterator that gives positions of bit equal to 1.
ccl_bittable * ccl_bittable_dup(const ccl_bittable *bt)
Duplicates the table bt.
A generic iterator interface.
ccl_bittable * ccl_bittable_sub(const ccl_bittable *bt1, const ccl_bittable *bt2)
Computes the bitwise difference of tables bt1 and bt2.
ccl_bittable * ccl_bittable_create(int size)
Creates a new table of bits large enough for size bits.
void ccl_bittable_set(ccl_bittable *bt, int index)
Set the bit at position index.
void ccl_bittable_window_union(ccl_bittable *bt_dst, int dst, const ccl_bittable *bt_src, int src, int w)
Makes a bitwise disjunction between bts_dst and bt_src but on a restricted part of indices...
ccl_bittable * ccl_bittable_union(const ccl_bittable *bt1, const ccl_bittable *bt2)
Computes the bitwise disjunction of tables bt1 and bt2.
int ccl_bittable_equals(const ccl_bittable *bt1, const ccl_bittable *bt2)
Checks if bt1 and bt2 are equal.
int ccl_bittable_get_next(const ccl_bittable *bt, int prev)
Returns the index of the first non-null bit encountered after the position prev.
void ccl_bittable_log(ccl_log_type log, const ccl_bittable *bt)
Display the content of the table bt to the stream log.
void ccl_bittable_clear(ccl_bittable *bt)
Sets to zero all bits of bt.
ccl_bittable * ccl_bittable_intersection(const ccl_bittable *bt1, const ccl_bittable *bt2)
Computes the bitwise conjunction of tables bt1 and bt2.
void ccl_bittable_unset(ccl_bittable *bt, int index)
Unset the bit at position index.
int ccl_bittable_is_included_in(const ccl_bittable *bt1, const ccl_bittable *bt2)
Checks if the set represented by bt1 is included in bt2.
struct ccl_bittable_st ccl_bittable
Abstract type of a vector of bytes.
Definition: ccl-bittable.h:34
int ccl_bittable_has(const ccl_bittable *bt, int index)
Checks if the bit at position index is set or not.
int ccl_bittable_window_union_with_roll(ccl_bittable *bt_dst, int dst, const ccl_bittable *bt_src, int src, int w)
Does the same work than ccl_bittable_window_union but the window of bt_src is rolled for 1 bit on the...
ccl_bittable * ccl_bittable_nary_union(ccl_bittable **bts, int nb_bts)
Computes the bitwise disjunction of tables bt[0], ..., bt[nb_bts-1].
Some useful and common macros.
enum ccl_log_type_enum ccl_log_type
Enum that indicates which kind of message has to be displayed. Each kind of message can be displayed ...
Definition: ccl-log.h:50
ccl_bittable * ccl_bittable_complement(const ccl_bittable *bt)
Negate the bits of bt.
Message displayer.
int ccl_bittable_get_first(const ccl_bittable *bt)
Returns the index of the first non-null bit.