ATLAS Offline Software
|
Set of values. More...
Go to the source code of this file.
Classes | |
struct | _SetIterator |
Definition of a SetIterator. More... | |
Macros | |
#define | SET_NULL ((void *) 0) |
A null SetValue. More... | |
Typedefs | |
typedef struct _Set | Set |
Represents a set of values. More... | |
typedef struct _SetIterator | SetIterator |
An object used to iterate over a set. More... | |
typedef struct _SetEntry | SetEntry |
Internal structure representing an entry in the set. More... | |
typedef void * | SetValue |
A value stored in a Set. More... | |
typedef unsigned long(* | SetHashFunc) (SetValue value) |
Hash function. More... | |
typedef int(* | SetEqualFunc) (SetValue value1, SetValue value2) |
Equality function. More... | |
typedef void(* | SetFreeFunc) (SetValue value) |
Function used to free values stored in a set. More... | |
Functions | |
Set * | set_new (SetHashFunc hash_func, SetEqualFunc equal_func) |
Create a new set. More... | |
void | set_free (Set *set) |
Destroy a set. More... | |
void | set_register_free_function (Set *set, SetFreeFunc free_func) |
Register a function to be called when values are removed from the set. More... | |
int | set_insert (Set *set, SetValue data) |
Add a value to a set. More... | |
int | set_remove (Set *set, SetValue data) |
Remove a value from a set. More... | |
int | set_query (Set *set, SetValue data) |
Query if a particular value is in a set. More... | |
int | set_num_entries (Set *set) |
Retrieve the number of entries in a set. More... | |
SetValue * | set_to_array (Set *set) |
Create an array containing all entries in a set. More... | |
Set * | set_union (Set *set1, Set *set2) |
Perform a union of two sets. More... | |
Set * | set_intersection (Set *set1, Set *set2) |
Perform an intersection of two sets. More... | |
void | set_iterate (Set *set, SetIterator *iter) |
Initialise a SetIterator structure to iterate over the values in a set. More... | |
int | set_iter_has_more (SetIterator *iterator) |
Determine if there are more values in the set to iterate over. More... | |
SetValue | set_iter_next (SetIterator *iterator) |
Using a set iterator, retrieve the next value from the set. More... | |
Set of values.
A set stores a collection of values. Each value can only exist once in the set.
To create a new set, use set_new. To destroy a set, use set_free.
To add a value to a set, use set_insert. To remove a value from a set, use set_remove.
To find the number of entries in a set, use set_num_entries.
To query if a particular value is in a set, use set_query.
To iterate over all values in a set, use set_iterate to initialise a SetIterator structure, with set_iter_next and set_iter_has_more to read each value in turn.
Two sets can be combined (union) using set_union, while the intersection of two sets can be generated using set_intersection.
Definition in file set.h.
typedef struct _Set Set |
typedef struct _SetEntry SetEntry |
typedef void(* SetFreeFunc) (SetValue value) |
Function used to free values stored in a set.
typedef unsigned long(* SetHashFunc) (SetValue value) |
typedef struct _SetIterator SetIterator |
void set_free | ( | Set * | set | ) |
Destroy a set.
set | The set to destroy. |
Add a value to a set.
set | The set. |
data | The value to add to the set. |
Perform an intersection of two sets.
set1 | The first set. |
set2 | The second set. |
int set_iter_has_more | ( | SetIterator * | iterator | ) |
Determine if there are more values in the set to iterate over.
iterator | The set iterator object. |
SetValue set_iter_next | ( | SetIterator * | iterator | ) |
Using a set iterator, retrieve the next value from the set.
iterator | The set iterator. |
void set_iterate | ( | Set * | set, |
SetIterator * | iter | ||
) |
Initialise a SetIterator structure to iterate over the values in a set.
set | The set to iterate over. |
iter | Pointer to an iterator structure to initialise. |
Set* set_new | ( | SetHashFunc | hash_func, |
SetEqualFunc | equal_func | ||
) |
Create a new set.
hash_func | Hash function used on values in the set. |
equal_func | Compares two values in the set to determine if they are equal. |
int set_num_entries | ( | Set * | set | ) |
Retrieve the number of entries in a set.
set | The set. |
Query if a particular value is in a set.
set | The set. |
data | The value to query for. |
void set_register_free_function | ( | Set * | set, |
SetFreeFunc | free_func | ||
) |
Register a function to be called when values are removed from the set.
set | The set. |
free_func | Function to call when values are removed from the set. |
Remove a value from a set.
set | The set. |
data | The value to remove from the set. |
Create an array containing all entries in a set.
set | The set. |