ccontainer/cc_vector.h file

Contents

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_vector

Parameters
initial_capacity initial capacity of cc_vector
Returns cc_vector_t*

void cc_vector_free(cc_vector_t* vector)

free cc_vector from memory

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_size(cc_vector_t* vector)

return the size of elements inside vector

Returns size_t

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_clear(cc_vector_t* vector)

Clears the entire vector.

Parameters
vector

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