VecFirst
Description
First element of the vector by value. Caller must ensure the vector is non-empty.
Parameters
| Name | Direction | Description |
|---|---|---|
v |
in | Vector to query. |
Usage example (Cross-references)
Usage examples (Cross-references)
- In
VecCharPtr.c:140:
case VEC_CHAR_PTR_FIRST : {
if (VecLen(vec) > 0) {
char *first = VecFirst(vec);
(void)first; // Use the result to avoid warnings
}- In
VecStr.c:162:
case VEC_STR_FIRST : {
if (VecLen(vec) > 0) {
Str first = VecFirst(vec);
(void)first; // Use the result to avoid warnings
}- In
VecInt.c:108:
case VEC_INT_FIRST : {
if (VecLen(vec) > 0) {
volatile i32 first = VecFirst(vec);
(void)first;
}- In
Vec.Access.c:101:
// Test VecFirst and VecLast functions
bool test_vec_first_last(void) {
WriteFmt("Testing VecFirst and VecLast\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
Vec.Access.c:115:
// Check first and last elements
bool result = (VecFirst(&vec) == 10);
result = result && (VecLast(&vec) == 30);- In
Vec.Access.c:119:
// Modify first and last elements
VecFirst(&vec) = 15;
VecLast(&vec) = 35;- In
Access.h:69:
/// TAGS: Str, Access, First
///
#define StrFirst(str) VecFirst(str)
///
Last updated on