From 9708235ec4147d2c0428c9ae5186fad452b116ad Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Fri, 29 Oct 2021 16:24:50 +0200 Subject: Renamed ..._value_t -> ..._value, etc. Deprecated, still works for cvec, cdeq, cmap, csmap, cslist --- include/stc/ccommon.h | 10 +++--- include/stc/cdeq.h | 24 ++++++------- include/stc/clist.h | 48 +++++++++++++------------- include/stc/cmap.h | 10 +++--- include/stc/csmap.h | 24 ++++++------- include/stc/cstr.h | 14 ++++---- include/stc/csview.h | 14 ++++---- include/stc/cvec.h | 28 +++++++-------- include/stc/forward.h | 94 +++++++++++++++++++++++++------------------------- include/stc/template.h | 18 +++++----- 10 files changed, 142 insertions(+), 142 deletions(-) (limited to 'include') diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index b6ab84ff..5c46852d 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -126,10 +126,10 @@ STC_INLINE uint64_t c_default_hash(const void *key, size_t len); #define c_foreach(...) c_MACRO_OVERLOAD(c_foreach, __VA_ARGS__) #define c_foreach_3(it, CX, cnt) \ - for (CX##_iter_t it = CX##_begin(&cnt), it##_end_ = CX##_end(&cnt) \ + for (CX##_iter it = CX##_begin(&cnt), it##_end_ = CX##_end(&cnt) \ ; it.ref != it##_end_.ref; CX##_next(&it)) #define c_foreach_4(it, CX, start, finish) \ - for (CX##_iter_t it = start, it##_end_ = finish \ + for (CX##_iter it = start, it##_end_ = finish \ ; it.ref != it##_end_.ref; CX##_next(&it)) #define c_forrange(...) c_MACRO_OVERLOAD(c_forrange, __VA_ARGS__) @@ -163,20 +163,20 @@ STC_INLINE uint64_t c_default_hash(const void *key, size_t len); ; b; b != _c_b ? c_free(b) : (void)0, b = NULL) #define c_apply(CX, method, cx, ...) do { \ - const CX##_rawvalue_t _c_arr[] = __VA_ARGS__; \ + const CX##_rawvalue _c_arr[] = __VA_ARGS__; \ CX* _c_cx = cx; \ for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \ CX##_##method(_c_cx, _c_arr[_c_i]); \ } while (0) #define c_apply_pair(CX, method, cx, ...) do { \ - const CX##_rawvalue_t _c_arr[] = __VA_ARGS__; \ + const CX##_rawvalue _c_arr[] = __VA_ARGS__; \ CX* _c_cx = cx; \ for (size_t _c_i = 0; _c_i < c_arraylen(_c_arr); ++_c_i) \ CX##_##method(_c_cx, _c_arr[_c_i].first, _c_arr[_c_i].second); \ } while (0) #define c_apply_n(CX, method, cx, arr, n) do { \ CX* _c_cx = cx; \ - for (const CX##_rawvalue_t *_c_i = arr, *_c_end = _c_i+(n); _c_i != _c_end; ++_c_i) \ + for (const CX##_rawvalue *_c_i = arr, *_c_end = _c_i+(n); _c_i != _c_end; ++_c_i) \ CX##_##method(_c_cx, *_c_i); \ } while (0) diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index e5e0fe67..ab454247 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -45,17 +45,17 @@ STC_API _cx_self _cx_memb(_init)(void); STC_API _cx_self _cx_memb(_clone)(_cx_self cx); STC_API void _cx_memb(_clear)(_cx_self* self); STC_API void _cx_memb(_del)(_cx_self* self); -STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value); +STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value); STC_API void _cx_memb(_expand_right_half_)(_cx_self* self, size_t idx, size_t n); #ifndef i_queue -STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, i_valraw raw); +STC_API _cx_iter _cx_memb(_find_in)(_cx_iter p1, _cx_iter p2, i_valraw raw); STC_API int _cx_memb(_value_compare)(const _cx_value* x, const _cx_value* y); -STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_val value); -STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2); -STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, +STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_val value); +STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2); +STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2, bool clone); -STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, +STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_rawvalue* p1, const _cx_rawvalue* p2); #endif // i_queue @@ -71,19 +71,19 @@ STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { if (self->data == other.data) return; _cx_memb(_del)(self); *self = _cx_memb(_clone)(other); } -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) { return _cx_memb(_push_back)(self, i_valfrom(raw)); } STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) { i_valdel(self->data); ++self->data; --cdeq_rep_(self)->size; } -STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) +STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) { return self->data + cdeq_rep_(self)->size - 1; } -STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return self->data; } -STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) +STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return self->data; } +STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) { return c_make(_cx_iter){self->data}; } -STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) +STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) { return c_make(_cx_iter){self->data + cdeq_rep_(self)->size}; } STC_INLINE void _cx_memb(_next)(_cx_iter* it) { ++it->ref; } -STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) +STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) { it.ref += offs; return it; } STC_INLINE _cx_self diff --git a/include/stc/clist.h b/include/stc/clist.h index 4d5cbd8d..0c023afa 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -59,9 +59,9 @@ #include #define _c_clist_complete_types(SELF, dummy) \ - struct SELF##_node_t { \ - struct SELF##_node_t *next; \ - SELF##_value_t value; \ + struct SELF##_node { \ + struct SELF##_node *next; \ + SELF##_value value; \ } #define clist_node_(vp) c_container_of(vp, _cx_node, value) @@ -93,17 +93,17 @@ STC_API size_t _clist_count(const clist_VOID* self); STC_API _cx_self _cx_memb(_clone)(_cx_self cx); STC_API void _cx_memb(_del)(_cx_self* self); -STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value); -STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_val value); -STC_API _cx_iter _cx_memb(_insert)(_cx_self* self, _cx_iter it, i_val value); -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 _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value); +STC_API _cx_value* _cx_memb(_push_front)(_cx_self* self, i_val value); +STC_API _cx_iter _cx_memb(_insert)(_cx_self* self, _cx_iter it, i_val value); +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 size_t _cx_memb(_remove)(_cx_self* self, i_valraw val); -STC_API _cx_iter _cx_memb(_splice)(_cx_self* self, _cx_iter it, _cx_self* other); +STC_API _cx_iter _cx_memb(_splice)(_cx_self* self, _cx_iter it, _cx_self* other); STC_API _cx_self _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2); STC_API void _cx_memb(_sort)(_cx_self* self); -STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw val); -STC_API _cx_node* _cx_memb(_erase_after_)(_cx_self* self, _cx_node* node); +STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw val); +STC_API _cx_node* _cx_memb(_erase_after_)(_cx_self* self, _cx_node* node); STC_INLINE _cx_self _cx_memb(_init)(void) { return c_make(_cx_self){NULL}; } STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return cx.last == NULL; } @@ -116,14 +116,14 @@ STC_INLINE i_val _cx_memb(_value_clone)(i_val val) { return i_valfrom(i_valto(&val)); } STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) { _cx_memb(_erase_after_)(self, self->last); } -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) { return _cx_memb(_push_back)(self, i_valfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_emplace_front)(_cx_self* self, i_valraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_front)(_cx_self* self, i_valraw raw) { return _cx_memb(_push_front)(self, i_valfrom(raw)); } -STC_INLINE _cx_iter _cx_memb(_emplace)(_cx_self* self, _cx_iter it, i_valraw raw) +STC_INLINE _cx_iter _cx_memb(_emplace)(_cx_self* self, _cx_iter it, i_valraw raw) { return _cx_memb(_insert)(self, it, i_valfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return &self->last->next->value; } -STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) { return &self->last->value; } +STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) { return &self->last->next->value; } +STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) { return &self->last->value; } STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) { @@ -296,19 +296,19 @@ _cx_memb(_split_off)(_cx_self* self, _cx_iter it1, _cx_iter it2) { } STC_DEF int -_cx_memb(_sort_cmp_)(const clist_VOID_node_t* x, const clist_VOID_node_t* y) { +_cx_memb(_sort_cmp_)(const clist_VOID_node* x, const clist_VOID_node* y) { i_valraw a = i_valto(&((const _cx_node *) x)->value); i_valraw b = i_valto(&((const _cx_node *) y)->value); return i_cmp(&a, &b); } -STC_API clist_VOID_node_t* -_clist_mergesort(clist_VOID_node_t *list, int (*cmp)(const clist_VOID_node_t*, const clist_VOID_node_t*)); +STC_API clist_VOID_node* +_clist_mergesort(clist_VOID_node *list, int (*cmp)(const clist_VOID_node*, const clist_VOID_node*)); STC_DEF void _cx_memb(_sort)(_cx_self* self) { if (self->last) - self->last = (_cx_node *) _clist_mergesort((clist_VOID_node_t *) self->last->next, _cx_memb(_sort_cmp_)); + self->last = (_cx_node *) _clist_mergesort((clist_VOID_node *) self->last->next, _cx_memb(_sort_cmp_)); } #endif // TEMPLATE IMPLEMENTATION @@ -317,7 +317,7 @@ _cx_memb(_sort)(_cx_self* self) { STC_DEF size_t _clist_count(const clist_VOID* self) { - const clist_VOID_node_t *node = self->last; + const clist_VOID_node *node = self->last; if (!node) return 0; size_t n = 1; while ((node = node->next) != self->last) ++n; @@ -326,9 +326,9 @@ _clist_count(const clist_VOID* self) { // Singly linked list Mergesort implementation by Simon Tatham. O(n*log n). // https://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html -STC_DEF clist_VOID_node_t * -_clist_mergesort(clist_VOID_node_t *list, int (*cmp)(const clist_VOID_node_t*, const clist_VOID_node_t*)) { - clist_VOID_node_t *p, *q, *e, *tail, *oldhead; +STC_DEF clist_VOID_node * +_clist_mergesort(clist_VOID_node *list, int (*cmp)(const clist_VOID_node*, const clist_VOID_node*)) { + clist_VOID_node *p, *q, *e, *tail, *oldhead; int insize = 1, nmerges, psize, qsize, i; while (1) { diff --git a/include/stc/cmap.h b/include/stc/cmap.h index df0f43c9..0c5aab4e 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -37,7 +37,7 @@ int main(void) { cmap_ichar_emplace(&m, 8, 'b'); cmap_ichar_emplace(&m, 12, 'c'); - cmap_ichar_value_t* v = cmap_ichar_get(&m, 10); // NULL + cmap_ichar_value* v = cmap_ichar_get(&m, 10); // NULL char val = *cmap_ichar_at(&m, 5); // 'a' cmap_ichar_emplace_or_assign(&m, 5, 'd'); // update cmap_ichar_erase(&m, 8); @@ -81,7 +81,7 @@ cx_MAP_ONLY( struct _cx_value { }; ) typedef i_keyraw _cx_rawkey; -typedef i_valraw _cx_memb(_rawmapped_t); +typedef i_valraw _cx_memb(_rawmapped); typedef cx_SET_ONLY( i_keyraw ) cx_MAP_ONLY( struct { i_keyraw first; i_valraw second; } ) @@ -93,7 +93,7 @@ STC_API void _cx_memb(_del)(_cx_self* self); STC_API void _cx_memb(_clear)(_cx_self* self); STC_API void _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, i_keyraw 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; } @@ -109,8 +109,8 @@ STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) { return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; } cx_MAP_ONLY( - STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key _key, i_val _mapped); - STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped); + STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key _key, i_val _mapped); + STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped); STC_INLINE _cx_result /* short-form, like operator[]: */ _cx_memb(_put)(_cx_self* self, i_key key, i_val mapped) { diff --git a/include/stc/csmap.h b/include/stc/csmap.h index b74dccd0..3319d435 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -38,7 +38,7 @@ int main(void) { csmap_sx_emplace(&m, "Testing two", 12.34); csmap_sx_emplace(&m, "Testing three", 123.4); - csmap_sx_value_t *v = csmap_sx_get(&m, "Testing five"); // NULL + csmap_sx_value *v = csmap_sx_get(&m, "Testing five"); // NULL double num = *csmap_sx_at(&m, "Testing one"); csmap_sx_emplace_or_assign(&m, "Testing three", 1000.0); // update csmap_sx_erase(&m, "Testing two"); @@ -88,23 +88,23 @@ struct _cx_node { }; typedef i_keyraw _cx_rawkey; -typedef i_valraw _cx_memb(_rawmapped_t); +typedef i_valraw _cx_memb(_rawmapped); typedef cx_SET_ONLY( i_keyraw ) cx_MAP_ONLY( struct { i_keyraw first; i_valraw second; } ) _cx_rawvalue; -STC_API _cx_self _cx_memb(_init)(void); -STC_API _cx_self _cx_memb(_clone)(_cx_self tree); +STC_API _cx_self _cx_memb(_init)(void); +STC_API _cx_self _cx_memb(_clone)(_cx_self tree); STC_API void _cx_memb(_del)(_cx_self* self); STC_API void _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(_front)(const _cx_self* self); -STC_API _cx_value* _cx_memb(_back)(const _cx_self* self); +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(_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 _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 _cx_result _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw 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 _cx_result _cx_memb(_insert_entry_)(_cx_self* self, i_keyraw rkey); STC_API void _cx_memb(_next)(_cx_iter* it); STC_INLINE bool _cx_memb(_empty)(_cx_self tree) { return _csmap_rep(&tree)->size == 0; } @@ -114,7 +114,7 @@ STC_INLINE void _cx_memb(_clear)(_cx_self* self) { _cx_memb(_del)(self); STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); } STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey) { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it) != NULL; } -STC_INLINE _cx_value* _cx_memb(_get)(const _cx_self* self, i_keyraw rkey) +STC_INLINE _cx_value* _cx_memb(_get)(const _cx_self* self, i_keyraw rkey) { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); } STC_INLINE _cx_self diff --git a/include/stc/cstr.h b/include/stc/cstr.h index 41af7925..5fc5d51a 100644 --- a/include/stc/cstr.h +++ b/include/stc/cstr.h @@ -31,8 +31,8 @@ #include typedef struct cstr { char* str; } cstr; -typedef struct cstr_iter { char *ref; } cstr_iter_t; -typedef char cstr_value_t; +typedef struct cstr_iter { char *ref; } cstr_iter; +typedef char cstr_value; #define cstr_npos (SIZE_MAX >> 1) STC_LIBRARY_ONLY( extern const cstr cstr_null; ) @@ -111,11 +111,11 @@ STC_INLINE void cstr_erase(cstr* self, size_t pos) STC_INLINE char* cstr_front(cstr* self) { return self->str; } STC_INLINE char* cstr_back(cstr* self) { return self->str + _cstr_rep(self)->size - 1; } -STC_INLINE cstr_iter_t cstr_begin(cstr* self) - { return c_make(cstr_iter_t){self->str}; } -STC_INLINE cstr_iter_t cstr_end(cstr* self) - { return c_make(cstr_iter_t){self->str + _cstr_rep(self)->size}; } -STC_INLINE void cstr_next(cstr_iter_t* it) {++it->ref; } +STC_INLINE cstr_iter cstr_begin(cstr* self) + { return c_make(cstr_iter){self->str}; } +STC_INLINE cstr_iter cstr_end(cstr* self) + { return c_make(cstr_iter){self->str + _cstr_rep(self)->size}; } +STC_INLINE void cstr_next(cstr_iter* it) {++it->ref; } STC_INLINE bool cstr_equalto(cstr s, const char* str) { return strcmp(s.str, str) == 0; } STC_INLINE bool cstr_equalto_s(cstr s1, cstr s2) diff --git a/include/stc/csview.h b/include/stc/csview.h index d4ef0bd1..78cb919a 100644 --- a/include/stc/csview.h +++ b/include/stc/csview.h @@ -26,8 +26,8 @@ #include "cstr.h" typedef struct csview { const char* str; size_t size; } csview; -typedef struct csview_iter { const char *ref; } csview_iter_t; -typedef char csview_value_t; +typedef struct csview_iter { const char *ref; } csview_iter; +typedef char csview_value; #define csview_null c_make(csview){"", 0} #define csview_npos cstr_npos @@ -70,11 +70,11 @@ STC_INLINE bool csview_starts_with(csview sv, csview sub) STC_INLINE bool csview_ends_with(csview sv, csview sub) { if (sub.size > sv.size) return false; return !memcmp(sv.str + sv.size - sub.size, sub.str, sub.size); } -STC_INLINE csview_iter_t csview_begin(const csview* self) - { return c_make(csview_iter_t){self->str}; } -STC_INLINE csview_iter_t csview_end(const csview* self) - { return c_make(csview_iter_t){self->str + self->size}; } -STC_INLINE void csview_next(csview_iter_t* it) { ++it->ref; } +STC_INLINE csview_iter csview_begin(const csview* self) + { return c_make(csview_iter){self->str}; } +STC_INLINE csview_iter csview_end(const csview* self) + { return c_make(csview_iter){self->str + self->size}; } +STC_INLINE void csview_next(csview_iter* it) { ++it->ref; } /* cstr interaction with csview: */ diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 3237f095..92c8f5bd 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -78,20 +78,20 @@ struct cvec_rep { size_t size, cap; void* data[]; }; #endif typedef i_valraw _cx_rawvalue; -STC_API _cx_self _cx_memb(_init)(void); -STC_API _cx_self _cx_memb(_clone)(_cx_self cx); +STC_API _cx_self _cx_memb(_init)(void); +STC_API _cx_self _cx_memb(_clone)(_cx_self cx); STC_API void _cx_memb(_del)(_cx_self* self); STC_API void _cx_memb(_clear)(_cx_self* self); STC_API void _cx_memb(_reserve)(_cx_self* self, size_t cap); STC_API void _cx_memb(_resize)(_cx_self* self, size_t size, i_val fill_val); STC_API int _cx_memb(_value_compare)(const _cx_value* x, const _cx_value* y); -STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw raw); -STC_API _cx_iter _cx_memb(_bsearch_in)(_cx_iter it1, _cx_iter it2, i_valraw raw); -STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value); -STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2); -STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, +STC_API _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw raw); +STC_API _cx_iter _cx_memb(_bsearch_in)(_cx_iter it1, _cx_iter it2, i_valraw raw); +STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value); +STC_API _cx_iter _cx_memb(_erase_range_p)(_cx_self* self, _cx_value* p1, _cx_value* p2); +STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos, const _cx_value* p1, const _cx_value* p2, bool clone); -STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, +STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* pos, const _cx_rawvalue* p1, const _cx_rawvalue* p2); STC_INLINE size_t _cx_memb(_size)(_cx_self cx) { return cvec_rep_(&cx)->size; } @@ -102,19 +102,19 @@ STC_INLINE i_valraw _cx_memb(_value_toraw)(_cx_value* val) { return i_valto( STC_INLINE i_val _cx_memb(_value_clone)(_cx_value val) { return i_valfrom(i_valto(&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) +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) { return self->data + cvec_rep_(self)->size - 1; } -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) +STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw) { return _cx_memb(_push_back)(self, i_valfrom(raw)); } STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) { _cx_value* p = &self->data[--cvec_rep_(self)->size]; i_valdel(p); } -STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) +STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) { return c_make(_cx_iter){self->data}; } -STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) +STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) { return c_make(_cx_iter){self->data + cvec_rep_(self)->size}; } STC_INLINE void _cx_memb(_next)(_cx_iter* it) { ++it->ref; } -STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) +STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) { it.ref += offs; return it; } STC_INLINE size_t _cx_memb(_index)(_cx_self cx, _cx_iter it) { return it.ref - cx.data; } diff --git a/include/stc/forward.h b/include/stc/forward.h index ec5f77b9..11a32550 100644 --- a/include/stc/forward.h +++ b/include/stc/forward.h @@ -46,111 +46,111 @@ #define c_false(...) #define _c_carr2_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ - typedef struct { SELF##_value_t *ref; } SELF##_iter_t; \ - typedef struct { SELF##_value_t **data; size_t xdim, ydim; } SELF + typedef VAL SELF##_value; \ + typedef struct { SELF##_value *ref; } SELF##_iter; \ + typedef struct { SELF##_value **data; size_t xdim, ydim; } SELF #define _c_carr3_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ - typedef struct { SELF##_value_t *ref; } SELF##_iter_t; \ - typedef struct { SELF##_value_t ***data; size_t xdim, ydim, zdim; } SELF + typedef VAL SELF##_value; \ + typedef struct { SELF##_value *ref; } SELF##_iter; \ + typedef struct { SELF##_value ***data; size_t xdim, ydim, zdim; } SELF #define _c_cdeq_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ - typedef struct {SELF##_value_t *ref; } SELF##_iter_t; \ - typedef struct {SELF##_value_t *_base, *data;} SELF + typedef VAL SELF##_value, SELF##_value_t; \ + typedef struct {SELF##_value *ref; } SELF##_iter, SELF##_iter_t; \ + typedef struct {SELF##_value *_base, *data;} SELF #define _c_clist_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ - typedef struct SELF##_node_t SELF##_node_t; \ + typedef VAL SELF##_value, SELF##_value_t; \ + typedef struct SELF##_node SELF##_node; \ \ typedef struct { \ - SELF##_value_t *ref; \ - SELF##_node_t *const *_last, *prev; \ - } SELF##_iter_t; \ + SELF##_value *ref; \ + SELF##_node *const *_last, *prev; \ + } SELF##_iter, SELF##_iter_t; \ \ typedef struct { \ - SELF##_node_t *last; \ + SELF##_node *last; \ } SELF #define _c_chash_types(SELF, KEY, VAL, MAP_ONLY, SET_ONLY) \ - typedef KEY SELF##_key_t; \ - typedef VAL SELF##_mapped_t; \ + typedef KEY SELF##_key; \ + typedef VAL SELF##_mapped; \ typedef MAP_SIZE_T SELF##_size_t; \ \ - typedef SET_ONLY( SELF##_key_t ) \ - MAP_ONLY( struct SELF##_value_t ) \ - SELF##_value_t; \ + typedef SET_ONLY( SELF##_key ) \ + MAP_ONLY( struct SELF##_value ) \ + SELF##_value, SELF##_value_t; \ \ typedef struct { \ - SELF##_value_t *ref; \ + SELF##_value *ref; \ bool inserted; \ - } SELF##_result_t; \ + } SELF##_result, SELF##_result_t; \ \ typedef struct { \ - SELF##_value_t *ref; \ + SELF##_value *ref; \ uint8_t* _hx; \ - } SELF##_iter_t; \ + } SELF##_iter, SELF##_iter_t; \ \ typedef struct { \ - SELF##_value_t* table; \ + SELF##_value* table; \ uint8_t* _hashx; \ SELF##_size_t size, bucket_count; \ float max_load_factor; \ } SELF #define _c_aatree_types(SELF, KEY, VAL, MAP_ONLY, SET_ONLY) \ - typedef KEY SELF##_key_t; \ - typedef VAL SELF##_mapped_t; \ + typedef KEY SELF##_key; \ + typedef VAL SELF##_mapped; \ typedef MAP_SIZE_T SELF##_size_t; \ - typedef struct SELF##_node_t SELF##_node_t; \ + typedef struct SELF##_node SELF##_node; \ \ - typedef SET_ONLY( SELF##_key_t ) \ - MAP_ONLY( struct SELF##_value_t ) \ - SELF##_value_t; \ + typedef SET_ONLY( SELF##_key ) \ + MAP_ONLY( struct SELF##_value ) \ + SELF##_value, SELF##_value_t; \ \ typedef struct { \ - SELF##_value_t *ref; \ + SELF##_value *ref; \ bool inserted; \ - } SELF##_result_t; \ + } SELF##_result, SELF##_result_t; \ \ typedef struct { \ - SELF##_value_t *ref; \ - SELF##_node_t *_d; \ + SELF##_value *ref; \ + SELF##_node *_d; \ int _top; \ SELF##_size_t _tn, _st[36]; \ - } SELF##_iter_t; \ + } SELF##_iter, SELF##_iter_t; \ \ typedef struct { \ - SELF##_node_t *nodes; \ + SELF##_node *nodes; \ } SELF #define _c_csptr_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ + typedef VAL SELF##_value; \ \ typedef struct { \ - SELF##_value_t* get; \ + SELF##_value* get; \ long* use_count; \ } SELF #define _c_cstack_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ - typedef struct { SELF##_value_t *ref; } SELF##_iter_t; \ + typedef VAL SELF##_value; \ + typedef struct { SELF##_value *ref; } SELF##_iter; \ typedef struct SELF { \ - SELF##_value_t* data; \ + SELF##_value* data; \ size_t size, capacity; \ } SELF #define _c_cpque_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ + typedef VAL SELF##_value; \ typedef struct SELF { \ - SELF##_value_t* data; \ + SELF##_value* data; \ size_t size, capacity; \ } SELF #define _c_cvec_types(SELF, VAL) \ - typedef VAL SELF##_value_t; \ - typedef struct { SELF##_value_t *ref; } SELF##_iter_t; \ - typedef struct { SELF##_value_t *data; } SELF + typedef VAL SELF##_value, SELF##_value_t; \ + typedef struct { SELF##_value *ref; } SELF##_iter, SELF##_iter_t; \ + typedef struct { SELF##_value *data; } SELF #endif // STC_FORWARD_H_INCLUDED diff --git a/include/stc/template.h b/include/stc/template.h index d65fda32..44bc595c 100644 --- a/include/stc/template.h +++ b/include/stc/template.h @@ -28,15 +28,15 @@ #define _cx_self c_PASTE(i_prefix, i_tag) #define _cx_memb(name) c_PASTE(_cx_self, name) #define _cx_deftypes(macro, SELF, ...) c_EXPAND(macro(SELF, __VA_ARGS__)) - #define _cx_value _cx_memb(_value_t) - #define _cx_key _cx_memb(_key_t) - #define _cx_mapped _cx_memb(_mapped_t) - #define _cx_rawvalue _cx_memb(_rawvalue_t) - #define _cx_rawkey _cx_memb(_rawkey_t) - #define _cx_rawmapped _cx_memb(_rawmapped_t) - #define _cx_iter _cx_memb(_iter_t) - #define _cx_result _cx_memb(_result_t) - #define _cx_node _cx_memb(_node_t) + #define _cx_value _cx_memb(_value) + #define _cx_key _cx_memb(_key) + #define _cx_mapped _cx_memb(_mapped) + #define _cx_rawvalue _cx_memb(_rawvalue) + #define _cx_rawkey _cx_memb(_rawkey) + #define _cx_rawmapped _cx_memb(_rawmapped) + #define _cx_iter _cx_memb(_iter) + #define _cx_result _cx_memb(_result) + #define _cx_node _cx_memb(_node) #define _cx_size _cx_memb(_size_t) #endif -- cgit v1.2.3