40 #ifndef __TOMMYARRAY_H
41 #define __TOMMYARRAY_H
54 #define TOMMY_ARRAY_BIT 6
59 #define TOMMY_ARRAY_BIT_MAX 32
97 assert(pos < array->count);
102 return &array->
bucket[bsr][pos];
void tommy_array_done(tommy_array *array)
Deinitializes the array.
void tommy_array_insert(tommy_array *array, void *element)
Grows and inserts a new element at the end of the array.
Definition: tommyarray.h:128
tommy_uint_t tommy_ilog2_u32(tommy_uint32_t value)
Bit scan reverse or integer log2.
Definition: tommytypes.h:331
tommy_uint32_t tommy_count_t
Generic unsigned integer for counting objects.
Definition: tommytypes.h:67
struct tommy_array_struct tommy_array
Array container type.
void tommy_array_grow(tommy_array *array, tommy_count_t size)
Grows the size up to the specified value.
tommy_uint_t bucket_bit
Bits used in the bit mask.
Definition: tommyarray.h:67
void ** bucket[TOMMY_ARRAY_BIT_MAX]
Dynamic array of buckets.
Definition: tommyarray.h:66
tommy_uint32_t tommy_uint_t
Generic unsigned integer type.
Definition: tommytypes.h:60
tommy_count_t count
Number of initialized elements in the array.
Definition: tommyarray.h:69
void tommy_array_set(tommy_array *array, tommy_count_t pos, void *element)
Sets the element at the specified position.
Definition: tommyarray.h:110
tommy_count_t tommy_array_size(tommy_array *array)
Gets the initialized size of the array.
Definition: tommyarray.h:140
void * tommy_array_get(tommy_array *array, tommy_count_t pos)
Gets the element at the specified position.
Definition: tommyarray.h:120
tommy_count_t bucket_max
Number of buckets.
Definition: tommyarray.h:68
tommy_size_t tommy_array_memory_usage(tommy_array *array)
Gets the size of allocated memory.
void tommy_array_init(tommy_array *array)
Initializes the array.
size_t tommy_size_t
Generic size_t type.
Definition: tommytypes.h:50
Array container type.
Definition: tommyarray.h:65
void ** tommy_array_ref(tommy_array *array, tommy_count_t pos)
Gets a reference of the element at the specified position.
Definition: tommyarray.h:93