diff options
| author | Tyge Løvset <[email protected]> | 2021-05-07 09:44:55 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-05-07 09:44:55 +0200 |
| commit | 66da5f82347d0022cfbaea405c9db50eac4a84d8 (patch) | |
| tree | e8fcc8d1ce9c9ffa3a4937e8d7deede037c139a1 /docs | |
| parent | 10c06664445843e7b516cdd041220a1f5e916a62 (diff) | |
| download | STC-modified-66da5f82347d0022cfbaea405c9db50eac4a84d8.tar.gz STC-modified-66da5f82347d0022cfbaea405c9db50eac4a84d8.zip | |
Cleanup, internal renames. API: c_strhash() -> c_string_hash(), added adv() and ind() to cvec and cdeq.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/cdeq_api.md | 9 | ||||
| -rw-r--r-- | docs/clist_api.md | 2 | ||||
| -rw-r--r-- | docs/cmap_api.md | 5 | ||||
| -rw-r--r-- | docs/csmap_api.md | 2 | ||||
| -rw-r--r-- | docs/cstr_api.md | 9 | ||||
| -rw-r--r-- | docs/cvec_api.md | 17 |
6 files changed, 25 insertions, 19 deletions
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md index 555976b5..61b0e164 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -23,7 +23,7 @@ be replaced by `i` in all of the following documentation. `using_cdeq_str()` is a shorthand for: ``` -using_cdeq(str, cstr, cstr_compare_raw, cstr_del, cstr_from, cstr_c_str, const char*) +using_cdeq(str, cstr, c_rstr_compare, cstr_del, cstr_from, cstr_toraw, const char*) ``` ## Methods @@ -63,7 +63,10 @@ cdeq_X_iter_t cdeq_X_insert_at(cdeq_X* self, cdeq_X_iter_t it, Value value cdeq_X_iter_t cdeq_X_emplace(cdeq_X* self, size_t idx, RawValue raw); cdeq_X_iter_t cdeq_X_emplace_n(cdeq_X* self, size_t idx, const RawValue[] arr, size_t n); cdeq_X_iter_t cdeq_X_emplace_at(cdeq_X* self, cdeq_X_iter_t it, RawValue raw); -cdeq_X_iter_t cdeq_X_emplace_range(cdeq_X* self, cdeq_X_iter_t it1, cdeq_X_iter_t it2); // will clone +cdeq_X_iter_t cdeq_X_emplace_range(cdeq_X* self, cdeq_X_iter_t it, + cdeq_X_iter_t it1, cdeq_X_iter_t it2); // will clone +cdeq_X_iter_t cdeq_X_emplace_range_p(cdeq_X* self, Value* pos, + const Value* p1, const Value* p2); cdeq_X_iter_t cdeq_X_erase(cdeq_X* self, size_t idx); cdeq_X_iter_t cdeq_X_erase_n(cdeq_X* self, size_t idx, size_t n); @@ -76,7 +79,7 @@ cdeq_X_value_t* cdeq_X_get(const cdeq_X* self, RawValue raw); void cdeq_X_sort(cdeq_X* self); void cdeq_X_sort_range(cdeq_X_iter_t i1, cdeq_X_iter_t i2, - int(*cmp)(const cdeq_X_value_t*, const cdeq_X_value_t*)); + int(*cmp)(const Value*, const Value*)); cdeq_X_iter_t cdeq_X_begin(const cdeq_X* self); cdeq_X_iter_t cdeq_X_end(const cdeq_X* self); diff --git a/docs/clist_api.md b/docs/clist_api.md index 7807b677..93384a10 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -38,7 +38,7 @@ The macro `using_clist()` must be instantiated in the global scope. `X` is a typ will affect the names of all clist types and methods. E.g. declaring `using_clist(i, int);`, `X` should be replaced by `i` in all of the following documentation. `using_clist_str()` is a shorthand for ```c -using_clist(str, cstr, cstr_compare_raw, cstr_del, cstr_from, cstr_c_str, const char*) +using_clist(str, cstr, c_rstr_compare, cstr_del, cstr_from, cstr_toraw, const char*) ``` ## Methods diff --git a/docs/cmap_api.md b/docs/cmap_api.md index bac1a9b2..30a7b84a 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -87,6 +87,7 @@ cmap_X_value_t cmap_X_value_clone(cmap_X_value_t val); ``` ```c uint64_t c_default_hash(const void *data, size_t len); // key any trivial type +uint64_t c_string_hash(const char* str); // uses c_default_hash() uint64_t c_default_hash32(const void* data, size_t); // key one 32bit int uint64_t c_default_hash64(const void* data, size_t); // key one 64bit int int c_default_equals(const RawKey* a, const RawKey* b); // the == operator @@ -273,7 +274,7 @@ static int Viking_equals(const Viking* a, const Viking* b) { } static uint32_t Viking_hash(const Viking* a, int ignored) { - return c_strhash(a->name.str) ^ (c_strhash(a->country.str) >> 15); + return cstr_hash(a->name) ^ (cstr_hash(a->country) >> 15); } static void Viking_del(Viking* v) { @@ -339,7 +340,7 @@ static int RViking_equals(const RViking* r1, const RViking* r2) { } static uint32_t RViking_hash(const RViking* r, int ignored) { - return c_strhash(r->name) ^ (c_strhash(r->country) >> 15); + return c_string_hash(r->name) ^ (c_string_hash(r->country) >> 15); } static Viking Viking_fromR(RViking r) {return (Viking){cstr_from(r.name), cstr_from(r.country)};} diff --git a/docs/csmap_api.md b/docs/csmap_api.md index e602c9f8..5b81f2e6 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -63,7 +63,7 @@ csmap_X_value_t* csmap_X_find_it(const csmap_X* self, RawKey rkey, csmap_X_it csmap_X_result_t csmap_X_insert(csmap_X* self, Key key, Mapped mapped); // no change if key in map csmap_X_result_t csmap_X_insert_or_assign(csmap_X* self, Key key, Mapped mapped); // always update mapped -csmap_X_result_t csmap_X_put(csmap_X* self, Key key, Mapped mapped); // alias for insert_or_assign +csmap_X_result_t csmap_X_put(csmap_X* self, Key key, Mapped mapped); // same as insert_or_assign() csmap_X_result_t csmap_X_emplace(csmap_X* self, RawKey rkey, RawMapped rmapped); // no change if rkey in map csmap_X_result_t csmap_X_emplace_or_assign(csmap_X* self, RawKey rkey, RawMapped rmapped); // always update rmapped diff --git a/docs/cstr_api.md b/docs/cstr_api.md index df457c0b..29e16b17 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -84,14 +84,13 @@ bool cstr_getdelim(cstr *self, int delim, FILE *stream); ``` Helper methods: ```c -const char* cstr_c_str(const cstr* x); -int cstr_compare_raw(const char** x, const char** y); -bool cstr_equals_raw(const char** x, const char** y); -uint64_t cstr_hash_raw(const char* const* x, size_t ignored); +const char* cstr_toraw(const cstr* x); +int c_rstr_compare(const char** x, const char** y); +bool c_rstr_equals(const char** x, const char** y); +uint64_t c_rstr_hash(const char* const* x, size_t ignored); int c_strncasecmp(const char* str1, const char* str2, size_t n); char* c_strnstr(const char* str, const char* needle, size_t n); char* c_strncasestr(const char* str, const char* needle, size_t n); -uint64_t c_strhash(const char* str); ``` ## Types diff --git a/docs/cvec_api.md b/docs/cvec_api.md index 0efd7a62..e6288336 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -27,7 +27,7 @@ be replaced by `i` in all of the following documentation. `using_cvec_str()` is a shorthand for: ``` -using_cvec(str, cstr, cstr_compare_raw, cstr_del, cstr_from, cstr_c_str, const char*) +using_cvec(str, cstr, c_rstr_compare, cstr_del, cstr_from, cstr_toraw, const char*) ``` ## Methods @@ -64,7 +64,10 @@ cvec_X_iter_t cvec_X_insert_at(cvec_X* self, cvec_X_iter_t it, Value value cvec_X_iter_t cvec_X_emplace(cvec_X* self, size_t idx, RawValue raw); cvec_X_iter_t cvec_X_emplace_n(cvec_X* self, size_t idx, const RawValue[] arr, size_t n); cvec_X_iter_t cvec_X_emplace_at(cvec_X* self, cvec_X_iter_t it, RawValue raw); -cvec_X_iter_t cvec_X_emplace_range(cvec_X* self, cvec_X_iter_t it1, cvec_X_iter_t it2); // will clone +cvec_X_iter_t cvec_X_emplace_range(cvec_X* self, cvec_X_iter_t it, + cvec_X_iter_t it1, cvec_X_iter_t it2); // will clone +cvec_X_iter_t cvec_X_emplace_range_p(cvec_X* self, Value* pos, + const Value* p1, const Value* p2); cvec_X_iter_t cvec_X_erase(cvec_X* self, size_t idx); cvec_X_iter_t cvec_X_erase_n(cvec_X* self, size_t idx, size_t n); @@ -79,7 +82,7 @@ cvec_X_iter_t cvec_X_bsearch_in(cvec_X_iter_t i1, cvec_X_iter_t i2, RawVal void cvec_X_sort(cvec_X* self); void cvec_X_sort_range(cvec_X_iter_t i1, cvec_X_iter_t i2, - int(*cmp)(const cvec_X_value_t*, const cvec_X_value_t*)); + int(*cmp)(const Value*, const Value*)); cvec_X_iter_t cvec_X_begin(const cvec_X* self); cvec_X_iter_t cvec_X_end(const cvec_X* self); @@ -116,7 +119,7 @@ int main() // Append a set of numbers c_emplace(cvec_i, vec, {7, 5, 16, 8}); - printf("initial: "); + printf("initial:"); c_foreach (k, cvec_i, vec) { printf(" %d", *k.ref); } @@ -124,7 +127,7 @@ int main() // Sort the vector cvec_i_sort(&vec); - printf("\nsorted: "); + printf("\nsorted:"); c_foreach (k, cvec_i, vec) { printf(" %d", *k.ref); } @@ -134,8 +137,8 @@ int main() ``` Output: ``` -initial: 7 5 16 8 25 13 -sorted: 5 7 8 13 16 25 +initial: 25 13 7 5 16 8 +sorted: 5 7 8 13 16 25 ``` ### Example 2 ```c |
