From 6e96a8f11783d9c8956ddf272739f005c7b17c16 Mon Sep 17 00:00:00 2001 From: Tyge Lovset Date: Sun, 29 May 2022 02:02:03 +0200 Subject: Internal: Changed using i_keyraw to using _cx_raw or _cx_rawkey typedefs: avoids problem when i_keyraw is pointer. --- examples/multimap.c | 4 ++-- include/stc/cdeq.h | 26 +++++++++++++------------- include/stc/clist.h | 34 +++++++++++++++++----------------- include/stc/cmap.h | 24 ++++++++++++------------ include/stc/csmap.h | 44 ++++++++++++++++++++++---------------------- include/stc/cvec.h | 34 +++++++++++++++++----------------- 6 files changed, 83 insertions(+), 83 deletions(-) diff --git a/examples/multimap.c b/examples/multimap.c index 08fd8ad5..17181d70 100644 --- a/examples/multimap.c +++ b/examples/multimap.c @@ -35,7 +35,7 @@ struct OlympicsData { int year; const char *city, *country, *date; } ol_data[] = typedef struct { int year; cstr city, date; } OlympicLocation; -int OlympicLocation_cmp(OlympicLocation* a, OlympicLocation* b); +int OlympicLocation_cmp(const OlympicLocation* a, const OlympicLocation* b); OlympicLocation OlympicLocation_clone(OlympicLocation loc); void OlympicLocation_drop(OlympicLocation* self); @@ -50,7 +50,7 @@ void OlympicLocation_drop(OlympicLocation* self); #define i_tag OL #include -int OlympicLocation_cmp(OlympicLocation* a, OlympicLocation* b) { +int OlympicLocation_cmp(const OlympicLocation* a, const OlympicLocation* b) { return a->year - b->year; } diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index 7d2362c7..b0198678 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -59,7 +59,7 @@ STC_API _cx_value* _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* po #endif // !_i_no_clone #if !c_option(c_no_cmp) -STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, i_keyraw raw); +STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, _cx_raw raw); STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); #endif STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_key value); @@ -71,7 +71,7 @@ STC_API _cx_value* _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos #if !defined _i_no_clone STC_API _cx_self _cx_memb(_clone)(_cx_self cx); #if !defined _i_no_emplace -STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, i_keyraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push)(self, i_keyfrom(raw)); } #endif STC_INLINE i_key _cx_memb(_value_clone)(i_key val) @@ -84,7 +84,7 @@ STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cdeq_rep_(&cx)->size; } STC_INLINE size_t _cx_memb(_capacity)(_cx_self cx) { return cdeq_rep_(&cx)->cap; } STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return !cdeq_rep_(&cx)->size; } -STC_INLINE i_keyraw _cx_memb(_value_toraw)(_cx_value* pval) { return i_keyto(pval); } +STC_INLINE _cx_raw _cx_memb(_value_toraw)(_cx_value* pval) { return i_keyto(pval); } STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); } STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return self->data; } STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) @@ -149,11 +149,11 @@ _cx_memb(_emplace_range)(_cx_self* self, _cx_iter it, _cx_iter it1, _cx_iter it2 } STC_INLINE _cx_value* -_cx_memb(_emplace_front)(_cx_self* self, i_keyraw raw) { +_cx_memb(_emplace_front)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push_front)(self, i_keyfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_keyraw raw) { +STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push)(self, i_keyfrom(raw)); } @@ -162,7 +162,7 @@ _cx_memb(_emplace_n)(_cx_self* self, const size_t idx, const _cx_raw arr[], cons return _cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n); } STC_INLINE _cx_value* -_cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_keyraw raw) { +_cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, _cx_raw raw) { return _cx_memb(_emplace_range_p)(self, it.ref, &raw, &raw + 1); } #endif // !_i_no_clone && !_i_no_emplace @@ -170,19 +170,19 @@ _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_keyraw raw) { #if !c_option(c_no_cmp) STC_INLINE _cx_iter -_cx_memb(_find)(const _cx_self* self, i_keyraw raw) { +_cx_memb(_find)(const _cx_self* self, _cx_raw raw) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw); } STC_INLINE const _cx_value* -_cx_memb(_get)(const _cx_self* self, i_keyraw raw) { +_cx_memb(_get)(const _cx_self* self, _cx_raw raw) { _cx_iter end = _cx_memb(_end)(self); _cx_value* val = _cx_memb(_find_in)(_cx_memb(_begin)(self), end, raw).ref; return val == end.ref ? NULL : val; } STC_INLINE _cx_value* -_cx_memb(_get_mut)(_cx_self* self, i_keyraw raw) +_cx_memb(_get_mut)(_cx_self* self, _cx_raw raw) { return (_cx_value *) _cx_memb(_get)(self, raw); } STC_INLINE void @@ -415,9 +415,9 @@ _cx_memb(_clone_range_p)(_cx_self* self, _cx_value* pos, #if !c_option(c_no_cmp) STC_DEF _cx_iter -_cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, i_keyraw raw) { +_cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { for (; i1.ref != i2.ref; ++i1.ref) { - i_keyraw r = i_keyto(i1.ref); + _cx_raw r = i_keyto(i1.ref); if (i_eq((&raw), (&r))) return i1; } @@ -426,8 +426,8 @@ _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, i_keyraw raw) { STC_DEF int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { - const i_keyraw rx = i_keyto(x); - const i_keyraw ry = i_keyto(y); + const _cx_raw rx = i_keyto(x); + const _cx_raw ry = i_keyto(y); return i_cmp((&rx), (&ry)); } #endif // !c_no_cmp diff --git a/include/stc/clist.h b/include/stc/clist.h index 654dc23b..2cc74824 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -102,8 +102,8 @@ STC_API _cx_iter _cx_memb(_insert_at)(_cx_self* self, _cx_iter it, i_key STC_API _cx_iter _cx_memb(_erase_at)(_cx_self* self, _cx_iter it); STC_API _cx_iter _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2); #if !c_option(c_no_cmp) -STC_API size_t _cx_memb(_remove)(_cx_self* self, i_keyraw val); -STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_keyraw val); +STC_API size_t _cx_memb(_remove)(_cx_self* self, _cx_raw val); +STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw val); STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); STC_API void _cx_memb(_sort)(_cx_self* self); #endif @@ -121,13 +121,13 @@ _cx_memb(_copy)(_cx_self *self, _cx_self other) { _cx_memb(_drop)(self); *self = _cx_memb(_clone)(other); } #if !defined _i_no_emplace -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_keyraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push_back)(self, i_keyfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_emplace_front)(_cx_self* self, i_keyraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_front)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push_front)(self, i_keyfrom(raw)); } -STC_INLINE _cx_iter _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_keyraw raw) +STC_INLINE _cx_iter _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, _cx_raw raw) { return _cx_memb(_insert_at)(self, it, i_keyfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, i_keyraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push_back)(self, i_keyfrom(raw)); } #endif // !_i_no_emplace #endif // !_i_no_clone @@ -183,17 +183,17 @@ _cx_memb(_splice_range)(_cx_self* self, _cx_iter it, #if !c_option(c_no_cmp) STC_INLINE _cx_iter -_cx_memb(_find)(const _cx_self* self, i_keyraw val) { +_cx_memb(_find)(const _cx_self* self, _cx_raw val) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val); } STC_INLINE const _cx_value* -_cx_memb(_get)(const _cx_self* self, i_keyraw val) { +_cx_memb(_get)(const _cx_self* self, _cx_raw val) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val).ref; } STC_INLINE _cx_value* -_cx_memb(_get_mut)(_cx_self* self, i_keyraw val) { +_cx_memb(_get_mut)(_cx_self* self, _cx_raw val) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val).ref; } #endif @@ -319,9 +319,9 @@ _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2) { #if !c_option(c_no_cmp) STC_DEF _cx_iter -_cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_keyraw val) { +_cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw val) { c_foreach (it, _cx_self, it1, it2) { - i_keyraw r = i_keyto(it.ref); + _cx_raw r = i_keyto(it.ref); if (i_eq((&r), (&val))) return it; } @@ -329,12 +329,12 @@ _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_keyraw val) { } STC_DEF size_t -_cx_memb(_remove)(_cx_self* self, i_keyraw val) { +_cx_memb(_remove)(_cx_self* self, _cx_raw val) { size_t n = 0; _cx_node* prev = self->last, *node; while (prev) { node = prev->next; - i_keyraw r = i_keyto((&node->value)); + _cx_raw r = i_keyto((&node->value)); if (i_eq((&r), (&val))) prev = _cx_memb(_erase_after_)(self, prev), ++n; else @@ -345,8 +345,8 @@ _cx_memb(_remove)(_cx_self* self, i_keyraw val) { static int _cx_memb(_sort_cmp_)(const clist_VOID_node* x, const clist_VOID_node* y) { - i_keyraw a = i_keyto((&((const _cx_node *) x)->value)); - i_keyraw b = i_keyto((&((const _cx_node *) y)->value)); + const _cx_raw a = i_keyto((&((const _cx_node *) x)->value)); + const _cx_raw b = i_keyto((&((const _cx_node *) y)->value)); return i_cmp((&a), (&b)); } @@ -361,8 +361,8 @@ _cx_memb(_sort)(_cx_self* self) { STC_DEF int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { - i_keyraw rx = i_keyto(x); - i_keyraw ry = i_keyto(y); + const _cx_raw rx = i_keyto(x); + const _cx_raw ry = i_keyto(y); return i_cmp((&rx), (&ry)); } #endif // !c_no_cmp diff --git a/include/stc/cmap.h b/include/stc/cmap.h index e66f60c0..eabd5f1c 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -96,7 +96,7 @@ STC_API void _cx_memb(_drop)(_cx_self* self); STC_API void _cx_memb(_clear)(_cx_self* self); STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t capacity); STC_API chash_bucket_t _cx_memb(_bucket_)(const _cx_self* self, const _cx_rawkey* rkeyptr); -STC_API _cx_result _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey); +STC_API _cx_result _cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey); STC_API void _cx_memb(_erase_entry)(_cx_self* self, _cx_value* val); STC_INLINE _cx_self _cx_memb(_init)(void) { return c_make(_cx_self)_cmap_inits; } @@ -108,23 +108,23 @@ STC_INLINE size_t _cx_memb(_bucket_count)(_cx_self map) { return map.bucke STC_INLINE size_t _cx_memb(_capacity)(_cx_self map) { return map.bucket_count ? (size_t)((map.bucket_count - 2)*map.max_load_factor) : 0u; } STC_INLINE void _cx_memb(_swap)(_cx_self *map1, _cx_self *map2) {c_swap(_cx_self, *map1, *map2); } -STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) +STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, _cx_rawkey rkey) { return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; } #ifndef _i_isset STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key _key, i_val _mapped); #if !defined _i_no_clone && !defined _i_no_emplace - STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped); + STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, _cx_rawkey rkey, i_valraw rmapped); #endif STC_INLINE const _cx_mapped* - _cx_memb(_at)(const _cx_self* self, i_keyraw rkey) { + _cx_memb(_at)(const _cx_self* self, _cx_rawkey rkey) { chash_bucket_t b = _cx_memb(_bucket_)(self, &rkey); assert(self->_hashx[b.idx]); return &self->table[b.idx].second; } STC_INLINE _cx_mapped* - _cx_memb(_at_mut)(_cx_self* self, i_keyraw rkey) + _cx_memb(_at_mut)(_cx_self* self, _cx_rawkey rkey) { return (_cx_mapped*)_cx_memb(_at)(self, rkey); } #endif // !_i_isset @@ -145,7 +145,7 @@ _cx_memb(_value_clone)(_cx_value _val) { #if !defined _i_no_emplace STC_INLINE _cx_result -_cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped)) { +_cx_memb(_emplace)(_cx_self* self, _cx_rawkey rkey _i_MAP_ONLY(, i_valraw rmapped)) { _cx_result _res = _cx_memb(_insert_entry_)(self, rkey); if (_res.inserted) { *_i_keyref(_res.ref) = i_keyfrom(rkey); @@ -189,7 +189,7 @@ _cx_memb(_push)(_cx_self* self, _cx_value _val) { } STC_INLINE _cx_iter -_cx_memb(_find)(const _cx_self* self, i_keyraw rkey) { +_cx_memb(_find)(const _cx_self* self, _cx_rawkey rkey) { i_size idx; if (!(self->size && self->_hashx[idx = _cx_memb(_bucket_)(self, &rkey).idx])) idx = self->bucket_count; @@ -197,7 +197,7 @@ _cx_memb(_find)(const _cx_self* self, i_keyraw rkey) { } STC_INLINE const _cx_value* -_cx_memb(_get)(const _cx_self* self, i_keyraw rkey) { +_cx_memb(_get)(const _cx_self* self, _cx_rawkey rkey) { i_size idx; if (self->size && self->_hashx[idx = _cx_memb(_bucket_)(self, &rkey).idx]) return self->table + idx; @@ -205,7 +205,7 @@ _cx_memb(_get)(const _cx_self* self, i_keyraw rkey) { } STC_INLINE _cx_value* -_cx_memb(_get_mut)(const _cx_self* self, i_keyraw rkey) +_cx_memb(_get_mut)(const _cx_self* self, _cx_rawkey rkey) { return (_cx_value*)_cx_memb(_get)(self, rkey); } STC_INLINE _cx_iter @@ -233,7 +233,7 @@ _cx_memb(_advance)(_cx_iter it, size_t n) { } STC_INLINE size_t -_cx_memb(_erase)(_cx_self* self, i_keyraw rkey) { +_cx_memb(_erase)(_cx_self* self, _cx_rawkey rkey) { if (self->size == 0) return 0; chash_bucket_t b = _cx_memb(_bucket_)(self, &rkey); @@ -301,7 +301,7 @@ STC_DEF void _cx_memb(_clear)(_cx_self* self) { #if !defined _i_no_clone && !defined _i_no_emplace STC_DEF _cx_result - _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped) { + _cx_memb(_emplace_or_assign)(_cx_self* self, _cx_rawkey rkey, i_valraw rmapped) { _cx_result _res = _cx_memb(_insert_entry_)(self, rkey); if (_res.inserted) _res.ref->first = i_keyfrom(rkey); @@ -332,7 +332,7 @@ _cx_memb(_bucket_)(const _cx_self* self, const _cx_rawkey* rkeyptr) { } STC_DEF _cx_result -_cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey) { +_cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey) { bool nomem = false; if (self->size + 1 >= (i_size)(self->bucket_count*self->max_load_factor)) nomem = !_cx_memb(_reserve)(self, ((size_t)self->size*3 >> 1) + 4); diff --git a/include/stc/csmap.h b/include/stc/csmap.h index d1db9031..a723185d 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -100,7 +100,7 @@ typedef _i_SET_ONLY( i_keyraw ) #if !defined _i_no_clone STC_API _cx_self _cx_memb(_clone)(_cx_self tree); #if !defined _i_no_emplace -STC_API _cx_result _cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped)); +STC_API _cx_result _cx_memb(_emplace)(_cx_self* self, _cx_rawkey rkey _i_MAP_ONLY(, i_valraw rmapped)); #endif // !_i_no_emplace #endif // !_i_no_clone STC_API _cx_self _cx_memb(_init)(void); @@ -108,11 +108,11 @@ STC_API _cx_result _cx_memb(_insert)(_cx_self* self, i_key key _i_MAP_ONLY( STC_API _cx_result _cx_memb(_push)(_cx_self* self, _cx_value _val); STC_API void _cx_memb(_drop)(_cx_self* self); STC_API bool _cx_memb(_reserve)(_cx_self* self, size_t cap); -STC_API _cx_value* _cx_memb(_find_it)(const _cx_self* self, i_keyraw rkey, _cx_iter* out); -STC_API _cx_iter _cx_memb(_lower_bound)(const _cx_self* self, i_keyraw rkey); +STC_API _cx_value* _cx_memb(_find_it)(const _cx_self* self, _cx_rawkey rkey, _cx_iter* out); +STC_API _cx_iter _cx_memb(_lower_bound)(const _cx_self* self, _cx_rawkey rkey); STC_API _cx_value* _cx_memb(_front)(const _cx_self* self); STC_API _cx_value* _cx_memb(_back)(const _cx_self* self); -STC_API int _cx_memb(_erase)(_cx_self* self, i_keyraw rkey); +STC_API int _cx_memb(_erase)(_cx_self* self, _cx_rawkey rkey); STC_API _cx_iter _cx_memb(_erase_at)(_cx_self* self, _cx_iter it); STC_API _cx_iter _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2); STC_API void _cx_memb(_next)(_cx_iter* it); @@ -121,13 +121,13 @@ STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return _csmap_rep(&cx)-> STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return _csmap_rep(&cx)->size; } STC_INLINE size_t _cx_memb(_capacity)(_cx_self cx) { return _csmap_rep(&cx)->cap; } STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); } -STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, i_keyraw rkey) +STC_INLINE _cx_iter _cx_memb(_find)(const _cx_self* self, _cx_rawkey rkey) { _cx_iter it; _cx_memb(_find_it)(self, rkey, &it); return it; } -STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) +STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, _cx_rawkey rkey) { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it) != NULL; } -STC_INLINE const _cx_value* _cx_memb(_get)(const _cx_self* self, i_keyraw rkey) +STC_INLINE const _cx_value* _cx_memb(_get)(const _cx_self* self, _cx_rawkey rkey) { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); } -STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, i_keyraw rkey) +STC_INLINE _cx_value* _cx_memb(_get_mut)(_cx_self* self, _cx_rawkey rkey) { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); } STC_INLINE _cx_self @@ -150,7 +150,7 @@ _cx_memb(_value_toraw)(_cx_value* val) { STC_INLINE int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { - _cx_rawkey rx = i_keyto(_i_keyref(x)), ry = i_keyto(_i_keyref(y)); + const _cx_rawkey rx = i_keyto(_i_keyref(x)), ry = i_keyto(_i_keyref(y)); return i_cmp((&rx), (&ry)); } @@ -185,15 +185,15 @@ _cx_memb(_shrink_to_fit)(_cx_self *self) { #ifndef _i_isset #if !defined _i_no_clone && !defined _i_no_emplace - STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped); + STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, _cx_rawkey rkey, i_valraw rmapped); #endif STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key key, i_val mapped); STC_INLINE const _cx_mapped* - _cx_memb(_at)(const _cx_self* self, i_keyraw rkey) + _cx_memb(_at)(const _cx_self* self, _cx_rawkey rkey) { _cx_iter it; return &_cx_memb(_find_it)(self, rkey, &it)->second; } STC_INLINE _cx_mapped* - _cx_memb(_at_mut)(_cx_self* self, i_keyraw rkey) + _cx_memb(_at_mut)(_cx_self* self, _cx_rawkey rkey) { _cx_iter it; return &_cx_memb(_find_it)(self, rkey, &it)->second; } #endif // !_i_isset @@ -287,7 +287,7 @@ _cx_memb(_new_node_)(_cx_self* self, int level) { return tn; } -static _cx_result _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey); +static _cx_result _cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey); STC_DEF _cx_result _cx_memb(_insert)(_cx_self* self, i_key key _i_MAP_ONLY(, i_val mapped)) { @@ -325,7 +325,7 @@ _cx_memb(_push)(_cx_self* self, _cx_value _val) { #if !defined _i_no_clone && !defined _i_no_emplace STC_DEF _cx_result - _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped) { + _cx_memb(_emplace_or_assign)(_cx_self* self, _cx_rawkey rkey, i_valraw rmapped) { _cx_result res = _cx_memb(_insert_entry_)(self, rkey); if (!res.nomem_error) { if (res.inserted) @@ -340,12 +340,12 @@ _cx_memb(_push)(_cx_self* self, _cx_value _val) { #endif // !_i_isset STC_DEF _cx_value* -_cx_memb(_find_it)(const _cx_self* self, i_keyraw rkey, _cx_iter* out) { +_cx_memb(_find_it)(const _cx_self* self, _cx_rawkey rkey, _cx_iter* out) { i_size tn = _csmap_rep(self)->root; _cx_node *d = out->_d = self->nodes; out->_top = 0; while (tn) { - int c; _cx_rawkey raw = i_keyto(_i_keyref(&d[tn].value)); + int c; const _cx_rawkey raw = i_keyto(_i_keyref(&d[tn].value)); if ((c = i_cmp((&raw), (&rkey))) < 0) tn = d[tn].link[1]; else if (c > 0) @@ -357,7 +357,7 @@ _cx_memb(_find_it)(const _cx_self* self, i_keyraw rkey, _cx_iter* out) { } STC_DEF _cx_iter -_cx_memb(_lower_bound)(const _cx_self* self, i_keyraw rkey) { +_cx_memb(_lower_bound)(const _cx_self* self, _cx_rawkey rkey) { _cx_iter it; _cx_memb(_find_it)(self, rkey, &it); if (!it.ref && it._top) { @@ -413,7 +413,7 @@ _cx_memb(_insert_entry_i_)(_cx_self* self, i_size tn, const _cx_rawkey* rkey, _c int c, top = 0, dir = 0; while (tx) { up[top++] = tx; - i_keyraw raw = i_keyto(_i_keyref(&d[tx].value)); + const _cx_rawkey raw = i_keyto(_i_keyref(&d[tx].value)); if (!(c = i_cmp((&raw), rkey))) { res->ref = &d[tx].value; return tn; } dir = (c < 0); @@ -438,7 +438,7 @@ _cx_memb(_insert_entry_i_)(_cx_self* self, i_size tn, const _cx_rawkey* rkey, _c } static _cx_result -_cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey) { +_cx_memb(_insert_entry_)(_cx_self* self, _cx_rawkey rkey) { _cx_result res = {NULL}; i_size tn = _cx_memb(_insert_entry_i_)(self, (i_size) _csmap_rep(self)->root, &rkey, &res); _csmap_rep(self)->root = tn; @@ -450,7 +450,7 @@ static i_size _cx_memb(_erase_r_)(_cx_node *d, i_size tn, const _cx_rawkey* rkey, int *erased) { if (tn == 0) return 0; - i_keyraw raw = i_keyto(_i_keyref(&d[tn].value)); + _cx_rawkey raw = i_keyto(_i_keyref(&d[tn].value)); i_size tx; int c = i_cmp((&raw), rkey); if (c != 0) d[tn].link[c < 0] = _cx_memb(_erase_r_)(d, d[tn].link[c < 0], rkey, erased); @@ -487,7 +487,7 @@ _cx_memb(_erase_r_)(_cx_node *d, i_size tn, const _cx_rawkey* rkey, int *erased) } STC_DEF int -_cx_memb(_erase)(_cx_self* self, i_keyraw rkey) { +_cx_memb(_erase)(_cx_self* self, _cx_rawkey rkey) { int erased = 0; i_size root = _cx_memb(_erase_r_)(self->nodes, (i_size) _csmap_rep(self)->root, &rkey, &erased); if (erased) { @@ -553,7 +553,7 @@ _cx_memb(_clone)(_cx_self tree) { #if !defined _i_no_emplace STC_DEF _cx_result -_cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped)) { +_cx_memb(_emplace)(_cx_self* self, _cx_rawkey rkey _i_MAP_ONLY(, i_valraw rmapped)) { _cx_result res = _cx_memb(_insert_entry_)(self, rkey); if (res.inserted) { *_i_keyref(res.ref) = i_keyfrom(rkey); diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 3ebed9b1..f4fc0fb6 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -89,8 +89,8 @@ STC_API _cx_value* _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos STC_API _cx_value* _cx_memb(_expand_uninit_p)(_cx_self* self, _cx_value* pos, const size_t n); #if !c_option(c_no_cmp) STC_API int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y); -STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_keyraw raw); -STC_API _cx_iter _cx_memb(_binary_search_in)(_cx_iter it1, _cx_iter it2, i_keyraw raw, _cx_iter* lower_bound); +STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, _cx_raw raw); +STC_API _cx_iter _cx_memb(_binary_search_in)(_cx_iter it1, _cx_iter it2, _cx_raw raw, _cx_iter* lower_bound); #endif #if !defined _i_no_clone @@ -107,16 +107,16 @@ STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { #if !defined _i_no_emplace STC_API _cx_value* _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_raw* p1, const _cx_raw* p2); -STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, i_keyraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push)(self, i_keyfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_keyraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, _cx_raw raw) { return _cx_memb(_push)(self, i_keyfrom(raw)); } STC_INLINE _cx_value* _cx_memb(_emplace_n)(_cx_self* self, const size_t idx, const _cx_raw arr[], const size_t n) { return _cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n); } STC_INLINE _cx_value* -_cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_keyraw raw) { +_cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, _cx_raw raw) { return _cx_memb(_emplace_range_p)(self, it.ref, &raw, &raw + 1); } STC_INLINE _cx_value* @@ -129,7 +129,7 @@ _cx_memb(_emplace_range)(_cx_self* self, _cx_iter it, _cx_iter it1, _cx_iter it2 STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cvec_rep_(&cx)->size; } STC_INLINE size_t _cx_memb(_capacity)(_cx_self cx) { return cvec_rep_(&cx)->cap; } STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return !cvec_rep_(&cx)->size; } -STC_INLINE i_keyraw _cx_memb(_value_toraw)(_cx_value* val) { return i_keyto(val); } +STC_INLINE _cx_raw _cx_memb(_value_toraw)(_cx_value* val) { return i_keyto(val); } STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); } STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return self->data; } STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) @@ -210,29 +210,29 @@ _cx_memb(_at_mut)(_cx_self* self, const size_t idx) { #if !c_option(c_no_cmp) STC_INLINE _cx_iter -_cx_memb(_find)(const _cx_self* self, i_keyraw raw) { +_cx_memb(_find)(const _cx_self* self, _cx_raw raw) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw); } STC_INLINE const _cx_value* -_cx_memb(_get)(const _cx_self* self, i_keyraw raw) { +_cx_memb(_get)(const _cx_self* self, _cx_raw raw) { _cx_iter end = _cx_memb(_end)(self); _cx_value* val = _cx_memb(_find)(self, raw).ref; return val == end.ref ? NULL : val; } STC_INLINE _cx_value* -_cx_memb(_get_mut)(const _cx_self* self, i_keyraw raw) +_cx_memb(_get_mut)(const _cx_self* self, _cx_raw raw) { return (_cx_value*) _cx_memb(_get)(self, raw); } STC_INLINE _cx_iter -_cx_memb(_binary_search)(const _cx_self* self, i_keyraw raw) { +_cx_memb(_binary_search)(const _cx_self* self, _cx_raw raw) { _cx_iter lower; return _cx_memb(_binary_search_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw, &lower); } STC_INLINE _cx_iter -_cx_memb(_lower_bound)(const _cx_self* self, i_keyraw raw) { +_cx_memb(_lower_bound)(const _cx_self* self, _cx_raw raw) { _cx_iter lower; _cx_memb(_binary_search_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw, &lower); return lower; @@ -398,9 +398,9 @@ _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, #if !c_option(c_no_cmp) STC_DEF _cx_iter -_cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, i_keyraw raw) { +_cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw) { for (; i1.ref != i2.ref; ++i1.ref) { - i_keyraw r = i_keyto(i1.ref); + const _cx_raw r = i_keyto(i1.ref); if (i_eq((&raw), (&r))) return i1; } @@ -408,11 +408,11 @@ _cx_memb(_find_in)(_cx_iter i1, _cx_iter i2, i_keyraw raw) { } STC_DEF _cx_iter -_cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, const i_keyraw raw, _cx_iter* lower_bound) { +_cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, _cx_raw raw, _cx_iter* lower_bound) { _cx_iter mid, last = i2; while (i1.ref != i2.ref) { mid.ref = i1.ref + ((i2.ref - i1.ref) >> 1); - int c; const i_keyraw m = i_keyto(mid.ref); + int c; const _cx_raw m = i_keyto(mid.ref); if (!(c = i_cmp((&raw), (&m)))) return *lower_bound = mid; else if (c < 0) @@ -426,8 +426,8 @@ _cx_memb(_binary_search_in)(_cx_iter i1, _cx_iter i2, const i_keyraw raw, _cx_it STC_DEF int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) { - const i_keyraw rx = i_keyto(x); - const i_keyraw ry = i_keyto(y); + const _cx_raw rx = i_keyto(x); + const _cx_raw ry = i_keyto(y); return i_cmp((&rx), (&ry)); } #endif // !c_no_cmp -- cgit v1.2.3