24#ifndef TOMMY_ARRAYOF_H
25#define TOMMY_ARRAYOF_H
39#define TOMMY_ARRAYOF_BIT 6
83 if (size > array->
count) {
128 assert(pos < array->count);
133 unsigned char* ptr = tommy_cast(
unsigned char*, array->
bucket[bsr]);
146 assert(array->
count != 0);
173 assert(array->
count != 0);
190 return array->
count == 0;
Array container type.
Definition: tommyarrayof.h:45
void * bucket[TOMMY_SIZE_BIT]
Dynamic array of buckets.
Definition: tommyarrayof.h:46
tommy_size_t count
Number of initialized elements in the array.
Definition: tommyarrayof.h:49
tommy_size_t bucket_max
Number of buckets.
Definition: tommyarrayof.h:48
tommy_uint_t bucket_bit
Bits used in the bit mask.
Definition: tommyarrayof.h:50
tommy_size_t element_size
Size of the stored element in bytes.
Definition: tommyarrayof.h:47
void * tommy_arrayof_ref(tommy_arrayof *array, tommy_size_t pos)
Gets a reference to the element at the specified position.
Definition: tommyarrayof.h:126
void tommy_arrayof_clear(tommy_arrayof *array)
Removes all elements, preserving the allocated capacity.
Definition: tommyarrayof.h:106
TOMMY_API tommy_size_t tommy_arrayof_memory_usage(const tommy_arrayof *array)
Gets the size of allocated memory.
tommy_size_t tommy_arrayof_size(const tommy_arrayof *array)
Gets the initialized size of the array.
Definition: tommyarrayof.h:198
void tommy_arrayof_swap(tommy_arrayof *first, tommy_arrayof *second)
Exchanges two initialized arrays without copying their elements.
Definition: tommyarrayof.h:221
void * tommy_arrayof_tail(tommy_arrayof *array)
Gets a reference to the last element.
Definition: tommyarrayof.h:144
void * tommy_arrayof_insert_tail(tommy_arrayof *array)
Adds a zero-initialized element and returns its reference.
Definition: tommyarrayof.h:155
TOMMY_API void tommy_arrayof_init(tommy_arrayof *array, tommy_size_t element_size)
Initializes the array.
TOMMY_API void tommy_arrayof_resize(tommy_arrayof *array, tommy_size_t size)
Changes the initialized size, preserving the common prefix.
TOMMY_API void tommy_arrayof_reserve(tommy_arrayof *array, tommy_size_t size)
Allocates space for at least the specified number of elements.
TOMMY_API void tommy_arrayof_foreach(tommy_arrayof *array, tommy_foreach_func *func)
Calls the specified function for each element in the array.
TOMMY_API void tommy_arrayof_shrink(tommy_arrayof *array)
Releases unused allocated memory.
void tommy_arrayof_remove_tail(tommy_arrayof *array)
Removes the last element without copying it.
Definition: tommyarrayof.h:171
struct tommy_arrayof_struct tommy_arrayof
Array container type.
tommy_bool_t tommy_arrayof_empty(const tommy_arrayof *array)
Checks whether the array is empty.
Definition: tommyarrayof.h:188
tommy_size_t tommy_arrayof_capacity(const tommy_arrayof *array)
Gets the number of elements that fit without further allocation.
Definition: tommyarrayof.h:208
TOMMY_API void tommy_arrayof_done(tommy_arrayof *array)
Deinitializes the array.
void tommy_arrayof_grow(tommy_arrayof *array, tommy_size_t size)
Grows the size up to the specified value.
Definition: tommyarrayof.h:81
TOMMY_API void tommy_arrayof_foreach_arg(tommy_arrayof *array, tommy_foreach_arg_func *func, void *arg)
Calls the specified function with an argument for each element in the array.
void tommy_foreach_func(void *elem)
Foreach function.
Definition: tommytypes.h:346
uint64_t tommy_size_t
Generic size_t type.
Definition: tommytypes.h:40
#define tommy_ilog2
Bit depth mapping.
Definition: tommytypes.h:573
void tommy_foreach_arg_func(void *arg, void *elem)
Foreach function with an argument.
Definition: tommytypes.h:353
tommy_uint32_t tommy_uint_t
Generic unsigned integer type.
Definition: tommytypes.h:61
int tommy_bool_t
Generic boolean type.
Definition: tommytypes.h:53