shmap.h: hash map handling (key-value storage)
Map functions handle key-value storage, which is implemented as a
hash table (O(n), with O(1) amortized time complexity for
insert/read/delete)
Supported key/value modes (enum eSHM_Type):
SHM_II32: int32_t key, int32_t value
SHM_UU32: uint32_t key, uint32_t value
SHM_II: int64_t key, int64_t value
SHM_FF: float (single-precision floating point) key, float value
SHM_DD: double (double-precision floating point) key, double value
SHM_IS: int64_t key, string value
SHM_IP: int64_t key, pointer value
SHM_SI: string key, int64_t value
SHM_DS: double key, string value
SHM_DP: double key, pointer value
SHM_SD: string key, double value
SHM_SS: string key, string value
SHM_SP: string key, pointer value
Callback types for the shm_itp_*() functions:
typedef srt_bool (*srt_hmap_it_ii32)(int32_t k, int32_t v, void *context);
typedef srt_bool (*srt_hmap_it_uu32)(uint32_t k, uint32_t v, void *context);
typedef srt_bool (*srt_hmap_it_ii)(int64_t k, int64_t v, void *context);
typedef srt_bool (*srt_hmap_it_ff)(float k, float v, void *context);
typedef srt_bool (*srt_hmap_it_dd)(double k, double v, void *context);
typedef srt_bool (*srt_hmap_it_is)(int64_t k, const srt_string *, void *context);
typedef srt_bool (*srt_hmap_it_ip)(int64_t k, const void *, void *context);
typedef srt_bool (*srt_hmap_it_si)(const srt_string *, int64_t v, void *context);
typedef srt_bool (*srt_hmap_it_ds)(double k, const srt_string *, void *context);
typedef srt_bool (*srt_hmap_it_dp)(double k, const void *, void *context);
typedef srt_bool (*srt_hmap_it_sd)(const srt_string *, double v, void *context);
typedef srt_bool (*srt_hmap_it_ss)(const srt_string *, const srt_string *, void *context);
typedef srt_bool (*srt_hmap_it_sp)(const srt_string *, const void *, void *context);
srt_hmap *shm_alloca(enum eSHM_Type t, size_t n)
- Allocate hash map (stack)
- enum eSHM_Type t: hash map type
- size_t n: initial reserve
- Return (srt_hmap *): hmap
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
double shm_at_dd(const srt_hmap *hm, double k)
- Access to element (SHM_DD)
- const srt_hmap *hm: hash map
- double k: key
- Return (double): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const void *shm_at_dp(const srt_hmap *hm, double k)
- Access to element (SHM_DP)
- const srt_hmap *hm: hash map
- double k: key
- Return (const void *): value pointer
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
const srt_string *shm_at_ds(const srt_hmap *hm, double k)
- Access to element (SHM_DS)
- const srt_hmap *hm: hash map
- double k: key
- Return (const srt_string *): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
float shm_at_ff(const srt_hmap *hm, float k)
- Access to element (SHM_FF)
- const srt_hmap *hm: hash map
- float k: key
- Return (float): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int64_t shm_at_ii(const srt_hmap *hm, int64_t k)
- Access to element (SHM_II)
- const srt_hmap *hm: hash map
- int64_t k: key
- Return (int64_t): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
int32_t shm_at_ii32(const srt_hmap *hm, int32_t k)
- Access to element (SHM_II32)
- const srt_hmap *hm: hash map
- int32_t k: key
- Return (int32_t): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const void *shm_at_ip(const srt_hmap *hm, int64_t k)
- Access to element (SHM_IP)
- const srt_hmap *hm: hash map
- int64_t k: key
- Return (const void *): value pointer
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
const srt_string *shm_at_is(const srt_hmap *hm, int64_t k)
- Access to element (SHM_IS)
- const srt_hmap *hm: hash map
- int64_t k: key
- Return (const srt_string *): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
double shm_at_sd(const srt_hmap *hm, const srt_string *k)
- Access to element (SHM_SD)
- const srt_hmap *hm: hash map
- const srt_string *k: key
- Return (double): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
int64_t shm_at_si(const srt_hmap *hm, const srt_string *k)
- Access to element (SHM_SI)
- const srt_hmap *hm: hash map
- const srt_string *k: key
- Return (int64_t): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
const void *shm_at_sp(const srt_hmap *hm, const srt_string *k)
- Access to element (SHM_SP)
- const srt_hmap *hm: hash map
- const srt_string *k: key
- Return (const void *): value pointer
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
const srt_string *shm_at_ss(const srt_hmap *hm, const srt_string *k)
- Access to element (SHM_SS)
- const srt_hmap *hm: hash map
- const srt_string *k: key
- Return (const srt_string *): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
uint32_t shm_at_uu32(const srt_hmap *hm, uint32_t k)
- Access to element (SHM_UU32)
- const srt_hmap *hm: hash map
- uint32_t k: key
- Return (uint32_t): value
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_capacity(const srt_hmap *hm)
- Allocated space
- const srt_hmap *hm: hmap
- 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 shm_capacity_left(const srt_hmap *hm)
- Preallocated space left
- const srt_hmap *hm: hmap
- 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)
void shm_clear(srt_hmap *hm)
- Clear/reset map (keeping map type)
- srt_hmap *hm: hmap
- Time complexity: O(1) for simple maps, O(n) for maps having nodes with strings
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
size_t shm_count_d(const srt_hmap *hm, double k)
- Map element count/check (SHM_D*)
- const srt_hmap *hm: hash map
- double k: key
- Return (size_t): S_TRUE: element found; S_FALSE: not in the map
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_count_f(const srt_hmap *hm, float k)
- Map element count/check (SHM_FF)
- const srt_hmap *hm: hash map
- float k: key
- Return (size_t): S_TRUE: element found; S_FALSE: not in the map
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_count_i(const srt_hmap *hm, int64_t k)
- Map element count/check (SHM_I*)
- const srt_hmap *hm: hash map
- int64_t k: key
- Return (size_t): S_TRUE: element found; S_FALSE: not in the map
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_count_i32(const srt_hmap *hm, int32_t k)
- Map element count/checks (SHM_II32)
- const srt_hmap *hm: hash map
- int32_t k: key
- Return (size_t): S_TRUE: element found; S_FALSE: not in the map
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_count_s(const srt_hmap *hm, const srt_string *k)
- Map element count/check (SHM_S*)
- const srt_hmap *hm: hash map
- const srt_string *k: key
- Return (size_t): S_TRUE: element found; S_FALSE: not in the map
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_count_u32(const srt_hmap *hm, uint32_t k)
- Map element count/check (SHM_UU32)
- const srt_hmap *hm: hash map
- uint32_t k: key
- Return (size_t): S_TRUE: element found; S_FALSE: not in the map
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_hmap *shm_cpy(srt_hmap **hm, const srt_hmap *src)
- Overwrite map with a map copy
- srt_hmap **hm: output hash map
- const srt_hmap *src: input map
- Return (srt_hmap *): output map reference (optional usage)
- Time complexity: O(n)
- Space complexity: no extra space
- Coverage: [0/2] basic (Coverity, clang analyzer)
- Quality: [1/4] reviewed, with quality issues
srt_bool shm_delete_d(srt_hmap *hm, double k)
- Delete map element (SHM_D*)
- srt_hmap *hm: hash map
- double k: key
- Return (srt_bool): S_TRUE: found and deleted; S_FALSE: not found
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_delete_f(srt_hmap *hm, float k)
- Delete map element (SHM_FF)
- srt_hmap *hm: hash map
- float k: key
- Return (srt_bool): S_TRUE: found and deleted; S_FALSE: not found
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_delete_i(srt_hmap *hm, int64_t k)
- Delete map element (SHM_I*)
- srt_hmap *hm: hash map
- int64_t k: key
- Return (srt_bool): S_TRUE: found and deleted; S_FALSE: not found
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_delete_i32(srt_hmap *hm, int32_t k)
- Delete map element (SHM_II32)
- srt_hmap *hm: hash map
- int32_t k: key
- Return (srt_bool): S_TRUE: found and deleted; S_FALSE: not found
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_delete_s(srt_hmap *hm, const srt_string *k)
- Delete map element (SHM_S*)
- srt_hmap *hm: hash map
- const srt_string *k: key
- Return (srt_bool): S_TRUE: found and deleted; S_FALSE: not found
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_delete_u32(srt_hmap *hm, uint32_t k)
- Delete map element (SHM_UU32)
- srt_hmap *hm: hash map
- uint32_t k: key
- Return (srt_bool): S_TRUE: found and deleted; S_FALSE: not found
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_hmap *shm_dup(const srt_hmap *src)
- Duplicate hash map
- const srt_hmap *src: input map
- Return (srt_hmap *): output map
- 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 shm_empty(const srt_hmap *hm)
- Tells if a hash map is empty (zero elements)
- const srt_hmap *hm: hmap
- Return (srt_bool): S_TRUE: empty; 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)
void shm_free(srt_hmap **hm, ...)
- Free one or more hash maps
- srt_hmap **hm: hash map
- ...: more hash maps (optional)
- Return (void): -
- Time complexity: O(1) for simple dmaps, O(n) for dmaps having nodes with strings
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_grow(srt_hmap **hm, size_t extra_elems)
- Ensure space for extra elements
- srt_hmap **hm: hash map
- size_t extra_elems: number of extra elements
- 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)
srt_bool shm_inc_dd(srt_hmap **hm, double k, double v)
- Increment map element (SHM_DD)
- srt_hmap **hm: hash map
- double k: key
- double v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_inc_ff(srt_hmap **hm, float k, float v)
- Increment map element (SHM_FF)
- srt_hmap **hm: hash map
- float k: key
- float v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_inc_ii(srt_hmap **hm, int64_t k, int64_t v)
- Increment map element (SHM_II)
- srt_hmap **hm: hash map
- int64_t k: key
- int64_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_inc_ii32(srt_hmap **hm, int32_t k, int32_t v)
- Increment value map element (SHM_II32)
- srt_hmap **hm: hash map
- int32_t k: key
- int32_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_inc_sd(srt_hmap **hm, const srt_string *k, double v)
- Increment map element (SHM_SD)
- srt_hmap **hm: hash map
- const srt_string *k: key
- double v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_inc_si(srt_hmap **hm, const srt_string *k, int64_t v)
- Increment map element (SHM_SI)
- srt_hmap **hm: hash map
- const srt_string *k: key
- int64_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_inc_uu32(srt_hmap **hm, uint32_t k, uint32_t v)
- Increment map element (SHM_UU32)
- srt_hmap **hm: hash map
- uint32_t k: key
- uint32_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_dd(srt_hmap **hm, double k, double v)
- Insert into map (SHM_DD)
- srt_hmap **hm: hash map
- double k: key
- double v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_dp(srt_hmap **hm, double k, const void *v)
- Insert into map (SHM_DP)
- srt_hmap **hm: hash map
- double k: key
- const void *v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_ds(srt_hmap **hm, double k, const srt_string *v)
- Insert into map (SHM_DS)
- srt_hmap **hm: hash map
- double k: key
- const srt_string *v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_ff(srt_hmap **hm, float k, float v)
- Insert into map (SHM_FF)
- srt_hmap **hm: hash map
- float k: key
- float v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_ii(srt_hmap **hm, int64_t k, int64_t v)
- Insert into map (SHM_II)
- srt_hmap **hm: hash map
- int64_t k: key
- int64_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_ii32(srt_hmap **hm, int32_t k, int32_t v)
- Insert into map (SHM_II32)
- srt_hmap **hm: hash map
- int32_t k: key
- int32_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_ip(srt_hmap **hm, int64_t k, const void *v)
- Insert into map (SHM_IP)
- srt_hmap **hm: hash map
- int64_t k: key
- const void *v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_is(srt_hmap **hm, int64_t k, const srt_string *v)
- Insert into map (SHM_IS)
- srt_hmap **hm: hash map
- int64_t k: key
- const srt_string *v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_sd(srt_hmap **hm, const srt_string *k, double v)
- Insert into map (SHM_SD)
- srt_hmap **hm: hash map
- const srt_string *k: key
- double v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_si(srt_hmap **hm, const srt_string *k, int64_t v)
- Insert into map (SHM_SI)
- srt_hmap **hm: hash map
- const srt_string *k: key
- int64_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_sp(srt_hmap **hm, const srt_string *k, const void *v)
- Insert into map (SHM_SP)
- srt_hmap **hm: hash map
- const srt_string *k: key
- const void *v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_ss(srt_hmap **hm, const srt_string *k, const srt_string *v)
- Insert into map (SHM_SS)
- srt_hmap **hm: hash map
- const srt_string *k: key
- const srt_string *v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
srt_bool shm_insert_uu32(srt_hmap **hm, uint32_t k, uint32_t v)
- Insert into map (SHM_UU32)
- srt_hmap **hm: hash map
- uint32_t k: key
- uint32_t v: value
- Return (srt_bool): S_TRUE: OK, S_FALSE: insertion error
- Time complexity: O(n), O(1) average amortized
- Space complexity: no extra space
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
double shm_it_d_k(const srt_hmap *hm, size_t i)
- Enumerate map keys (SHM_D*)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (double): double
- 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 shm_it_dd_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_DD)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (double): double
- 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 *shm_it_dp_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_DP)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const void *): double
- 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 srt_string *shm_it_ds_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_DS)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const srt_string *): double
- 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 shm_it_f_k(const srt_hmap *hm, size_t i)
- Enumerate map keys (SHM_FF)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (float): float
- 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 shm_it_ff_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_FF)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (float): float
- 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 shm_it_i32_k(const srt_hmap *hm, size_t i)
- Enumerate map keys (SHM_II32)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (int32_t): int32_t
- 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 shm_it_i_k(const srt_hmap *hm, size_t i)
- Enumerate map keys (SHM_I*)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (int64_t): int64_t
- 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 shm_it_ii32_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_II32)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (int32_t): int32_t
- 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 shm_it_ii_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_II)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (int64_t): int64_t
- 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 *shm_it_ip_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_IP)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const void *): pointer
- 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 srt_string *shm_it_is_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_IS)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const srt_string *): string
- 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 srt_string *shm_it_s_k(const srt_hmap *hm, size_t i)
- Enumerate map keys (SHM_S*)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const srt_string *): string
- 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 shm_it_sd_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_SD)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (double): int64_t
- 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 shm_it_si_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_SI)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (int64_t): int64_t
- 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 *shm_it_sp_v(const srt_hmap *hm, size_t i)
- Enumerate map (SHM_SP)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const void *): pointer
- 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 srt_string *shm_it_ss_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_SS)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (const srt_string *): string
- 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 shm_it_u32_k(const srt_hmap *hm, size_t i)
- Enumerate map keys (SHM_UU32)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (uint32_t): uint32_t
- 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 shm_it_uu32_v(const srt_hmap *hm, size_t i)
- Enumerate map values (SHM_UU32)
- const srt_hmap *hm: hash map
- size_t i: element, 0 to n - 1
- Return (uint32_t): uint32_t
- 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 shm_itp_dd(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_dd f, void *context)
- Enumerate map elements in portions (SHM_DD)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_dd f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_dp(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_dp f, void *context)
- Enumerate map elements in portions (SHM_DP)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_dp f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_ds(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_ds f, void *context)
- Enumerate map elements in portions (SHM_DS)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_ds f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_ff(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_ff f, void *context)
- Enumerate map elements in portions (SHM_FF)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_ff f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_ii(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_ii f, void *context)
- Enumerate map elements in portions (SHM_II)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_ii f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_ii32(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_ii32 f, void *context)
- Enumerate map elements in portions (SHM_II32)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_ii32 f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_ip(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_ip f, void *context)
- Enumerate map elements in portions (SHM_IP)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_ip f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_is(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_is f, void *context)
- Enumerate map elements in portions (SHM_IS)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_is f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_sd(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_sd f, void *context)
- Enumerate map elements in portions (SHM_SD)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_sd f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_si(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_si f, void *context)
- Enumerate map elements in portions (SHM_SI)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_si f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_sp(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_sp f, void *context)
- Enumerate map elements in portions (SHM_SP)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_sp f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_ss(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_ss f, void *context)
- Enumerate map elements in portions (SHM_SS)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_ss f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_itp_uu32(const srt_hmap *m, size_t begin, size_t end, srt_hmap_it_uu32 f, void *context)
- Enumerate map elements in portions (SHM_UU32)
- const srt_hmap *m: map
- size_t begin: index start
- size_t end: index end
- srt_hmap_it_uu32 f: callback function
- void *context: callback function context
- Return (size_t): Elements processed
- 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 shm_max_size(const srt_hmap *hm)
- Get hmap size
- const srt_hmap *hm: hmap
- Return (size_t): Hash map current max 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)
size_t shm_reserve(srt_hmap **hm, size_t max_elems)
- Ensure space for elements
- srt_hmap **hm: hash map
- 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_hmap *shm_shrink(srt_hmap **hm)
- Make the hmap use the minimum possible memory
- srt_hmap **hm: hmap
- Return (srt_hmap *): hmap reference (optional usage)
- Time complexity: O(1) for allocators using memory remap
- Space complexity: O(n) for naive allocators
- Coverage: [1/2] test covered (test + Valgrind)
- Quality: [2/4] reviewed, clean (-Wall, style, speed)
size_t shm_size(const srt_hmap *hm)
- Get hmap size
- const srt_hmap *hm: hmap
- Return (size_t): Hash map 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)