Site hosted by Angelfire.com: Build your free website today!

(c) 2002 - Pedro Flynn <pflynn@microsoftsucks.org>

OSet


#define OSET_CRESCENT OLLIST_CRESCENT
#define OSET_DECRESCENT OLLIST_DECRESCENT

typedef
OLListElement OSetElement;

typedef OLList OSet;


    The OSet data structure represents an ordered set and it is a front-end to the OLList data structure. 

Related functions and macros



OSet* oset_create(destroyfunc* destroy, comparefunc* cmp, int order);

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 oset_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. The order parameter has two possible values: OSET_CRESCENT, for the set to store it's elements in crescent order, or OSET_DECRESCENT, for the set to store it's elements in decrescent order.

return value: a pointer to a  new OSet data structure or NULL if the allocation fails.

since: YACLib 1.0

int oset_insert(OSet* oset, const void* data)

description: inserts an element into the ordered set specified by oset. The new element stores a pointer to data.

return value:
0 if the element could be inserted, -1 otherwise.

since: YACLib 1.0
int oset_remove(OSet* oset, void** data)

description: removes the element matching data from the ordered set specified by oset. 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 oset_remove_all(OSet* oset)

description: removes all elements from the ordered set specified by oset.

return value:
none.

since: YACLib 1.0

OSet* oset_union(const OSet* oseta, const OSet* osetb, int order)

description: creates a new ordered set that is the union of oseta and osetb, with order order.  

return value:
a pointer to a new OSet data structure that is the union of oseta and osetb, or NULL if the operation fails.

since: YACLib 1.0
OSet* oset_intersection(const OSet* oseta, const OSet* osetb, int order)

description: creates a new ordered set that is the intersection of oseta and osetb, with order order.

return value:
 a pointer to a new OSet data structure that is the intersection of oseta and osetb, or NULL if the operation fails.

since: YACLib 1.0
OSet* oset_difference(const OSet* oseta, const OSet* osetb, int order)

description: creates a new ordered set that is the difference of oseta and osetb, with order order.

return value:
 a pointer to a new OSet data structure that is the difference of oseta and osetb, or NULL if the operation fails.

since: YACLib 1.0
int oset_is_subset(const OSet* oseta, const OSet* osetb)

description: determines if the ordered set specified by oseta is a subset of the ordered set specified by osetb.

return value:
1 if oseta is a subset of osetb, 0 otherwise.

since: YACLib 1.0
int oset_is_equal(const OSet* oseta, const OSet* osetb)

description: determines if the ordered set specified by oseta is equal to the ordered set specified by osetb.

return value:
1 if oseta is equal to osetb, 0 otherwise.

since: YACLib 1.0
int oset_element_is_member(const OSet* oset, const void* data)

description: determines if there is an element matching data in the ordered set specified by oset.

return value:
1 if  an element matching  data was found, 0 otherwise.

since: YACLib 1.0
void oset_destroy(OSet* oset)

description:  destroys the ordered set specified by oset. It removes all the elements of the ordered set and calls the destroyfunc function passed to oset_create for each element as it is removed from the ordered set, provided destroy wasn't set to NULL.

return value: none

since: YACLib 1.0
int oset_size(const OSet* oset)

description:  macro that evaluates to the number of  elements in the ordered set specified by oset.

return value: the number of elements in oset.

since: YACLib 1.0
OSetElement* oset_head(const OSet* oset)

description:  macro that evaluates to the  head of the ordered set specified by oset.

return value: the head of oset.

since: YACLib 1.0
OSetElement* oset_tail(const OSet* oset)

description:  macro that evaluates to the tail of the ordered set specified by oset.

return value: the tail of oset.

since: YACLib 1.0

OSetElement* oset_element_next(const OSetElement* element)

description:  macro that evaluates to the next pointer of  the  ordered set element specified by element.

return value: the next pointer of element.

since: YACLib 1.0
void* oset_element_data(const OSetElement* element)

description:  macro that evaluates to the data pointer of  the  ordered set element specified by element.

return value: the data pointer of element.

since: YACLib 1.0