C Container Collection (CCC)
|
The C Container Collection Traits Interface. More...
#include "impl/impl_traits.h"
Go to the source code of this file.
Entry Interface | |
Obtain and operate on container entries for efficient queries when non-trivial control flow is needed. | |
#define | ccc_insert(container_ptr, insert_args...) ccc_impl_insert(container_ptr, insert_args) |
Insert an element and obtain the old value if Occupied. | |
#define | ccc_insert_r(container_ptr, insert_args...) ccc_impl_insert_r(container_ptr, insert_args) |
Insert an element and obtain the old value if Occupied. | |
#define | ccc_try_insert(container_ptr, try_insert_args...) ccc_impl_try_insert(container_ptr, try_insert_args) |
Insert an element if the entry is Vacant. | |
#define | ccc_try_insert_r(container_ptr, try_insert_args...) ccc_impl_try_insert_r(container_ptr, try_insert_args) |
Insert an element if the entry is Vacant. | |
#define | ccc_insert_or_assign(container_ptr, insert_or_assign_args...) ccc_impl_insert_or_assign(container_ptr, insert_or_assign_args) |
Insert an element or overwrite the Occupied entry. | |
#define | ccc_insert_or_assign_r(container_ptr, insert_or_assign_args...) ccc_impl_insert_or_assign_r(container_ptr, insert_or_assign_args) |
Insert an element or overwrite the Occupied entry. | |
#define | ccc_remove(container_ptr, remove_args...) ccc_impl_remove(container_ptr, remove_args) |
Remove an element and retain access to its value. | |
#define | ccc_remove_r(container_ptr, remove_args...) ccc_impl_remove_r(container_ptr, remove_args) |
Remove an element and retain access to its value. | |
#define | ccc_entry(container_ptr, key_ptr...) ccc_impl_entry(container_ptr, key_ptr) |
Obtain a container specific entry for the Entry Interface. | |
#define | ccc_entry_r(container_ptr, key_ptr...) ccc_impl_entry_r(container_ptr, key_ptr) |
Obtain a container specific entry for the Entry Interface. | |
#define | ccc_and_modify(entry_ptr, mod_fn) ccc_impl_and_modify(entry_ptr, mod_fn) |
Modify an entry if Occupied. | |
#define | ccc_and_modify_aux(entry_ptr, mod_fn, aux_args...) ccc_impl_and_modify_aux(entry_ptr, mod_fn, aux_args) |
Modify an entry if Occupied. | |
#define | ccc_insert_entry(entry_ptr, insert_entry_args...) ccc_impl_insert_entry(entry_ptr, insert_entry_args) |
Insert new element or overwrite old element. | |
#define | ccc_or_insert(entry_ptr, or_insert_args...) ccc_impl_or_insert(entry_ptr, or_insert_args) |
Insert new element if the entry is Vacant. | |
#define | ccc_remove_entry(entry_ptr) ccc_impl_remove_entry(entry_ptr) |
Remove the element if the entry is Occupied. | |
#define | ccc_remove_entry_r(entry_ptr) ccc_impl_remove_entry_r(entry_ptr) |
Remove the element if the entry is Occupied. | |
#define | ccc_unwrap(entry_ptr) ccc_impl_unwrap(entry_ptr) |
Unwrap user type in entry. | |
#define | ccc_occupied(entry_ptr) ccc_impl_occupied(entry_ptr) |
Check occupancy of entry. | |
#define | ccc_insert_error(entry_ptr) ccc_impl_insert_error(entry_ptr) |
Check last insert status. | |
Membership Interface | |
Test membership or obtain references to stored user types directly. | |
#define | ccc_get_key_val(container_ptr, key_ptr...) ccc_impl_get_key_val(container_ptr, key_ptr) |
Obtain a reference to the user type stored at the key. | |
#define | ccc_contains(container_ptr, key_ptr...) ccc_impl_contains(container_ptr, key_ptr) |
Check for membership of the key. | |
Push Pop Front Back Interface | |
Push, pop, and view elements in sorted or unsorted containers. | |
#define | ccc_push(container_ptr, push_args...) ccc_impl_push(container_ptr, push_args) |
Push an element into a container. | |
#define | ccc_push_back(container_ptr, push_args...) ccc_impl_push_back(container_ptr, push_args) |
Push an element to the back of a container. | |
#define | ccc_push_front(container_ptr, push_args...) ccc_impl_push_front(container_ptr, push_args) |
Push an element to the front of a container. | |
#define | ccc_pop(container_ptr) ccc_impl_pop(container_ptr) |
Pop an element from a container. | |
#define | ccc_pop_front(container_ptr) ccc_impl_pop_front(container_ptr) |
Pop an element from the front of a container. | |
#define | ccc_pop_back(container_ptr) ccc_impl_pop_back(container_ptr) |
Pop an element from the back of a container. | |
#define | ccc_front(container_ptr) ccc_impl_front(container_ptr) |
Obtain a reference the front element of a container. | |
#define | ccc_back(container_ptr) ccc_impl_back(container_ptr) |
Obtain a reference the back element of a container. | |
#define | ccc_splice(container_ptr, splice_args...) ccc_impl_splice(container_ptr, splice_args) |
Splice an element from one position to another in the same or a different container. | |
#define | ccc_splice_range(container_ptr, splice_args...) ccc_impl_splice_range(container_ptr, splice_args) |
Splice a range of elements from one position to another in the same or a different container. | |
Priority Queue Interface | |
Interface to support generic priority queue operations. | |
#define | ccc_update(container_ptr, update_args...) ccc_impl_update(container_ptr, update_args) |
Update the value of an element known to be in a container. | |
#define | ccc_increase(container_ptr, increase_args...) ccc_impl_increase(container_ptr, increase_args) |
Increase the value of an element known to be in a container. | |
#define | ccc_decrease(container_ptr, decrease_args...) ccc_impl_decrease(container_ptr, decrease_args) |
Decrease the value of an element known to be in a container. | |
#define | ccc_erase(container_ptr, erase_args...) ccc_impl_erase(container_ptr, erase_args) |
Erase an element known to be in a container. | |
#define | ccc_extract(container_ptr, extract_args...) ccc_impl_extract(container_ptr, extract_args) |
Extract an element known to be in a container (does not free). | |
#define | ccc_extract_range(container_ptr, extract_args...) ccc_impl_extract_range(container_ptr, extract_args) |
Extract elements known to be in a container (does not free). | |
Iterator Interface | |
Obtain and manage iterators over the container. | |
#define | ccc_begin(container_ptr) ccc_impl_begin(container_ptr) |
Obtain a reference to the start of a container. | |
#define | ccc_rbegin(container_ptr) ccc_impl_rbegin(container_ptr) |
Obtain a reference to the reversed start of a container. | |
#define | ccc_next(container_ptr, void_iterator_ptr) ccc_impl_next(container_ptr, void_iterator_ptr) |
Obtain a reference to the next element in the container. | |
#define | ccc_rnext(container_ptr, void_iterator_ptr) ccc_impl_rnext(container_ptr, void_iterator_ptr) |
Obtain a reference to the rnext element in the container. | |
#define | ccc_end(container_ptr) ccc_impl_end(container_ptr) |
Obtain a reference to the end sentinel of a container. | |
#define | ccc_rend(container_ptr) ccc_impl_rend(container_ptr) |
Obtain a reference to the rend sentinel of a container. | |
#define | ccc_equal_range(container_ptr, range_args...) ccc_impl_equal_range(container_ptr, range_args) |
Obtain a range of values from a container. | |
#define | ccc_equal_range_r(container_ptr, range_args...) ccc_impl_equal_range_r(container_ptr, range_args) |
Obtain a range of values from a container. | |
#define | ccc_equal_rrange(container_ptr, rrange_args...) ccc_impl_equal_rrange(container_ptr, rrange_args) |
Obtain a rrange of values from a container. | |
#define | ccc_equal_rrange_r(container_ptr, rrange_args...) ccc_impl_equal_rrange_r(container_ptr, rrange_args) |
Obtain a rrange of values from a container. | |
State Interface | |
Obtain the container state. | |
#define | ccc_size(container_ptr) ccc_impl_size(container_ptr) |
Return the size of the container. | |
#define | ccc_is_empty(container_ptr) ccc_impl_is_empty(container_ptr) |
Return the size status of a container. | |
#define | ccc_validate(container_ptr) ccc_impl_validate(container_ptr) |
Return the invariant statuses of the container. | |
The C Container Collection Traits Interface.
Many functionalities across containers are similar. These can be described as traits that each container implements (see Rust Traits for a more pure example of the topic). Only a selections of shared traits across containers are represented here because some containers implement unique functionality that cannot be shared with other containers. These can simplify code greatly at a slightly higher compilation time cost. There is no runtime cost to using traits.
To shorten names in the interface, define the following preprocessor directive at the top of your file.
All traits can then be written without the ccc_
prefix.
#define ccc_and_modify | ( | entry_ptr, | |
mod_fn | |||
) | ccc_impl_and_modify(entry_ptr, mod_fn) |
Modify an entry if Occupied.
[in] | entry_ptr | a pointer to the container. |
[in] | mod_fn | a modification function that does not need aux. |
See container documentation for specific behavior.
#define ccc_and_modify_aux | ( | entry_ptr, | |
mod_fn, | |||
aux_args... | |||
) | ccc_impl_and_modify_aux(entry_ptr, mod_fn, aux_args) |
Modify an entry if Occupied.
[in] | entry_ptr | a pointer to the container. |
[in] | mod_fn | a modification function. |
[in] | aux_args | auxiliary data for mod_fn. |
See container documentation for specific behavior.
#define ccc_back | ( | container_ptr | ) | ccc_impl_back(container_ptr) |
Obtain a reference the back element of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_begin | ( | container_ptr | ) | ccc_impl_begin(container_ptr) |
Obtain a reference to the start of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_contains | ( | container_ptr, | |
key_ptr... | |||
) | ccc_impl_contains(container_ptr, key_ptr) |
Check for membership of the key.
[in] | container_ptr | a pointer to the container. |
[in] | key_ptr | a pointer to the search key. |
See container documentation for specific behavior.
#define ccc_decrease | ( | container_ptr, | |
decrease_args... | |||
) | ccc_impl_decrease(container_ptr, decrease_args) |
Decrease the value of an element known to be in a container.
[in] | container_ptr | a pointer to the container. |
decrease_args | depend on the container. |
See container documentation for specific behavior.
#define ccc_end | ( | container_ptr | ) | ccc_impl_end(container_ptr) |
Obtain a reference to the end sentinel of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_entry | ( | container_ptr, | |
key_ptr... | |||
) | ccc_impl_entry(container_ptr, key_ptr) |
Obtain a container specific entry for the Entry Interface.
[in] | container_ptr | a pointer to the container. |
[in] | key_ptr | a pointer to the search key. |
See container documentation for specific behavior.
#define ccc_entry_r | ( | container_ptr, | |
key_ptr... | |||
) | ccc_impl_entry_r(container_ptr, key_ptr) |
Obtain a container specific entry for the Entry Interface.
[in] | container_ptr | a pointer to the container. |
[in] | key_ptr | a pointer to the search key. |
See container documentation for specific behavior.
#define ccc_equal_range | ( | container_ptr, | |
range_args... | |||
) | ccc_impl_equal_range(container_ptr, range_args) |
Obtain a range of values from a container.
[in] | container_ptr | a pointer to the container. |
range_args | are container specific. |
See container documentation for specific behavior.
#define ccc_equal_range_r | ( | container_ptr, | |
range_args... | |||
) | ccc_impl_equal_range_r(container_ptr, range_args) |
Obtain a range of values from a container.
[in] | container_ptr | a pointer to the container. |
range_args | are container specific. |
See container documentation for specific behavior.
#define ccc_equal_rrange | ( | container_ptr, | |
rrange_args... | |||
) | ccc_impl_equal_rrange(container_ptr, rrange_args) |
Obtain a rrange of values from a container.
[in] | container_ptr | a pointer to the container. |
rrange_args | are container specific. |
See container documentation for specific behavior.
#define ccc_equal_rrange_r | ( | container_ptr, | |
rrange_args... | |||
) | ccc_impl_equal_rrange_r(container_ptr, rrange_args) |
Obtain a rrange of values from a container.
[in] | container_ptr | a pointer to the container. |
rrange_args | are container specific. |
See container documentation for specific behavior.
#define ccc_erase | ( | container_ptr, | |
erase_args... | |||
) | ccc_impl_erase(container_ptr, erase_args) |
Erase an element known to be in a container.
[in] | container_ptr | a pointer to the container. |
erase_args | depend on the container. |
See container documentation for specific behavior.
#define ccc_extract | ( | container_ptr, | |
extract_args... | |||
) | ccc_impl_extract(container_ptr, extract_args) |
Extract an element known to be in a container (does not free).
[in] | container_ptr | a pointer to the container. |
extract_args | depend on the container. |
See container documentation for specific behavior.
#define ccc_extract_range | ( | container_ptr, | |
extract_args... | |||
) | ccc_impl_extract_range(container_ptr, extract_args) |
Extract elements known to be in a container (does not free).
[in] | container_ptr | a pointer to the container. |
extract_args | depend on the container. |
See container documentation for specific behavior.
#define ccc_front | ( | container_ptr | ) | ccc_impl_front(container_ptr) |
Obtain a reference the front element of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_get_key_val | ( | container_ptr, | |
key_ptr... | |||
) | ccc_impl_get_key_val(container_ptr, key_ptr) |
Obtain a reference to the user type stored at the key.
[in] | container_ptr | a pointer to the container. |
[in] | key_ptr | a pointer to the search key. |
See container documentation for specific behavior.
#define ccc_increase | ( | container_ptr, | |
increase_args... | |||
) | ccc_impl_increase(container_ptr, increase_args) |
Increase the value of an element known to be in a container.
[in] | container_ptr | a pointer to the container. |
increase_args | depend on the container. |
See container documentation for specific behavior.
#define ccc_insert | ( | container_ptr, | |
insert_args... | |||
) | ccc_impl_insert(container_ptr, insert_args) |
Insert an element and obtain the old value if Occupied.
[in] | container_ptr | a pointer to the container. |
insert_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_insert_entry | ( | entry_ptr, | |
insert_entry_args... | |||
) | ccc_impl_insert_entry(entry_ptr, insert_entry_args) |
Insert new element or overwrite old element.
[in] | entry_ptr | a pointer to the container. |
insert_entry_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_insert_error | ( | entry_ptr | ) | ccc_impl_insert_error(entry_ptr) |
Check last insert status.
[in] | entry_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_insert_or_assign | ( | container_ptr, | |
insert_or_assign_args... | |||
) | ccc_impl_insert_or_assign(container_ptr, insert_or_assign_args) |
Insert an element or overwrite the Occupied entry.
[in] | container_ptr | a pointer to the container. |
insert_or_assign_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_insert_or_assign_r | ( | container_ptr, | |
insert_or_assign_args... | |||
) | ccc_impl_insert_or_assign_r(container_ptr, insert_or_assign_args) |
Insert an element or overwrite the Occupied entry.
[in] | container_ptr | a pointer to the container. |
insert_or_assign_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_insert_r | ( | container_ptr, | |
insert_args... | |||
) | ccc_impl_insert_r(container_ptr, insert_args) |
Insert an element and obtain the old value if Occupied.
[in] | container_ptr | a pointer to the container. |
insert_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_is_empty | ( | container_ptr | ) | ccc_impl_is_empty(container_ptr) |
Return the size status of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_next | ( | container_ptr, | |
void_iterator_ptr | |||
) | ccc_impl_next(container_ptr, void_iterator_ptr) |
Obtain a reference to the next element in the container.
[in] | container_ptr | a pointer to the container. |
[in] | void_iterator_ptr | the user type returned from the last iteration. |
See container documentation for specific behavior.
#define ccc_occupied | ( | entry_ptr | ) | ccc_impl_occupied(entry_ptr) |
Check occupancy of entry.
[in] | entry_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_or_insert | ( | entry_ptr, | |
or_insert_args... | |||
) | ccc_impl_or_insert(entry_ptr, or_insert_args) |
Insert new element if the entry is Vacant.
[in] | entry_ptr | a pointer to the container. |
or_insert_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_pop | ( | container_ptr | ) | ccc_impl_pop(container_ptr) |
Pop an element from a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_pop_back | ( | container_ptr | ) | ccc_impl_pop_back(container_ptr) |
Pop an element from the back of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_pop_front | ( | container_ptr | ) | ccc_impl_pop_front(container_ptr) |
Pop an element from the front of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_push | ( | container_ptr, | |
push_args... | |||
) | ccc_impl_push(container_ptr, push_args) |
Push an element into a container.
[in] | container_ptr | a pointer to the container. |
push_args | depend on container. |
See container documentation for specific behavior.
#define ccc_push_back | ( | container_ptr, | |
push_args... | |||
) | ccc_impl_push_back(container_ptr, push_args) |
Push an element to the back of a container.
[in] | container_ptr | a pointer to the container. |
push_args | depend on container. |
See container documentation for specific behavior.
#define ccc_push_front | ( | container_ptr, | |
push_args... | |||
) | ccc_impl_push_front(container_ptr, push_args) |
Push an element to the front of a container.
[in] | container_ptr | a pointer to the container. |
push_args | depend on container. |
See container documentation for specific behavior.
#define ccc_rbegin | ( | container_ptr | ) | ccc_impl_rbegin(container_ptr) |
Obtain a reference to the reversed start of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_remove | ( | container_ptr, | |
remove_args... | |||
) | ccc_impl_remove(container_ptr, remove_args) |
Remove an element and retain access to its value.
[in] | container_ptr | a pointer to the container. |
remove_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_remove_entry | ( | entry_ptr | ) | ccc_impl_remove_entry(entry_ptr) |
Remove the element if the entry is Occupied.
[in] | entry_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_remove_entry_r | ( | entry_ptr | ) | ccc_impl_remove_entry_r(entry_ptr) |
Remove the element if the entry is Occupied.
[in] | entry_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_remove_r | ( | container_ptr, | |
remove_args... | |||
) | ccc_impl_remove_r(container_ptr, remove_args) |
Remove an element and retain access to its value.
[in] | container_ptr | a pointer to the container. |
remove_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_rend | ( | container_ptr | ) | ccc_impl_rend(container_ptr) |
Obtain a reference to the rend sentinel of a container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_rnext | ( | container_ptr, | |
void_iterator_ptr | |||
) | ccc_impl_rnext(container_ptr, void_iterator_ptr) |
Obtain a reference to the rnext element in the container.
[in] | container_ptr | a pointer to the container. |
[in] | void_iterator_ptr | the user type returned from the last iteration. |
See container documentation for specific behavior.
#define ccc_size | ( | container_ptr | ) | ccc_impl_size(container_ptr) |
Return the size of the container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_splice | ( | container_ptr, | |
splice_args... | |||
) | ccc_impl_splice(container_ptr, splice_args) |
Splice an element from one position to another in the same or a different container.
[in] | container_ptr | a pointer to the container. |
splice_args | are container specific. |
See container documentation for specific behavior.
#define ccc_splice_range | ( | container_ptr, | |
splice_args... | |||
) | ccc_impl_splice_range(container_ptr, splice_args) |
Splice a range of elements from one position to another in the same or a different container.
[in] | container_ptr | a pointer to the container. |
splice_args | are container specific. |
See container documentation for specific behavior.
#define ccc_try_insert | ( | container_ptr, | |
try_insert_args... | |||
) | ccc_impl_try_insert(container_ptr, try_insert_args) |
Insert an element if the entry is Vacant.
[in] | container_ptr | a pointer to the container. |
try_insert_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_try_insert_r | ( | container_ptr, | |
try_insert_args... | |||
) | ccc_impl_try_insert_r(container_ptr, try_insert_args) |
Insert an element if the entry is Vacant.
[in] | container_ptr | a pointer to the container. |
try_insert_args | args depend on container. |
See container documentation for specific behavior.
#define ccc_unwrap | ( | entry_ptr | ) | ccc_impl_unwrap(entry_ptr) |
Unwrap user type in entry.
[in] | entry_ptr | a pointer to the container. |
See container documentation for specific behavior.
#define ccc_update | ( | container_ptr, | |
update_args... | |||
) | ccc_impl_update(container_ptr, update_args) |
Update the value of an element known to be in a container.
[in] | container_ptr | a pointer to the container. |
update_args | depend on the container. |
See container documentation for specific behavior.
#define ccc_validate | ( | container_ptr | ) | ccc_impl_validate(container_ptr) |
Return the invariant statuses of the container.
[in] | container_ptr | a pointer to the container. |
See container documentation for specific behavior.