diff options
| author | Tyge Løvset <[email protected]> | 2021-02-04 21:46:15 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-02-04 21:46:15 +0100 |
| commit | dff0972dd98a2a8c46a7bd0bf1308ae06dc670f5 (patch) | |
| tree | 412ba0dbe8fd561ddb6ba2b3b212bd1224b3fdb6 /stc | |
| parent | 0f8091e48049755007f3de7742fab65c62786f5f (diff) | |
| download | STC-modified-dff0972dd98a2a8c46a7bd0bf1308ae06dc670f5.tar.gz STC-modified-dff0972dd98a2a8c46a7bd0bf1308ae06dc670f5.zip | |
Fixed a minor API mixup, Docs: open addressing/closed hashing..
Diffstat (limited to 'stc')
| -rw-r--r-- | stc/cdeq.h | 4 | ||||
| -rw-r--r-- | stc/cmap.h | 6 | ||||
| -rw-r--r-- | stc/cset.h | 2 | ||||
| -rw-r--r-- | stc/csmap.h | 48 |
4 files changed, 30 insertions, 30 deletions
@@ -149,11 +149,11 @@ return cdeq_##X##_erase_range_p(self, first.ref, finish.ref); \
} \
STC_INLINE cdeq_##X##_iter_t \
- cdeq_##X##_erase(cdeq_##X* self, cdeq_##X##_iter_t pos) { \
+ cdeq_##X##_erase_at(cdeq_##X* self, cdeq_##X##_iter_t pos) { \
return cdeq_##X##_erase_range_p(self, pos.ref, pos.ref + 1); \
} \
STC_INLINE cdeq_##X##_iter_t \
- cdeq_##X##_erase_at(cdeq_##X* self, size_t idx, size_t n) { \
+ cdeq_##X##_erase(cdeq_##X* self, size_t idx, size_t n) { \
return cdeq_##X##_erase_range_p(self, self->data + idx, self->data + idx + n); \
} \
\
@@ -23,7 +23,7 @@ #ifndef CMAP__H__
#define CMAP__H__
-// Unordered set/map - implemented as open hashing with linear probing and no tombstones.
+// Unordered set/map - implemented as closed hashing with linear probing and no tombstones.
/*
#include <stdio.h>
#include <stc/cmap.h>
@@ -433,8 +433,8 @@ typedef struct {size_t idx; uint32_t hx;} cmap_bucket_t, cset_bucket_t; C##_##X##_value_t* slot = self->table; \
uint8_t* hashx = self->_hashx; \
C##_##X##_entry_del(&slot[i]); \
- do { /* deletion from hash table without tombstone */ \
- if (++j == cap) j = 0; /* ++j; j %= cap; is slow */ \
+ do { /* delete without leaving tombstone */ \
+ if (++j == cap) j = 0; \
if (! hashx[j]) \
break; \
RawKey r = keyToRaw(KEY_REF_##C(slot + j)); \
@@ -23,7 +23,7 @@ #ifndef CSET__H__
#define CSET__H__
-// Unordered set - implemented as open hashing with linear probing and no tombstones.
+// Unordered set - implemented as closed hashing with linear probing and no tombstones.
#include "cmap.h"
diff --git a/stc/csmap.h b/stc/csmap.h index 978578de..3755e2ca 100644 --- a/stc/csmap.h +++ b/stc/csmap.h @@ -61,8 +61,8 @@ int main(void) { #define using_csmap_10(X, Key, Mapped, keyCompareRaw, mappedDel, mappedClone, \
keyDel, keyFromRaw, keyToRaw, RawKey) \
- _using_CBST(X, csmap, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
- keyFromRaw, keyToRaw, RawKey, mappedClone, c_default_to_raw, Mapped)
+ _using_AATREE(X, csmap, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, mappedClone, c_default_to_raw, Mapped)
/* csset: */
#define using_csset(...) \
@@ -78,28 +78,28 @@ int main(void) { using_csset_7(X, Key, keyCompare, keyDel, keyClone, c_default_to_raw, Key)
#define using_csset_7(X, Key, keyCompareRaw, keyDel, keyFromRaw, keyToRaw, RawKey) \
- _using_CBST(X, csset, Key, Key, keyCompareRaw, _UNUSED_, keyDel, \
- keyFromRaw, keyToRaw, RawKey, _UNUSED_, _UNUSED_, void)
+ _using_AATREE(X, csset, Key, Key, keyCompareRaw, _UNUSED_, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, _UNUSED_, _UNUSED_, void)
/* csset_str, csmap_str, csmap_strkey, csmap_strval: */
#define using_csset_str() \
- _using_CBST_strkey(str, csset, cstr_t, _UNUSED_, _UNUSED_)
+ _using_AATREE_strkey(str, csset, cstr_t, _UNUSED_, _UNUSED_)
#define using_csmap_str() \
- _using_CBST(str, csmap, cstr_t, cstr_t, cstr_compare_raw, cstr_del, cstr_del, \
+ _using_AATREE(str, csmap, cstr_t, cstr_t, cstr_compare_raw, cstr_del, cstr_del, \
cstr_from, cstr_to_raw, const char*, cstr_from, cstr_to_raw, const char*)
#define using_csmap_strkey(...) \
c_MACRO_OVERLOAD(using_csmap_strkey, __VA_ARGS__)
#define using_csmap_strkey_2(X, Mapped) \
- _using_CBST_strkey(X, csmap, Mapped, c_default_del, c_default_clone)
+ _using_AATREE_strkey(X, csmap, Mapped, c_default_del, c_default_clone)
#define using_csmap_strkey_4(X, Mapped, mappedDel, mappedClone) \
- _using_CBST_strkey(X, csmap, Mapped, mappedDel, mappedClone)
+ _using_AATREE_strkey(X, csmap, Mapped, mappedDel, mappedClone)
-#define _using_CBST_strkey(X, C, Mapped, mappedDel, mappedClone) \
- _using_CBST(X, C, cstr_t, Mapped, cstr_compare_raw, mappedDel, cstr_del, \
- cstr_from, cstr_to_raw, const char*, mappedClone, c_default_to_raw, Mapped)
+#define _using_AATREE_strkey(X, C, Mapped, mappedDel, mappedClone) \
+ _using_AATREE(X, C, cstr_t, Mapped, cstr_compare_raw, mappedDel, cstr_del, \
+ cstr_from, cstr_to_raw, const char*, mappedClone, c_default_to_raw, Mapped)
#define using_csmap_strval(...) \
c_MACRO_OVERLOAD(using_csmap_strval, __VA_ARGS__)
@@ -114,8 +114,8 @@ int main(void) { using_csmap_strval_7(X, Key, keyCompare, keyDel, keyClone, c_default_to_raw, Key)
#define using_csmap_strval_7(X, Key, keyCompare, keyDel, keyFromRaw, keyToRaw, RawKey) \
- _using_CBST(X, csmap, Key, cstr_t, keyCompare, cstr_del, keyDel, \
- keyFromRaw, keyToRaw, RawKey, cstr_from, cstr_to_raw, const char*)
+ _using_AATREE(X, csmap, Key, cstr_t, keyCompare, cstr_del, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, cstr_from, cstr_to_raw, const char*)
#define SET_ONLY_csset(...) __VA_ARGS__
#define SET_ONLY_csmap(...)
@@ -127,7 +127,7 @@ int main(void) { #define CSMAP_SIZE_T uint32_t
#endif
-#define _using_CBST_types(X, C, Key, Mapped) \
+#define _using_AATREE_types(X, C, Key, Mapped) \
typedef Key C##_##X##_key_t; \
typedef Mapped C##_##X##_mapped_t; \
typedef CSMAP_SIZE_T C##_##X##_size_t; \
@@ -150,9 +150,9 @@ int main(void) { C##_##X##_size_t _tn, _st[48]; \
} C##_##X##_iter_t
-#define _using_CBST(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
- keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped) \
- _using_CBST_types(X, C, Key, Mapped); \
+#define _using_AATREE(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped) \
+ _using_AATREE_types(X, C, Key, Mapped); \
\
typedef struct { \
C##_##X##_node_t* data; \
@@ -286,15 +286,15 @@ int main(void) { return C##_##X##_erase(self, keyToRaw(KEY_REF_##C(pos.ref))); \
} \
\
- _implement_CBST(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
- keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped) \
+ _implement_AATREE(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped) \
typedef C##_##X C##_##X##_t
/* -------------------------- IMPLEMENTATION ------------------------- */
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-#define _implement_CBST(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
- keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped) \
+#define _implement_AATREE(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped) \
STC_DEF C##_##X \
C##_##X##_init(void) { \
C##_##X m = {(C##_##X##_node_t *) (_smap_inits + 4)}; \
@@ -516,12 +516,12 @@ int main(void) { } \
}
-_using_CBST_types(_, csmap, int, int);
+_using_AATREE_types(_, csmap, int, int);
static size_t _smap_inits[4] = {0, 0, 0, 0};
#else
-#define _implement_CBST(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
- keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped)
+#define _implement_AATREE(X, C, Key, Mapped, keyCompareRaw, mappedDel, keyDel, \
+ keyFromRaw, keyToRaw, RawKey, mappedFromRaw, mappedToRaw, RawMapped)
#endif
enum {_smap_ROOT=0, _smap_DISP=1, _smap_SIZE=2, _smap_CAP=3};
|
