svector.h: vector handling
Vector handling functions for managing integer data and
generic data.
Supported vector types (enum eSV_Type):
SV_I8: int8_t
SV_U8: uint8_t
SV_I16: int16_t
SV_U16: uint16_t
SV_I32: int32_t
SV_U32: uint32_t
SV_I64: int64_t
SV_U64: uint64_t
SV_F: float
SV_D: double
SV_GEN: generic-data (user defined)
srt_vector *sv_alloc(size_t elem_size, size_t initial_num_elems_reserve, const srt_vector_cmp f)
- Allocate SV_GEN vector (heap)
- size_t elem_size: element size
- size_t initial_num_elems_reserve: space preallocated to store n elements
- const srt_vector_cmp f: compare function (used for sorting, pass NULL for none)
- Return (srt_vector *): vector
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_alloc_t(enum eSV_Type t, size_t initial_num_elems_reserve)
- Allocate typed vector (heap)
- enum eSV_Type t: Vector type
- size_t initial_num_elems_reserve: space preallocated to store n elements
- Return (srt_vector *): vector
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_alloca(size_t initial_reserve)
- Allocate SV_GEN vector (stack)
- size_t initial_reserve: space preallocated to store n elements
- Return (srt_vector *): allocated vector
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_alloca_t(enum eSV_Type t, size_t initial_num_elems_reserve)
- Allocate typed vector (stack)
- enum eSV_Type t: Vector type
- size_t initial_num_elems_reserve: space preallocated to store n elements
- Return (srt_vector *): vector
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const void *sv_at(const srt_vector *v, size_t index)
- Vector random access (SV_GEN)
- const srt_vector *v: vector
- size_t index: location
- Return (const void *): NULL: not found; != NULL: element reference
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
double sv_at_d(const srt_vector *v, size_t index)
- Vector random access (SV_D)
- const srt_vector *v: vector
- size_t index: location
- Return (double): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
float sv_at_f(const srt_vector *v, size_t index)
- Vector random access (SV_F)
- const srt_vector *v: vector
- size_t index: location
- Return (float): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int16_t sv_at_i16(const srt_vector *v, size_t index)
- Vector random access (SV_I16)
- const srt_vector *v: vector
- size_t index: location
- Return (int16_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int32_t sv_at_i32(const srt_vector *v, size_t index)
- Vector random access (SV_I32)
- const srt_vector *v: vector
- size_t index: location
- Return (int32_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int64_t sv_at_i64(const srt_vector *v, size_t index)
- Vector random access (SV_I64)
- const srt_vector *v: vector
- size_t index: location
- Return (int64_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int8_t sv_at_i8(const srt_vector *v, size_t index)
- Vector random access (SV_I8)
- const srt_vector *v: vector
- size_t index: location
- Return (int8_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint16_t sv_at_u16(const srt_vector *v, size_t index)
- Vector random access (SV_U16)
- const srt_vector *v: vector
- size_t index: location
- Return (uint16_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t sv_at_u32(const srt_vector *v, size_t index)
- Vector random access (SV_U32)
- const srt_vector *v: vector
- size_t index: location
- Return (uint32_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint64_t sv_at_u64(const srt_vector *v, size_t index)
- Vector random access (SV_U64)
- const srt_vector *v: vector
- size_t index: location
- Return (uint64_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint8_t sv_at_u8(const srt_vector *v, size_t index)
- Vector random access (SV_U8)
- const srt_vector *v: vector
- size_t index: location
- Return (uint8_t): Element value
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_capacity(const srt_vector *v)
- Allocated space
- const srt_vector *v: vector
- Return (size_t): current allocated space (vector elements)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_capacity_left(const srt_vector *v)
- Preallocated space left
- const srt_vector *v: vector
- Return (size_t): allocated space left
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_cat(srt_vector **v, const srt_vector *v1, ...)
- Concatenate vectors to vector
- srt_vector **v: vector
- const srt_vector *v1: first vector to be concatenated
- ...: optional: N additional vectors to be concatenated
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_cat_erase(srt_vector **v, const srt_vector *src, size_t off, size_t n)
- Concatenate vector with erase operation
- srt_vector **v: output vector
- const srt_vector *src: input vector
- size_t off: input vector offset for erase start
- size_t n: erase element count
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_cat_resize(srt_vector **v, const srt_vector *src, size_t n)
- Concatenate vector with input vector copy plus resize operation
- srt_vector **v: output vector
- const srt_vector *src: input vector
- size_t n: number of elements of input vector
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
void sv_clear(srt_vector *v)
- Reset/clean vector (keeping vector type)
- srt_vector *v: vector
- Return (void): -
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int sv_cmp(const srt_vector *v, size_t a_off, size_t b_off)
- Compare two elements from same vector
- const srt_vector *v: vector
- size_t a_off: element 'a' offset
- size_t b_off: element :b' offset
- Return (int): 0: equals; < 0 if a < b; > 0 if a > b
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_cpy(srt_vector **v, const srt_vector *src)
- Overwrite vector with a vector copy
- srt_vector **v: output vector
- const srt_vector *src: input vector
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_cpy_erase(srt_vector **v, const srt_vector *src, size_t off, size_t n)
- Overwrite vector with input vector copy applying a erase operation
- srt_vector **v: output vector
- const srt_vector *src: input vector
- size_t off: input vector erase start offset
- size_t n: number of elements to erase
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_cpy_resize(srt_vector **v, const srt_vector *src, size_t n)
- Overwrite vector with input vector copy plus resize operation
- srt_vector **v: output vector
- const srt_vector *src: input vector
- size_t n: number of elements of input vector
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_dup(const srt_vector *src)
- Duplicate vector
- const srt_vector *src: vector
- Return (srt_vector *): output vector
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_dup_erase(const srt_vector *src, size_t off, size_t n)
- Duplicate vector portion
- const srt_vector *src: vector
- size_t off: offset start
- size_t n: number of elements to take
- Return (srt_vector *): output vector
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_dup_resize(const srt_vector *src, size_t n)
- Duplicate vector with resize operation
- const srt_vector *src: vector
- size_t n: size for the output
- Return (srt_vector *): output vector
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint8_t sv_elem_size(enum eSV_Type t)
- Get vector type element size
- enum eSV_Type t: vector type
- Return (uint8_t): Element size (bytes)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_empty(const srt_vector *v)
- Tells if a vector is empty (zero elements)
- const srt_vector *v: vector
- Return (srt_bool): S_TRUE: empty vector; S_FALSE: not empty
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_erase(srt_vector **v, size_t off, size_t n)
- Erase portion of a vector
- srt_vector **v: input/output vector
- size_t off: element offset where to start the cut
- size_t n: number of elements to be cut
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find(const srt_vector *v, size_t off, const void *target)
- Find value in vector (SV_GEN)
- const srt_vector *v: vector
- size_t off: search offset start
- const void *target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_d(const srt_vector *v, size_t off, double target)
- Find value in vector (SV_D)
- const srt_vector *v: vector
- size_t off: search offset start
- double target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_f(const srt_vector *v, size_t off, float target)
- Find value in vector (SV_F)
- const srt_vector *v: vector
- size_t off: search offset start
- float target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_i16(const srt_vector *v, size_t off, int16_t target)
- Find value in vector (SV_I16)
- const srt_vector *v: vector
- size_t off: search offset start
- int16_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_i32(const srt_vector *v, size_t off, int32_t target)
- Find value in vector (SV_I32)
- const srt_vector *v: vector
- size_t off: search offset start
- int32_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_i64(const srt_vector *v, size_t off, int64_t target)
- Find value in vector (SV_I64)
- const srt_vector *v: vector
- size_t off: search offset start
- int64_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_i8(const srt_vector *v, size_t off, int8_t target)
- Find value in vector (SV_I8)
- const srt_vector *v: vector
- size_t off: search offset start
- int8_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_u16(const srt_vector *v, size_t off, uint16_t target)
- Find value in vector (SV_U16)
- const srt_vector *v: vector
- size_t off: search offset start
- uint16_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_u32(const srt_vector *v, size_t off, uint32_t target)
- Find value in vector (SV_U32)
- const srt_vector *v: vector
- size_t off: search offset start
- uint32_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_u64(const srt_vector *v, size_t off, uint64_t target)
- Find value in vector (SV_U64)
- const srt_vector *v: vector
- size_t off: search offset start
- uint64_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_find_u8(const srt_vector *v, size_t off, uint8_t target)
- Find value in vector (SV_U8)
- const srt_vector *v: vector
- size_t off: search offset start
- uint8_t target: target to be located
- Return (size_t): offset: >=0 found; S_NPOS: not found
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
void sv_free(srt_vector **v, ...)
- Free one or more vectors (heap)
- srt_vector **v: vector
- ...: more vectors (optional)
- Return (void): -
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
char *sv_get_buffer(srt_vector *v)
- Get vector buffer access
- srt_vector *v: vector
- Return (char *): pointer to the internal vector buffer (raw data)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const char *sv_get_buffer_r(const srt_vector *v)
- Get vector buffer access (read-only)
- const srt_vector *v: vector
- Return (const char *): pointer to the internal vector buffer (raw data)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_get_buffer_size(const srt_vector *v)
- Get vector buffer size
- const srt_vector *v: vector
- Return (size_t): Number of bytes in use for storing all vector elements
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_grow(srt_vector **v, size_t extra_elems)
- Ensure space for extra elements
- srt_vector **v: vector
- size_t extra_elems: number of extra eelements
- Return (size_t): extra size allocated
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_len(const srt_vector *v)
- Equivalent to sv_size
- const srt_vector *v: vector
- Return (size_t): Number of vector elements
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int sv_ncmp(const srt_vector *v1, size_t v1off, const srt_vector *v2, size_t v2off, size_t n)
- Compare two vectors [TODO: this may be removed, as it is unnecesary complex]
- const srt_vector *v1: vector #1
- size_t v1off: vector #1 offset start
- const srt_vector *v2: vector #2
- size_t v2off: vector #2 start
- size_t n: compare size
- Return (int): 0: equals; < 0 if a < b; > 0 if a > b
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
void *sv_pop(srt_vector *v)
- Pop/extract element (SV_GEN)
- srt_vector *v: vector
- Return (void *): Element reference
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
double sv_pop_d(srt_vector *v)
- Pop/extract element (SV_D)
- srt_vector *v: vector
- Return (double): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
float sv_pop_f(srt_vector *v)
- Pop/extract element (SV_F)
- srt_vector *v: vector
- Return (float): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int16_t sv_pop_i16(srt_vector *v)
- Pop/extract element (SV_I16)
- srt_vector *v: vector
- Return (int16_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int32_t sv_pop_i32(srt_vector *v)
- Pop/extract element (SV_I32)
- srt_vector *v: vector
- Return (int32_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int64_t sv_pop_i64(srt_vector *v)
- Pop/extract element (SV_I64)
- srt_vector *v: vector
- Return (int64_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int8_t sv_pop_i8(srt_vector *v)
- Pop/extract element (SV_I8)
- srt_vector *v: vector
- Return (int8_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint16_t sv_pop_u16(srt_vector *v)
- Pop/extract element (SV_U16)
- srt_vector *v: vector
- Return (uint16_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t sv_pop_u32(srt_vector *v)
- Pop/extract element (SV_U32)
- srt_vector *v: vector
- Return (uint32_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint64_t sv_pop_u64(srt_vector *v)
- Pop/extract element (SV_U64)
- srt_vector *v: vector
- Return (uint64_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint8_t sv_pop_u8(srt_vector *v)
- Pop/extract element (SV_U8)
- srt_vector *v: vector
- Return (uint8_t): Integer element
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push(srt_vector **v, const void *c1, ...)
- Push/add multiple elements (SV_GEN)
- srt_vector **v: vector
- const void *c1: new element to be added
- ...: more elements to be added (optional)
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_d(srt_vector **v, double c)
- Push/add element (SV_D)
- srt_vector **v: vector
- double c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_f(srt_vector **v, float c)
- Push/add element (SV_F)
- srt_vector **v: vector
- float c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_i16(srt_vector **v, int16_t c)
- Push/add element (SV_I16)
- srt_vector **v: vector
- int16_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_i32(srt_vector **v, int32_t c)
- Push/add element (SV_I32)
- srt_vector **v: vector
- int32_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_i64(srt_vector **v, int64_t c)
- Push/add element (SV_I64)
- srt_vector **v: vector
- int64_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_i8(srt_vector **v, int8_t c)
- Push/add element (SV_I8)
- srt_vector **v: vector
- int8_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_raw(srt_vector **v, const void *src, size_t n)
- Push/add element
- srt_vector **v: vector
- const void *src: data source
- size_t n: number of elements
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_u16(srt_vector **v, uint16_t c)
- Push/add element (SV_U16)
- srt_vector **v: vector
- uint16_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_u32(srt_vector **v, uint32_t c)
- Push/add element (SV_U32)
- srt_vector **v: vector
- uint32_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_u64(srt_vector **v, uint64_t c)
- Push/add element (SV_U64)
- srt_vector **v: vector
- uint64_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_push_u8(srt_vector **v, uint8_t c)
- Push/add element (SV_U8)
- srt_vector **v: vector
- uint8_t c: data source
- Return (srt_bool): S_TRUE: added OK; S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_reserve(srt_vector **v, size_t max_elems)
- Ensure space for elements
- srt_vector **v: vector
- size_t max_elems: absolute element reserve
- Return (size_t): reserved elements
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_resize(srt_vector **v, size_t n)
- Resize vector
- srt_vector **v: input/output vector
- size_t n: new size
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set(srt_vector **v, size_t index, const void *value)
- Vector random access write (SV_GEN)
- srt_vector **v: vector
- size_t index: location
- const void *value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_d(srt_vector **v, size_t index, double value)
- Vector random access write (SV_D)
- srt_vector **v: vector
- size_t index: location
- double value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_f(srt_vector **v, size_t index, float value)
- Vector random access write (SV_F)
- srt_vector **v: vector
- size_t index: location
- float value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_i16(srt_vector **v, size_t index, int16_t value)
- Vector random access write (SV_I16)
- srt_vector **v: vector
- size_t index: location
- int16_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_i32(srt_vector **v, size_t index, int32_t value)
- Vector random access write (SV_I32)
- srt_vector **v: vector
- size_t index: location
- int32_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_i64(srt_vector **v, size_t index, int64_t value)
- Vector random access write (SV_I64)
- srt_vector **v: vector
- size_t index: location
- int64_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_i8(srt_vector **v, size_t index, int8_t value)
- Vector random access write (SV_I8)
- srt_vector **v: vector
- size_t index: location
- int8_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_u16(srt_vector **v, size_t index, uint16_t value)
- Vector random access write (SV_U16)
- srt_vector **v: vector
- size_t index: location
- uint16_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_u32(srt_vector **v, size_t index, uint32_t value)
- Vector random access write (SV_U32)
- srt_vector **v: vector
- size_t index: location
- uint32_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_u64(srt_vector **v, size_t index, uint64_t value)
- Vector random access write (SV_U64)
- srt_vector **v: vector
- size_t index: location
- uint64_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool sv_set_u8(srt_vector **v, size_t index, uint8_t value)
- Vector random access write (SV_U8)
- srt_vector **v: vector
- size_t index: location
- uint8_t value: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: not enough memory
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_shrink(srt_vector **v)
- Free unused space
- srt_vector **v: vector
- Return (srt_vector *): same vector (optional usage)
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t sv_size(const srt_vector *v)
- Get vector size
- const srt_vector *v: vector
- Return (size_t): vector number of elements
- Time complexity: O(1)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_vector *sv_sort(srt_vector *v)
- Sort vector
- srt_vector *v: input/output vector
- Return (srt_vector *): output vector reference (optional usage)
- Time complexity: relies on libc "qsort" implementation, e.g. glibc implements introsort (O(n log n)), musl does smoothsort (O(n log n)), etc.
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)