cvector · Section 3
cvector_push_back
NAME
cvector_push_back - append an element to the end of the vector
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cvector.h> ccol_retval cvector_push_back(cvec v, const void *new_elem);
DESCRIPTION
Adds a new element at the end of the vector, which doubles its capacity by itself when it is full. The element is copied in with an assignment that the library picks from the element size.
PARAMETERS
v Vector to append to new_elem Pointer to the element to append (must not be NULL)
RETURN VALUE
ccol_success - The element was appended ccol_invalid_args - new_elem is NULL ccol_container_full - The vector has reached ccol_max_elem_count ccol_not_enough_memory - Growing the capacity failed
NOTES
Amortized O(1). The element is copied into the vector, and a full vector doubles its capacity. Asserts if v is NULL. new_elem can safely point into the backing buffer of v, for example a pointer from cvector_data_ptr(3) or cvector_at(3); a capacity growth started by this call doesn't invalidate it.