C Container Collection (CCC)
Loading...
Searching...
No Matches
ccc_any_key_cmp 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. Left and right do not matter if equality 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 my_key = cmp.any_key_lhs;
struct key_val const *const my_type = cmp.any_type_rhs;
return *my_key == my_type->key;

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 any_key_lhs
 
void const *const any_type_rhs
 
void * aux
 

Field Documentation

◆ any_key_lhs

void const* const ccc_any_key_cmp::any_key_lhs

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

◆ any_type_rhs

void const* const ccc_any_key_cmp::any_type_rhs

The complete user type stored in the container.

◆ aux

void* ccc_any_key_cmp::aux

A reference to aux data provided to the container on initialization.


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