C Container Collection (CCC)
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
9#ifndef CCC_TYPES_H
10#define CCC_TYPES_H
11
13#include <stdbool.h>
14#include <stddef.h>
15#include <stdint.h>
18#include "impl/impl_types.h"
19
30typedef union ccc_range_ ccc_range;
31
38typedef union ccc_rrange_ ccc_rrange;
39
47typedef union ccc_entry_ ccc_entry;
48
57typedef enum ccc_entry_status_ ccc_entry_status;
58
64typedef enum
65{
67 CCC_OK = 0,
77
83typedef enum
84{
86 CCC_LES = -1,
94
103typedef struct
104{
106 void const *const user_type_lhs;
108 void const *const user_type_rhs;
110 void *aux;
111} ccc_cmp;
112
117typedef struct
118{
120 void const *const key_lhs;
122 void const *const user_type_rhs;
124 void *aux;
126
131typedef struct
132{
136 void *aux;
138
144typedef struct
145{
147 void const *const user_key;
149 void *aux;
151
199typedef void *ccc_alloc_fn(void *ptr, size_t size, void *aux);
200
208
217
235
241
248
253typedef uint64_t ccc_hash_fn(ccc_user_key to_hash);
254
265
273
280
292
307
317void *ccc_end_range(ccc_range const *r);
318
328
339
354char const *ccc_result_msg(ccc_result res);
355
362
375
380#ifdef TYPES_USING_NAMESPACE_CCC
381typedef ccc_range range;
382typedef ccc_rrange rrange;
383typedef ccc_entry entry;
384typedef ccc_result result;
385typedef ccc_threeway_cmp threeway_cmp;
386typedef ccc_cmp cmp;
387typedef ccc_key_cmp key_cmp;
388typedef ccc_user_type user_type;
389typedef ccc_user_key user_key;
390typedef ccc_alloc_fn alloc_fn;
391typedef ccc_cmp_fn cmp_fn;
392typedef ccc_update_fn update_fn;
393typedef ccc_destructor_fn destructor_fn;
394typedef ccc_key_eq_fn key_eq_fn;
395typedef ccc_key_cmp_fn key_cmp_fn;
396typedef ccc_hash_fn hash_fn;
397# define entry_occupied(entry_ptr) ccc_entry_occupied(entry_ptr)
398# define entry_insert_error(entry_ptr) ccc_entry_insert_error(entry_ptr)
399# define entry_unwrap(entry_ptr) ccc_entry_unwrap(entry_ptr)
400# define begin_range(range_ptr) ccc_begin_range(range_ptr)
401# define end_range(range_ptr) ccc_end_range(range_ptr)
402# define rbegin_rrange(range_ptr) ccc_rbegin_rrange(range_ptr)
403# define rend_rrange(range_ptr) ccc_rend_rrange(range_ptr)
404# define result_msg(res) ccc_result_msg(res)
405# define entry_status_msg(status) ccc_entry_status_msg(status)
406#endif /* TYPES_USING_NAMESPACE_CCC */
407
408#endif /* CCC_TYPES_H */
An element comparison helper.
Definition: types.h:104
void * aux
Definition: types.h:110
void const *const user_type_lhs
Definition: types.h:106
void const *const user_type_rhs
Definition: types.h:108
A key comparison helper to avoid argument swapping.
Definition: types.h:118
void const *const user_type_rhs
Definition: types.h:122
void * aux
Definition: types.h:124
void const *const key_lhs
Definition: types.h:120
A read only reference to a key type matching the key field type used for hash containers.
Definition: types.h:145
void const *const user_key
Definition: types.h:147
void * aux
Definition: types.h:149
A reference to a user type within the container.
Definition: types.h:132
void * user_type
Definition: types.h:134
void * aux
Definition: types.h:136
void * ccc_entry_unwrap(ccc_entry const *e)
Unwraps the provided entry providing a reference to the user type obtained from the operation that pr...
uint64_t ccc_hash_fn(ccc_user_key to_hash)
A callback function to hash the key type used in a container.
Definition: types.h:253
char const * ccc_result_msg(ccc_result res)
Obtain a string message with a description of the error returned from a container operation,...
ccc_result
A result of actions on containers.
Definition: types.h:65
@ CCC_MEM_ERR
Definition: types.h:71
@ CCC_OK
Definition: types.h:67
@ CCC_INPUT_ERR
Definition: types.h:73
@ CCC_NO_ALLOC
Definition: types.h:69
@ CCC_RESULTS_SIZE
Definition: types.h:75
void ccc_update_fn(ccc_user_type)
A callback function for modifying an element in the container.
Definition: types.h:216
union ccc_range_ ccc_range
The result of a range query on iterable containers.
Definition: types.h:30
void * ccc_begin_range(ccc_range const *r)
Obtain a reference to the beginning user element stored in a container in the provided range.
union ccc_entry_ ccc_entry
An Occupied or Vacant position in a searchable container.
Definition: types.h:47
ccc_threeway_cmp ccc_cmp_fn(ccc_cmp)
A callback function for comparing two elements in a container.
Definition: types.h:207
bool ccc_entry_insert_error(ccc_entry const *e)
Determine if an insertion error has occurred when a function that attempts to insert a value in a con...
ccc_threeway_cmp ccc_key_cmp_fn(ccc_key_cmp)
A callback function for three-way comparing two stored keys.
Definition: types.h:247
void * ccc_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:199
enum ccc_entry_status_ ccc_entry_status
The status monitoring and entry state once it is obtained.
Definition: types.h:57
void * ccc_rend_rrange(ccc_rrange const *r)
Obtain a reference to the reverse end user element stored in a container in the provided range.
void * ccc_end_range(ccc_range const *r)
Obtain a reference to the end user element stored in a container in the provided range.
ccc_threeway_cmp
A three-way comparison for comparison functions.
Definition: types.h:84
@ CCC_EQL
Definition: types.h:88
@ CCC_CMP_ERR
Definition: types.h:92
@ CCC_GRT
Definition: types.h:90
@ CCC_LES
Definition: types.h:86
bool ccc_entry_input_error(ccc_entry const *e)
Determine if an input error has occurred for a function that generates an entry.
void ccc_destructor_fn(ccc_user_type)
A callback function for destroying an element in the container.
Definition: types.h:234
char const * ccc_entry_status_msg(ccc_entry_status status)
Obtain a string message with a description of the entry status.
union ccc_rrange_ ccc_rrange
The result of a rrange query on iterable containers.
Definition: types.h:38
bool ccc_entry_occupied(ccc_entry const *e)
Determine if an entry is Occupied in the container.
bool ccc_key_eq_fn(ccc_key_cmp)
A callback function to determining equality between two stored keys.
Definition: types.h:240
ccc_entry_status ccc_get_entry_status(ccc_entry const *e)
Obtain the entry status from a generic entry.
void * ccc_rbegin_rrange(ccc_rrange const *r)
Obtain a reference to the reverse beginning user element stored in a container in the provided range.