diff options
| author | Tyge Løvset <[email protected]> | 2023-09-05 18:10:14 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-09-05 18:10:14 +0200 |
| commit | 493c34e9c2de0587f38681340db8f2735e72d7dd (patch) | |
| tree | 158838cfe8a4a59d258a9a5817faf2a18808ff38 /docs | |
| parent | 3628e4389ef9455960c42466487385fc228566c3 (diff) | |
| download | STC-modified-493c34e9c2de0587f38681340db8f2735e72d7dd.tar.gz STC-modified-493c34e9c2de0587f38681340db8f2735e72d7dd.zip | |
Renamed (half)internal functions:
cfasthash() => stc_hash()
cstrhash() => stc_strhash()
cnextpow2() => stc_nextpow2()
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cmap_api.md | 15 | ||||
| -rw-r--r-- | docs/cstr_api.md | 5 |
2 files changed, 11 insertions, 9 deletions
diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 0fbd9b7a..8e29efe1 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -72,7 +72,7 @@ cmap_X_result cmap_X_push(cmap_X* self, cmap_X_value entry); cmap_X_result cmap_X_emplace(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map cmap_X_result cmap_X_emplace_or_assign(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update mapped -cmap_X_result cmap_X_emplace_key(cmap_X* self, i_keyraw rkey); // see example 1. +cmap_X_result cmap_X_emplace_key(cmap_X* self, i_keyraw rkey); // see example 1. int cmap_X_erase(cmap_X* self, i_keyraw rkey); // return 0 or 1 cmap_X_iter cmap_X_erase_at(cmap_X* self, cmap_X_iter it); // return iter after it @@ -86,13 +86,14 @@ cmap_X_iter cmap_X_advance(cmap_X_iter it, cmap_X_ssize n); cmap_X_value cmap_X_value_clone(cmap_X_value val); cmap_X_raw cmap_X_value_toraw(cmap_X_value* pval); ``` -Helpers: +Free helper functions: ```c -uint64_t cbytehash(const void *data, intptr_t len); // base hash function -uint64_t cstrhash(const char *str); // string hash funcion, uses strlen() -uint64_t c_default_hash(const X *obj); // macro, calls cbytehash(obj, sizeof *obj) +uint64_t stc_hash(const void *data, intptr_t len); // base hash function +uint64_t stc_strhash(const char *str); // string hash funcion, uses strlen() +uint64_t stc_nextpow2(intptr_t i); // get next power of 2 >= i -// equalto template parameter functions: +// hash/equal template default functions: +uint64_t c_default_hash(const X *obj); // macro, calls stc_hash(obj, sizeof *obj) bool c_default_eq(const i_keyraw* a, const i_keyraw* b); // *a == *b bool c_memcmp_eq(const i_keyraw* a, const i_keyraw* b); // !memcmp(a, b, sizeof *a) ``` @@ -381,7 +382,7 @@ static inline RViking Viking_toraw(const Viking* vp) { #define i_keyraw RViking #define i_keyfrom Viking_from #define i_opt c_no_clone // disable map cloning -#define i_hash(rp) (cstrhash(rp->name) ^ cstrhash(rp->country)) +#define i_hash(rp) (stc_strhash(rp->name) ^ stc_strhash(rp->country)) #define i_val int #include <stc/cmap.h> diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 397634ec..69512a9e 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -142,8 +142,9 @@ Note that all methods with arguments `(..., const char* str, intptr_t n)`, `n` m ```c int cstr_cmp(const cstr* s1, const cstr* s2); bool cstr_eq(const cstr* s1, const cstr* s2); -bool cstr_hash(const cstr* self); -char* cstrnstrn(const char* str, const char* search, intptr_t slen, intptr_t nlen); +uint64_t cstr_hash(const cstr* self); + +char* stc_strnstrn(const char* str, const char* search, intptr_t slen, intptr_t nlen); ``` ## Types |
