|
ucx
UAP Common Extensions
|
Common definitions for various collection implementations. More...
Go to the source code of this file.
Data Structures | |
| struct | cx_collection_s |
| Base attributes of a collection. More... | |
Macros | |
| #define | CX_STORE_POINTERS 0 |
| Special constant used for creating collections that are storing pointers. | |
| #define | CX_COLLECTION_BASE struct cx_collection_s collection |
| Use this macro to declare common members for a collection structure. | |
| #define | cxCollectionSize(c) |
| Returns the number of elements currently stored. | |
| #define | cxCollectionElementSize(c) |
| Returns the size of one element. | |
| #define | cxCollectionStoresPointers(c) |
| Indicates whether this collection only stores pointers instead of the actual data. | |
| #define | cx_ref(c, elem) |
| Convenience macro for adding indirection to an element if the collection is storing pointers. | |
| #define | cx_deref(c, elem) |
| Convenience macro for dereferencing an element if the collection is storing pointers. | |
| #define | cxCollectionSorted(c) |
| Indicates whether the collection can guarantee that the stored elements are currently sorted. | |
| #define | cxSetCompareFunc(c, func) |
| Sets a simple compare function for a collection. | |
| #define | cxSetAdvancedCompareFunc(c, func, data) |
| Sets an advanced compare function that supports custom data for a collection. | |
| #define | cx_invoke_simple_compare_func(c, left, right) |
| Invokes the simple comparator function for two elements. | |
| #define | cx_invoke_advanced_compare_func(c, left, right) |
| Invokes the advanced comparator function for two elements. | |
| #define | cx_invoke_compare_func(c, left, right) |
| Invokes the configured comparator function for two elements. | |
| #define | cxSetDestructor(c, destr) |
| Sets a simple destructor function for this collection. | |
| #define | cxSetAdvancedDestructor(c, destr, data) |
| Sets an advanced destructor function for this collection. | |
| #define | cx_invoke_simple_destructor(c, e) |
| Invokes the simple destructor function for a specific element. | |
| #define | cx_invoke_advanced_destructor(c, e) |
| Invokes the advanced destructor function for a specific element. | |
| #define | cx_invoke_destructor(c, e) |
| Invokes all available destructor functions for a specific element. | |
| #define | cx_invoke_destructor_raw(c, e) |
| Invokes all available destructor functions for a specific element. | |
Common definitions for various collection implementations.
| #define CX_COLLECTION_BASE struct cx_collection_s collection |
Use this macro to declare common members for a collection structure.
| #define cx_deref | ( | c, | |
| elem ) |
Convenience macro for dereferencing an element if the collection is storing pointers.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| elem | a pointer to the collection element |
elem, otherwise returns elem | #define cx_invoke_advanced_compare_func | ( | c, | |
| left, | |||
| right ) |
Invokes the advanced comparator function for two elements.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| left | (void*) pointer to data |
| right | (void*) pointer to data |
| #define cx_invoke_advanced_destructor | ( | c, | |
| e ) |
Invokes the advanced destructor function for a specific element.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
When the collection stores pointers, those pointers are directly passed to the destructor. Otherwise, a pointer to the element is passed.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| e | the element (the type is void* or void** depending on context) |
| #define cx_invoke_compare_func | ( | c, | |
| left, | |||
| right ) |
Invokes the configured comparator function for two elements.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| left | (void*) pointer to data |
| right | (void*) pointer to data |
| #define cx_invoke_destructor | ( | c, | |
| e ) |
Invokes all available destructor functions for a specific element.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
When the collection stores pointers, those pointers are directly passed to the destructor. Otherwise, a pointer to the element is passed.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| e | the element (the type is void* or void** depending on context) |
| #define cx_invoke_destructor_raw | ( | c, | |
| e ) |
Invokes all available destructor functions for a specific element.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
In contrast to cx_invoke_destructor(), this macro does not automatically dereference pointers to the elements when cxCollectionStoresPointers() returns true.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| e | pointer to the element |
| #define cx_invoke_simple_compare_func | ( | c, | |
| left, | |||
| right ) |
Invokes the simple comparator function for two elements.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| left | (void*) pointer to data |
| right | (void*) pointer to data |
| #define cx_invoke_simple_destructor | ( | c, | |
| e ) |
Invokes the simple destructor function for a specific element.
Usually only used by collection implementations. There should be no need to invoke this macro manually.
When the collection stores pointers, those pointers are directly passed to the destructor. Otherwise, a pointer to the element is passed.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| e | the element (the type is void* or void** depending on context) |
| #define cx_ref | ( | c, | |
| elem ) |
Convenience macro for adding indirection to an element if the collection is storing pointers.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| elem | the pointer that shall be taken the address from, if the collection is storing pointers |
elem, otherwise returns elem | #define cxCollectionElementSize | ( | c | ) |
Returns the size of one element.
If cxCollectionStoresPointers() returns true, this is the size of a pointer.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
size_t) the size of one element in bytes | #define cxCollectionSize | ( | c | ) |
Returns the number of elements currently stored.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
size_t) the number of currently stored elements | #define cxCollectionSorted | ( | c | ) |
Indicates whether the collection can guarantee that the stored elements are currently sorted.
This may return false even when the elements are sorted. It is totally up to the implementation of the collection when to check if the elements are sorted. It is usually a good practice to establish this property as an invariant that does not need to be re-checked on certain operations.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| true | if the elements are currently sorted wrt. the collection's compare function |
| false | if the order of elements is unknown |
| #define cxCollectionStoresPointers | ( | c | ) |
Indicates whether this collection only stores pointers instead of the actual data.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| true | if this collection stores only pointers to data |
| false | if this collection stores the actual element's data |
| #define cxSetAdvancedCompareFunc | ( | c, | |
| func, | |||
| data ) |
Sets an advanced compare function that supports custom data for a collection.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| func | (cx_compare_func2) the compare function |
| data | (void*) the pointer to custom data that is passed to the compare function |
| #define cxSetAdvancedDestructor | ( | c, | |
| destr, | |||
| data ) |
Sets an advanced destructor function for this collection.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| destr | (cx_destructor_func2) the destructor function |
| data | (void*) the additional data the advanced destructor is invoked with |
| #define cxSetCompareFunc | ( | c, | |
| func ) |
Sets a simple compare function for a collection.
Erases a possible advanced compare function. If you want to set both, because you want to access the simple function in your advanced function, you must set the simple function first.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| func | (cx_compare_func) the compare function |
| #define cxSetDestructor | ( | c, | |
| destr ) |
Sets a simple destructor function for this collection.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| destr | (cx_destructor_func) the destructor function |