|
Vector 1.0.0
|
Access and manipulate elements of a vector. More...
Functions | |
| char * | vector_data (const vector_t *const vector) |
| Gives a pointer to a location where elements' data begins. | |
| void * | vector_get (const vector_t *const vector, const size_t index) |
Returns pointer for the element at index. | |
| void | vector_set (vector_t *const vector, const size_t index, const void *const value) |
Sets element at given index to a value. | |
| void | vector_set_zero (vector_t *const vector, const size_t index) |
Sets element at given index to a zero value. | |
| void | vector_copy (const vector_t *const vector, char *dest, const size_t offset, const size_t length) |
| Copy element range to other location. | |
| void | vector_move (const vector_t *const vector, char *dest, const size_t offset, const size_t length) |
| Moves range of the vector elements to another location. | |
| void | vector_part_copy (const vector_t *const vector, char *dest, const size_t offset, const size_t length, const size_t part_offset, const size_t part_length) |
| Partial copying. | |
| void | vector_spread (vector_t *const vector, const size_t index, const size_t amount) |
| Duplicates existing element across range. | |
| void | vector_shift (vector_t *const vector, const size_t offset, const size_t length, const ssize_t shift) |
| Shift range of elements. | |
| void | vector_swap (vector_t *const vector, const size_t index_a, const size_t index_b) |
| Swaps values of elements designated by indicies. | |
| int | vector_foreach (const vector_t *const vector, const size_t limit, const foreach_t func, void *const param) |
| Perform immutable action on each element of the vector. | |
| int | vector_aggregate (const vector_t *const vector, const size_t limit, const aggregate_t func, void *const acc, void *const param) |
| Perform immutable accamulating action on each element of the vector. | |
| int | vector_transform (vector_t *const vector, const size_t limit, const transform_t func, void *const param) |
| Perform mutable transformation on each element of the vector. | |
Access and manipulate elements of a vector.
| char * vector_data | ( | const vector_t *const | vector | ) |
Gives a pointer to a location where elements' data begins.
| [in] | vector | Pointer to a vector instance. |
Definition at line 264 of file vector.c.
| void * vector_get | ( | const vector_t *const | vector, |
| const size_t | index ) |
| void vector_set | ( | vector_t *const | vector, |
| const size_t | index, | ||
| const void *const | value ) |
| void vector_set_zero | ( | vector_t *const | vector, |
| const size_t | index ) |
| void vector_copy | ( | const vector_t *const | vector, |
| char * | dest, | ||
| const size_t | offset, | ||
| const size_t | length ) |
Copy element range to other location.
Copies range [offset, offset + length) elements into a destination pointer. Destination pointer can point to vector's buffer.
| [in] | vector | Pointer to vector instance. |
| [out] | dest | Destination pointer. |
| [in] | offset | Offset in elements (begin index). |
| [in] | length | Size of the coping range in elements. |
Definition at line 296 of file vector.c.
| void vector_move | ( | const vector_t *const | vector, |
| char * | dest, | ||
| const size_t | offset, | ||
| const size_t | length ) |
Moves range of the vector elements to another location.
Works as vector_copy, but supports overlapping regions.
| [in] | vector | Pointer to vector instance. |
| [out] | dest | Destination pointer. |
| [in] | offset | Offset in elements (begin index). |
| [in] | length | Size of the coping range in elements. |
Definition at line 306 of file vector.c.
| void vector_part_copy | ( | const vector_t *const | vector, |
| char * | dest, | ||
| const size_t | offset, | ||
| const size_t | length, | ||
| const size_t | part_offset, | ||
| const size_t | part_length ) |
Partial copying.
Partial copy of the elements in a range [offset, offset + length], where part of the element described by part_offset and part_length in bytes. All parts stored in a contiguous destination array one next to another.
| [in] | vector | Pointer to vector instance. |
| [out] | dest | Destination pointer. |
| [in] | offset | Offset in elements (begin index). |
| [in] | length | Size of the coping range in elements. |
| [in] | part_offset | Offset in bytes inside an element, begining of the portion to copy. |
| [in] | part_length | Length of the copying portion in bytes. |
Definition at line 316 of file vector.c.
| void vector_spread | ( | vector_t *const | vector, |
| const size_t | index, | ||
| const size_t | amount ) |
Duplicates existing element across range.
Copies element at index across amount of elements including index.
| 0 | 1 | 2 | 3 | | | X | | index = 1 | | X | X | X | amount = 3
| [in] | vector | Pointer to a vector instance. |
| [in] | index | Index at which perform spread. |
| [in] | amount | Length of the spread range. (1 - has no effect) |
Definition at line 334 of file vector.c.
| void vector_shift | ( | vector_t *const | vector, |
| const size_t | offset, | ||
| const size_t | length, | ||
| const ssize_t | shift ) |
Shift range of elements.
Shifting length elements at offset by shift times in direction of a sign. Data will be overriden by shifted range. shift < 0 => left; shift > 0 => right;
| [in] | vector | Pointer to vector instance. |
| [in] | offset | Offset in elements (begin index). |
| [in] | length | Size of the shifting range in elements. |
| [in] | shift | Direction and steps to shift in elements. |
Definition at line 358 of file vector.c.
| void vector_swap | ( | vector_t *const | vector, |
| const size_t | index_a, | ||
| const size_t | index_b ) |
Swaps values of elements designated by indicies.
| [in] | vector | Pointer to vector instance. |
| [in] | index_a | Designator of the first element. |
| [in] | index_b | Designarot of the second element. |
Definition at line 370 of file vector.c.
| int vector_foreach | ( | const vector_t *const | vector, |
| const size_t | limit, | ||
| const foreach_t | func, | ||
| void *const | param ) |
Perform immutable action on each element of the vector.
Run non-modifying func on limit elements of the vector.
| [in] | vector | Pointer to vector instance. |
| [in] | limit | Limit maximum iterations. |
| [in] | func | Action to be performed. |
| [in,out] | param | User defined parameter, passed to func. |
Definition at line 382 of file vector.c.
| int vector_aggregate | ( | const vector_t *const | vector, |
| const size_t | limit, | ||
| const aggregate_t | func, | ||
| void *const | acc, | ||
| void *const | param ) |
Perform immutable accamulating action on each element of the vector.
Run non-modifying function on limit elements of the vector reducing them into acc. Return zero on success, or nonzero value - user defined status code.
| [in] | vector | Pointer to vector instance. |
| [in] | limit | Limit maximum iterations. |
| [in] | func | Action to be performed. |
| [out] | acc | Accamulator that stores calculation result. |
| [in,out] | param | User defined parameter, passed to func. |
Definition at line 398 of file vector.c.
| int vector_transform | ( | vector_t *const | vector, |
| const size_t | limit, | ||
| const transform_t | func, | ||
| void *const | param ) |
Perform mutable transformation on each element of the vector.
Run modifying function on limit elements of the vector.
| [in] | vector | Pointer to vector instance. |
| [in] | limit | Limit maximum iterations. |
| [in] | func | Action to be performed. |
| [in,out] | param | User defined parameter, passed to func. |
Definition at line 414 of file vector.c.