VecPopBack
Description
Remove and optionally return the last element of the vector.
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in,out | Vector handle. |
ptr |
out | Optional destination for the popped element. Pass NULL to just delete it (the configured copy_deinit is invoked instead). |
Success
Returns to the caller. The vector length shrinks by one. When ptr is non-NULL the removed value is bit-copied into *ptr.
Failure
Function cannot fail. Calling on an empty vector is a caller bug and aborts via LOG_FATAL.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Graph.c:192:
}
VecPopBack(&graph->free_indices, &index);
return index;
}- In
VecCharPtr.c:77:
if (VecLen(vec) > 0) {
char *str;
VecPopBack(vec, &str);
// char_ptr_deinit is called automatically by the vector
}- In
VecStr.c:102:
if (VecLen(vec) > 0) {
Str str;
VecPopBack(vec, &str);
// StrDeinit is called automatically by the vector
}- In
VecInt.c:51:
if (VecLen(vec) > 0) {
i32 popped;
VecPopBack(vec, &popped);
}
break;- In
Vec.Remove.c:31:
bool test_vec_pop_back(void) {
WriteFmtLn("Testing VecPopBack");
// Create a vector of integers
- In
Vec.Remove.c:49:
// Pop from the back
int popped;
VecPopBack(&vec, &popped);
// Check popped value
- In
Vec.Remove.c:63:
// Pop again
VecPopBack(&vec, &popped);
// Check popped value
- In
Remove.h:172:
/// TAGS: Vec, Delete, Back
///
#define VecDeleteLast(v) VecPopBack((v), (VEC_DATATYPE(v) *)NULL)
///
- In
Remove.h:23:
/// TAGS: Str, Remove, Pop, Back
///
#define StrPopBack(str, chr) VecPopBack((str), (chr))
///
Last updated on