cc_vector.h file
Classes
- struct cc_vector
- struct cc_vector_iterator
- Iterator support for cc_
vector.
Typedefs
-
using cc_vector_t = struct cc_
vector -
using cc_vector_iterator_t = struct cc_
vector_ iterator - Iterator support for cc_
vector.
Functions
-
auto cc_vector_create(size_t initial_capacity) -> cc_
vector_ t* - create cc_
vector -
void cc_vector_free(cc_
vector_ t* vector) - free cc_
vector from memory -
auto cc_vector_at(cc_
vector_ t* vector, size_t index) -> void* - get request data at given index (with bound checking)
-
auto cc_vector_front(cc_
vector_ t* vector) -> void* - Get first element of the vector.
-
auto cc_vector_back(cc_
vector_ t* vector) -> void* - get the last element of the vector
-
void cc_vector_push_back(cc_
vector_ t* vector, void* data) - insert new data to the vector as last element
-
auto cc_vector_size(cc_
vector_ t* vector) -> size_t - return the size of elements inside vector
- auto cc_vector_maxsize(void) -> size_t
- Returns the maximum number of elements the container is able to hold due to system or library implementation limitations.
-
void cc_vector_shrint_to_fix(cc_
vector_ t* vector) - Requests the removal of unused capacity.
-
auto cc_vector_capacity(cc_
vector_ t* vector) -> size_t - Returns the number of elements that the container has currently allocated space for.
-
void cc_vector_clear(cc_
vector_ t* vector) - Clears the entire vector.
-
void cc_vector_erase(cc_
vector_ t* vector, size_t pos) - Erase the element at position.
-
auto cc_vector_iterator_begin(cc_
vector_ t* vector) -> cc_ vector_ iterator_ t - initializes the iterator at the beginning of the vector.
-
auto cc_vector_iterator_next(cc_
vector_ iterator_ t* iter) -> void* - advances the iterator and returns the current element.
Defines
- #define CC_VECTOR_DEFAULT_CAPACITY_INCREASE_SIZE
- #define CC_VECTOR_MAX_SIZE
- #define CC_VECTOR_DEFAULT_CAPACITY
- #define CC_VECTOR_EXIT_FAILURE
- #define CC_VECTOR_LOG(format, ...)
Function documentation
cc_ vector_ t* cc_vector_create(size_t initial_capacity)
create cc_
| Parameters | |
|---|---|
| initial_capacity | initial capacity of cc_ |
| Returns | cc_vector_t* |
void cc_vector_free(cc_ vector_ t* vector)
free cc_
| Parameters | |
|---|---|
| vector | cc_vector_t to free |
void* cc_vector_at(cc_ vector_ t* vector,
size_t index)
get request data at given index (with bound checking)
| Parameters | |
|---|---|
| vector | vector to look for |
| index | index to look for given vector |
| Returns | cc_vector_t* |
void* cc_vector_front(cc_ vector_ t* vector)
Get first element of the vector.
| Parameters | |
|---|---|
| vector | |
| Returns | void* |
void* cc_vector_back(cc_ vector_ t* vector)
get the last element of the vector
| Parameters | |
|---|---|
| vector | |
| Returns | void* |
void cc_vector_push_back(cc_ vector_ t* vector,
void* data)
insert new data to the vector as last element
| Parameters | |
|---|---|
| vector | |
| data | |
size_t cc_vector_maxsize(void)
Returns the maximum number of elements the container is able to hold due to system or library implementation limitations.
| Returns | const size_t |
|---|
void cc_vector_shrint_to_fix(cc_ vector_ t* vector)
Requests the removal of unused capacity.
| Parameters | |
|---|---|
| vector | |
size_t cc_vector_capacity(cc_ vector_ t* vector)
Returns the number of elements that the container has currently allocated space for.
| Parameters | |
|---|---|
| vector | |
| Returns | size_t |
void cc_vector_erase(cc_ vector_ t* vector,
size_t pos)
Erase the element at position.
| Parameters | |
|---|---|
| vector | |
| pos | |
cc_ vector_ iterator_ t cc_vector_iterator_begin(cc_ vector_ t* vector)
initializes the iterator at the beginning of the vector.
| Parameters | |
|---|---|
| vector | to initilize iterator on |
| Returns | cc_vector_iterator_t iterator itself |
void* cc_vector_iterator_next(cc_ vector_ iterator_ t* iter)
advances the iterator and returns the current element.
| Parameters | |
|---|---|
| iter | iterator that runs |
| Returns | void* data to return |