CLibs
|
Sets implemented via a hash table. More...
Go to the source code of this file.
Data Structures | |
struct | set_item |
struct | SetEnumeratedEntry |
Macros | |
#define | SET_ITEMCOUNT_LINE_LENGTH 4 |
Typedefs | |
typedef struct hash_set | Set |
Enumerations | |
enum | SetInsertRV { SETINSERT_INSERTED = 0 , SETINSERT_WAS_IN = 1 } |
enum | SetRemoveRV { SETREMOVE_REMOVED = 0 , SETREMOVE_NOT_FOUND = 1 } |
Functions | |
Constructor Set * | set_init (void) |
Constructor Set * | set_init_cap (size_t capacity) |
int | set_insert_f (Set *, const void *data, size_t len, PrintFunction func) |
int | set_insert (Set *, const void *data, size_t len) |
int | set_remove (Set *, const void *data, size_t len) |
bool | set_search (const Set *, const void *data, size_t len) |
int | set_intersection (const Set *, const Set *, Set **result) |
int | set_intersect (Set *, const Set *intr) |
int | set_union (const Set *, const Set *, Set **result) |
int | set_unionize (Set *, const Set *add) |
int | set_difference (const Set *set, const Set *sub, Set **result) |
int | set_subtract (Set *set, const Set *sub) |
int | set_cmp (const Set *, const Set *) |
void | set_destroy (Set *) |
Const size_t | set_size (const Set *set) |
SetEnumeratedEntry | set_get_next (const Set *, int64_t index_last) |
void | set_print (const Set *) |
void | set_print_as (const Set *, PrintFunction) |
Sets implemented via a hash table.
Sets contain at most one copy of an item. Items can be of any type – they are treated as arrays of bytes. Their keys are a combination of the number of bytes and each byte of the data.
#define SET_ITEMCOUNT_LINE_LENGTH 4 |
Max number of items that can be printed on one line in a set.
This may be redefined.
typedef struct hash_set Set |
enum SetInsertRV |
enum SetRemoveRV |
Compares sets (pretty arbitrarily). First by size, then by items.
SetEnumeratedEntry set_get_next | ( | const Set * | , |
int64_t | index_last ) |
Iterator over set.
index_last | index of the last iterated element |
Constructor Set * set_init | ( | void | ) |
Constructor Set * set_init_cap | ( | size_t | capacity | ) |
int set_insert | ( | Set * | , |
const void * | data, | ||
size_t | len ) |
Inserts a value into the set.
data | pointer to data |
len | number of bytes in data |
int set_insert_f | ( | Set * | , |
const void * | data, | ||
size_t | len, | ||
PrintFunction | func ) |
Inserts a value into the set.
data | pointer to data |
len | number of bytes in data |
func | PrintFunction |
Leaves the set with only the items which are in intr.
intr | Second set |
Creates an intersection of the two sets and shallowly copies the data to a new set, stored under result
result | if the val at result is NULL, the function creates a new hash set with the proper values. If the val isn't NULL, the function adds the intersecting values to the hash set in result |
void set_print | ( | const Set * | ) |
Prints each item using the PrintFunctions they have saved in them.
void set_print_as | ( | const Set * | , |
PrintFunction | ) |
Prints each item using the supplied PrintFunction.
int set_remove | ( | Set * | , |
const void * | data, | ||
size_t | len ) |
Removes a value from the set.
data | pointer to data |
len | sizeof data |
bool set_search | ( | const Set * | , |
const void * | data, | ||
size_t | len ) |
Searches the set for an element.
data | data |
len | size of data |
set is left with the items which are not in sub
set | set to be subtracted from |
sub | set to be subtracted |
Creates a union of the two sets, containing all items from both.
result | pointer to a Set * |