|
My Project
|
#include <stdbool.h>#include <stdint.h>#include <stdlib.h>

Go to the source code of this file.
Classes | |
| struct | dynamic_array |
Typedefs | |
| typedef struct dynamic_array | dynamic_array |
Functions | |
| dynamic_array * | dynamic_array_create (size_t item_size, unsigned int starting_capacity, unsigned char growth_factor, bool is_multithread_safe) |
| Create and initialize a new dynamic array. | |
| unsigned int | dynamic_array_get_occupancy (const dynamic_array *array) |
| Get the number of elements currently in the array. | |
| unsigned int | dynamic_array_get_capacity (const dynamic_array *array) |
| Get the total capacity of the array. | |
| void * | dynamic_array_get_pointer_to_index (const dynamic_array *array, const unsigned int index) |
| Get a pointer to the element at the specified index. | |
| const void * | dynamic_array_get_const_pointer_to_index (const dynamic_array *array, const unsigned int index) |
| Get a const pointer to the element at the specified index. | |
| bool | dynamic_array_append (const dynamic_array *array, const void *element) |
| Append an element to the end of the array. | |
| bool | dynamic_array_pop (const dynamic_array *array) |
| Remove the last element from the array. | |
| bool | dynamic_array_remove (const dynamic_array *array, const unsigned int index) |
| Remove an element at the specified index. | |
| void | dynamic_array_clear (const dynamic_array *array) |
| Clear all elements from the array. | |
| bool | dynamic_array_is_empty (const dynamic_array *array) |
| Check if the array is empty. | |
| bool | dynamic_array_increase_capacity (const dynamic_array *array, const unsigned int new_capacity) |
| Reserve additional capacity without changing size. | |
| bool | dynamic_array_acquire (const dynamic_array *array) |
| Increment the owner count for shared ownership. | |
| bool | dynamic_array_release (const dynamic_array *array) |
| Decrement the owner count for shared ownership. | |
| unsigned short | dynamic_array_get_owner_count (const dynamic_array *array) |
| Get the current owner count. | |
| bool | dynamic_array_is_thread_safe (const dynamic_array *array) |
| Check if the array is thread-safe. | |
| bool | dynamic_array_clone (const dynamic_array *original_array, const dynamic_array *new_array) |
| Creates a deep copy of the array. | |
| typedef struct dynamic_array dynamic_array |
| bool dynamic_array_acquire | ( | const dynamic_array * | array | ) |
Increment the owner count for shared ownership.
| array | Pointer to the dynamic_array. |
| bool dynamic_array_append | ( | const dynamic_array * | array, |
| const void * | element | ||
| ) |
Append an element to the end of the array.
Automatically resizes if current_size equals current_capacity.
| array | Pointer to the dynamic_array. |
| element | Pointer to the element to append. |
| void dynamic_array_clear | ( | const dynamic_array * | array | ) |
Clear all elements from the array.
Sets current_size to 0. Does not free the memory block.
| array | Pointer to the dynamic_array. |
| bool dynamic_array_clone | ( | const dynamic_array * | original_array, |
| const dynamic_array * | new_array | ||
| ) |
Creates a deep copy of the array.
| array | Pointer to the copy being copied, and one to copy it onto. Must create your own struct instance. |
| dynamic_array * dynamic_array_create | ( | size_t | item_size, |
| unsigned int | starting_capacity, | ||
| unsigned char | growth_factor, | ||
| bool | is_multithread_safe | ||
| ) |
Create and initialize a new dynamic array.
Creates a dynamic array with the specified item size and starting capacity. The growth_factor determines how the array expands when capacity is exceeded.
| item_size | Size of each element in bytes. |
| starting_capacity | Initial number of elements to allocate space for. |
| growth_factor | Growth strategy: 0 = linear (+starting_capacity), 1 = 1.5x, 2+ = multiplier (2 = 2x, 3 = 3x, etc.) |
| is_multithread_safe | If true, enables thread-safe operations. |
| unsigned int dynamic_array_get_capacity | ( | const dynamic_array * | array | ) |
Get the total capacity of the array.
| array | Pointer to the dynamic_array. |
| const void * dynamic_array_get_const_pointer_to_index | ( | const dynamic_array * | array, |
| const unsigned int | index | ||
| ) |
Get a const pointer to the element at the specified index.
| array | Pointer to the dynamic_array. |
| index | Index of the element to access. |
| unsigned int dynamic_array_get_occupancy | ( | const dynamic_array * | array | ) |
Get the number of elements currently in the array.
| array | Pointer to the dynamic_array. |
| unsigned short dynamic_array_get_owner_count | ( | const dynamic_array * | array | ) |
Get the current owner count.
| array | Pointer to the dynamic_array. |
| void * dynamic_array_get_pointer_to_index | ( | const dynamic_array * | array, |
| const unsigned int | index | ||
| ) |
Get a pointer to the element at the specified index.
| array | Pointer to the dynamic_array. |
| index | Index of the element to access. |
| bool dynamic_array_increase_capacity | ( | const dynamic_array * | array, |
| const unsigned int | new_capacity | ||
| ) |
Reserve additional capacity without changing size.
| array | Pointer to the dynamic_array. |
| new_capacity | Desired capacity. |
| bool dynamic_array_is_empty | ( | const dynamic_array * | array | ) |
Check if the array is empty.
| array | Pointer to the dynamic_array. |
| bool dynamic_array_is_thread_safe | ( | const dynamic_array * | array | ) |
Check if the array is thread-safe.
| array | Pointer to the dynamic_array. |
| bool dynamic_array_pop | ( | const dynamic_array * | array | ) |
Remove the last element from the array.
Decrements current_size. Does not free the memory block.
| array | Pointer to the dynamic_array. |
| bool dynamic_array_release | ( | const dynamic_array * | array | ) |
Decrement the owner count for shared ownership.
If owner_count reaches 0, the array is automatically destroyed.
| array | Pointer to the dynamic_array. |
| bool dynamic_array_remove | ( | const dynamic_array * | array, |
| const unsigned int | index | ||
| ) |
Remove an element at the specified index.
Shifts subsequent elements down to fill the gap.
| array | Pointer to the dynamic_array. |
| index | Index of the element to remove. |