TaPAS  0.2
ccl-set.h
Go to the documentation of this file.
1 /*
2  * ccl-set.h -- A simple set implementation
3  *
4  * This file is a part of the C Common Library (CCL) project.
5  *
6  * Copyright (C) 2014 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 GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  */
23 
29 #ifndef CCL_SET_H
30 # define CCL_SET_H
31 
32 # include <ccl/ccl-common.h>
33 # include <ccl/ccl-iterator.h>
34 # include <ccl/ccl-hash.h>
35 
36 BEGIN_C_DECLS
37 
38 typedef ccl_hash ccl_set;
39 
40 extern ccl_set *
41 ccl_set_create (void);
42 
43 extern ccl_set *
44 ccl_set_create_for_objects (ccl_hash_func *hash,
45  ccl_compare_func *cmp,
46  ccl_delete_proc *del);
47 
48 extern void
49 ccl_set_delete (ccl_set *set);
50 
51 extern int
52 ccl_set_has (const ccl_set *set, void *obj);
53 
54 extern void
55 ccl_set_add (ccl_set *set, void *obj);
56 
57 extern void
58 ccl_set_remove (ccl_set *set, void *obj);
59 
60 extern ccl_pointer_iterator *
61 ccl_set_get_elements (const ccl_set *set);
62 
63 extern int
64 ccl_set_is_empty (const ccl_set *set);
65 
66 extern int
67 ccl_set_get_size (const ccl_set *set);
68 
69 extern ccl_set *
70 ccl_set_dup (const ccl_set *set);
71 
72 extern void
73 ccl_set_merge (ccl_set *set, const ccl_set *other);
74 
75 extern ccl_set *
76 ccl_set_union (const ccl_set *s1, const ccl_set *s2);
77 
78 extern ccl_set *
79 ccl_set_intersect (const ccl_set *s1, const ccl_set *s2);
80 
81 
82 END_C_DECLS
83 
84 #endif /* ! CCL_SET_H */
A generic iterator interface.
int ccl_compare_func(const void *ptr1, const void *ptr2)
Prototype of functions used to order two objects pointed respectively by ptr1 and ptr2...
Definition: ccl-protos.h:73
void ccl_delete_proc(void *ptr)
Prototype of procedures used to release the resources allocated to the object pointed by ptr...
Definition: ccl-protos.h:44
Some useful and common macros.
A dynamic association table implemented by hashing.
struct ccl_hash_st ccl_hash
abstract type of an hash table.
Definition: ccl-hash.h:57
unsigned int ccl_hash_func(const void *ptr)
Prototype of functions used to compute a hashed value from an abstract object pointed by ptr...
Definition: ccl-protos.h:32