Vector 0.0.2
Loading...
Searching...
No Matches
Elements

Access and manipulate elements of a vector. More...

Collaboration diagram for Elements:

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.
 

Detailed Description

Access and manipulate elements of a vector.

Function Documentation

◆ vector_data()

char * vector_data ( const vector_t *const vector)

Gives a pointer to a location where elements' data begins.

Warning
Does not assert when capacity is zero. Intended to be used for pointer arithmetics in derived containers.
Parameters
[in]vectorPointer to a vector instance.
Returns
Location where elements are stored.

Definition at line 264 of file vector.c.

Here is the call graph for this function:

◆ vector_get()

void * vector_get ( const vector_t *const vector,
const size_t index )

Returns pointer for the element at index.

Parameters
[in]vectorPointer to a vector instance.
[in]indexDenotes an element to be accessed.
Returns
A pointer to a vector element at index.

Definition at line 271 of file vector.c.

Here is the call graph for this function:

◆ vector_set()

void vector_set ( vector_t *const vector,
const size_t index,
const void *const value )

Sets element at given index to a value.

Parameters
[in]vectorPointer to a vector instance.
[in]indexDenotes an element to be overriden by value.
[in]valueValue to be stored at the index.

Definition at line 280 of file vector.c.

Here is the call graph for this function:

◆ vector_set_zero()

void vector_set_zero ( vector_t *const vector,
const size_t index )

Sets element at given index to a zero value.

Parameters
[in]vectorPointer to a vector instance.
[in]indexDenotes an element to be zeroed.

Definition at line 288 of file vector.c.

Here is the call graph for this function:

◆ vector_copy()

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.

Parameters
[in]vectorPointer to vector instance.
[out]destDestination pointer.
[in]offsetOffset in elements (begin index).
[in]lengthSize of the coping range in elements.

Definition at line 296 of file vector.c.

Here is the call graph for this function:

◆ vector_move()

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.

Parameters
[in]vectorPointer to vector instance.
[out]destDestination pointer.
[in]offsetOffset in elements (begin index).
[in]lengthSize of the coping range in elements.

Definition at line 306 of file vector.c.

Here is the call graph for this function:

◆ vector_part_copy()

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.

Parameters
[in]vectorPointer to vector instance.
[out]destDestination pointer.
[in]offsetOffset in elements (begin index).
[in]lengthSize of the coping range in elements.
[in]part_offsetOffset in bytes inside an element, begining of the portion to copy.
[in]part_lengthLength of the copying portion in bytes.

Definition at line 316 of file vector.c.

Here is the call graph for this function:

◆ vector_spread()

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
Parameters
[in]vectorPointer to a vector instance.
[in]indexIndex at which perform spread.
[in]amountLength of the spread range. (1 - has no effect)

Definition at line 334 of file vector.c.

Here is the call graph for this function:

◆ vector_shift()

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;

Parameters
[in]vectorPointer to vector instance.
[in]offsetOffset in elements (begin index).
[in]lengthSize of the shifting range in elements.
[in]shiftDirection and steps to shift in elements.

Definition at line 358 of file vector.c.

Here is the call graph for this function:

◆ vector_swap()

void vector_swap ( vector_t *const vector,
const size_t index_a,
const size_t index_b )

Swaps values of elements designated by indicies.

Warning
index_a should differ from index_b
Parameters
[in]vectorPointer to vector instance.
[in]index_aDesignator of the first element.
[in]index_bDesignarot of the second element.

Definition at line 370 of file vector.c.

Here is the call graph for this function:

◆ vector_foreach()

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.

Parameters
[in]vectorPointer to vector instance.
[in]limitLimit maximum iterations.
[in]funcAction to be performed.
[in,out]paramUser defined parameter, passed to func.
Returns
Zero on success, or nonzero value - user defined status code.

Definition at line 382 of file vector.c.

Here is the call graph for this function:

◆ vector_aggregate()

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.

Parameters
[in]vectorPointer to vector instance.
[in]limitLimit maximum iterations.
[in]funcAction to be performed.
[out]accAccamulator that stores calculation result.
[in,out]paramUser defined parameter, passed to func.
Returns
Zero on success, or nonzero value - user defined status code.

Definition at line 398 of file vector.c.

Here is the call graph for this function:

◆ vector_transform()

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.

Parameters
[in]vectorPointer to vector instance.
[in]limitLimit maximum iterations.
[in]funcAction to be performed.
[in,out]paramUser defined parameter, passed to func.
Returns
Zero on success, or nonzero value - user defined status code.

Definition at line 414 of file vector.c.

Here is the call graph for this function: