CLibs
Loading...
Searching...
No Matches
set.h
Go to the documentation of this file.
1
14
15#ifndef CLIBS_SETS_H
16#define CLIBS_SETS_H
17
18#include "../headers/extra_types.h" /* stddef, stdint, stdbool */
19#include "../item_print_functions.h" /* PrintFunction */
20
21
22struct hash_set;
23typedef struct hash_set Set;
24
25
29struct set_item {
30 void *data;
31 size_t size;
32
33 bool removed;
34
36};
37
38
43
48
49
62Constructor Set *set_init_cap( size_t capacity );
63
72int set_insert_f( Set *, const void *data, size_t len, PrintFunction func );
80int set_insert( Set *, const void *data, size_t len );
81
89int set_remove( Set *, const void *data, size_t len );
90
98bool set_search( const Set *, const void *data, size_t len );
99
109int set_intersection( const Set *, const Set *, Set **result );
116int set_intersect( Set *, const Set *intr );
117
124int set_union( const Set *, const Set *, Set **result );
131int set_unionize( Set *, const Set *add );
132
142int set_difference( const Set *set, const Set *sub, Set **result );
150int set_subtract( Set *set, const Set *sub );
151
152
158int set_cmp( const Set *, const Set * );
159
160
162void set_destroy( Set * );
163
164
166Const size_t set_size( const Set *set );
167
168
169typedef struct {
170 const struct set_item *item;
171 int64_t index;
173
179SetEnumeratedEntry set_get_next( const Set *, int64_t index_last );
180
181
182#ifndef SET_ITEMCOUNT_LINE_LENGTH
188#define SET_ITEMCOUNT_LINE_LENGTH 4
189#endif //SET_ITEMCOUNT_LINE_LENGTH
190
192void set_print( const Set * );
195
196#endif //CLIBS_SETS_H
#define Const
Definition attributes.h:67
#define Constructor
Definition attributes.h:101
void(* PrintFunction)(const void *, size_t)
Interface for functions that print data.
Definition item_print_functions.h:17
int set_intersect(Set *, const Set *intr)
SetEnumeratedEntry set_get_next(const Set *, int64_t index_last)
struct hash_set Set
Definition set.h:23
SetRemoveRV
Definition set.h:44
@ SETREMOVE_NOT_FOUND
Definition set.h:46
@ SETREMOVE_REMOVED
Definition set.h:45
Constructor Set * set_init(void)
void set_destroy(Set *)
Const size_t set_size(const Set *set)
bool set_search(const Set *, const void *data, size_t len)
int set_subtract(Set *set, const Set *sub)
int set_insert_f(Set *, const void *data, size_t len, PrintFunction func)
int set_intersection(const Set *, const Set *, Set **result)
Constructor Set * set_init_cap(size_t capacity)
int set_remove(Set *, const void *data, size_t len)
void set_print_as(const Set *, PrintFunction)
int set_unionize(Set *, const Set *add)
int set_insert(Set *, const void *data, size_t len)
void set_print(const Set *)
int set_cmp(const Set *, const Set *)
SetInsertRV
Definition set.h:39
@ SETINSERT_WAS_IN
Definition set.h:41
@ SETINSERT_INSERTED
Definition set.h:40
int set_union(const Set *, const Set *, Set **result)
int set_difference(const Set *set, const Set *sub, Set **result)
Definition set.h:169
int64_t index
Definition set.h:171
const struct set_item * item
Definition set.h:170
Definition set.h:29
PrintFunction func
Definition set.h:35
void * data
Definition set.h:30
size_t size
Definition set.h:31
bool removed
Definition set.h:33