| include/Zycore/Vector.h(3) | Library Functions Manual | include/Zycore/Vector.h(3) |
include/Zycore/Vector.h
#include <Zycore/Allocator.h>
#include <Zycore/Comparison.h>
#include <Zycore/Object.h>
#include <Zycore/Status.h>
#include <Zycore/Types.h>
struct ZyanVector_
#define ZYAN_VECTOR_MIN_CAPACITY 1
#define ZYAN_VECTOR_DEFAULT_GROWTH_FACTOR 2
#define ZYAN_VECTOR_DEFAULT_SHRINK_THRESHOLD 4
#define ZYAN_VECTOR_INITIALIZER
#define ZYAN_VECTOR_GET(type, vector, index) (*(const
type*)ZyanVectorGet(vector, index))
#define ZYAN_VECTOR_FOREACH(type, vector, item_name, body)
#define ZYAN_VECTOR_FOREACH_MUTABLE(type, vector, item_name, body)
typedef struct ZyanVector_ ZyanVector
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus
ZyanVectorInit (ZyanVector *vector, ZyanUSize element_size,
ZyanUSize capacity, ZyanMemberProcedure destructor)
ZYCORE_EXPORT ZyanStatus ZyanVectorInitEx
(ZyanVector *vector, ZyanUSize element_size, ZyanUSize capacity,
ZyanMemberProcedure destructor, ZyanAllocator *allocator,
ZyanU8 growth_factor, ZyanU8 shrink_threshold)
ZYCORE_EXPORT ZyanStatus ZyanVectorInitCustomBuffer
(ZyanVector *vector, ZyanUSize element_size, void *buffer, ZyanUSize
capacity, ZyanMemberProcedure destructor)
ZYCORE_EXPORT ZyanStatus ZyanVectorDestroy
(ZyanVector *vector)
ZYCORE_EXPORT ZYAN_REQUIRES_LIBC ZyanStatus
ZyanVectorDuplicate (ZyanVector *destination, const
ZyanVector *source, ZyanUSize capacity)
ZYCORE_EXPORT ZyanStatus ZyanVectorDuplicateEx
(ZyanVector *destination, const ZyanVector *source, ZyanUSize
capacity, ZyanAllocator *allocator, ZyanU8 growth_factor, ZyanU8
shrink_threshold)
ZYCORE_EXPORT ZyanStatus ZyanVectorDuplicateCustomBuffer
(ZyanVector *destination, const ZyanVector *source, void
*buffer, ZyanUSize capacity)
ZYCORE_EXPORT const void * ZyanVectorGet (const
ZyanVector *vector, ZyanUSize index)
ZYCORE_EXPORT void * ZyanVectorGetMutable (const
ZyanVector *vector, ZyanUSize index)
ZYCORE_EXPORT ZyanStatus ZyanVectorGetPointer (const
ZyanVector *vector, ZyanUSize index, const void **value)
ZYCORE_EXPORT ZyanStatus ZyanVectorGetPointerMutable
(const ZyanVector *vector, ZyanUSize index, void **value)
ZYCORE_EXPORT ZyanStatus ZyanVectorSet (ZyanVector
*vector, ZyanUSize index, const void *value)
ZYCORE_EXPORT ZyanStatus ZyanVectorPushBack
(ZyanVector *vector, const void *element)
ZYCORE_EXPORT ZyanStatus ZyanVectorInsert
(ZyanVector *vector, ZyanUSize index, const void *element)
ZYCORE_EXPORT ZyanStatus ZyanVectorInsertRange
(ZyanVector *vector, ZyanUSize index, const void *elements, ZyanUSize
count)
ZYCORE_EXPORT ZyanStatus ZyanVectorEmplace
(ZyanVector *vector, void **element, ZyanMemberFunction
constructor)
ZYCORE_EXPORT ZyanStatus ZyanVectorEmplaceEx
(ZyanVector *vector, ZyanUSize index, void **element,
ZyanMemberFunction constructor)
ZYCORE_EXPORT ZyanStatus ZyanVectorSwapElements
(ZyanVector *vector, ZyanUSize index_first, ZyanUSize index_second)
ZYCORE_EXPORT ZyanStatus ZyanVectorDelete
(ZyanVector *vector, ZyanUSize index)
ZYCORE_EXPORT ZyanStatus ZyanVectorDeleteRange
(ZyanVector *vector, ZyanUSize index, ZyanUSize count)
ZYCORE_EXPORT ZyanStatus ZyanVectorPopBack
(ZyanVector *vector)
ZYCORE_EXPORT ZyanStatus ZyanVectorClear
(ZyanVector *vector)
ZYCORE_EXPORT ZyanStatus ZyanVectorFind (const
ZyanVector *vector, const void *element, ZyanISize *found_index,
ZyanEqualityComparison comparison)
ZYCORE_EXPORT ZyanStatus ZyanVectorFindEx (const
ZyanVector *vector, const void *element, ZyanISize *found_index,
ZyanEqualityComparison comparison, ZyanUSize index, ZyanUSize count)
ZYCORE_EXPORT ZyanStatus ZyanVectorBinarySearch (const
ZyanVector *vector, const void *element, ZyanUSize *found_index,
ZyanComparison comparison)
ZYCORE_EXPORT ZyanStatus ZyanVectorBinarySearchEx (const
ZyanVector *vector, const void *element, ZyanUSize *found_index,
ZyanComparison comparison, ZyanUSize index, ZyanUSize count)
ZYCORE_EXPORT ZyanStatus ZyanVectorResize
(ZyanVector *vector, ZyanUSize size)
ZYCORE_EXPORT ZyanStatus ZyanVectorResizeEx
(ZyanVector *vector, ZyanUSize size, const void *initializer)
ZYCORE_EXPORT ZyanStatus ZyanVectorReserve
(ZyanVector *vector, ZyanUSize capacity)
ZYCORE_EXPORT ZyanStatus ZyanVectorShrinkToFit
(ZyanVector *vector)
ZYCORE_EXPORT ZyanStatus ZyanVectorGetCapacity (const
ZyanVector *vector, ZyanUSize *capacity)
ZYCORE_EXPORT ZyanStatus ZyanVectorGetSize (const
ZyanVector *vector, ZyanUSize *size)
Implements the vector container class.
The default growth factor for all vector instances.
The default shrink threshold for all vector instances.
Value:.PP
{ \
const ZyanUSize ZYAN_MACRO_CONCAT_EXPAND(size_d50d3303, item_name) = (vector)->size; \
for (ZyanUSize ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name) = 0; \
ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name) < \
ZYAN_MACRO_CONCAT_EXPAND(size_d50d3303, item_name); \
++ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name)) \
{ \
const type item_name = ZYAN_VECTOR_GET(type, vector, \
ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name)); \
body \
} \
}
Loops through all elements of the vector.
Parameters
Value:.PP
{ \
const ZyanUSize ZYAN_MACRO_CONCAT_EXPAND(size_d50d3303, item_name) = (vector)->size; \
for (ZyanUSize ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name) = 0; \
ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name) < \
ZYAN_MACRO_CONCAT_EXPAND(size_d50d3303, item_name); \
++ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name)) \
{ \
type* const item_name = ZyanVectorGetMutable(vector, \
ZYAN_MACRO_CONCAT_EXPAND(i_bfd62679, item_name)); \
body \
} \
}
Loops through all elements of the vector.
Parameters
Returns the value of the element at the given index.
Parameters
Returns
Note that this function is unsafe and might dereference a null-pointer.
Value:.PP
{ \
/* allocator */ ZYAN_NULL, \
/* growth_factor */ 0, \
/* shrink_threshold */ 0, \
/* size */ 0, \
/* capacity */ 0, \
/* element_size */ 0, \
/* destructor */ ZYAN_NULL, \
/* data */ ZYAN_NULL \
}
Defines an uninitialized ZyanVector instance.
The initial minimum capacity (number of elements) for all dynamically allocated vector instances.
Defines the ZyanVector struct.
All fields in this struct should be considered as 'private'. Any changes may lead to unexpected behavior.
Searches for the first occurrence of element in the given vector using a binary- search algorithm.
Parameters
Returns
If found, found_index contains the zero-based index of element. If not found, found_index contains the index of the first entry larger than element.
This function requires all elements in the vector to be strictly ordered (sorted).
Searches for the first occurrence of element in the given vector using a binary- search algorithm.
Parameters
Returns
If found, found_index contains the zero-based index of element. If not found, found_index contains the index of the first entry larger than element.
This function requires all elements in the vector to be strictly ordered (sorted).
Erases all elements of the given vector.
Parameters
Returns
Deletes the element at the given index of the vector.
Parameters
Returns
Deletes multiple elements from the given vector, starting at index.
Parameters
Returns
Destroys the given ZyanVector instance.
Parameters
Returns
Initializes a new ZyanVector instance by duplicating an existing vector.
Parameters
This value is automatically adjusted to the size of the source vector, if
a smaller value was passed.
Returns
The memory for the vector is dynamically allocated by the default allocator using the default growth factor and the default shrink threshold.
Finalization with ZyanVectorDestroy is required for all instances created by this function.
Initializes a new ZyanVector instance by duplicating an existing vector and configures it to use a custom user defined buffer with a fixed size.
Parameters
This function will fail, if the capacity of the buffer is less than the
size of the source vector.
Returns
Finalization is not required for instances created by this function.
Initializes a new ZyanVector instance by duplicating an existing vector and sets a custom allocator and memory allocation/deallocation parameters.
Parameters
This value is automatically adjusted to the size of the source
vector, if a smaller value was passed.
allocator A pointer to a ZyanAllocator instance.
growth_factor The growth factor.
shrink_threshold The shrink threshold.
Returns
A growth factor of 1 disables overallocation and a shrink threshold of 0 disables dynamic shrinking.
Finalization with ZyanVectorDestroy is required for all instances created by this function.
Constructs an element in-place at the end of the vector.
Parameters
Returns
Constructs an element in-place and inserts it at the given index of the vector.
Parameters
Returns
Sequentially searches for the first occurrence of element in the given vector.
Parameters
Returns
The found_index is set to -1, if the element was not found.
Sequentially searches for the first occurrence of element in the given vector.
Parameters
Returns
The found_index is set to -1, if the element was not found.
Returns a constant pointer to the element at the given index.
Parameters
Returns
Note that the returned pointer might get invalid when the vector is resized by either a manual call to the memory-management functions or implicitly by inserting or removing elements.
Take a look at ZyanVectorGetPointer instead, if you need a function that returns a zyan status code.
Returns the current capacity of the vector.
Parameters
Returns
Returns a mutable pointer to the element at the given index.
Parameters
Returns
Note that the returned pointer might get invalid when the vector is resized by either a manual call to the memory-management functions or implicitly by inserting or removing elements.
Take a look at ZyanVectorGetPointerMutable instead, if you need a function that returns a zyan status code.
Returns a constant pointer to the element at the given index.
Parameters
Note that the returned pointer might get invalid when the vector is resized by either a manual call to the memory-management functions or implicitly by inserting or removing elements.
Returns
Returns a mutable pointer to the element at the given index.
Parameters
Note that the returned pointer might get invalid when the vector is resized by either a manual call to the memory-management functions or implicitly by inserting or removing elements.
Returns
Returns the current size of the vector.
Parameters
Returns
Initializes the given ZyanVector instance.
Parameters
Returns
The memory for the vector elements is dynamically allocated by the default allocator using the default growth factor and the default shrink threshold.
Finalization with ZyanVectorDestroy is required for all instances created by this function.
Initializes the given ZyanVector instance and configures it to use a custom user defined buffer with a fixed size.
Parameters
Returns
Finalization is not required for instances created by this function.
Initializes the given ZyanVector instance and sets a custom allocator and memory allocation/deallocation parameters.
Parameters
Returns
A growth factor of 1 disables overallocation and a shrink threshold of 0 disables dynamic shrinking.
Finalization with ZyanVectorDestroy is required for all instances created by this function.
Inserts an element at the given index of the vector.
Parameters
Returns
Inserts multiple elements at the given index of the vector.
Parameters
Returns
Removes the last element of the vector.
Parameters
Returns
Adds a new element to the end of the vector.
Parameters
Returns
Changes the capacity of the given ZyanVector instance.
Parameters
Returns
Resizes the given ZyanVector instance.
Parameters
Returns
Resizes the given ZyanVector instance.
Parameters
Returns
Assigns a new value to the element at the given index.
Parameters
Returns
Shrinks the capacity of the given vector to match it's size.
Parameters
Returns
Swaps the element at index_first with the element at index_second.
Parameters
Returns
This function requires the vector to have spare capacity for one temporary element. Call ZyanVectorReserve before this function to increase capacity, if needed.
Generated automatically by Doxygen for Zycore from the source code.
| Version 1.5.2.0 | Zycore |