|
C Container Collection (CCC)
|
A key comparison helper to avoid argument swapping. More...
#include <types.h>
A key comparison helper to avoid argument swapping.
The key is considered the left hand side of the operation if three-way comparison is needed. Note a comparison is taking place between the key on the left hand side and the complete user type on the right hand side. This means the right hand side will need to manually access its key field.
Notice that the user type must access its key field of its struct. Comparison must happen this way to support searching by key in associative containers rather than by entire user struct. Only needing to provide a key can save significant memory for a search depending on the size of the user type.
The pointers are const to bind the key and type closely with their context, if context is provided. Because container code is providing the user reference to the key and type type it currently stores, it is critical the user does not accidentally move or misuse the pointer to jeopardize container invariants.
Data Fields | |
| void const *const | key_left |
| void const *const | type_right |
| void *const | context |
| void* const CCC_Key_comparator_arguments::context |
A reference to context for this key comparison.
| void const* const CCC_Key_comparator_arguments::key_left |
Key matching the key field of the provided type to the container.
| void const* const CCC_Key_comparator_arguments::type_right |
The complete user type stored in the container.