summaryrefslogtreecommitdiffhomepage
path: root/benchmarks
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-10-29 14:39:12 +0200
committerTyge Løvset <[email protected]>2021-10-29 14:39:12 +0200
commita0899da505475f4f98e67027d13ffc8da155c201 (patch)
treed27788c588543163190807c063ce7b6ccc37e22a /benchmarks
parent583a0ac357dba6b8c35db7450e8286469516a3b9 (diff)
downloadSTC-modified-a0899da505475f4f98e67027d13ffc8da155c201.tar.gz
STC-modified-a0899da505475f4f98e67027d13ffc8da155c201.zip
renamed cx_..._t to _cx_..._t, and Self to _cx_self
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/others/old/clist.h252
-rw-r--r--benchmarks/others/old/csmap.h302
2 files changed, 277 insertions, 277 deletions
diff --git a/benchmarks/others/old/clist.h b/benchmarks/others/old/clist.h
index 10d8092e..c10909d3 100644
--- a/benchmarks/others/old/clist.h
+++ b/benchmarks/others/old/clist.h
@@ -59,153 +59,153 @@
_c_clist_types(clist_VOID, int);
STC_API size_t _clist_count(const clist_VOID* self);
-#define _clist_node(Self, vp) c_container_of(vp, cx_node_t, value)
+#define _clist_node(_cx_self, vp) c_container_of(vp, _cx_node_t, value)
-#define _c_using_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw, defTypes) \
+#define _c_using_clist(_cx_self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw, defTypes) \
\
- defTypes( _c_clist_types(Self, i_val); ) \
- typedef i_valraw cx_rawvalue_t; \
+ defTypes( _c_clist_types(_cx_self, i_val); ) \
+ typedef i_valraw _cx_rawvalue_t; \
\
- STC_API Self cx_memb(_clone)(Self lst); \
- STC_API void cx_memb(_del)(Self* self); \
- STC_API void cx_memb(_push_back)(Self* self, i_val value); \
- STC_API void cx_memb(_push_front)(Self* self, i_val value); \
- STC_API void cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n); \
- STC_API Self cx_memb(_split_after)(Self* self, cx_iter_t pos1, cx_iter_t pos2); \
- STC_API void cx_memb(_splice_after)(Self* self, cx_iter_t pos, Self* other); \
- STC_DEF void cx_memb(_splice_after_range)(Self* self, cx_iter_t pos, Self* other, cx_iter_t i1, cx_iter_t i2); \
- STC_API cx_iter_t cx_memb(_find)(const Self* self, i_valraw val); \
- STC_API cx_iter_t cx_memb(_find_before)(const Self* self, i_valraw val); \
- STC_API cx_iter_t cx_memb(_find_before_in)(cx_iter_t it1, cx_iter_t it2, i_valraw val); \
- STC_API void cx_memb(_sort)(Self* self); \
- STC_API size_t cx_memb(_remove)(Self* self, i_valraw val); \
- STC_API cx_iter_t cx_memb(_insert_after)(Self* self, cx_iter_t pos, i_val value); \
- STC_API cx_iter_t cx_memb(_erase_after)(Self* self, cx_iter_t pos); \
- STC_API cx_iter_t cx_memb(_erase_range_after)(Self* self, cx_iter_t pos, cx_iter_t it2); \
- STC_API cx_node_t* cx_memb(_erase_after_)(Self* self, cx_node_t* node); \
+ STC_API _cx_self _cx_memb(_clone)(_cx_self lst); \
+ STC_API void _cx_memb(_del)(_cx_self* self); \
+ STC_API void _cx_memb(_push_back)(_cx_self* self, i_val value); \
+ STC_API void _cx_memb(_push_front)(_cx_self* self, i_val value); \
+ STC_API void _cx_memb(_emplace_items)(_cx_self *self, const _cx_rawvalue_t arr[], size_t n); \
+ STC_API _cx_self _cx_memb(_split_after)(_cx_self* self, _cx_iter_t pos1, _cx_iter_t pos2); \
+ STC_API void _cx_memb(_splice_after)(_cx_self* self, _cx_iter_t pos, _cx_self* other); \
+ STC_DEF void _cx_memb(_splice_after_range)(_cx_self* self, _cx_iter_t pos, _cx_self* other, _cx_iter_t i1, _cx_iter_t i2); \
+ STC_API _cx_iter_t _cx_memb(_find)(const _cx_self* self, i_valraw val); \
+ STC_API _cx_iter_t _cx_memb(_find_before)(const _cx_self* self, i_valraw val); \
+ STC_API _cx_iter_t _cx_memb(_find_before_in)(_cx_iter_t it1, _cx_iter_t it2, i_valraw val); \
+ STC_API void _cx_memb(_sort)(_cx_self* self); \
+ STC_API size_t _cx_memb(_remove)(_cx_self* self, i_valraw val); \
+ STC_API _cx_iter_t _cx_memb(_insert_after)(_cx_self* self, _cx_iter_t pos, i_val value); \
+ STC_API _cx_iter_t _cx_memb(_erase_after)(_cx_self* self, _cx_iter_t pos); \
+ STC_API _cx_iter_t _cx_memb(_erase_range_after)(_cx_self* self, _cx_iter_t pos, _cx_iter_t it2); \
+ STC_API _cx_node_t* _cx_memb(_erase_after_)(_cx_self* self, _cx_node_t* node); \
\
- STC_INLINE Self cx_memb(_init)(void) {Self lst = {NULL}; return lst; } \
- STC_INLINE bool cx_memb(_empty)(Self lst) { return lst.last == NULL; } \
- STC_INLINE size_t cx_memb(_count)(Self lst) { return _clist_count((const clist_VOID*) &lst); } \
- STC_INLINE i_val cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); } \
- STC_INLINE i_val cx_memb(_value_clone)(i_val val) { return i_valfrom(i_valto(&val)); } \
- STC_INLINE void cx_memb(_clear)(Self* self) { cx_memb(_del)(self); } \
- STC_INLINE void cx_memb(_emplace_back)(Self* self, i_valraw raw) \
- { cx_memb(_push_back)(self, i_valfrom(raw)); } \
- STC_INLINE void cx_memb(_emplace_front)(Self* self, i_valraw raw) \
- { cx_memb(_push_front)(self, i_valfrom(raw)); } \
- STC_INLINE cx_value_t* \
- cx_memb(_front)(const Self* self) { return &self->last->next->value; } \
- STC_INLINE cx_value_t* \
- cx_memb(_back)(const Self* self) { return &self->last->value; } \
- STC_INLINE void cx_memb(_pop_front)(Self* self) { cx_memb(_erase_after_)(self, self->last); } \
- STC_INLINE void cx_memb(_splice_front)(Self* self, Self* other) \
- { cx_memb(_splice_after)(self, cx_memb(_before_begin)(self), other); } \
- STC_INLINE void cx_memb(_splice_back)(Self* self, Self* other) \
- { cx_memb(_splice_after)(self, cx_memb(_last)(self), other); } \
+ STC_INLINE _cx_self _cx_memb(_init)(void) {_cx_self lst = {NULL}; return lst; } \
+ STC_INLINE bool _cx_memb(_empty)(_cx_self lst) { return lst.last == NULL; } \
+ STC_INLINE size_t _cx_memb(_count)(_cx_self lst) { return _clist_count((const clist_VOID*) &lst); } \
+ STC_INLINE i_val _cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); } \
+ STC_INLINE i_val _cx_memb(_value_clone)(i_val val) { return i_valfrom(i_valto(&val)); } \
+ STC_INLINE void _cx_memb(_clear)(_cx_self* self) { _cx_memb(_del)(self); } \
+ STC_INLINE void _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) \
+ { _cx_memb(_push_back)(self, i_valfrom(raw)); } \
+ STC_INLINE void _cx_memb(_emplace_front)(_cx_self* self, i_valraw raw) \
+ { _cx_memb(_push_front)(self, i_valfrom(raw)); } \
+ STC_INLINE _cx_value_t* \
+ _cx_memb(_front)(const _cx_self* self) { return &self->last->next->value; } \
+ STC_INLINE _cx_value_t* \
+ _cx_memb(_back)(const _cx_self* self) { return &self->last->value; } \
+ STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) { _cx_memb(_erase_after_)(self, self->last); } \
+ STC_INLINE void _cx_memb(_splice_front)(_cx_self* self, _cx_self* other) \
+ { _cx_memb(_splice_after)(self, _cx_memb(_before_begin)(self), other); } \
+ STC_INLINE void _cx_memb(_splice_back)(_cx_self* self, _cx_self* other) \
+ { _cx_memb(_splice_after)(self, _cx_memb(_last)(self), other); } \
\
- STC_INLINE cx_iter_t \
- cx_memb(_emplace_after)(Self* self, cx_iter_t pos, i_valraw raw) { \
- return cx_memb(_insert_after)(self, pos, i_valfrom(raw)); \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_emplace_after)(_cx_self* self, _cx_iter_t pos, i_valraw raw) { \
+ return _cx_memb(_insert_after)(self, pos, i_valfrom(raw)); \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_before_begin)(const Self* self) { \
- cx_value_t *last = self->last ? &self->last->value : NULL; \
- cx_iter_t it = {&self->last, last, -1}; return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_before_begin)(const _cx_self* self) { \
+ _cx_value_t *last = self->last ? &self->last->value : NULL; \
+ _cx_iter_t it = {&self->last, last, -1}; return it; \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_begin)(const Self* self) { \
- cx_value_t* head = self->last ? &self->last->next->value : NULL; \
- cx_iter_t it = {&self->last, head, 0}; return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_begin)(const _cx_self* self) { \
+ _cx_value_t* head = self->last ? &self->last->next->value : NULL; \
+ _cx_iter_t it = {&self->last, head, 0}; return it; \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_last)(const Self* self) { \
- cx_value_t *last = self->last ? &self->last->value : NULL; \
- cx_iter_t it = {&self->last, last, 0}; return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_last)(const _cx_self* self) { \
+ _cx_value_t *last = self->last ? &self->last->value : NULL; \
+ _cx_iter_t it = {&self->last, last, 0}; return it; \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_end)(const Self* self) { \
- cx_iter_t it = {NULL, NULL}; return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_end)(const _cx_self* self) { \
+ _cx_iter_t it = {NULL, NULL}; return it; \
} \
\
STC_INLINE void \
- cx_memb(_next)(cx_iter_t* it) { \
- cx_node_t* node = _clist_node(Self, it->ref); \
+ _cx_memb(_next)(_cx_iter_t* it) { \
+ _cx_node_t* node = _clist_node(_cx_self, it->ref); \
it->ref = ((it->_state += node == *it->_last) == 1) ? NULL : &node->next->value; \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_advance)(cx_iter_t it, size_t n) { \
- while (n-- && it.ref) cx_memb(_next)(&it); return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_advance)(_cx_iter_t it, size_t n) { \
+ while (n-- && it.ref) _cx_memb(_next)(&it); return it; \
} \
\
- _c_implement_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
+ _c_implement_clist(_cx_self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
struct stc_trailing_semicolon
/* -------------------------- IMPLEMENTATION ------------------------- */
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION)
-#define _c_implement_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
+#define _c_implement_clist(_cx_self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw) \
\
- STC_DEF Self \
- cx_memb(_clone)(Self lst) { \
- Self out = cx_memb(_init)(); \
- c_foreach_3 (i, Self, lst) \
- cx_memb(_emplace_back)(&out, i_valto(i.ref)); \
+ STC_DEF _cx_self \
+ _cx_memb(_clone)(_cx_self lst) { \
+ _cx_self out = _cx_memb(_init)(); \
+ c_foreach_3 (i, _cx_self, lst) \
+ _cx_memb(_emplace_back)(&out, i_valto(i.ref)); \
return out; \
} \
\
STC_DEF void \
- cx_memb(_del)(Self* self) { \
- while (self->last) cx_memb(_erase_after_)(self, self->last); \
+ _cx_memb(_del)(_cx_self* self) { \
+ while (self->last) _cx_memb(_erase_after_)(self, self->last); \
} \
\
STC_DEF void \
- cx_memb(_push_back)(Self* self, i_val value) { \
- _c_clist_insert_after(self, Self, self->last, value); \
+ _cx_memb(_push_back)(_cx_self* self, i_val value) { \
+ _c_clist_insert_after(self, _cx_self, self->last, value); \
self->last = entry; \
} \
STC_DEF void \
- cx_memb(_push_front)(Self* self, i_val value) { \
- _c_clist_insert_after(self, Self, self->last, value); \
+ _cx_memb(_push_front)(_cx_self* self, i_val value) { \
+ _c_clist_insert_after(self, _cx_self, self->last, value); \
if (!self->last) self->last = entry; \
} \
\
STC_DEF void \
- cx_memb(_emplace_items)(Self *self, const cx_rawvalue_t arr[], size_t n) { \
- for (size_t i=0; i<n; ++i) cx_memb(_push_back)(self, i_valfrom(arr[i])); \
+ _cx_memb(_emplace_items)(_cx_self *self, const _cx_rawvalue_t arr[], size_t n) { \
+ for (size_t i=0; i<n; ++i) _cx_memb(_push_back)(self, i_valfrom(arr[i])); \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_insert_after)(Self* self, cx_iter_t pos, i_val value) { \
- cx_node_t* node = pos.ref ? _clist_node(Self, pos.ref) : NULL; \
- _c_clist_insert_after(self, Self, node, value); \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_insert_after)(_cx_self* self, _cx_iter_t pos, i_val value) { \
+ _cx_node_t* node = pos.ref ? _clist_node(_cx_self, pos.ref) : NULL; \
+ _c_clist_insert_after(self, _cx_self, node, value); \
if (!node || node == self->last && pos._state == 0) self->last = entry; \
pos.ref = &entry->value, pos._state = 0; return pos; \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_erase_after)(Self* self, cx_iter_t pos) { \
- cx_memb(_erase_after_)(self, _clist_node(Self, pos.ref)); \
- cx_memb(_next)(&pos); return pos; \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_erase_after)(_cx_self* self, _cx_iter_t pos) { \
+ _cx_memb(_erase_after_)(self, _clist_node(_cx_self, pos.ref)); \
+ _cx_memb(_next)(&pos); return pos; \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_erase_range_after)(Self* self, cx_iter_t it1, cx_iter_t it2) { \
- cx_node_t* node = _clist_node(Self, it1.ref), *done = it2.ref ? _clist_node(Self, it2.ref) : NULL; \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_erase_range_after)(_cx_self* self, _cx_iter_t it1, _cx_iter_t it2) { \
+ _cx_node_t* node = _clist_node(_cx_self, it1.ref), *done = it2.ref ? _clist_node(_cx_self, it2.ref) : NULL; \
while (node && node->next != done) \
- node = cx_memb(_erase_after_)(self, node); \
- cx_memb(_next)(&it1); return it1; \
+ node = _cx_memb(_erase_after_)(self, node); \
+ _cx_memb(_next)(&it1); return it1; \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_find_before_in)(cx_iter_t it1, cx_iter_t it2, i_valraw val) { \
- cx_iter_t i = it1; \
- for (cx_memb(_next)(&i); i.ref != it2.ref; cx_memb(_next)(&i)) { \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_find_before_in)(_cx_iter_t it1, _cx_iter_t it2, i_valraw val) { \
+ _cx_iter_t i = it1; \
+ for (_cx_memb(_next)(&i); i.ref != it2.ref; _cx_memb(_next)(&i)) { \
i_valraw r = i_valto(i.ref); \
if (i_cmp(&r, &val) == 0) return it1; \
it1 = i; \
@@ -213,22 +213,22 @@ STC_API size_t _clist_count(const clist_VOID* self);
it1.ref = NULL; return it1; \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_find_before)(const Self* self, i_valraw val) { \
- cx_iter_t it = cx_memb(_find_before_in)(cx_memb(_before_begin)(self), cx_memb(_end)(self), val); \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_find_before)(const _cx_self* self, i_valraw val) { \
+ _cx_iter_t it = _cx_memb(_find_before_in)(_cx_memb(_before_begin)(self), _cx_memb(_end)(self), val); \
return it; \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_find)(const Self* self, i_valraw val) { \
- cx_iter_t it = cx_memb(_find_before_in)(cx_memb(_before_begin)(self), cx_memb(_end)(self), val); \
- if (it.ref != cx_memb(_end)(self).ref) cx_memb(_next)(&it); \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_find)(const _cx_self* self, i_valraw val) { \
+ _cx_iter_t it = _cx_memb(_find_before_in)(_cx_memb(_before_begin)(self), _cx_memb(_end)(self), val); \
+ if (it.ref != _cx_memb(_end)(self).ref) _cx_memb(_next)(&it); \
return it; \
} \
\
- STC_DEF cx_node_t* \
- cx_memb(_erase_after_)(Self* self, cx_node_t* node) { \
- cx_node_t* del = node->next, *next = del->next; \
+ STC_DEF _cx_node_t* \
+ _cx_memb(_erase_after_)(_cx_self* self, _cx_node_t* node) { \
+ _cx_node_t* del = node->next, *next = del->next; \
node->next = next; \
if (del == next) self->last = node = NULL; \
else if (self->last == del) self->last = node, node = NULL; \
@@ -237,35 +237,35 @@ STC_API size_t _clist_count(const clist_VOID* self);
} \
\
STC_DEF size_t \
- cx_memb(_remove)(Self* self, i_valraw val) { \
+ _cx_memb(_remove)(_cx_self* self, i_valraw val) { \
size_t n = 0; \
- cx_node_t* prev = self->last, *node; \
+ _cx_node_t* prev = self->last, *node; \
while (prev) { \
node = prev->next; \
i_valraw r = i_valto(&node->value); \
if (i_cmp(&r, &val) == 0) \
- prev = cx_memb(_erase_after_)(self, prev), ++n; \
+ prev = _cx_memb(_erase_after_)(self, prev), ++n; \
else \
prev = (node == self->last ? NULL : node); \
} \
return n; \
} \
\
- STC_DEF Self \
- cx_memb(_split_after)(Self* self, cx_iter_t pos1, cx_iter_t pos2) { \
- cx_node_t *node1 = _clist_node(Self, pos1.ref), *next1 = node1->next, \
- *node2 = _clist_node(Self, pos2.ref); \
+ STC_DEF _cx_self \
+ _cx_memb(_split_after)(_cx_self* self, _cx_iter_t pos1, _cx_iter_t pos2) { \
+ _cx_node_t *node1 = _clist_node(_cx_self, pos1.ref), *next1 = node1->next, \
+ *node2 = _clist_node(_cx_self, pos2.ref); \
node1->next = node2->next, node2->next = next1; \
if (self->last == node2) self->last = node1; \
- Self lst = {node2}; return lst; \
+ _cx_self lst = {node2}; return lst; \
} \
\
STC_DEF void \
- cx_memb(_splice_after)(Self* self, cx_iter_t pos, Self* other) { \
+ _cx_memb(_splice_after)(_cx_self* self, _cx_iter_t pos, _cx_self* other) { \
if (!pos.ref) \
self->last = other->last; \
else if (other->last) { \
- cx_node_t *node = _clist_node(Self, pos.ref), *next = node->next; \
+ _cx_node_t *node = _clist_node(_cx_self, pos.ref), *next = node->next; \
node->next = other->last->next; \
other->last->next = next; \
if (node == self->last && pos._state == 0) self->last = other->last; \
@@ -274,27 +274,27 @@ STC_API size_t _clist_count(const clist_VOID* self);
} \
\
STC_DEF void \
- cx_memb(_splice_after_range)(Self* self, cx_iter_t pos, Self* other, cx_iter_t pos1, cx_iter_t pos2) { \
- Self tmp = cx_memb(_split_after)(other, pos1, pos2); \
- cx_memb(_splice_after)(self, pos, &tmp); \
+ _cx_memb(_splice_after_range)(_cx_self* self, _cx_iter_t pos, _cx_self* other, _cx_iter_t pos1, _cx_iter_t pos2) { \
+ _cx_self tmp = _cx_memb(_split_after)(other, pos1, pos2); \
+ _cx_memb(_splice_after)(self, pos, &tmp); \
} \
\
STC_DEF int \
- cx_memb(_sort_cmp_)(const void* x, const void* y) { \
- i_valraw a = i_valto(&((cx_node_t *) x)->value); \
- i_valraw b = i_valto(&((cx_node_t *) y)->value); \
+ _cx_memb(_sort_cmp_)(const void* x, const void* y) { \
+ i_valraw a = i_valto(&((_cx_node_t *) x)->value); \
+ i_valraw b = i_valto(&((_cx_node_t *) y)->value); \
return i_cmp(&a, &b); \
} \
\
STC_DEF void \
- cx_memb(_sort)(Self* self) { \
+ _cx_memb(_sort)(_cx_self* self) { \
if (self->last) \
- self->last = (cx_node_t *) _clist_mergesort((clist_VOID_node_t *) self->last->next, cx_memb(_sort_cmp_)); \
+ self->last = (_cx_node_t *) _clist_mergesort((clist_VOID_node_t *) self->last->next, _cx_memb(_sort_cmp_)); \
}
-#define _c_clist_insert_after(self, Self, node, val) \
- cx_node_t *entry = c_new (cx_node_t); \
+#define _c_clist_insert_after(self, _cx_self, node, val) \
+ _cx_node_t *entry = c_new (_cx_node_t); \
if (node) entry->next = node->next, node->next = entry; \
else entry->next = entry; \
entry->value = val
@@ -361,7 +361,7 @@ _clist_mergesort(clist_VOID_node_t *list, int (*cmp)(const void*, const void*))
}
#else
-#define _c_implement_clist(Self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw)
+#define _c_implement_clist(_cx_self, i_val, i_cmp, i_valdel, i_valfrom, i_valto, i_valraw)
#endif
#endif
diff --git a/benchmarks/others/old/csmap.h b/benchmarks/others/old/csmap.h
index 4a380614..848e6170 100644
--- a/benchmarks/others/old/csmap.h
+++ b/benchmarks/others/old/csmap.h
@@ -52,71 +52,71 @@ int main(void) {
#include <string.h>
#define KEY_REF_csmap_(vp) (&(vp)->first)
-#define _c_aatree_complete_types(Self, C) \
- cx_MAP_ONLY( struct cx_value_t { \
- cx_key_t first; \
- cx_mapped_t second; \
+#define _c_aatree_complete_types(_cx_self, C) \
+ cx_MAP_ONLY( struct _cx_value_t { \
+ _cx_key_t first; \
+ _cx_mapped_t second; \
}; ) \
- struct cx_node_t { \
- struct cx_node_t *link[2]; \
+ struct _cx_node_t { \
+ struct _cx_node_t *link[2]; \
uint8_t level; \
- cx_value_t value; \
+ _cx_value_t value; \
}
#ifndef cx_forwarded
- _c_aatree_types(Self, C, i_key, i_val);
+ _c_aatree_types(_cx_self, C, i_key, i_val);
#endif
- _c_aatree_complete_types(Self, C); \
+ _c_aatree_complete_types(_cx_self, C); \
\
- typedef i_keyraw cx_rawkey_t; \
- typedef i_valraw cx_memb(_rawmapped_t); \
- typedef cx_SET_ONLY( cx_rawkey_t ) \
- cx_MAP_ONLY( struct { cx_rawkey_t first; \
- cx_memb(_rawmapped_t) second; } ) \
- cx_rawvalue_t; \
+ typedef i_keyraw _cx_rawkey_t; \
+ typedef i_valraw _cx_memb(_rawmapped_t); \
+ typedef cx_SET_ONLY( _cx_rawkey_t ) \
+ cx_MAP_ONLY( struct { _cx_rawkey_t first; \
+ _cx_memb(_rawmapped_t) second; } ) \
+ _cx_rawvalue_t; \
\
- STC_API Self cx_memb(_init)(void); \
- STC_API cx_value_t* cx_memb(_find_it)(const Self* self, i_keyraw rkey, cx_iter_t* out); \
- STC_API cx_iter_t cx_memb(_lower_bound)(const Self* self, i_keyraw rkey); \
- STC_API cx_value_t* cx_memb(_front)(const Self* self); \
- STC_API cx_value_t* cx_memb(_back)(const Self* self); \
- STC_API cx_iter_t cx_memb(_erase_at)(Self* self, cx_iter_t it); \
- STC_API cx_iter_t cx_memb(_erase_range)(Self* self, cx_iter_t it1, cx_iter_t it2); \
- STC_API cx_node_t* cx_memb(_erase_r_)(cx_node_t *tn, const cx_rawkey_t* rkey, int *erased); \
- STC_API void cx_memb(_del_r_)(cx_node_t* tn); \
- STC_API cx_node_t* cx_memb(_clone_r_)(cx_node_t *tn); \
- STC_API cx_result_t cx_memb(_insert_entry_)(Self* self, i_keyraw rkey); \
- STC_API void cx_memb(_next)(cx_iter_t* it); \
+ STC_API _cx_self _cx_memb(_init)(void); \
+ STC_API _cx_value_t* _cx_memb(_find_it)(const _cx_self* self, i_keyraw rkey, _cx_iter_t* out); \
+ STC_API _cx_iter_t _cx_memb(_lower_bound)(const _cx_self* self, i_keyraw rkey); \
+ STC_API _cx_value_t* _cx_memb(_front)(const _cx_self* self); \
+ STC_API _cx_value_t* _cx_memb(_back)(const _cx_self* self); \
+ STC_API _cx_iter_t _cx_memb(_erase_at)(_cx_self* self, _cx_iter_t it); \
+ STC_API _cx_iter_t _cx_memb(_erase_range)(_cx_self* self, _cx_iter_t it1, _cx_iter_t it2); \
+ STC_API _cx_node_t* _cx_memb(_erase_r_)(_cx_node_t *tn, const _cx_rawkey_t* rkey, int *erased); \
+ STC_API void _cx_memb(_del_r_)(_cx_node_t* tn); \
+ STC_API _cx_node_t* _cx_memb(_clone_r_)(_cx_node_t *tn); \
+ STC_API _cx_result_t _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey); \
+ STC_API void _cx_memb(_next)(_cx_iter_t* it); \
\
- STC_INLINE bool cx_memb(_empty)(Self cx) { return cx.size == 0; } \
- STC_INLINE size_t cx_memb(_size)(Self cx) { return cx.size; } \
- STC_INLINE void cx_memb(_del)(Self* self) { cx_memb(_del_r_)(self->root); } \
- STC_INLINE void cx_memb(_clear)(Self* self) { cx_memb(_del)(self); *self = cx_memb(_init)(); } \
- STC_INLINE void cx_memb(_swap)(Self* a, Self* b) {c_swap(Self, *a, *b); } \
- STC_INLINE Self cx_memb(_clone)(Self cx) { return c_make(Self){ cx_memb(_clone_r_)(cx.root), cx.size}; } \
- STC_INLINE cx_iter_t cx_memb(_find)(const Self* self, i_keyraw rkey) \
- {cx_iter_t it; cx_memb(_find_it)(self, rkey, &it); return it; } \
- STC_INLINE bool cx_memb(_contains)(const Self* self, i_keyraw rkey) \
- {cx_iter_t it; return cx_memb(_find_it)(self, rkey, &it) != NULL; } \
- STC_INLINE cx_value_t* cx_memb(_get)(const Self* self, i_keyraw rkey) \
- {cx_iter_t it; return cx_memb(_find_it)(self, rkey, &it); } \
+ STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return cx.size == 0; } \
+ STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cx.size; } \
+ STC_INLINE void _cx_memb(_del)(_cx_self* self) { _cx_memb(_del_r_)(self->root); } \
+ STC_INLINE void _cx_memb(_clear)(_cx_self* self) { _cx_memb(_del)(self); *self = _cx_memb(_init)(); } \
+ STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) {c_swap(_cx_self, *a, *b); } \
+ STC_INLINE _cx_self _cx_memb(_clone)(_cx_self cx) { return c_make(_cx_self){ _cx_memb(_clone_r_)(cx.root), cx.size}; } \
+ STC_INLINE _cx_iter_t _cx_memb(_find)(const _cx_self* self, i_keyraw rkey) \
+ {_cx_iter_t it; _cx_memb(_find_it)(self, rkey, &it); return it; } \
+ STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) \
+ {_cx_iter_t it; return _cx_memb(_find_it)(self, rkey, &it) != NULL; } \
+ STC_INLINE _cx_value_t* _cx_memb(_get)(const _cx_self* self, i_keyraw rkey) \
+ {_cx_iter_t it; return _cx_memb(_find_it)(self, rkey, &it); } \
\
STC_INLINE void \
- cx_memb(_value_del)(cx_value_t* val) { \
+ _cx_memb(_value_del)(_cx_value_t* val) { \
i_keydel(cx_keyref(val)); \
cx_MAP_ONLY( i_valdel(&val->second); ) \
} \
\
STC_INLINE void \
- cx_memb(_value_clone)(cx_value_t* dst, cx_value_t* val) { \
+ _cx_memb(_value_clone)(_cx_value_t* dst, _cx_value_t* val) { \
*cx_keyref(dst) = i_keyfrom(i_keyto(cx_keyref(val))); \
cx_MAP_ONLY( dst->second = i_valfrom(i_valto(&val->second)); ) \
} \
\
- STC_INLINE cx_result_t \
- cx_memb(_emplace)(Self* self, i_keyraw rkey cx_MAP_ONLY(, i_valraw rmapped)) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, rkey); \
+ STC_INLINE _cx_result_t \
+ _cx_memb(_emplace)(_cx_self* self, i_keyraw rkey cx_MAP_ONLY(, i_valraw rmapped)) { \
+ _cx_result_t res = _cx_memb(_insert_entry_)(self, rkey); \
if (res.inserted) { \
*cx_keyref(res.ref) = i_keyfrom(rkey); \
cx_MAP_ONLY(res.ref->second = i_valfrom(rmapped);) \
@@ -125,72 +125,72 @@ int main(void) {
} \
\
STC_INLINE void \
- cx_memb(_emplace_items)(Self* self, const cx_rawvalue_t arr[], size_t n) { \
- for (size_t i=0; i<n; ++i) cx_SET_ONLY( cx_memb(_emplace)(self, arr[i]); ) \
- cx_MAP_ONLY( cx_memb(_emplace)(self, arr[i].first, arr[i].second); ) \
+ _cx_memb(_emplace_items)(_cx_self* self, const _cx_rawvalue_t arr[], size_t n) { \
+ for (size_t i=0; i<n; ++i) cx_SET_ONLY( _cx_memb(_emplace)(self, arr[i]); ) \
+ cx_MAP_ONLY( _cx_memb(_emplace)(self, arr[i].first, arr[i].second); ) \
} \
\
- STC_INLINE cx_result_t \
- cx_memb(_insert)(Self* self, i_key key cx_MAP_ONLY(, i_val mapped)) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, i_keyto(&key)); \
+ STC_INLINE _cx_result_t \
+ _cx_memb(_insert)(_cx_self* self, i_key key cx_MAP_ONLY(, i_val mapped)) { \
+ _cx_result_t res = _cx_memb(_insert_entry_)(self, i_keyto(&key)); \
if (res.inserted) {*cx_keyref(res.ref) = key; cx_MAP_ONLY( res.ref->second = mapped; )} \
else {i_keydel(&key); cx_MAP_ONLY( i_valdel(&mapped); )} \
return res; \
} \
\
cx_MAP_ONLY( \
- STC_INLINE cx_result_t \
- cx_memb(_insert_or_assign)(Self* self, i_key key, i_val mapped) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, i_keyto(&key)); \
+ STC_INLINE _cx_result_t \
+ _cx_memb(_insert_or_assign)(_cx_self* self, i_key key, i_val mapped) { \
+ _cx_result_t res = _cx_memb(_insert_entry_)(self, i_keyto(&key)); \
if (res.inserted) res.ref->first = key; \
else {i_keydel(&key); i_valdel(&res.ref->second); } \
res.ref->second = mapped; return res; \
} \
\
- STC_INLINE cx_result_t \
- cx_memb(_put)(Self* self, i_key key, i_val mapped) { \
- return cx_memb(_insert_or_assign)(self, key, mapped); \
+ STC_INLINE _cx_result_t \
+ _cx_memb(_put)(_cx_self* self, i_key key, i_val mapped) { \
+ return _cx_memb(_insert_or_assign)(self, key, mapped); \
} \
\
- STC_INLINE cx_result_t \
- cx_memb(_emplace_or_assign)(Self* self, i_keyraw rkey, i_valraw rmapped) { \
- cx_result_t res = cx_memb(_insert_entry_)(self, rkey); \
+ STC_INLINE _cx_result_t \
+ _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped) { \
+ _cx_result_t res = _cx_memb(_insert_entry_)(self, rkey); \
if (res.inserted) res.ref->first = i_keyfrom(rkey); \
else i_valdel(&res.ref->second); \
res.ref->second = i_valfrom(rmapped); return res; \
} \
\
- STC_INLINE cx_mapped_t* \
- cx_memb(_at)(const Self* self, i_keyraw rkey) { \
- cx_iter_t it; \
- return &cx_memb(_find_it)(self, rkey, &it)->second; \
+ STC_INLINE _cx_mapped_t* \
+ _cx_memb(_at)(const _cx_self* self, i_keyraw rkey) { \
+ _cx_iter_t it; \
+ return &_cx_memb(_find_it)(self, rkey, &it)->second; \
}) \
\
- STC_INLINE cx_iter_t \
- cx_memb(_begin)(const Self* self) { \
- cx_iter_t it = {NULL, 0, self->root}; \
- cx_memb(_next)(&it); return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_begin)(const _cx_self* self) { \
+ _cx_iter_t it = {NULL, 0, self->root}; \
+ _cx_memb(_next)(&it); return it; \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_end)(const Self* self) {\
- cx_iter_t it = {NULL}; return it; \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_end)(const _cx_self* self) {\
+ _cx_iter_t it = {NULL}; return it; \
} \
\
STC_INLINE size_t \
- cx_memb(_erase)(Self* self, i_keyraw rkey) { \
+ _cx_memb(_erase)(_cx_self* self, i_keyraw rkey) { \
int erased = 0; \
- self->root = cx_memb(_erase_r_)(self->root, &rkey, &erased); \
+ self->root = _cx_memb(_erase_r_)(self->root, &rkey, &erased); \
self->size -= erased; return erased; \
} \
\
- STC_INLINE cx_iter_t \
- cx_memb(_advance)(cx_iter_t it, size_t n) { \
- while (n-- && it.ref) cx_memb(_next)(&it); \
+ STC_INLINE _cx_iter_t \
+ _cx_memb(_advance)(_cx_iter_t it, size_t n) { \
+ while (n-- && it.ref) _cx_memb(_next)(&it); \
return it; \
} \
\
- _c_implement_aatree(Self, C, i_key, i_val, i_cmp, \
+ _c_implement_aatree(_cx_self, C, i_key, i_val, i_cmp, \
i_valdel, i_valfrom, i_valto, i_valraw, \
i_keydel, i_keyfrom, i_keyto, i_keyraw) \
struct stc_trailing_semicolon
@@ -203,35 +203,35 @@ _c_aatree_types(csmap_SENTINEL, csmap_, int, int);
_c_aatree_complete_types(csmap_SENTINEL, csmap_);
static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sentinel, 0};
-#define _c_implement_aatree(Self, C, i_key, i_val, i_cmp, \
+#define _c_implement_aatree(_cx_self, C, i_key, i_val, i_cmp, \
i_valdel, i_valfrom, i_valto, i_valraw, \
i_keydel, i_keyfrom, i_keyto, i_keyraw) \
- STC_DEF Self \
- cx_memb(_init)(void) { \
- Self cx = {(cx_node_t *) &_aatree_sentinel, 0}; \
+ STC_DEF _cx_self \
+ _cx_memb(_init)(void) { \
+ _cx_self cx = {(_cx_node_t *) &_aatree_sentinel, 0}; \
return cx; \
} \
\
- STC_DEF cx_value_t* \
- cx_memb(_front)(const Self* self) { \
- cx_node_t *tn = self->root; \
+ STC_DEF _cx_value_t* \
+ _cx_memb(_front)(const _cx_self* self) { \
+ _cx_node_t *tn = self->root; \
while (tn->link[0]->level) tn = tn->link[0]; \
return &tn->value; \
} \
\
- STC_DEF cx_value_t* \
- cx_memb(_back)(const Self* self) { \
- cx_node_t *tn = self->root; \
+ STC_DEF _cx_value_t* \
+ _cx_memb(_back)(const _cx_self* self) { \
+ _cx_node_t *tn = self->root; \
while (tn->link[1]->level) tn = tn->link[1]; \
return &tn->value; \
} \
\
- STC_DEF cx_value_t* \
- cx_memb(_find_it)(const Self* self, cx_rawkey_t rkey, cx_iter_t* out) { \
- cx_node_t *tn = self->root; \
+ STC_DEF _cx_value_t* \
+ _cx_memb(_find_it)(const _cx_self* self, _cx_rawkey_t rkey, _cx_iter_t* out) { \
+ _cx_node_t *tn = self->root; \
out->_top = 0; \
while (tn->level) { \
- int c; cx_rawkey_t rx = i_keyto(cx_keyref(&tn->value)); \
+ int c; _cx_rawkey_t rx = i_keyto(cx_keyref(&tn->value)); \
if ((c = i_cmp(&rx, &rkey)) < 0) tn = tn->link[1]; \
else if (c > 0) {out->_st[out->_top++] = tn; tn = tn->link[0]; } \
else {out->_tn = tn->link[1]; return (out->ref = &tn->value); } \
@@ -239,12 +239,12 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen
return (out->ref = NULL); \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_lower_bound)(const Self* self, i_keyraw rkey) { \
- cx_iter_t it; \
- cx_memb(_find_it)(self, rkey, &it); \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_lower_bound)(const _cx_self* self, i_keyraw rkey) { \
+ _cx_iter_t it; \
+ _cx_memb(_find_it)(self, rkey, &it); \
if (!it.ref && it._top) { \
- cx_node_t *tn = it._st[--it._top]; \
+ _cx_node_t *tn = it._st[--it._top]; \
it._tn = tn->link[1]; \
it.ref = &tn->value; \
} \
@@ -252,8 +252,8 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen
} \
\
STC_DEF void \
- cx_memb(_next)(cx_iter_t *it) { \
- cx_node_t *tn = it->_tn; \
+ _cx_memb(_next)(_cx_iter_t *it) { \
+ _cx_node_t *tn = it->_tn; \
if (it->_top || tn->level) { \
while (tn->level) { \
it->_st[it->_top++] = tn; \
@@ -266,10 +266,10 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen
it->ref = NULL; \
} \
\
- static cx_node_t * \
- cx_memb(_skew_)(cx_node_t *tn) { \
+ static _cx_node_t * \
+ _cx_memb(_skew_)(_cx_node_t *tn) { \
if (tn && tn->link[0]->level == tn->level && tn->level) { \
- cx_node_t *tmp = tn->link[0]; \
+ _cx_node_t *tmp = tn->link[0]; \
tn->link[0] = tmp->link[1]; \
tmp->link[1] = tn; \
tn = tmp; \
@@ -277,10 +277,10 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen
return tn; \
} \
\
- static cx_node_t * \
- cx_memb(_split_)(cx_node_t *tn) { \
+ static _cx_node_t * \
+ _cx_memb(_split_)(_cx_node_t *tn) { \
if (tn->link[1]->link[1]->level == tn->level && tn->level) { \
- cx_node_t *tmp = tn->link[1]; \
+ _cx_node_t *tmp = tn->link[1]; \
tn->link[1] = tmp->link[0]; \
tmp->link[0] = tn; \
tn = tmp; \
@@ -289,55 +289,55 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen
return tn; \
} \
\
- static inline cx_node_t* \
- cx_memb(_insert_entry_i_)(cx_node_t* tn, const cx_rawkey_t* rkey, cx_result_t* res) { \
- cx_node_t *up[64], *tx = tn; \
+ static inline _cx_node_t* \
+ _cx_memb(_insert_entry_i_)(_cx_node_t* tn, const _cx_rawkey_t* rkey, _cx_result_t* res) { \
+ _cx_node_t *up[64], *tx = tn; \
int c, top = 0, dir = 0; \
while (tx->level) { \
up[top++] = tx; \
- cx_rawkey_t r = i_keyto(cx_keyref(&tx->value)); \
+ _cx_rawkey_t r = i_keyto(cx_keyref(&tx->value)); \
if (!(c = i_cmp(&r, rkey))) {res->ref = &tx->value; return tn; } \
tx = tx->link[(dir = (c < 0))]; \
} \
- tn = c_new(cx_node_t); \
+ tn = c_new(_cx_node_t); \
res->ref = &tn->value, res->inserted = true; \
- tn->link[0] = tn->link[1] = (cx_node_t*) &_aatree_sentinel, tn->level = 1; \
+ tn->link[0] = tn->link[1] = (_cx_node_t*) &_aatree_sentinel, tn->level = 1; \
if (top == 0) return tn; \
up[top - 1]->link[dir] = tn; \
while (top--) { \
if (top) dir = (up[top - 1]->link[1] == up[top]); \
- up[top] = cx_memb(_skew_)(up[top]); \
- up[top] = cx_memb(_split_)(up[top]); \
+ up[top] = _cx_memb(_skew_)(up[top]); \
+ up[top] = _cx_memb(_split_)(up[top]); \
if (top) up[top - 1]->link[dir] = up[top]; \
} \
return up[0]; \
} \
\
- STC_DEF cx_result_t \
- cx_memb(_insert_entry_)(Self* self, i_keyraw rkey) { \
- cx_result_t res = {NULL, false}; \
- self->root = cx_memb(_insert_entry_i_)(self->root, &rkey, &res); \
+ STC_DEF _cx_result_t \
+ _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey) { \
+ _cx_result_t res = {NULL, false}; \
+ self->root = _cx_memb(_insert_entry_i_)(self->root, &rkey, &res); \
self->size += res.inserted; \
return res; \
} \
\
- STC_DEF cx_node_t* \
- cx_memb(_erase_r_)(cx_node_t *tn, const cx_rawkey_t* rkey, int *erased) { \
+ STC_DEF _cx_node_t* \
+ _cx_memb(_erase_r_)(_cx_node_t *tn, const _cx_rawkey_t* rkey, int *erased) { \
if (tn->level == 0) \
return tn; \
- cx_rawkey_t raw = i_keyto(cx_keyref(&tn->value)); \
- cx_node_t *tx; int c = i_cmp(&raw, rkey); \
+ _cx_rawkey_t raw = i_keyto(cx_keyref(&tn->value)); \
+ _cx_node_t *tx; int c = i_cmp(&raw, rkey); \
if (c != 0) \
- tn->link[c < 0] = cx_memb(_erase_r_)(tn->link[c < 0], rkey, erased); \
+ tn->link[c < 0] = _cx_memb(_erase_r_)(tn->link[c < 0], rkey, erased); \
else { \
- if (!*erased) { cx_memb(_value_del)(&tn->value); *erased = 1; } \
+ if (!*erased) { _cx_memb(_value_del)(&tn->value); *erased = 1; } \
if (tn->link[0]->level && tn->link[1]->level) { \
tx = tn->link[0]; \
while (tx->link[1]->level) \
tx = tx->link[1]; \
tn->value = tx->value; \
raw = i_keyto(cx_keyref(&tn->value)); \
- tn->link[0] = cx_memb(_erase_r_)(tn->link[0], &raw, erased); \
+ tn->link[0] = _cx_memb(_erase_r_)(tn->link[0], &raw, erased); \
} else { \
tx = tn; \
tn = tn->link[tn->link[0]->level == 0]; \
@@ -347,55 +347,55 @@ static csmap_SENTINEL_node_t _aatree_sentinel = {&_aatree_sentinel, &_aatree_sen
if (tn->link[0]->level < tn->level - 1 || tn->link[1]->level < tn->level - 1) { \
if (tn->link[1]->level > --tn->level) \
tn->link[1]->level = tn->level; \
- tn = cx_memb(_skew_)(tn); \
- tx = tn->link[0] = cx_memb(_skew_)(tn->link[0]); \
- tx->link[0] = cx_memb(_skew_)(tx->link[0]); \
- tn = cx_memb(_split_)(tn); \
- tn->link[0] = cx_memb(_split_)(tn->link[0]); \
+ tn = _cx_memb(_skew_)(tn); \
+ tx = tn->link[0] = _cx_memb(_skew_)(tn->link[0]); \
+ tx->link[0] = _cx_memb(_skew_)(tx->link[0]); \
+ tn = _cx_memb(_split_)(tn); \
+ tn->link[0] = _cx_memb(_split_)(tn->link[0]); \
} \
return tn; \
} \
- STC_DEF cx_iter_t \
- cx_memb(_erase_at)(Self* self, cx_iter_t it) { \
- cx_rawkey_t raw = i_keyto(cx_keyref(it.ref)), nxt; \
- cx_memb(_next)(&it); \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_erase_at)(_cx_self* self, _cx_iter_t it) { \
+ _cx_rawkey_t raw = i_keyto(cx_keyref(it.ref)), nxt; \
+ _cx_memb(_next)(&it); \
if (it.ref) nxt = i_keyto(cx_keyref(it.ref)); \
- cx_memb(_erase)(self, raw); \
- if (it.ref) cx_memb(_find_it)(self, nxt, &it); \
+ _cx_memb(_erase)(self, raw); \
+ if (it.ref) _cx_memb(_find_it)(self, nxt, &it); \
return it; \
} \
\
- STC_DEF cx_iter_t \
- cx_memb(_erase_range)(Self* self, cx_iter_t it1, cx_iter_t it2) { \
- if (!it2.ref) { while (it1.ref) it1 = cx_memb(_erase_at)(self, it1); \
+ STC_DEF _cx_iter_t \
+ _cx_memb(_erase_range)(_cx_self* self, _cx_iter_t it1, _cx_iter_t it2) { \
+ if (!it2.ref) { while (it1.ref) it1 = _cx_memb(_erase_at)(self, it1); \
return it1; } \
- cx_key_t k1 = *cx_keyref(it1.ref), k2 = *cx_keyref(it2.ref); \
- cx_rawkey_t r1 = i_keyto(&k1); \
+ _cx_key_t k1 = *cx_keyref(it1.ref), k2 = *cx_keyref(it2.ref); \
+ _cx_rawkey_t r1 = i_keyto(&k1); \
for (;;) { \
if (memcmp(&k1, &k2, sizeof k1) == 0) return it1; \
- cx_memb(_next)(&it1); k1 = *cx_keyref(it1.ref); \
- cx_memb(_erase)(self, r1); \
- cx_memb(_find_it)(self, (r1 = i_keyto(&k1)), &it1); \
+ _cx_memb(_next)(&it1); k1 = *cx_keyref(it1.ref); \
+ _cx_memb(_erase)(self, r1); \
+ _cx_memb(_find_it)(self, (r1 = i_keyto(&k1)), &it1); \
} \
} \
\
- STC_DEF cx_node_t* \
- cx_memb(_clone_r_)(cx_node_t *tn) { \
+ STC_DEF _cx_node_t* \
+ _cx_memb(_clone_r_)(_cx_node_t *tn) { \
if (! tn->level) return tn; \
- cx_node_t *cn = c_new(cx_node_t); \
- cn->link[0] = cx_memb(_clone_r_)(tn->link[0]); \
- cn->link[1] = cx_memb(_clone_r_)(tn->link[1]); \
+ _cx_node_t *cn = c_new(_cx_node_t); \
+ cn->link[0] = _cx_memb(_clone_r_)(tn->link[0]); \
+ cn->link[1] = _cx_memb(_clone_r_)(tn->link[1]); \
cn->level = tn->level; \
- cx_memb(_value_clone)(&cn->value, &tn->value); \
+ _cx_memb(_value_clone)(&cn->value, &tn->value); \
return cn; \
} \
\
STC_DEF void \
- cx_memb(_del_r_)(cx_node_t* tn) { \
+ _cx_memb(_del_r_)(_cx_node_t* tn) { \
if (tn->level != 0) { \
- cx_memb(_del_r_)(tn->link[0]); \
- cx_memb(_del_r_)(tn->link[1]); \
- cx_memb(_value_del)(&tn->value); \
+ _cx_memb(_del_r_)(tn->link[0]); \
+ _cx_memb(_del_r_)(tn->link[1]); \
+ _cx_memb(_value_del)(&tn->value); \
c_free(tn); \
} \
}