![]() |
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 | cxCollectionSorted(c) |
| Indicates whether the collection can guarantee that the stored elements are currently sorted. | |
| #define | cxCollectionCompareFunc(c, func) |
| Sets the compare function for a collection. | |
| #define | cxDefineDestructor(c, destr) |
| Sets a simple destructor function for this collection. | |
| #define | cxDefineAdvancedDestructor(c, destr, data) |
| Sets a simple 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. | |
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_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_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_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 cxCollectionCompareFunc | ( | c, | |
| func ) |
Sets the compare function for a collection.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| func | (cx_compare_func) the compare function that shall be used by c |
| #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 cxDefineAdvancedDestructor | ( | c, | |
| destr, | |||
| data ) |
Sets a simple destructor function for this collection.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| destr | the destructor function |
| #define cxDefineDestructor | ( | c, | |
| destr ) |
Sets a simple destructor function for this collection.
| c | a pointer to a struct that contains CX_COLLECTION_BASE |
| destr | the destructor function |