Automatically growing array of arbitrary data. More...
#include "kzc_comparator.h"
#include "kzc_collection_value.h"
#include <system/kzs_types.h>
#include <system/debug/kzs_error.h>
#include <system/kzs_header.h>
#include "kzc_dynamic_array_accessors_h.inl"
Classes | |
struct | KzcDynamicArrayIterator |
Read-only iterator for dynamic array. More... | |
struct | KzcDynamicArrayMutableIterator |
Mutable iterator for dynamic array. More... | |
Macros | |
#define | kzcDynamicArrayIterate(iterator_param) |
Finds the next entry in the attached dynamic array. More... | |
#define | kzcDynamicArrayMutableIterate(iterator_param) |
Finds the next entry in the iterated dynamic array. More... | |
#define | kzcDynamicArrayMutableIteratorRemove(iterator_param) |
Removes the entry pointed by the iterator from the dynamic array. More... | |
Functions | |
KANZI_API kzsError | kzcDynamicArrayCreate (const struct KzcMemoryManager *memoryManager, struct KzcDynamicArray **out_dynamicArray) |
Creates a new initially empty dynamic array with initial capacity of 10. More... | |
kzsError | kzcDynamicArrayCreateWithCapacity (const struct KzcMemoryManager *memoryManager, kzUint capacity, struct KzcDynamicArray **out_dynamicArray) |
Creates a new initially empty dynamic array. More... | |
KANZI_API kzsError | kzcDynamicArrayDelete (struct KzcDynamicArray *dynamicArray) |
Frees the memory allocated for the dynamic array. More... | |
kzsError | kzcDynamicArrayCopy (const struct KzcMemoryManager *memoryManager, const struct KzcDynamicArray *original, struct KzcDynamicArray **out_copy) |
Creates a copy of a dynamic array. More... | |
KANZI_API void | kzcDynamicArrayClear (struct KzcDynamicArray *dynamicArray) |
Removes all the elements from the dynamic array. More... | |
kzsError | kzcDynamicArrayRemoveByIndex (struct KzcDynamicArray *dynamicArray, const kzUint index) |
Removes the index'th element from the dynamic array. More... | |
void | kzcDynamicArraySort (const struct KzcDynamicArray *dynamicArray, KzcComparatorFunction comparator) |
Sorts the given dynamic array according to the given comparator function. More... | |
void | kzcDynamicArraySortWithContext (const struct KzcDynamicArray *dynamicArray, KzcComparatorWithContextFunction comparator, const void *context) |
Sorts the given dynamic array according to the given comparator function. More... | |
void | kzcDynamicArraySwap (const struct KzcDynamicArray *dynamicArray, kzUint indexA, kzUint indexB) |
Swaps places of two elements of a dynamic array with each other. More... | |
void | kzcDynamicArrayReverse (const struct KzcDynamicArray *dynamicArray) |
Reverses the order of a dynamic array. More... | |
KANZI_API kzUint | kzcDynamicArrayGetSize (const struct KzcDynamicArray *dynamicArray) |
Returns the number of elements in the dynamic array. More... | |
KANZI_API kzBool | kzcDynamicArrayIsEmpty (const struct KzcDynamicArray *dynamicArray) |
Checks if the dynamic array is empty or not. More... | |
KANZI_API struct KzcDynamicArrayIterator | kzcDynamicArrayGetIterator (const struct KzcDynamicArray *dynamicArray) |
Returns an iterator for the dynamic array. More... | |
struct KzcDynamicArrayMutableIterator | kzcDynamicArrayGetMutableIterator (struct KzcDynamicArray *dynamicArray) |
Returns a mutable iterator for the dynamic array. More... | |
KZ_INLINE kzBool | kzcDynamicArrayIterate_private (struct KzcDynamicArrayIterator *iterator) |
KZ_INLINE kzBool | kzcDynamicArrayMutableIterate_private (struct KzcDynamicArrayMutableIterator *iterator) |
kzsError | kzcDynamicArrayMutableIteratorRemove_private (struct KzcDynamicArrayMutableIterator *iterator) |
Variables | |
const struct KzcDynamicArrayIterator | KZC_DYNAMIC_ARRAY_EMPTY_ITERATOR |
Dynamic array iterator that can be used for an empty iteration result e.g. More... | |
Automatically growing array of arbitrary data.
The data type of the elements is determined when the first element is added with kzcDynamicArrayPointerAdd(), kzcDynamicArrayIntAdd(), kzcDynamicArrayUintAdd(), kzcDynamicArrayFloatAdd() or kzcDynamicArrayStringAdd(). It is the caller's responsibility to use accessor functions of the right type.
Copyright 2008-2020 by Rightware. All rights reserved.
#define kzcDynamicArrayIterate | ( | iterator_param | ) |
#define kzcDynamicArrayMutableIterate | ( | iterator_param | ) |
#define kzcDynamicArrayMutableIteratorRemove | ( | iterator_param | ) |
Removes the entry pointed by the iterator from the dynamic array.
KANZI_API kzsError kzcDynamicArrayCreate | ( | const struct KzcMemoryManager * | memoryManager, |
struct KzcDynamicArray ** | out_dynamicArray | ||
) |
Creates a new initially empty dynamic array with initial capacity of 10.
memoryManager | The memory manager to use. |
out_dynamicArray | A pointer that is set to point to the new dynamic array on success. |
kzsError kzcDynamicArrayCreateWithCapacity | ( | const struct KzcMemoryManager * | memoryManager, |
kzUint | capacity, | ||
struct KzcDynamicArray ** | out_dynamicArray | ||
) |
Creates a new initially empty dynamic array.
Initial capacity is given as a parameter.
memoryManager | The memory manager to use. |
capacity | The initial capacity of the array. I.e. the number of elements that can be added to the array before more memory needs to be allocated. |
out_dynamicArray | A pointer that is set to point to the new dynamic array on success. |
KANZI_API kzsError kzcDynamicArrayDelete | ( | struct KzcDynamicArray * | dynamicArray | ) |
Frees the memory allocated for the dynamic array.
kzsError kzcDynamicArrayCopy | ( | const struct KzcMemoryManager * | memoryManager, |
const struct KzcDynamicArray * | original, | ||
struct KzcDynamicArray ** | out_copy | ||
) |
Creates a copy of a dynamic array.
memoryManager | The memory manager to use for allocating the copy. |
original | A valid dynamic array. |
out_copy | A pointer that is set to point to the copy on success. |
KANZI_API void kzcDynamicArrayClear | ( | struct KzcDynamicArray * | dynamicArray | ) |
Removes all the elements from the dynamic array.
kzsError kzcDynamicArrayRemoveByIndex | ( | struct KzcDynamicArray * | dynamicArray, |
const kzUint | index | ||
) |
Removes the index'th element from the dynamic array.
dynamicArray | A valid dynamic array. |
index | The index of the element. |
void kzcDynamicArraySort | ( | const struct KzcDynamicArray * | dynamicArray, |
KzcComparatorFunction | comparator | ||
) |
Sorts the given dynamic array according to the given comparator function.
dynamicArray | A valid dynamic array. |
comparator | The comparator function to use for sorting. |
void kzcDynamicArraySortWithContext | ( | const struct KzcDynamicArray * | dynamicArray, |
KzcComparatorWithContextFunction | comparator, | ||
const void * | context | ||
) |
Sorts the given dynamic array according to the given comparator function.
The given arbitrary context is passed to the comparator.
dynamicArray | A valid dynamic array. |
comparator | The comparator function to use for sorting. |
context | An arbitrary pointer passed to the comparator function. |
void kzcDynamicArraySwap | ( | const struct KzcDynamicArray * | dynamicArray, |
kzUint | indexA, | ||
kzUint | indexB | ||
) |
Swaps places of two elements of a dynamic array with each other.
dynamicArray | A valid dynamic array. |
indexA | Index of the first element. |
indexB | Index of the second element. |
void kzcDynamicArrayReverse | ( | const struct KzcDynamicArray * | dynamicArray | ) |
Reverses the order of a dynamic array.
dynamicArray | A valid dynamic array. |
KANZI_API kzUint kzcDynamicArrayGetSize | ( | const struct KzcDynamicArray * | dynamicArray | ) |
Returns the number of elements in the dynamic array.
dynamicArray | A valid dynamic array. |
KANZI_API kzBool kzcDynamicArrayIsEmpty | ( | const struct KzcDynamicArray * | dynamicArray | ) |
KANZI_API struct KzcDynamicArrayIterator kzcDynamicArrayGetIterator | ( | const struct KzcDynamicArray * | dynamicArray | ) |
Returns an iterator for the dynamic array.
dynamicArray | A valid dynamic array. |
struct KzcDynamicArrayMutableIterator kzcDynamicArrayGetMutableIterator | ( | struct KzcDynamicArray * | dynamicArray | ) |
Returns a mutable iterator for the dynamic array.
dynamicArray | A valid dynamic array. |
KZ_INLINE kzBool kzcDynamicArrayIterate_private | ( | struct KzcDynamicArrayIterator * | iterator | ) |
KZ_INLINE kzBool kzcDynamicArrayMutableIterate_private | ( | struct KzcDynamicArrayMutableIterator * | iterator | ) |
kzsError kzcDynamicArrayMutableIteratorRemove_private | ( | struct KzcDynamicArrayMutableIterator * | iterator | ) |
const struct KzcDynamicArrayIterator KZC_DYNAMIC_ARRAY_EMPTY_ITERATOR |
Dynamic array iterator that can be used for an empty iteration result e.g.
when an actual empty dynamic array doesn't exist.