C Container Collection (CCC)
Loading...
Searching...
No Matches
CCC_Key_comparator_context Struct Reference

A key comparison helper to avoid argument swapping. More...

#include <types.h>

Detailed Description

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.

int const *const key_left = order.key_left;
struct Key_val const *const type_right = order.type_right;
return (*key_left > type_right->key) - (*key_left < type_right->key);
void const *const key_left
Definition: types.h:247
void const *const type_right
Definition: types.h:249

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.

Data Fields

void const *const key_left
 
void const *const type_right
 
void * context
 

Field Documentation

◆ context

void* CCC_Key_comparator_context::context

A reference to context provided to the container on initialization.

◆ key_left

void const* const CCC_Key_comparator_context::key_left

Key matching the key field of the provided type to the container.

◆ type_right

void const* const CCC_Key_comparator_context::type_right

The complete user type stored in the container.


The documentation for this struct was generated from the following file: