C Collections

cvector · Section 3

cvector_pop_back

cvector_pop_back - remove and return the last element from the vector

C Collections (libccollections, -lccollections)

#include <ccollections/cvector.h>
 
ccol_retval cvector_pop_back(cvec v, void *target_elem);

Removes the last element of the vector and copies it into the target
buffer. When that leaves the vector less than 1/4 full, the capacity is
halved, down to the minimum of 4.

v            Vector to pop from
target_elem  Pointer to the buffer that receives the element (must not
             be NULL)

ccol_success        - The element was popped
ccol_invalid_args   - target_elem is NULL
ccol_container_empty - The vector is empty

O(1). The element is copied into target_elem, and the capacity halves
when the vector is less than 1/4 full, never going below 4. Asserts if v
is NULL.

cvector_push_back(3), cvec_pop(3)