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 <stddef.h>
14#include <stdint.h>
17#include "impl/impl_types.h"
18
29typedef union ccc_range_ ccc_range;
30
37typedef union ccc_rrange_ ccc_rrange;
38
46typedef union ccc_entry_ ccc_entry;
47
56typedef enum ccc_entry_status_ ccc_entry_status;
57
66typedef union ccc_handle_ ccc_handle;
67
78typedef size_t ccc_handle_i;
79
88typedef enum ccc_entry_status_ ccc_handle_status;
89
101typedef enum : int8_t
102{
110
116typedef enum : uint8_t
117{
130} ccc_result;
131
137typedef enum : int8_t
138{
148
171typedef struct
172{
176 size_t count;
177} ccc_ucount;
178
187typedef struct
188{
190 void const *const user_type_lhs;
192 void const *const user_type_rhs;
194 void *aux;
195} ccc_cmp;
196
201typedef struct
202{
204 void const *const key_lhs;
206 void const *const user_type_rhs;
208 void *aux;
210
215typedef struct
216{
220 void *aux;
222
228typedef struct
229{
231 void const *const user_key;
233 void *aux;
235
283typedef void *ccc_alloc_fn(void *ptr, size_t size, void *aux);
284
292
301
319
327
334
339typedef uint64_t ccc_hash_fn(ccc_user_key to_hash);
340
351
359
366
378
383
391
398
410
425
435void *ccc_end_range(ccc_range const *r);
436
446
457
472char const *ccc_result_msg(ccc_result res);
473
480
487
500
513
518#ifdef TYPES_USING_NAMESPACE_CCC
519typedef ccc_range range;
520typedef ccc_rrange rrange;
521typedef ccc_entry entry;
522typedef ccc_handle handle;
523typedef ccc_handle_i handle_i;
524typedef ccc_result result;
525typedef ccc_threeway_cmp threeway_cmp;
526typedef ccc_cmp cmp;
527typedef ccc_key_cmp key_cmp;
528typedef ccc_user_type user_type;
529typedef ccc_user_key user_key;
530typedef ccc_alloc_fn alloc_fn;
531typedef ccc_cmp_fn cmp_fn;
532typedef ccc_update_fn update_fn;
533typedef ccc_destructor_fn destructor_fn;
534typedef ccc_key_eq_fn key_eq_fn;
535typedef ccc_key_cmp_fn key_cmp_fn;
536typedef ccc_hash_fn hash_fn;
537# define entry_occupied(entry_ptr) ccc_entry_occupied(entry_ptr)
538# define entry_insert_error(entry_ptr) ccc_entry_insert_error(entry_ptr)
539# define entry_unwrap(entry_ptr) ccc_entry_unwrap(entry_ptr)
540# define get_entry_status(entry_ptr) ccc_get_entry_status(entry_ptr)
541# define entry_status_msg(status) ccc_entry_status_msg(status)
542# define handle_occupied(handle_ptr) ccc_handle_occupied(handle_ptr)
543# define handle_insert_error(handle_ptr) ccc_handle_insert_error(handle_ptr)
544# define handle_unwrap(handle_ptr) ccc_handle_unwrap(handle_ptr)
545# define get_handle_status(handle_ptr) ccc_get_handle_status(handle_ptr)
546# define handle_status_msg(status) ccc_handle_status_msg(status)
547# define begin_range(range_ptr) ccc_begin_range(range_ptr)
548# define end_range(range_ptr) ccc_end_range(range_ptr)
549# define rbegin_rrange(range_ptr) ccc_rbegin_rrange(range_ptr)
550# define rend_rrange(range_ptr) ccc_rend_rrange(range_ptr)
551# define result_msg(res) ccc_result_msg(res)
552#endif /* TYPES_USING_NAMESPACE_CCC */
553
554#endif /* CCC_TYPES_H */
An element comparison helper.
Definition: types.h:188
void * aux
Definition: types.h:194
void const *const user_type_lhs
Definition: types.h:190
void const *const user_type_rhs
Definition: types.h:192
A key comparison helper to avoid argument swapping.
Definition: types.h:202
void const *const user_type_rhs
Definition: types.h:206
void * aux
Definition: types.h:208
void const *const key_lhs
Definition: types.h:204
A type for returning an unsigned integer from a container for counting. Intended to count sizes,...
Definition: types.h:172
size_t count
Definition: types.h:176
ccc_result error
Definition: types.h:174
A read only reference to a key type matching the key field type used for hash containers.
Definition: types.h:229
void const *const user_key
Definition: types.h:231
void * aux
Definition: types.h:233
A reference to a user type within the container.
Definition: types.h:216
void * user_type
Definition: types.h:218
void * aux
Definition: types.h:220
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:339
char const * ccc_result_msg(ccc_result res)
Obtain a string message with a description of the error returned from a container operation,...
ccc_tribool ccc_entry_occupied(ccc_entry const *e)
Determine if an entry is Occupied in the container.
void ccc_update_fn(ccc_user_type)
A callback function for modifying an element in the container.
Definition: types.h:300
ccc_tribool ccc_handle_insert_error(ccc_handle const *e)
Determine if an insertion error has occurred when a function that attempts to insert a value in a con...
union ccc_handle_ ccc_handle
An Occupied or Vacant handle to a flat searchable container entry.
Definition: types.h:66
size_t ccc_handle_i
A stable index to user data in a container that uses a flat array as the underlying storage method.
Definition: types.h:78
union ccc_range_ ccc_range
The result of a range query on iterable containers.
Definition: types.h:29
ccc_tribool ccc_handle_input_error(ccc_handle const *e)
Determine if an input error has occurred for a function that generates an handle.
void * ccc_begin_range(ccc_range const *r)
Obtain a reference to the beginning user element stored in a container in the provided range.
ccc_result
A result of actions on containers.
Definition: types.h:117
@ CCC_RESULT_ARG_ERROR
Definition: types.h:127
@ CCC_RESULT_MEM_ERROR
Definition: types.h:125
@ CCC_RESULT_SIZE
Definition: types.h:129
@ CCC_RESULT_FAIL
Definition: types.h:121
@ CCC_RESULT_OK
Definition: types.h:119
@ CCC_RESULT_NO_ALLOC
Definition: types.h:123
enum ccc_entry_status_ ccc_handle_status
The status monitoring and handle state once it is obtained.
Definition: types.h:88
ccc_handle_status ccc_get_handle_status(ccc_handle const *e)
Obtain the handle status from a generic handle.
ccc_handle_i ccc_handle_unwrap(ccc_handle const *e)
Unwraps the provided handle providing a reference to the user type obtained from the operation that p...
union ccc_entry_ ccc_entry
An Occupied or Vacant position in a searchable container.
Definition: types.h:46
ccc_threeway_cmp ccc_cmp_fn(ccc_cmp)
A callback function for comparing two elements in a container.
Definition: types.h:291
ccc_tribool ccc_entry_input_error(ccc_entry const *e)
Determine if an input error has occurred for a function that generates an entry.
ccc_threeway_cmp ccc_key_cmp_fn(ccc_key_cmp)
A callback function for three-way comparing two stored keys.
Definition: types.h:333
ccc_tribool
A three state boolean to allow for an error state. Error is -1, False is 0, and True is 1.
Definition: types.h:102
@ CCC_TRIBOOL_ERROR
Definition: types.h:104
@ CCC_TRUE
Definition: types.h:108
@ CCC_FALSE
Definition: types.h:106
void * ccc_alloc_fn(void *ptr, size_t size, void *aux)
An allocation function at the core of all containers.
Definition: types.h:283
enum ccc_entry_status_ ccc_entry_status
The status monitoring and entry state once it is obtained.
Definition: types.h:56
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.
void ccc_destructor_fn(ccc_user_type)
A callback function for destroying an element in the container.
Definition: types.h:318
ccc_tribool ccc_key_eq_fn(ccc_key_cmp)
A callback function to determining equality between two stored keys.
Definition: types.h:326
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:37
char const * ccc_handle_status_msg(ccc_handle_status status)
Obtain a string message with a description of the handle status.
ccc_tribool 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_tribool ccc_handle_occupied(ccc_handle const *e)
Determine if an handle is Occupied in the container.
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.
ccc_threeway_cmp
A three-way comparison for comparison functions.
Definition: types.h:138
@ CCC_EQL
Definition: types.h:142
@ CCC_GRT
Definition: types.h:144
@ CCC_LES
Definition: types.h:140
@ CCC_CMP_ERROR
Definition: types.h:146