typedef LListElement SetElement; typedef LList Set; The Set data structure represents a set and it is a front-end to the LList data structure. |
| Set* set_create(destroyfunc*
destroy, comparefunc* cmp) description: creates a new, empty set. The destroy parameter is a pointer to a user-defined destroyfunc . This function is called to free dynammically allocated data when set_destroy is called. If the set contains data that should not be freed, it should be set to NULL.The cmp parameter is a valid pointer to a user-defined comparefunc . This function is used by the Set data structure to compare it's elements. return value: a pointer to a new Set data structure or NULL if the allocation fails. since: YACLib 1.0 int set_insert(Set* set, const void* data) description: inserts an element into the set specified by set. The new element stores a pointer to data. return value: 0 if the element could be inserted, -1 otherwise. since: YACLib 1.0 int set_remove(Set* set, void** data) description: removes the element matching data from the set specified by set. Upon return, data points to the data stored in the element that was removed. return value: 0 if the element could be removed, -1 otherwise. since: YACLib 1.0 void set_remove_all(Set* set) description: removes all elements from the set specified by set. return value: none. since: YACLib 1.0 Set* set_union(const Set* seta, const Set* setb) description: creates a new set that is the union of seta and setb. return value: a pointer to a new Set data structure that is the union of seta and setb, or NULL if the operation fails. since: YACLib 1.0 Set* set_intersection(const Set* seta, const Set* setb) description: creates a new set that is the intersection of seta and setb. return value: a pointer to a new Set data structure that is the intersection of seta and setb, or NULL if the operation fails. since: YACLib 1.0 Set* set_difference(const Set* seta, const Set* setb) description: creates a new set that is the difference of seta and setb. return value: a pointer to a new Set data structure that is the difference of seta and setb, or NULL if the operation fails. since: YACLib 1.0 int set_is_subset(const Set* seta, const Set* setb) description: determines if the set specified by seta is a subset of the set specified by setb. return value: 1 if seta is a subset of setb, 0 otherwise. since: YACLib 1.0 int set_is_equal(const Set* seta, const Set* setb) description: determines if the set specified by seta is equal to the set specified by setb. return value: 1 if seta is equal to setb, 0 otherwise. since: YACLib 1.0 int set_element_is_member(const Set* set,const void* data) description: determines if there is an element matching data in the set specified by set. return value: 1 if an element matching data was found, 0 otherwise. since: YACLib 1.0 void set_destroy(Set* set) description: destroys the set specified by set. It removes all the elements of the set and calls the destroyfunc function passed to set_create for each element as it is removed from the set, provided destroy wasn't set to NULL. return value: none since: YACLib 1.0 int set_size(const Set* set) description: macro that evaluates to the number of the elements in the set specified by set. return value: the number of elements of set. since: YACLib 1.0 SetElement* set_head(const Set* set) description: macro that evaluates to the head of the set specified by set. return value: the head of set. since: YACLib 1.0 SetElement* set_tail(const Set* set) description: macro that evaluates to the tail of the set specified by set. return value: the tail of set. since: YACLib 1.0 SetElement* set_element_next(const SetElement* element) description: macro that evaluates to the next pointer of the set element specified by element. return value: the next pointer of element. since: YACLib 1.0 void* set_element_data(const SetElement* element) description: macro that evaluates to the data pointer of the set element specified by element. return value: the data pointer of element. since: YACLib 1.0 |