From c692cbed293c6df2d160e0d97be465cd4d65c8b7 Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Thu, 8 Apr 2021 16:31:53 +0200 Subject: Minor formatting. Fix inaccuracy in doc. --- docs/clist_api.md | 4 ++-- stc/cmap.h | 27 ++++++++++++++------------- stc/csmap.h | 14 ++++++++------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/docs/clist_api.md b/docs/clist_api.md index 4adfdf29..f09de26c 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -65,10 +65,10 @@ void clist_X_push_back(clist_X* self, Value value); void clist_X_emplace_back(clist_X* self, RawValue raw); void clist_X_emplace_n(clist_X *self, const clist_X_rawvalue_t arr[], size_t size); -clist_X_iter_t clist_X_insert(clist_X* self, clist_X_iter_t it, Value value); // return iter to new elem; `it` may be end +clist_X_iter_t clist_X_insert(clist_X* self, clist_X_iter_t it, Value value); // return iter to new elem; 'it' may be end clist_X_iter_t clist_X_emplace(clist_X* self, clist_X_iter_t it, RawValue raw); -clist_X_iter_t clist_X_erase_at(clist_X* self, clist_X_iter_t it); // return iter before it +clist_X_iter_t clist_X_erase_at(clist_X* self, clist_X_iter_t it); // return iter after it clist_X_iter_t clist_X_erase_range(clist_X* self, clist_X_iter_t it1, clist_X_iter_t it2); size_t clist_X_remove(clist_X* self, RawValue raw); // removes all elements equal to raw diff --git a/stc/cmap.h b/stc/cmap.h index 4dea5566..f3062400 100644 --- a/stc/cmap.h +++ b/stc/cmap.h @@ -59,47 +59,47 @@ typedef struct {size_t idx; uint_fast8_t hx;} chash_bucket_t; using_cmap_5(X, Key, Mapped, c_default_equals, c_default_hash) #define using_cmap_5(X, Key, Mapped, keyEquals, keyHash) \ using_cmap_7(X, Key, Mapped, keyEquals, keyHash, \ - c_trivial_del, c_trivial_fromraw) + c_trivial_del, c_trivial_fromraw) #define using_cmap_6(X, Key, Mapped, keyEquals, keyHash, mappedDel) \ using_cmap_7(X, Key, Mapped, keyEquals, keyHash, \ - mappedDel, c_no_clone) + mappedDel, c_no_clone) #define using_cmap_7(X, Key, Mapped, keyEquals, keyHash, mappedDel, mappedClone) \ using_cmap_9(X, Key, Mapped, keyEquals, keyHash, \ - mappedDel, mappedClone, c_trivial_toraw, Mapped) + mappedDel, mappedClone, c_trivial_toraw, Mapped) #define using_cmap_9(X, Key, Mapped, keyEquals, keyHash, \ - mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \ + mappedDel, mappedFromRaw, mappedToRaw, RawMapped) \ _c_using_chash(cmap_##X, cmap_, Key, Mapped, keyEquals, keyHash, \ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ c_trivial_del, c_trivial_fromraw, c_trivial_toraw, Key) #define using_cmap_13(X, Key, Mapped, keyEqualsRaw, keyHashRaw, \ - mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ - keyDel, keyFromRaw, keyToRaw, RawKey) \ + mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ + keyDel, keyFromRaw, keyToRaw, RawKey) \ _c_using_chash(cmap_##X, cmap_, Key, Mapped, keyEqualsRaw, keyHashRaw, \ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ keyDel, keyFromRaw, keyToRaw, RawKey) + #define using_cmap_keydef(...) c_MACRO_OVERLOAD(using_cmap_keydef, __VA_ARGS__) #define using_cmap_keydef_7(X, Key, Mapped, keyEquals, keyHash, keyDel, keyClone) \ using_cmap_keydef_9(X, Key, Mapped, keyEquals, keyHash, \ - keyDel, keyClone, c_trivial_toraw, Key) + keyDel, keyClone, c_trivial_toraw, Key) #define using_cmap_keydef_9(X, Key, Mapped, keyEqualsRaw, keyHashRaw, \ - keyDel, keyFromRaw, keyToRaw, RawKey) \ + keyDel, keyFromRaw, keyToRaw, RawKey) \ _c_using_chash(cmap_##X, cmap_, Key, Mapped, keyEqualsRaw, keyHashRaw, \ c_trivial_del, c_trivial_fromraw, c_trivial_toraw, Mapped, \ keyDel, keyFromRaw, keyToRaw, RawKey) -/* cmap_str, cmap_strkey, cmap_strval: */ #define using_cmap_str() \ _c_using_chash(cmap_str, cmap_, cstr_t, cstr_t, cstr_equals_raw, cstr_hash_raw, \ cstr_del, cstr_from, cstr_c_str, const char*, \ cstr_del, cstr_from, cstr_c_str, const char*) -#define using_cmap_strkey(...) \ - c_MACRO_OVERLOAD(using_cmap_strkey, __VA_ARGS__) + +#define using_cmap_strkey(...) c_MACRO_OVERLOAD(using_cmap_strkey, __VA_ARGS__) #define using_cmap_strkey_2(X, Mapped) \ using_cmap_strkey_4(X, Mapped, c_trivial_del, c_trivial_fromraw) @@ -115,8 +115,8 @@ typedef struct {size_t idx; uint_fast8_t hx;} chash_bucket_t; mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ cstr_del, cstr_from, cstr_c_str, const char*) -#define using_cmap_strval(...) \ - c_MACRO_OVERLOAD(using_cmap_strval, __VA_ARGS__) + +#define using_cmap_strval(...) c_MACRO_OVERLOAD(using_cmap_strval, __VA_ARGS__) #define using_cmap_strval_2(X, Key) \ using_cmap_strval_4(X, Key, c_default_equals, c_default_hash) @@ -139,6 +139,7 @@ typedef struct {size_t idx; uint_fast8_t hx;} chash_bucket_t; #define CMAP_SIZE_T uint32_t #endif + #define _c_using_chash(CX, C, Key, Mapped, keyEqualsRaw, keyHashRaw, \ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ keyDel, keyFromRaw, keyToRaw, RawKey) \ diff --git a/stc/csmap.h b/stc/csmap.h index c425515c..a96eac83 100644 --- a/stc/csmap.h +++ b/stc/csmap.h @@ -72,24 +72,26 @@ int main(void) { mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ keyDel, keyFromRaw, keyToRaw, RawKey) + #define using_csmap_keydef(...) c_MACRO_OVERLOAD(using_csmap_keydef, __VA_ARGS__) + #define using_csmap_keydef_6(X, Key, Mapped, keyCompare, keyDel, keyClone) \ using_csmap_keydef_8(X, Key, Mapped, keyCompare, \ keyDel, keyClone, c_trivial_toraw, Key) + #define using_csmap_keydef_8(X, Key, Mapped, keyCompareRaw, \ keyDel, keyFromRaw, keyToRaw, RawKey) \ _c_using_aatree(csmap_##X, csmap_, Key, Mapped, keyCompareRaw, \ c_trivial_del, c_trivial_fromraw, c_trivial_toraw, Mapped, \ keyDel, keyFromRaw, keyToRaw, RawKey) -/* csmap_str, csmap_strkey, csmap_strval: */ #define using_csmap_str() \ _c_using_aatree(csmap_str, csmap_, cstr_t, cstr_t, cstr_compare_raw, \ cstr_del, cstr_from, cstr_c_str, const char*, \ cstr_del, cstr_from, cstr_c_str, const char*) -#define using_csmap_strkey(...) \ - c_MACRO_OVERLOAD(using_csmap_strkey, __VA_ARGS__) + +#define using_csmap_strkey(...) c_MACRO_OVERLOAD(using_csmap_strkey, __VA_ARGS__) #define using_csmap_strkey_2(X, Mapped) \ using_csmap_strkey_4(X, Mapped, c_trivial_del, c_trivial_fromraw) @@ -105,8 +107,8 @@ int main(void) { mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ cstr_del, cstr_from, cstr_c_str, const char*) -#define using_csmap_strval(...) \ - c_MACRO_OVERLOAD(using_csmap_strval, __VA_ARGS__) + +#define using_csmap_strval(...) c_MACRO_OVERLOAD(using_csmap_strval, __VA_ARGS__) #define using_csmap_strval_2(X, Key) \ using_csmap_strval_3(X, Key, c_default_compare) @@ -128,10 +130,10 @@ int main(void) { #ifndef CSMAP_SIZE_T #define CSMAP_SIZE_T uint32_t #endif - struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; #define _csmap_rep(self) c_container_of((self)->nodes, struct csmap_rep, nodes) + #define _c_using_aatree(CX, C, Key, Mapped, keyCompareRaw, \ mappedDel, mappedFromRaw, mappedToRaw, RawMapped, \ keyDel, keyFromRaw, keyToRaw, RawKey) \ -- cgit v1.2.3