Automatically growing array of arbitrary data. More...
#include <kanzi/core/legacy/util/collection/kzc_comparator.hpp>
#include <kanzi/core/legacy/util/collection/kzc_collection_value.hpp>
#include <kanzi/core/legacy/memory/kzc_memory_manager.hpp>
#include <kanzi/core/legacy/kzs_types.hpp>
#include <kanzi/core/legacy/debug/kzs_error.hpp>
#include "kzc_dynamic_array_accessors_hpp.inl"
Classes | |
struct | KzcDynamicArray |
Structure of a DynamicArray. More... | |
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... | |
KANZI_API 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... | |
KANZI_API 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... | |
KANZI_API kzsError | kzcDynamicArrayRemoveByIndex (struct KzcDynamicArray *dynamicArray, const kzUint index) |
Removes the index'th element from the dynamic array. More... | |
KANZI_API void | kzcDynamicArraySort (const struct KzcDynamicArray *dynamicArray, KzcComparatorFunction comparator) |
Sorts the given dynamic array according to the given comparator function. More... | |
KANZI_API void | kzcDynamicArraySortWithContext (const struct KzcDynamicArray *dynamicArray, KzcComparatorWithContextFunction comparator, const void *context) |
Sorts the given dynamic array according to the given comparator function. More... | |
KANZI_API void | kzcDynamicArraySwap (const struct KzcDynamicArray *dynamicArray, kzUint indexA, kzUint indexB) |
Swaps places of two elements of a dynamic array with each other. More... | |
KANZI_API 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... | |
KANZI_API 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) |
KANZI_API kzsError | kzcDynamicArrayMutableIteratorRemove_private (struct KzcDynamicArrayMutableIterator *iterator) |
void * | kzcDynamicArrayPointerGet (const struct KzcDynamicArray *dynamicArray, kzUint index) |
Retrieves an element from the pointer dynamic array from the given index. More... | |
Variables | |
KANZI_API 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-2017 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. |
KANZI_API 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.
KANZI_API 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.
KANZI_API 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. |
KANZI_API 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. |
KANZI_API 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. |
KANZI_API 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. |
KANZI_API void kzcDynamicArrayReverse | ( | const struct KzcDynamicArray * | dynamicArray | ) |
Reverses the order of a dynamic array.
dynamicArray | A valid dynamic array. |
|
inline |
Returns the number of elements in the dynamic array.
dynamicArray | A valid dynamic array. |
|
inline |
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 | ) |
KANZI_API kzsError kzcDynamicArrayMutableIteratorRemove_private | ( | struct KzcDynamicArrayMutableIterator * | iterator | ) |
|
inline |
Retrieves an element from the pointer dynamic array from the given index.
The index must not be out of bounds.
KANZI_API 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.