diff options
| author | Tyge Løvset <[email protected]> | 2021-10-29 16:24:50 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-10-29 16:24:50 +0200 |
| commit | 9708235ec4147d2c0428c9ae5186fad452b116ad (patch) | |
| tree | 523a12b1ebee4a138e12c02c13c0a38d5f818f93 | |
| parent | 0205c4913430aa54eb0536eb1621287da719be1f (diff) | |
| download | STC-modified-9708235ec4147d2c0428c9ae5186fad452b116ad.tar.gz STC-modified-9708235ec4147d2c0428c9ae5186fad452b116ad.zip | |
Renamed ..._value_t -> ..._value, etc. Deprecated, still works for cvec, cdeq, cmap, csmap, cslist
54 files changed, 553 insertions, 556 deletions
@@ -165,11 +165,11 @@ int main(void) { csmap_int_insert(&map, 40, 4); // find an element in each container - cset_int_iter_t i1 = cset_int_find(&set, 20); - cvec_pnt_iter_t i2 = cvec_pnt_find(&vec, (struct Point) {20, 2}); - cdeq_int_iter_t i3 = cdeq_int_find(&deq, 20); - clist_int_iter_t i4 = clist_int_find(&lst, 20); - csmap_int_iter_t i5 = csmap_int_find(&map, 20); + cset_int_iter i1 = cset_int_find(&set, 20); + cvec_pnt_iter i2 = cvec_pnt_find(&vec, (struct Point) {20, 2}); + cdeq_int_iter i3 = cdeq_int_find(&deq, 20); + clist_int_iter i4 = clist_int_find(&lst, 20); + csmap_int_iter i5 = csmap_int_find(&map, 20); printf("\nFound: %d, (%g, %g), %d, %d, [%d: %d]\n", *i1.ref, i2.ref->x, i2.ref->y, *i3.ref, *i4.ref, i5.ref->first, i5.ref->second); @@ -322,7 +322,7 @@ but still not expose or include the full implementation / API of the container. ```c // Header file #include <stc/forward.h> // only include data structures -forward_cstack(cstack_pnt, struct Point); // declare cstack_pnt and cstack_pnt_value_t, cstack_pnt_iter_t; +forward_cstack(cstack_pnt, struct Point); // declare cstack_pnt and cstack_pnt_value, cstack_pnt_iter; // the element may be forward declared type as well typedef struct Dataset { cstack_pnt vertices; diff --git a/benchmarks/cdeq_benchmark.cpp b/benchmarks/cdeq_benchmark.cpp index 0c4def50..6db167b0 100644 --- a/benchmarks/cdeq_benchmark.cpp +++ b/benchmarks/cdeq_benchmark.cpp @@ -88,7 +88,7 @@ Sample test_stc_deque() { c_forrange (N) cdeq_x_push_back(&con, stc64_random() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
- //cdeq_x_iter_t it, end = cdeq_x_end(&con);
+ //cdeq_x_iter it, end = cdeq_x_end(&con);
//c_forrange (S) if ((it = cdeq_x_find(&con, stc64_random() & mask2)).ref != end.ref) sum += *it.ref;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
diff --git a/benchmarks/clist_benchmark.cpp b/benchmarks/clist_benchmark.cpp index 525bcc5a..676d31e7 100644 --- a/benchmarks/clist_benchmark.cpp +++ b/benchmarks/clist_benchmark.cpp @@ -85,7 +85,7 @@ Sample test_stc_forward_list() { c_forrange (N) clist_x_push_front(&con, stc64_random() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
- //clist_x_iter_t it, end = clist_x_end(&con);
+ //clist_x_iter it, end = clist_x_end(&con);
//c_forrange (S) if ((it = clist_x_find(&con, stc64_random() & mask2)).ref != end.ref) sum += *it.ref;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
diff --git a/benchmarks/cmap_benchmark.cpp b/benchmarks/cmap_benchmark.cpp index d94f2f24..dc104c2d 100644 --- a/benchmarks/cmap_benchmark.cpp +++ b/benchmarks/cmap_benchmark.cpp @@ -91,7 +91,7 @@ Sample test_stc_unordered_map() { stc64_srandom(seed);
s.test[FIND].t1 = clock();
size_t sum = 0;
- cmap_x_value_t* val;
+ cmap_x_value* val;
c_forrange (N)
if ((val = cmap_x_get(&con, stc64_random() & mask1)))
sum += val->second;
diff --git a/benchmarks/csmap_benchmark.cpp b/benchmarks/csmap_benchmark.cpp index fa1e10cf..bb055367 100644 --- a/benchmarks/csmap_benchmark.cpp +++ b/benchmarks/csmap_benchmark.cpp @@ -91,7 +91,7 @@ Sample test_stc_map() { stc64_srandom(seed);
s.test[FIND].t1 = clock();
size_t sum = 0;
- csmap_x_value_t* val;
+ csmap_x_value* val;
c_forrange (N)
if ((val = csmap_x_get(&con, stc64_random() & mask1)))
sum += val->second;
diff --git a/benchmarks/cvec_benchmark.cpp b/benchmarks/cvec_benchmark.cpp index f7755cf6..c4648e34 100644 --- a/benchmarks/cvec_benchmark.cpp +++ b/benchmarks/cvec_benchmark.cpp @@ -84,7 +84,7 @@ Sample test_stc_vector() { c_forrange (N) cvec_x_push_back(&con, stc64_random() & mask2);
s.test[FIND].t1 = clock();
size_t sum = 0;
- //cvec_x_iter_t it, end = cvec_x_end(&con);
+ //cvec_x_iter it, end = cvec_x_end(&con);
//c_forrange (S) if ((it = cvec_x_find(&con, stc64_random() & mask2)).ref != end.ref) sum += *it.ref;
s.test[FIND].t2 = clock();
s.test[FIND].sum = sum;
diff --git a/benchmarks/others/old/carray_v1.h b/benchmarks/others/old/carray_v1.h index 65777416..c4f294cf 100644 --- a/benchmarks/others/old/carray_v1.h +++ b/benchmarks/others/old/carray_v1.h @@ -53,15 +53,15 @@ int main() #define using_carray2_4(X, Value, valueDel, valueClone) \
\
- typedef Value carray1##X##_value_t, carray2##X##_value_t; \
+ typedef Value carray1##X##_value, carray2##X##_value; \
\
typedef struct { \
- carray1##X##_value_t *data; \
+ carray1##X##_value *data; \
size_t _xdim; \
} carray1##X; \
\
typedef struct { \
- carray2##X##_value_t *data; \
+ carray2##X##_value *data; \
size_t _xdim, _ydim; \
} carray2##X; \
\
@@ -77,7 +77,7 @@ int main() \
STC_INLINE carray1##X \
carray1##X##_init(size_t xdim, Value val) { \
- carray1##X##_value_t* m = c_new_n(carray1##X##_value_t, xdim); \
+ carray1##X##_value* m = c_new_n(carray1##X##_value, xdim); \
for (size_t i=0; i<xdim; ++i) m[i] = val; \
carray1##X a = {m, xdim | _carray_OWN}; \
return a; \
@@ -85,24 +85,24 @@ int main() STC_INLINE carray2##X \
carray2##X##_init(size_t ydim, size_t xdim, Value val) { \
const size_t n = ydim * xdim; \
- carray2##X##_value_t* m = c_new_n(carray2##X##_value_t, n); \
+ carray2##X##_value* m = c_new_n(carray2##X##_value, n); \
for (size_t i=0; i<n; ++i) m[i] = val; \
carray2##X a = {m, xdim | _carray_OWN, ydim}; \
return a; \
} \
\
STC_INLINE carray1##X \
- carray1##X##_from(carray1##X##_value_t* array, size_t xdim) { \
+ carray1##X##_from(carray1##X##_value* array, size_t xdim) { \
carray1##X a = {array, xdim}; \
return a; \
} \
STC_INLINE carray2##X \
- carray2##X##_from(carray2##X##_value_t* array, size_t ydim, size_t xdim) { \
+ carray2##X##_from(carray2##X##_value* array, size_t ydim, size_t xdim) { \
carray2##X a = {array, xdim, ydim}; \
return a; \
} \
\
- STC_INLINE carray1##X##_value_t* \
+ STC_INLINE carray1##X##_value* \
carray1##X##_at(const carray1##X *a, size_t x) { return a->data + x; } \
\
STC_INLINE carray1##X \
@@ -110,7 +110,7 @@ int main() carray1##X sub = {a->data + y*_carray_xdim(*a), _carray_xdim(*a)}; \
return sub; \
} \
- STC_INLINE carray2##X##_value_t* \
+ STC_INLINE carray2##X##_value* \
carray2##X##_at(const carray2##X *a, size_t y, size_t x) { \
return a->data + y*_carray_xdim(*a) + x; \
} \
@@ -125,10 +125,10 @@ int main() #define using_carray3_4(X, Value, valueDel, valueClone) \
\
using_carray2_4(X, Value, valueDel, valueClone); \
- typedef Value carray3##X##_value_t; \
+ typedef Value carray3##X##_value; \
\
typedef struct { \
- carray3##X##_value_t *data; \
+ carray3##X##_value *data; \
size_t _xdim, _ydim, _zdim; \
} carray3##X; \
\
@@ -144,14 +144,14 @@ int main() STC_INLINE carray3##X \
carray3##X##_init(size_t zdim, size_t ydim, size_t xdim, Value val) { \
const size_t n = zdim * ydim * xdim; \
- carray3##X##_value_t* m = c_new_n(carray3##X##_value_t, n); \
+ carray3##X##_value* m = c_new_n(carray3##X##_value, n); \
for (size_t i=0; i<n; ++i) m[i] = val; \
carray3##X a = {m, xdim | _carray_OWN, ydim, zdim}; \
return a; \
} \
\
STC_INLINE carray3##X \
- carray3##X##_from(carray3##X##_value_t* array, size_t zdim, size_t ydim, size_t xdim) { \
+ carray3##X##_from(carray3##X##_value* array, size_t zdim, size_t ydim, size_t xdim) { \
carray3##X a = {array, xdim, ydim, zdim}; \
return a; \
} \
@@ -166,7 +166,7 @@ int main() carray1##X sub = {a->data + (z*_carray_ydim(*a) + y)*_carray_xdim(*a), _carray_xdim(*a)}; \
return sub; \
} \
- STC_INLINE carray3##X##_value_t* \
+ STC_INLINE carray3##X##_value* \
carray3##X##_at(const carray3##X *a, size_t z, size_t y, size_t x) { \
return a->data + (z*_carray_ydim(*a) + y)*_carray_xdim(*a) + x; \
} \
@@ -180,18 +180,18 @@ int main() #define _carray_zdim(a) (a)._zdim
#define _using_carray_common(D, X, Value, valueDel, valueClone) \
- typedef struct { carray1##X##_value_t *ref; } carray##D##X##_iter_t; \
+ typedef struct { carray1##X##_value *ref; } carray##D##X##_iter; \
\
- STC_INLINE carray##D##X##_iter_t \
+ STC_INLINE carray##D##X##_iter \
carray##D##X##_begin(const carray##D##X* a) { \
- carray##D##X##_iter_t it = {a->data}; return it; \
+ carray##D##X##_iter it = {a->data}; return it; \
} \
- STC_INLINE carray##D##X##_iter_t \
+ STC_INLINE carray##D##X##_iter \
carray##D##X##_end(const carray##D##X* a) { \
- carray##D##X##_iter_t it = {a->data + carray##D##X##_size(*a)}; return it; \
+ carray##D##X##_iter it = {a->data + carray##D##X##_size(*a)}; return it; \
} \
STC_INLINE void \
- carray##D##X##_next(carray##D##X##_iter_t* it) {++it->ref;} \
+ carray##D##X##_next(carray##D##X##_iter* it) {++it->ref;} \
\
STC_INLINE void \
carray##D##X##_del(carray##D##X* self) { \
@@ -204,7 +204,7 @@ int main() STC_INLINE carray##D##X \
carray##D##X##_clone(carray##D##X arr) { \
carray##D##X cp = arr; size_t k = 0; \
- cp.data = c_new_n(carray1##X##_value_t, carray##D##X##_size(arr)); \
+ cp.data = c_new_n(carray1##X##_value, carray##D##X##_size(arr)); \
c_foreach_3 (i, carray##D##X, arr) \
cp.data[k++] = valueClone(*i.ref); \
return cp; \
diff --git a/benchmarks/others/old/clist.h b/benchmarks/others/old/clist.h index e677e40d..ea1bb9a5 100644 --- a/benchmarks/others/old/clist.h +++ b/benchmarks/others/old/clist.h @@ -289,7 +289,7 @@ STC_API size_t _clist_count(const clist_VOID* self); 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_)); \
}
@@ -302,7 +302,7 @@ STC_API size_t _clist_count(const clist_VOID* self); STC_DEF size_t
_clist_count(const clist_VOID* self) {
- const clist_VOID_node_t *nd = self->last;
+ const clist_VOID_node *nd = self->last;
if (!nd) return 0;
size_t n = 1;
while ((nd = nd->next) != self->last) ++n;
@@ -312,9 +312,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 void*, const void*)) {
- clist_VOID_node_t *p, *q, *e, *tail, *oldhead;
+STC_DEF clist_VOID_node *
+_clist_mergesort(clist_VOID_node *list, int (*cmp)(const void*, const void*)) {
+ clist_VOID_node *p, *q, *e, *tail, *oldhead;
int insize = 1, nmerges, psize, qsize, i;
while (1) {
diff --git a/benchmarks/others/old/csmap.h b/benchmarks/others/old/csmap.h index a60d16e0..699e18c1 100644 --- a/benchmarks/others/old/csmap.h +++ b/benchmarks/others/old/csmap.h @@ -36,7 +36,7 @@ int main(void) { csmap_mx_insert(&m, 8, 'b');
csmap_mx_insert(&m, 12, 'c');
- csmap_mx_iter_t it = csmap_mx_find(&m, 10); // none
+ csmap_mx_iter it = csmap_mx_find(&m, 10); // none
char val = csmap_mx_find(&m, 5).ref->second;
csmap_mx_put(&m, 5, 'd'); // update
csmap_mx_erase(&m, 8);
@@ -70,10 +70,10 @@ int main(void) { _c_aatree_complete_types(_cx_self, C); \
\
typedef i_keyraw _cx_rawkey; \
- typedef i_valraw _cx_memb(_rawmapped_t); \
+ typedef i_valraw _cx_memb(_rawmapped); \
typedef cx_SET_ONLY( _cx_rawkey ) \
cx_MAP_ONLY( struct { _cx_rawkey first; \
- _cx_memb(_rawmapped_t) second; } ) \
+ _cx_memb(_rawmapped) second; } ) \
_cx_rawvalue; \
\
STC_API _cx_self _cx_memb(_init)(void); \
@@ -201,7 +201,7 @@ int main(void) { _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};
+static csmap_SENTINEL_node _aatree_sentinel = {&_aatree_sentinel, &_aatree_sentinel, 0};
#define _c_implement_aatree(_cx_self, C, i_key, i_val, i_cmp, \
i_valdel, i_valfrom, i_valto, i_valraw, \
diff --git a/benchmarks/others/parallel_hashmap/btree.h b/benchmarks/others/parallel_hashmap/btree.h index ae1aec5b..b8c95433 100644 --- a/benchmarks/others/parallel_hashmap/btree.h +++ b/benchmarks/others/parallel_hashmap/btree.h @@ -699,7 +699,7 @@ namespace phmap { template < typename Compare, typename K, typename LK, - phmap::enable_if_t<!std::is_same<bool, phmap::invoke_result_t< + phmap::enable_if_t<!std::is_same<bool, phmap::invoke_result< Compare, const K &, const LK &>>::value, int> = 0> constexpr phmap::weak_ordering do_three_way_comparison(const Compare &compare, @@ -708,7 +708,7 @@ namespace phmap { } template < typename Compare, typename K, typename LK, - phmap::enable_if_t<std::is_same<bool, phmap::invoke_result_t<Compare, + phmap::enable_if_t<std::is_same<bool, phmap::invoke_result<Compare, const K &, const LK &>>::value, int> = 0> constexpr phmap::weak_ordering do_three_way_comparison(const Compare &compare, @@ -730,7 +730,7 @@ namespace priv { // comparator. template <typename Compare, typename T> using btree_is_key_compare_to = - std::is_convertible<phmap::invoke_result_t<Compare, const T &, const T &>, + std::is_convertible<phmap::invoke_result<Compare, const T &, const T &>, phmap::weak_ordering>; struct StringBtreeDefaultLess { @@ -2494,7 +2494,7 @@ namespace priv { // Verify that key_compare returns an phmap::{weak,strong}_ordering or bool. using compare_result_type = - phmap::invoke_result_t<key_compare, key_type, key_type>; + phmap::invoke_result<key_compare, key_type, key_type>; static_assert( std::is_same<compare_result_type, bool>::value || std::is_convertible<compare_result_type, phmap::weak_ordering>::value, diff --git a/benchmarks/others/parallel_hashmap/phmap_base.h b/benchmarks/others/parallel_hashmap/phmap_base.h index 6b9ea9ee..d0c6f3ce 100644 --- a/benchmarks/others/parallel_hashmap/phmap_base.h +++ b/benchmarks/others/parallel_hashmap/phmap_base.h @@ -330,9 +330,9 @@ using underlying_type_t = typename std::underlying_type<T>::type; template< class F, class... ArgTypes> #if PHMAP_HAVE_CC17 - using invoke_result_t = typename std::invoke_result_t<F, ArgTypes...>; + using invoke_result = typename std::invoke_result<F, ArgTypes...>; #else - using invoke_result_t = typename std::result_of<F(ArgTypes...)>::type; + using invoke_result = typename std::result_of<F(ArgTypes...)>::type; #endif namespace type_traits_internal { diff --git a/benchmarks/shootout3_csmap.cpp b/benchmarks/shootout3_csmap.cpp index 3682c874..dfa0ab1b 100644 --- a/benchmarks/shootout3_csmap.cpp +++ b/benchmarks/shootout3_csmap.cpp @@ -179,7 +179,7 @@ static void ins_and_access_csmap_i(picobench::state& s) picobench::scope scope(s);
c_forrange (s.iterations()) {
result += ++csmap_i_emplace(&map, stc64_random() & mask, 0).ref->second;
- csmap_i_value_t* val = csmap_i_get(&map, stc64_random() & mask);
+ csmap_i_value* val = csmap_i_get(&map, stc64_random() & mask);
if (val) csmap_i_erase(&map, val->first);
}
s.set_result(result + csmap_i_size(map));
@@ -236,7 +236,7 @@ static void ins_and_access_csmap_s(picobench::state& s) c_forrange (s.iterations()) {
randomize(str.str, cstr_size(str));
result += csmap_str_erase(&map, str.str);
- /*csmap_str_iter_t it = csmap_str_find(&map, str.str);
+ /*csmap_str_iter it = csmap_str_find(&map, str.str);
if (it.ref) {
++result;
csmap_str_erase(&map, it.ref->first.str);
diff --git a/benchmarks/string_bench.c b/benchmarks/string_bench.c index 7da3b838..8e639aa2 100644 --- a/benchmarks/string_bench.c +++ b/benchmarks/string_bench.c @@ -119,7 +119,7 @@ void benchmark(cvec_str vec_string, struct Maps maps) stopwatch = clock();
for (size_t i = 0; i < MAX_LOOP; ++i)
{
- csmap_str_iter_t it, end = csmap_str_end(maps.snormal);
+ csmap_str_iter it, end = csmap_str_end(maps.snormal);
for (size_t j = 0; j < cvec_str_size(vec_string); ++j)
{
csmap_str_find_it(maps.snormal, vec_string.data[j].str, &it);
@@ -136,7 +136,7 @@ void benchmark(cvec_str vec_string, struct Maps maps) stopwatch = clock();
for (size_t i = 0; i < MAX_LOOP; ++i)
{
- cmap_str_iter_t it, end = cmap_str_end(maps.unormal);
+ cmap_str_iter it, end = cmap_str_end(maps.unormal);
for (size_t j = 0; j < cvec_str_size(vec_string); ++j)
{
it = cmap_str_find(maps.unormal, vec_string.data[j].str);
diff --git a/docs/carray_api.md b/docs/carray_api.md index d7ece0fa..a6870b91 100644 --- a/docs/carray_api.md +++ b/docs/carray_api.md @@ -35,9 +35,9 @@ size_t carr2_X_size(carr2_X arr); i_val* carr2_X_data(carr2_X* self); // access storage data i_val* carr2_X_at(carr2_X* self, size_t x, size_t y); -carr2_X_iter_t carr2_X_begin(const carr2_X* self); -carr2_X_iter_t carr2_X_end(const carr2_X* self); -void carr2_X_next(carr2_X_iter_t* it); +carr2_X_iter carr2_X_begin(const carr2_X* self); +carr2_X_iter carr2_X_end(const carr2_X* self); +void carr2_X_next(carr2_X_iter* it); ``` carr3: ```c @@ -53,21 +53,21 @@ size_t carr3_X_size(carr3_X arr); i_val* carr3_X_data(carr3_X* self); // access storage data i_val* carr3_X_at(carr3_X* self, size_t x, size_t y, size_t z); -carr3_X_iter_t carr3_X_begin(const carr3_X* self); -carr3_X_iter_t carr3_X_end(const carr3_X* self); -void carr3_X_next(carr3_X_iter_t* it); +carr3_X_iter carr3_X_begin(const carr3_X* self); +carr3_X_iter carr3_X_end(const carr3_X* self); +void carr3_X_next(carr3_X_iter* it); ``` ## Types | Type name | Type definition | Used to represent... | |:------------------|:-----------------------------------------------------|:---------------------| | `carr2_X` | `struct { i_val **data; size_t xdim, ydim; }` | The array 2D type | -| `carr2_X_value_t` | `i_val` | The value type | -| `carr2_X_iter_t` | `struct { i_val *ref; }` | Iterator type | +| `carr2_X_value` | `i_val` | The value type | +| `carr2_X_iter` | `struct { i_val *ref; }` | Iterator type | | | | | | `carr3_X` | `struct { i_val ***data; size_t xdim, ydim, zdim; }` | The array 3D type | -| `carr3_X_value_t` | `i_val` | The value type | -| `carr3_X_iter_t` | `struct { i_val *ref; }` | Iterator type | +| `carr3_X_value` | `i_val` | The value type | +| `carr3_X_iter` | `struct { i_val *ref; }` | Iterator type | The **carr3** elements can be accessed like `carr3_i arr = ...; int val = arr.data[x][y][z];`, or with `carr3_i_at(&arr, x, y, z)`. diff --git a/docs/cbits_api.md b/docs/cbits_api.md index 4264b1d4..f13c5e8c 100644 --- a/docs/cbits_api.md +++ b/docs/cbits_api.md @@ -58,7 +58,7 @@ void cbits_xor(cbits *self, cbits other); // set of disjoint | cbits | Type definition | Used to represent... | |:--------------------|:--------------------------|:-----------------------------| | `cbits` | `struct { ... }` | The cbits type | -| `cbits_iter_t` | `struct { ... }` | The cbits iterator type | +| `cbits_iter` | `struct { ... }` | The cbits iterator type | ## Example ```c diff --git a/docs/ccommon_api.md b/docs/ccommon_api.md index 83f5dc6f..9a309835 100644 --- a/docs/ccommon_api.md +++ b/docs/ccommon_api.md @@ -95,7 +95,7 @@ c_apply(csset_x, insert, &set, {23, 3, 7, 5, 12}); c_foreach (i, csset_x, set) printf(" %d", *i.ref); // 3 5 7 12 23 -csset_x_iter_t it = csset_x_find(&set, 7); +csset_x_iter it = csset_x_find(&set, 7); c_foreach (i, csset_x, it, csset_x_end(&set)) printf(" %d", *i.ref); // 7 12 23 diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md index 4f188143..ab0a1b12 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -38,58 +38,58 @@ bool cdeq_X_empty(cdeq_X deq); size_t cdeq_X_size(cdeq_X deq); size_t cdeq_X_capacity(cdeq_X deq); -cdeq_X_value_t* cdeq_X_at(const cdeq_X* self, size_t idx); -cdeq_X_value_t* cdeq_X_front(const cdeq_X* self); -cdeq_X_value_t* cdeq_X_back(const cdeq_X* self); +cdeq_X_value* cdeq_X_at(const cdeq_X* self, size_t idx); +cdeq_X_value* cdeq_X_front(const cdeq_X* self); +cdeq_X_value* cdeq_X_back(const cdeq_X* self); -cdeq_X_value_t* cdeq_X_push_front(cdeq_X* self, i_val value); -cdeq_X_value_t* cdeq_X_emplace_front(cdeq_X* self, i_valraw raw); +cdeq_X_value* cdeq_X_push_front(cdeq_X* self, i_val value); +cdeq_X_value* cdeq_X_emplace_front(cdeq_X* self, i_valraw raw); void cdeq_X_pop_front(cdeq_X* self); -cdeq_X_value_t* cdeq_X_push_back(cdeq_X* self, i_val value); -cdeq_X_value_t* cdeq_X_emplace_back(cdeq_X* self, i_valraw raw); +cdeq_X_value* cdeq_X_push_back(cdeq_X* self, i_val value); +cdeq_X_value* cdeq_X_emplace_back(cdeq_X* self, i_valraw raw); void cdeq_X_pop_back(cdeq_X* self); -cdeq_X_iter_t cdeq_X_insert(cdeq_X* self, size_t idx, i_val value); // move value -cdeq_X_iter_t cdeq_X_insert_n(cdeq_X* self, size_t idx, const i_val[] arr, size_t n); // move arr values -cdeq_X_iter_t cdeq_X_insert_at(cdeq_X* self, cdeq_X_iter_t it, i_val value); // move value +cdeq_X_iter cdeq_X_insert(cdeq_X* self, size_t idx, i_val value); // move value +cdeq_X_iter cdeq_X_insert_n(cdeq_X* self, size_t idx, const i_val[] arr, size_t n); // move arr values +cdeq_X_iter cdeq_X_insert_at(cdeq_X* self, cdeq_X_iter it, i_val value); // move value -cdeq_X_iter_t cdeq_X_emplace(cdeq_X* self, size_t idx, i_valraw raw); -cdeq_X_iter_t cdeq_X_emplace_n(cdeq_X* self, size_t idx, const i_valraw[] arr, size_t n); -cdeq_X_iter_t cdeq_X_emplace_at(cdeq_X* self, cdeq_X_iter_t it, i_valraw raw); -cdeq_X_iter_t cdeq_X_emplace_range(cdeq_X* self, cdeq_X_iter_t it, - cdeq_X_iter_t it1, cdeq_X_iter_t it2); // will clone -cdeq_X_iter_t cdeq_X_emplace_range_p(cdeq_X* self, i_val* pos, +cdeq_X_iter cdeq_X_emplace(cdeq_X* self, size_t idx, i_valraw raw); +cdeq_X_iter cdeq_X_emplace_n(cdeq_X* self, size_t idx, const i_valraw[] arr, size_t n); +cdeq_X_iter cdeq_X_emplace_at(cdeq_X* self, cdeq_X_iter it, i_valraw raw); +cdeq_X_iter cdeq_X_emplace_range(cdeq_X* self, cdeq_X_iter it, + cdeq_X_iter it1, cdeq_X_iter it2); // will clone +cdeq_X_iter cdeq_X_emplace_range_p(cdeq_X* self, i_val* pos, const i_val* p1, const i_val* p2); -cdeq_X_iter_t cdeq_X_erase_n(cdeq_X* self, size_t idx, size_t n); -cdeq_X_iter_t cdeq_X_erase_at(cdeq_X* self, cdeq_X_iter_t it); -cdeq_X_iter_t cdeq_X_erase_range(cdeq_X* self, cdeq_X_iter_t it1, cdeq_X_iter_t it2); +cdeq_X_iter cdeq_X_erase_n(cdeq_X* self, size_t idx, size_t n); +cdeq_X_iter cdeq_X_erase_at(cdeq_X* self, cdeq_X_iter it); +cdeq_X_iter cdeq_X_erase_range(cdeq_X* self, cdeq_X_iter it1, cdeq_X_iter it2); -cdeq_X_iter_t cdeq_X_find(const cdeq_X* self, i_valraw raw); -cdeq_X_iter_t cdeq_X_find_in(cdeq_X_iter_t i1, cdeq_X_iter_t i2, i_valraw raw); -cdeq_X_value_t* cdeq_X_get(const cdeq_X* self, i_valraw raw); // returns NULL if not found +cdeq_X_iter cdeq_X_find(const cdeq_X* self, i_valraw raw); +cdeq_X_iter cdeq_X_find_in(cdeq_X_iter i1, cdeq_X_iter i2, i_valraw raw); +cdeq_X_value* cdeq_X_get(const cdeq_X* self, i_valraw raw); // returns NULL if not found void cdeq_X_sort(cdeq_X* self); -void cdeq_X_sort_range(cdeq_X_iter_t i1, cdeq_X_iter_t i2, +void cdeq_X_sort_range(cdeq_X_iter i1, cdeq_X_iter i2, int(*cmp)(const i_val*, const i_val*)); -cdeq_X_iter_t cdeq_X_begin(const cdeq_X* self); -cdeq_X_iter_t cdeq_X_end(const cdeq_X* self); -void cdeq_X_next(cdeq_X_iter_t* it); +cdeq_X_iter cdeq_X_begin(const cdeq_X* self); +cdeq_X_iter cdeq_X_end(const cdeq_X* self); +void cdeq_X_next(cdeq_X_iter* it); -cdeq_X_rawvalue_t cdeq_X_value_toraw(cdeq_X_value_t* pval); -cdeq_X_value_t cdeq_X_value_clone(cdeq_X_value_t val); +cdeq_X_rawvalue cdeq_X_value_toraw(cdeq_X_value* pval); +cdeq_X_value cdeq_X_value_clone(cdeq_X_value val); ``` ## Types -| Type name | Type definition | Used to represent... | -|:---------------------|:------------------------------------|:-----------------------| -| `cdeq_X` | `struct { cdeq_X_value_t* data; }` | The cdeq type | -| `cdeq_X_value_t` | `i_val` | The cdeq value type | -| `cdeq_X_rawvalue_t` | `i_valraw` | The raw value type | -| `cdeq_X_iter_t` | `struct { cdeq_X_value_t* ref; }` | The iterator type | +| Type name | Type definition | Used to represent... | +|:-------------------|:------------------------------------|:-----------------------| +| `cdeq_X` | `struct { cdeq_X_value* data; }` | The cdeq type | +| `cdeq_X_value` | `i_val` | The cdeq value type | +| `cdeq_X_rawvalue` | `i_valraw` | The raw value type | +| `cdeq_X_iter` | `struct { cdeq_X_value* ref; }` | The iterator type | ## Examples ```c diff --git a/docs/clist_api.md b/docs/clist_api.md index 7ef12153..6bb241f9 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -47,8 +47,8 @@ void clist_X_del(clist_X* self); bool clist_X_empty(clist_X list); size_t clist_X_count(clist_X list); // size() in O(n) time -clist_X_value_t* clist_X_front(const clist_X* self); -clist_X_value_t* clist_X_back(const clist_X* self); +clist_X_value* clist_X_front(const clist_X* self); +clist_X_value* clist_X_back(const clist_X* self); void clist_X_push_front(clist_X* self, i_val value); void clist_X_emplace_front(clist_X* self, i_valraw raw); @@ -57,40 +57,40 @@ void clist_X_pop_front(clist_X* self); void clist_X_push_back(clist_X* self, i_val value); // note: no pop_back(). void clist_X_emplace_back(clist_X* self, i_valraw raw); -clist_X_iter_t clist_X_insert(clist_X* self, clist_X_iter_t it, i_val value); // return iter to new elem -clist_X_iter_t clist_X_emplace(clist_X* self, clist_X_iter_t it, i_valraw raw); +clist_X_iter clist_X_insert(clist_X* self, clist_X_iter it, i_val value); // return iter to new elem +clist_X_iter clist_X_emplace(clist_X* self, clist_X_iter it, i_valraw raw); -clist_X_iter_t clist_X_erase_at(clist_X* self, clist_X_iter_t it); // return iter after it -clist_X_iter_t clist_X_erase_range(clist_X* self, clist_X_iter_t it1, clist_X_iter_t it2); +clist_X_iter clist_X_erase_at(clist_X* self, clist_X_iter it); // return iter after it +clist_X_iter clist_X_erase_range(clist_X* self, clist_X_iter it1, clist_X_iter it2); size_t clist_X_remove(clist_X* self, i_valraw raw); // removes matching elements -clist_X clist_X_split_off(clist_X* self, clist_X_iter_t i1, clist_X_iter_t i2); // split off [i1, i2) -clist_X_iter_t clist_X_splice(clist_X* self, clist_X_iter_t it, clist_X* other); // return updated valid it -clist_X_iter_t clist_X_splice_range(clist_X* self, clist_X_iter_t it, // return updated valid it - clist_X* other, clist_X_iter_t it1, clist_X_iter_t it2); +clist_X clist_X_split_off(clist_X* self, clist_X_iter i1, clist_X_iter i2); // split off [i1, i2) +clist_X_iter clist_X_splice(clist_X* self, clist_X_iter it, clist_X* other); // return updated valid it +clist_X_iter clist_X_splice_range(clist_X* self, clist_X_iter it, // return updated valid it + clist_X* other, clist_X_iter it1, clist_X_iter it2); -clist_X_iter_t clist_X_find(const clist_X* self, i_valraw raw); -clist_X_iter_t clist_X_find_in(clist_X_iter_t it1, clist_X_iter_t it2, i_valraw raw); +clist_X_iter clist_X_find(const clist_X* self, i_valraw raw); +clist_X_iter clist_X_find_in(clist_X_iter it1, clist_X_iter it2, i_valraw raw); void clist_X_sort(clist_X* self); -clist_X_iter_t clist_X_begin(const clist_X* self); -clist_X_iter_t clist_X_end(const clist_X* self); -void clist_X_next(clist_X_iter_t* it); -clist_X_iter_t clist_X_advance(clist_X_iter it, size_t n); // return it n elements ahead. End allowed. +clist_X_iter clist_X_begin(const clist_X* self); +clist_X_iter clist_X_end(const clist_X* self); +void clist_X_next(clist_X_iter* it); +clist_X_iter clist_X_advance(clist_X_iter it, size_t n); // return it n elements ahead. End allowed. -clist_X_rawvalue_t clist_X_value_toraw(clist_X_value_t* pval); -clist_X_value_t clist_X_value_clone(clist_X_value_t val); +clist_X_rawvalue clist_X_value_toraw(clist_X_value* pval); +clist_X_value clist_X_value_clone(clist_X_value val); ``` ## Types -| Type name | Type definition | Used to represent... | -|:----------------------|:------------------------------------|:--------------------------| -| `clist_X` | `struct { clist_X_node_t* last; }` | The clist type | -| `clist_X_value_t` | `i_val` | The clist element type | -| `clist_X_rawvalue_t` | `i_valraw` | clist raw value type | -| `clist_X_iter_t` | `struct { clist_value_t *ref; ... }`| clist iterator | +| Type name | Type definition | Used to represent... | +|:--------------------|:------------------------------------|:--------------------------| +| `clist_X` | `struct { clist_X_node* last; }` | The clist type | +| `clist_X_value` | `i_val` | The clist element type | +| `clist_X_rawvalue` | `i_valraw` | clist raw value type | +| `clist_X_iter` | `struct { clist_value *ref; ... }` | clist iterator | ## Example @@ -147,11 +147,11 @@ int main () clist_i L = clist_i_init(); c_apply(clist_i, push_back, &L, {10, 20, 30, 40, 50}); // 10 20 30 40 50 - clist_i_iter_t it = clist_i_begin(&L); // ^ + clist_i_iter it = clist_i_begin(&L); // ^ clist_i_next(&it); it = clist_i_erase_at(&L, it); // 10 30 40 50 // ^ - clist_i_iter_t end = clist_i_end(&L); // + clist_i_iter end = clist_i_end(&L); // clist_i_next(&it); it = clist_i_erase_range(&L, it, end); // 10 30 // ^ @@ -183,8 +183,8 @@ int main() { c_apply(clist_i, push_back, &L1, {1, 2, 3, 4, 5}); c_apply(clist_i, push_back, &L2, {10, 20, 30, 40, 50}); - clist_i_iter_t i = clist_i_advance(clist_i_begin(&L1), 2); - clist_i_iter_t j1 = clist_i_advance(clist_i_begin(&L2), 2), j2 = clist_i_advance(j1, 2); + clist_i_iter i = clist_i_advance(clist_i_begin(&L1), 2); + clist_i_iter j1 = clist_i_advance(clist_i_begin(&L2), 2), j2 = clist_i_advance(j1, 2); clist_i_splice_range(&L1, i, &L2, j1, j2); diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 31dd3f63..628e982a 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -55,27 +55,27 @@ size_t cmap_X_capacity(cmap_X map); size_t cmap_X_bucket_count(cmap_X map); // num. of allocated buckets bool cmap_X_contains(const cmap_X* self, i_keyraw rkey); -cmap_X_mapped_t* cmap_X_at(const cmap_X* self, i_keyraw rkey); // rkey must be in map. -cmap_X_value_t* cmap_X_get(const cmap_X* self, i_keyraw rkey); // return NULL if not found -cmap_X_iter_t cmap_X_find(const cmap_X* self, i_keyraw rkey); +cmap_X_mapped* cmap_X_at(const cmap_X* self, i_keyraw rkey); // rkey must be in map. +cmap_X_value* cmap_X_get(const cmap_X* self, i_keyraw rkey); // return NULL if not found +cmap_X_iter cmap_X_find(const cmap_X* self, i_keyraw rkey); -cmap_X_result_t cmap_X_insert(cmap_X* self, i_key key, i_val mapped); // no change if key in map -cmap_X_result_t cmap_X_insert_or_assign(cmap_X* self, i_key key, i_val mapped); // always update mapped -cmap_X_result_t cmap_X_put(cmap_X* self, i_key key, i_val mapped); // alias for insert_or_assign +cmap_X_result cmap_X_insert(cmap_X* self, i_key key, i_val mapped); // no change if key in map +cmap_X_result cmap_X_insert_or_assign(cmap_X* self, i_key key, i_val mapped); // always update mapped +cmap_X_result cmap_X_put(cmap_X* self, i_key key, i_val mapped); // alias for insert_or_assign -cmap_X_result_t cmap_X_emplace(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map -cmap_X_result_t cmap_X_emplace_or_assign(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped +cmap_X_result cmap_X_emplace(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map +cmap_X_result cmap_X_emplace_or_assign(cmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped size_t cmap_X_erase(cmap_X* self, i_keyraw rkey); // return 0 or 1 -cmap_X_iter_t cmap_X_erase_at(cmap_X* self, cmap_X_iter_t it); // return iter after it -void cmap_X_erase_entry(cmap_X* self, cmap_X_value_t* entry); +cmap_X_iter cmap_X_erase_at(cmap_X* self, cmap_X_iter it); // return iter after it +void cmap_X_erase_entry(cmap_X* self, cmap_X_value* entry); -cmap_X_iter_t cmap_X_begin(const cmap_X* self); -cmap_X_iter_t cmap_X_end(const cmap_X* self); -void cmap_X_next(cmap_X_iter_t* it); +cmap_X_iter cmap_X_begin(const cmap_X* self); +cmap_X_iter cmap_X_end(const cmap_X* self); +void cmap_X_next(cmap_X_iter* it); -cmap_X_value_t cmap_X_value_clone(cmap_X_value_t val); -cmap_X_rawvalue_t cmap_X_value_toraw(cmap_X_value_t* pval); +cmap_X_value cmap_X_value_clone(cmap_X_value val); +cmap_X_rawvalue cmap_X_value_toraw(cmap_X_value* pval); ``` Helpers: ```c @@ -99,17 +99,17 @@ void c_default_del(Type* val); // d ## Types -| Type name | Type definition | Used to represent... | -|:---------------------|:------------------------------------------------|:------------------------------| -| `cmap_X` | `struct { ... }` | The cmap type | -| `cmap_X_rawkey_t` | `i_keyraw` | The raw key type | -| `cmap_X_rawmapped_t` | `i_valraw` | The raw mapped type | -| `cmap_X_rawvalue_t` | `struct { i_keyraw first; i_valraw second; }` | i_keyraw + i_valraw type | -| `cmap_X_key_t` | `i_key` | The key type | -| `cmap_X_mapped_t` | `i_val` | The mapped type | -| `cmap_X_value_t` | `struct { const i_key first; i_val second; }` | The value: key is immutable | -| `cmap_X_result_t` | `struct { cmap_X_value_t *ref; bool inserted; }`| Result of insert/put/emplace | -| `cmap_X_iter_t` | `struct { cmap_X_value_t *ref; ... }` | Iterator type | +| Type name | Type definition | Used to represent... | +|:-------------------|:------------------------------------------------|:------------------------------| +| `cmap_X` | `struct { ... }` | The cmap type | +| `cmap_X_rawkey` | `i_keyraw` | The raw key type | +| `cmap_X_rawmapped` | `i_valraw` | The raw mapped type | +| `cmap_X_rawvalue` | `struct { i_keyraw first; i_valraw second; }` | i_keyraw + i_valraw type | +| `cmap_X_key` | `i_key` | The key type | +| `cmap_X_mapped` | `i_val` | The mapped type | +| `cmap_X_value` | `struct { const i_key first; i_val second; }` | The value: key is immutable | +| `cmap_X_result` | `struct { cmap_X_value *ref; bool inserted; }` | Result of insert/put/emplace | +| `cmap_X_iter` | `struct { cmap_X_value *ref; ... }` | Iterator type | ## Examples diff --git a/docs/cpque_api.md b/docs/cpque_api.md index 4f22fe0e..365ba4b9 100644 --- a/docs/cpque_api.md +++ b/docs/cpque_api.md @@ -32,26 +32,26 @@ void cpque_X_del(cpque_X* self); // destructor size_t cpque_X_size(cpque_X pq); bool cpque_X_empty(cpque_X pq); -cpque_X_value_t* cpque_X_top(const cpque_X* self); +cpque_X_value* cpque_X_top(const cpque_X* self); void cpque_X_make_heap(cpque_X* self); // call after using push_back(). -void cpque_X_push(cpque_X* self, cpque_X_value_t value); -void cpque_X_emplace(cpque_X* self, cpque_X_rawvalue_t raw); +void cpque_X_push(cpque_X* self, cpque_X_value value); +void cpque_X_emplace(cpque_X* self, cpque_X_rawvalue raw); void cpque_X_pop(cpque_X* self); void cpque_X_erase_at(cpque_X* self, size_t idx); -void cpque_X_push_back(cpque_X* self, cpque_X_value_t value); // breaks heap-property -cpque_X_value_t cpque_X_value_clone(cpque_X_value_t val); +void cpque_X_push_back(cpque_X* self, cpque_X_value value); // breaks heap-property +cpque_X_value cpque_X_value_clone(cpque_X_value val); ``` ## Types -| Type name | Type definition | Used to represent... | -|:---------------------|:--------------------------------------|:------------------------| -| `cpque_X` | `struct {cpque_X_value_t* data; ...}` | The cpque type | -| `cpque_X_value_t` | `i_val` | The cpque element type | -| `cpque_X_rawvalue_t` | `i_valraw` | cpque raw value type | +| Type name | Type definition | Used to represent... | +|:-------------------|:--------------------------------------|:------------------------| +| `cpque_X` | `struct {cpque_X_value* data; ...}` | The cpque type | +| `cpque_X_value` | `i_val` | The cpque element type | +| `cpque_X_rawvalue` | `i_valraw` | cpque raw value type | ## Example ```c diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md index 087f9da5..469b7c99 100644 --- a/docs/cqueue_api.md +++ b/docs/cqueue_api.md @@ -31,29 +31,29 @@ void cqueue_X_del(cqueue_X* self); // destructor size_t cqueue_X_size(cqueue_X q); bool cqueue_X_empty(cqueue_X q); -cqueue_X_value_t* cqueue_X_front(const cqueue_X* self); -cqueue_X_value_t* cqueue_X_back(const cqueue_X* self); +cqueue_X_value* cqueue_X_front(const cqueue_X* self); +cqueue_X_value* cqueue_X_back(const cqueue_X* self); -cqueue_X_value_t* cqueue_X_push(cqueue_X* self, i_val value); -cqueue_X_value_t* cqueue_X_emplace(cqueue_X* self, i_valraw raw); +cqueue_X_value* cqueue_X_push(cqueue_X* self, i_val value); +cqueue_X_value* cqueue_X_emplace(cqueue_X* self, i_valraw raw); void cqueue_X_pop(cqueue_X* self); -cqueue_X_iter_t cqueue_X_begin(const cqueue_X* self); -cqueue_X_iter_t cqueue_X_end(const cqueue_X* self); -void cqueue_X_next(cqueue_X_iter_t* it); +cqueue_X_iter cqueue_X_begin(const cqueue_X* self); +cqueue_X_iter cqueue_X_end(const cqueue_X* self); +void cqueue_X_next(cqueue_X_iter* it); i_val cqueue_X_value_clone(i_val value); ``` ## Types -| Type name | Type definition | Used to represent... | -|:----------------------|:---------------------|:-------------------------| -| `cqueue_X` | `cdeq_X` | The cqueue type | -| `cqueue_X_value_t` | `i_val` | The cqueue element type | -| `cqueue_X_rawvalue_t` | `i_valraw` | cqueue raw value type | -| `cqueue_X_iter_t` | `cdeq_X_iter_t` | cqueue iterator | +| Type name | Type definition | Used to represent... | +|:--------------------|:---------------------|:-------------------------| +| `cqueue_X` | `cdeq_X` | The cqueue type | +| `cqueue_X_value` | `i_val` | The cqueue element type | +| `cqueue_X_rawvalue` | `i_valraw` | cqueue raw value type | +| `cqueue_X_iter` | `cdeq_X_iter` | cqueue iterator | ## Examples ```c diff --git a/docs/cset_api.md b/docs/cset_api.md index e09436ea..c422fdb2 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -41,34 +41,34 @@ size_t cset_X_capacity(cset_X set); size_t cset_X_bucket_count(cset_X set);
bool cset_X_contains(const cset_X* self, i_keyraw rkey);
-cset_X_value_t* cset_X_get(const cset_X* self, i_keyraw rkey); // return NULL if not found
-cset_X_iter_t cset_X_find(const cset_X* self, i_keyraw rkey);
+cset_X_value* cset_X_get(const cset_X* self, i_keyraw rkey); // return NULL if not found
+cset_X_iter cset_X_find(const cset_X* self, i_keyraw rkey);
-cset_X_result_t cset_X_insert(cset_X* self, i_key key);
-cset_X_result_t cset_X_emplace(cset_X* self, i_keyraw rkey);
+cset_X_result cset_X_insert(cset_X* self, i_key key);
+cset_X_result cset_X_emplace(cset_X* self, i_keyraw rkey);
size_t cset_X_erase(cset_X* self, i_keyraw rkey); // return 0 or 1
-cset_X_iter_t cset_X_erase_at(cset_X* self, cset_X_iter_t it); // return iter after it
-void cset_X_erase_entry(cset_X* self, cset_X_value_t* entry);
+cset_X_iter cset_X_erase_at(cset_X* self, cset_X_iter it); // return iter after it
+void cset_X_erase_entry(cset_X* self, cset_X_value* entry);
-cset_X_iter_t cset_X_begin(const cset_X* self);
-cset_X_iter_t cset_X_end(const cset_X* self);
-void cset_X_next(cset_X_iter_t* it);
+cset_X_iter cset_X_begin(const cset_X* self);
+cset_X_iter cset_X_end(const cset_X* self);
+void cset_X_next(cset_X_iter* it);
-cset_X_value_t cset_X_value_clone(cset_X_value_t val);
+cset_X_value cset_X_value_clone(cset_X_value val);
```
## Types
-| Type name | Type definition | Used to represent... |
-|:---------------------|:-------------------------------------------------|:----------------------------|
-| `cset_X` | `struct { ... }` | The cset type |
-| `cset_X_rawkey_t` | `i_keyraw` | The raw key type |
-| `cset_X_rawvalue_t` | `i_keyraw` | The raw value type |
-| `cset_X_key_t` | `i_key` | The key type |
-| `cset_X_value_t` | `i_key` | The value |
-| `cset_X_result_t` | `struct { cset_X_value_t* ref; bool inserted; }` | Result of insert/emplace |
-| `cset_X_iter_t` | `struct { cset_X_value_t *ref; ... }` | Iterator type |
+| Type name | Type definition | Used to represent... |
+|:-------------------|:-------------------------------------------------|:----------------------------|
+| `cset_X` | `struct { ... }` | The cset type |
+| `cset_X_rawkey` | `i_keyraw` | The raw key type |
+| `cset_X_rawvalue` | `i_keyraw` | The raw value type |
+| `cset_X_key` | `i_key` | The key type |
+| `cset_X_value` | `i_key` | The value |
+| `cset_X_result` | `struct { cset_X_value* ref; bool inserted; }` | Result of insert/emplace |
+| `cset_X_iter` | `struct { cset_X_value *ref; ... }` | Iterator type |
## Example
```c
diff --git a/docs/csmap_api.md b/docs/csmap_api.md index d76502b2..96d71d30 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -46,44 +46,44 @@ bool csmap_X_empty(csmap_X map); size_t csmap_X_size(csmap_X map); bool csmap_X_contains(const csmap_X* self, i_keyraw rkey); -csmap_X_mapped_t* csmap_X_at(const csmap_X* self, i_keyraw rkey); // rkey must be in map. -csmap_X_value_t* csmap_X_get(const csmap_X* self, i_keyraw rkey); // return NULL if not found -csmap_X_iter_t csmap_X_lower_bound(const csmap_X* self, i_keyraw rkey); // find closest entry >= rkey -csmap_X_iter_t csmap_X_find(const csmap_X* self, i_keyraw rkey); -csmap_X_value_t* csmap_X_find_it(const csmap_X* self, i_keyraw rkey, csmap_X_iter_t* out); // return NULL if not found +csmap_X_mapped* csmap_X_at(const csmap_X* self, i_keyraw rkey); // rkey must be in map. +csmap_X_value* csmap_X_get(const csmap_X* self, i_keyraw rkey); // return NULL if not found +csmap_X_iter csmap_X_lower_bound(const csmap_X* self, i_keyraw rkey); // find closest entry >= rkey +csmap_X_iter csmap_X_find(const csmap_X* self, i_keyraw rkey); +csmap_X_value* csmap_X_find_it(const csmap_X* self, i_keyraw rkey, csmap_X_iter* out); // return NULL if not found -csmap_X_result_t csmap_X_insert(csmap_X* self, i_key key, i_val mapped); // no change if key in map -csmap_X_result_t csmap_X_insert_or_assign(csmap_X* self, i_key key, i_val mapped); // always update mapped -csmap_X_result_t csmap_X_put(csmap_X* self, i_key key, i_val mapped); // same as insert_or_assign() +csmap_X_result csmap_X_insert(csmap_X* self, i_key key, i_val mapped); // no change if key in map +csmap_X_result csmap_X_insert_or_assign(csmap_X* self, i_key key, i_val mapped); // always update mapped +csmap_X_result csmap_X_put(csmap_X* self, i_key key, i_val mapped); // same as insert_or_assign() -csmap_X_result_t csmap_X_emplace(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map -csmap_X_result_t csmap_X_emplace_or_assign(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped +csmap_X_result csmap_X_emplace(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // no change if rkey in map +csmap_X_result csmap_X_emplace_or_assign(csmap_X* self, i_keyraw rkey, i_valraw rmapped); // always update rmapped size_t csmap_X_erase(csmap_X* self, i_keyraw rkey); -csmap_X_iter_t csmap_X_erase_at(csmap_X* self, csmap_X_iter_t it); // returns iter after it -csmap_X_iter_t csmap_X_erase_range(csmap_X* self, csmap_X_iter_t it1, csmap_X_iter_t it2); // returns updated it2 +csmap_X_iter csmap_X_erase_at(csmap_X* self, csmap_X_iter it); // returns iter after it +csmap_X_iter csmap_X_erase_range(csmap_X* self, csmap_X_iter it1, csmap_X_iter it2); // returns updated it2 -csmap_X_iter_t csmap_X_begin(const csmap_X* self); -csmap_X_iter_t csmap_X_end(const csmap_X* self); -void csmap_X_next(csmap_X_iter_t* iter); -csmap_X_iter_t csmap_X_advance(csmap_X_iter_t it, size_t n); +csmap_X_iter csmap_X_begin(const csmap_X* self); +csmap_X_iter csmap_X_end(const csmap_X* self); +void csmap_X_next(csmap_X_iter* iter); +csmap_X_iter csmap_X_advance(csmap_X_iter it, size_t n); -csmap_X_value_t csmap_X_value_clone(csmap_X_value_t val); -csmap_X_rawvalue_t csmap_X_value_toraw(csmap_X_value_t* pval); +csmap_X_value csmap_X_value_clone(csmap_X_value val); +csmap_X_rawvalue csmap_X_value_toraw(csmap_X_value* pval); ``` ## Types -| Type name | Type definition | Used to represent... | -|:----------------------|:--------------------------------------------------|:-----------------------------| -| `csmap_X` | `struct { ... }` | The csmap type | -| `csmap_X_rawkey_t` | `i_keyraw` | The raw key type | -| `csmap_X_rawmapped_t` | `i_valraw` | The raw mapped type | -| `csmap_X_rawvalue_t` | `struct { i_keyraw first; i_valraw second; }` | i_keyraw+i_valraw type | -| `csmap_X_key_t` | `i_key` | The key type | -| `csmap_X_mapped_t` | `i_val` | The mapped type | -| `csmap_X_value_t` | `struct { const i_key first; i_val second; }` | The value: key is immutable | -| `csmap_X_result_t` | `struct { csmap_X_value_t *ref; bool inserted; }` | Result of insert/put/emplace | -| `csmap_X_iter_t` | `struct { csmap_X_value_t *ref; ... }` | Iterator type | +| Type name | Type definition | Used to represent... | +|:--------------------|:--------------------------------------------------|:-----------------------------| +| `csmap_X` | `struct { ... }` | The csmap type | +| `csmap_X_rawkey` | `i_keyraw` | The raw key type | +| `csmap_X_rawmapped` | `i_valraw` | The raw mapped type | +| `csmap_X_rawvalue` | `struct { i_keyraw first; i_valraw second; }` | i_keyraw+i_valraw type | +| `csmap_X_key` | `i_key` | The key type | +| `csmap_X_mapped` | `i_val` | The mapped type | +| `csmap_X_value` | `struct { const i_key first; i_val second; }` | The value: key is immutable | +| `csmap_X_result` | `struct { csmap_X_value *ref; bool inserted; }` | Result of insert/put/emplace | +| `csmap_X_iter` | `struct { csmap_X_value *ref; ... }` | Iterator type | ## Examples ```c diff --git a/docs/csptr_api.md b/docs/csptr_api.md index bd9bf7d2..60825152 100644 --- a/docs/csptr_api.md +++ b/docs/csptr_api.md @@ -60,8 +60,8 @@ bool csptr_X_equals(const csptr_X* x, const csptr_X* y); | Type name | Type definition | Used to represent... | |:--------------------|:--------------------------------------------------------------|:-------------------------| | `csptr_null` | `{NULL, NULL}` | Init nullptr const | -| `csptr_X` | `struct { csptr_X_value_t* get; atomic_count_t* use_count; }` | The csptr type | -| `csptr_X_value_t` | `i_val` | The csptr element type | +| `csptr_X` | `struct { csptr_X_value* get; atomic_count_t* use_count; }` | The csptr type | +| `csptr_X_value` | `i_val` | The csptr element type | | `atomic_count_t` | `long` | The reference counter | ## Example diff --git a/docs/csset_api.md b/docs/csset_api.md index 67ff1911..22573b25 100644 --- a/docs/csset_api.md +++ b/docs/csset_api.md @@ -34,36 +34,36 @@ bool csset_X_empty(csset_X set); size_t csset_X_size(csset_X set);
bool csset_X_contains(const csset_X* self, i_keyraw rkey);
-csset_X_value_t* csset_X_get(const csset_X* self, i_keyraw rkey); // return NULL if not found
-csset_X_iter_t csset_X_lower_bound(const csset_X* self, i_keyraw rkey); // find closest entry >= rkey
-csset_X_iter_t csset_X_find(const csset_X* self, i_keyraw rkey);
-csset_X_value_t* csset_X_find_it(const csset_X* self, i_keyraw rkey, csset_X_iter_t* out); // return NULL if not found
+csset_X_value* csset_X_get(const csset_X* self, i_keyraw rkey); // return NULL if not found
+csset_X_iter csset_X_lower_bound(const csset_X* self, i_keyraw rkey); // find closest entry >= rkey
+csset_X_iter csset_X_find(const csset_X* self, i_keyraw rkey);
+csset_X_value* csset_X_find_it(const csset_X* self, i_keyraw rkey, csset_X_iter* out); // return NULL if not found
-csset_X_result_t csset_X_insert(csset_X* self, i_key key);
-csset_X_result_t csset_X_emplace(csset_X* self, i_keyraw rkey);
+csset_X_result csset_X_insert(csset_X* self, i_key key);
+csset_X_result csset_X_emplace(csset_X* self, i_keyraw rkey);
size_t csset_X_erase(csset_X* self, i_keyraw rkey);
-csset_X_iter_t csset_X_erase_at(csset_X* self, csset_X_iter_t it); // return iter after it
-csset_X_iter_t csset_X_erase_range(csset_X* self, csset_X_iter_t it1, csset_X_iter_t it2); // return updated it2
+csset_X_iter csset_X_erase_at(csset_X* self, csset_X_iter it); // return iter after it
+csset_X_iter csset_X_erase_range(csset_X* self, csset_X_iter it1, csset_X_iter it2); // return updated it2
-csset_X_iter_t csset_X_begin(const csset_X* self);
-csset_X_iter_t csset_X_end(const csset_X* self);
-void csset_X_next(csset_X_iter_t* it);
+csset_X_iter csset_X_begin(const csset_X* self);
+csset_X_iter csset_X_end(const csset_X* self);
+void csset_X_next(csset_X_iter* it);
-csset_X_value_t csset_X_value_clone(csset_X_value_t val);
+csset_X_value csset_X_value_clone(csset_X_value val);
```
## Types
-| Type name | Type definition | Used to represent... |
-|:---------------------|:--------------------------------------------------|:----------------------------|
-| `csset_X` | `struct { ... }` | The csset type |
-| `csset_X_rawkey_t` | `i_rawkey` | The raw key type |
-| `csset_X_rawvalue_t` | `i_rawkey` | The raw key type |
-| `csset_X_key_t` | `i_key` | The key type |
-| `csset_X_value_t` | `i_key ` | The value: key is immutable |
-| `csset_X_result_t` | `struct { csset_X_value_t* ref; bool inserted; }` | Result of insert/emplace |
-| `csset_X_iter_t` | `struct { csset_X_value_t *ref; ... }` | Iterator type |
+| Type name | Type definition | Used to represent... |
+|:-------------------|:--------------------------------------------------|:----------------------------|
+| `csset_X` | `struct { ... }` | The csset type |
+| `csset_X_rawkey` | `i_rawkey` | The raw key type |
+| `csset_X_rawvalue` | `i_rawkey` | The raw key type |
+| `csset_X_key` | `i_key` | The key type |
+| `csset_X_value` | `i_key ` | The value: key is immutable |
+| `csset_X_result` | `struct { csset_X_value* ref; bool inserted; }` | Result of insert/emplace |
+| `csset_X_iter` | `struct { csset_X_value *ref; ... }` | Iterator type |
## Example
```c
diff --git a/docs/cstack_api.md b/docs/cstack_api.md index c4a806e1..a1edf9ea 100644 --- a/docs/cstack_api.md +++ b/docs/cstack_api.md @@ -36,30 +36,30 @@ void cstack_X_del(cstack_X* self); // destructor size_t cstack_X_size(cstack_X st); size_t cstack_X_capacity(cstack_X st); bool cstack_X_empty(cstack_X st); -cstack_X_value_t* cstack_X_top(const cstack_X* self); -cstack_X_value_t* cstack_X_at(const cstack_X* self, size_t idx); +cstack_X_value* cstack_X_top(const cstack_X* self); +cstack_X_value* cstack_X_at(const cstack_X* self, size_t idx); -cstack_X_value_t* cstack_X_push(cstack_X* self, i_val value); -cstack_X_value_t* cstack_X_emplace(cstack_X* self, i_valraw raw); +cstack_X_value* cstack_X_push(cstack_X* self, i_val value); +cstack_X_value* cstack_X_emplace(cstack_X* self, i_valraw raw); void cstack_X_pop(cstack_X* self); -cstack_X_iter_t cstack_X_begin(const cstack_X* self); -cstack_X_iter_t cstack_X_end(const cstack_X* self); -void cstack_X_next(cstack_X_iter_t* it); +cstack_X_iter cstack_X_begin(const cstack_X* self); +cstack_X_iter cstack_X_end(const cstack_X* self); +void cstack_X_next(cstack_X_iter* it); -i_valraw cstack_X_value_toraw(cvec_X_value_t* pval); +i_valraw cstack_X_value_toraw(cvec_X_value* pval); i_val cstack_X_value_clone(i_val value); ``` ## Types -| Type name | Type definition | Used to represent... | -|:----------------------|:---------------------------------------|:----------------------------| -| `cstack_X` | `struct { cstack_value_t *data; ... }` | The cstack type | -| `cstack_X_value_t` | `i_val` | The cstack element type | -| `cstack_X_rawvalue_t` | `i_valraw` | cstack raw value type | -| `cstack_X_iter_t` | `struct { cstack_value_t *ref; }` | cstack iterator | +| Type name | Type definition | Used to represent... | +|:--------------------|:---------------------------------------|:----------------------------| +| `cstack_X` | `struct { cstack_value *data; ... }` | The cstack type | +| `cstack_X_value` | `i_val` | The cstack element type | +| `cstack_X_rawvalue` | `i_valraw` | cstack raw value type | +| `cstack_X_iter` | `struct { cstack_value *ref; }` | cstack iterator | ## Example ```c diff --git a/docs/cstr_api.md b/docs/cstr_api.md index ecb58637..4b1c959f 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -73,9 +73,9 @@ void cstr_pop_back(cstr* self); char* cstr_front(cstr* self); char* cstr_back(cstr* self); -cstr_iter_t cstr_begin(cstr* self); -cstr_iter_t cstr_end(cstr* self); -void cstr_next(cstr_iter_t* it); +cstr_iter cstr_begin(cstr* self); +cstr_iter cstr_end(cstr* self); +void cstr_next(cstr_iter* it); bool cstr_getline(cstr *self, FILE *stream); // cstr_getdelim(self, '\n', stream) bool cstr_getdelim(cstr *self, int delim, FILE *stream); // does not append delim to result @@ -100,11 +100,11 @@ int c_strncasecmp(const char* str1, const char* str2, size_t n); ## Types -| Type name | Type definition | Used to represent... | -|:------------------|:---------------------------------|:-------------------------| -| `cstr` | `struct { char *str; }` | The string type | -| `cstr_value_t` | `char` | The string element type | -| `cstr_iter_t` | `struct { cstr_value_t *ref; }` | cstr iterator | +| Type name | Type definition | Used to represent... | +|:----------------|:-------------------------------|:-------------------------| +| `cstr` | `struct { char *str; }` | The string type | +| `cstr_value` | `char` | The string element type | +| `cstr_iter` | `struct { cstr_value *ref; }` | cstr iterator | ## Constants and macros diff --git a/docs/csview_api.md b/docs/csview_api.md index 6125ef07..4295e4e9 100644 --- a/docs/csview_api.md +++ b/docs/csview_api.md @@ -51,9 +51,9 @@ bool csview_contains(csview sv, csview needle); bool csview_starts_with(csview sv, csview sub); bool csview_ends_with(csview sv, csview sub); -csview_iter_t csview_begin(const csview* self); -csview_iter_t csview_end(const csview* self); -void csview_next(csview_iter_t* it); +csview_iter csview_begin(const csview* self); +csview_iter csview_end(const csview* self); +void csview_next(csview_iter* it); ``` #### Extended cstr methods ```c @@ -84,11 +84,11 @@ uint64_t csview_hash(const csview* x, ...); ``` ## Types -| Type name | Type definition | Used to represent... | -|:------------------|:------------------------------------------|:-------------------------| -| `csview` | `struct { const char *str; size_t size }` | The string view type | -| `csview_value_t` | `char` | The string element type | -| `csview_iter_t` | `struct { csview_value_t *ref; }` | csview iterator | +| Type name | Type definition | Used to represent... | +|:----------------|:------------------------------------------|:-------------------------| +| `csview` | `struct { const char *str; size_t size }` | The string view type | +| `csview_value` | `char` | The string element type | +| `csview_iter` | `struct { csview_value *ref; }` | csview iterator | ## Constants and macros diff --git a/docs/cvec_api.md b/docs/cvec_api.md index a14f6952..9953bb4b 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -45,61 +45,60 @@ bool cvec_X_empty(cvec_X vec); size_t cvec_X_size(cvec_X vec); size_t cvec_X_capacity(cvec_X vec); -cvec_X_value_t* cvec_X_at(const cvec_X* self, size_t idx); -cvec_X_value_t* cvec_X_front(const cvec_X* self); -cvec_X_value_t* cvec_X_back(const cvec_X* self); +cvec_X_value* cvec_X_at(const cvec_X* self, size_t idx); +cvec_X_value* cvec_X_front(const cvec_X* self); +cvec_X_value* cvec_X_back(const cvec_X* self); -cvec_X_value_t* cvec_X_push_back(cvec_X* self, i_val value); -cvec_X_value_t* cvec_X_emplace_back(cvec_X* self, i_valraw raw); +cvec_X_value* cvec_X_push_back(cvec_X* self, i_val value); +cvec_X_value* cvec_X_emplace_back(cvec_X* self, i_valraw raw); void cvec_X_pop_back(cvec_X* self); -cvec_X_iter_t cvec_X_insert(cvec_X* self, size_t idx, i_val value); // move value -cvec_X_iter_t cvec_X_insert_n(cvec_X* self, size_t idx, const i_val[] arr, size_t n); // move arr values -cvec_X_iter_t cvec_X_insert_at(cvec_X* self, cvec_X_iter_t it, i_val value); // move value +cvec_X_iter cvec_X_insert(cvec_X* self, size_t idx, i_val value); // move value +cvec_X_iter cvec_X_insert_n(cvec_X* self, size_t idx, const i_val[] arr, size_t n); // move arr values +cvec_X_iter cvec_X_insert_at(cvec_X* self, cvec_X_iter it, i_val value); // move value -cvec_X_iter_t cvec_X_emplace(cvec_X* self, size_t idx, i_valraw raw); -cvec_X_iter_t cvec_X_emplace_n(cvec_X* self, size_t idx, const i_valraw[] arr, size_t n); -cvec_X_iter_t cvec_X_emplace_at(cvec_X* self, cvec_X_iter_t it, i_valraw raw); -cvec_X_iter_t cvec_X_emplace_range(cvec_X* self, cvec_X_iter_t it, - cvec_X_iter_t it1, cvec_X_iter_t it2); // will clone -cvec_X_iter_t cvec_X_emplace_range_p(cvec_X* self, i_val* pos, +cvec_X_iter cvec_X_emplace(cvec_X* self, size_t idx, i_valraw raw); +cvec_X_iter cvec_X_emplace_n(cvec_X* self, size_t idx, const i_valraw[] arr, size_t n); +cvec_X_iter cvec_X_emplace_at(cvec_X* self, cvec_X_iter it, i_valraw raw); +cvec_X_iter cvec_X_emplace_range(cvec_X* self, cvec_X_iter it, + cvec_X_iter it1, cvec_X_iter it2); // will clone +cvec_X_iter cvec_X_emplace_range_p(cvec_X* self, i_val* pos, const i_val* p1, const i_val* p2); -cvec_X_iter_t cvec_X_erase_n(cvec_X* self, size_t idx, size_t n); -cvec_X_iter_t cvec_X_erase_at(cvec_X* self, cvec_X_iter_t it); -cvec_X_iter_t cvec_X_erase_range(cvec_X* self, cvec_X_iter_t it1, cvec_X_iter_t it2); +cvec_X_iter cvec_X_erase_n(cvec_X* self, size_t idx, size_t n); +cvec_X_iter cvec_X_erase_at(cvec_X* self, cvec_X_iter it); +cvec_X_iter cvec_X_erase_range(cvec_X* self, cvec_X_iter it1, cvec_X_iter it2); -cvec_X_iter_t cvec_X_find(const cvec_X* self, i_valraw raw); -cvec_X_iter_t cvec_X_find_in(cvec_X_iter_t i1, cvec_X_iter_t i2, i_valraw raw); -cvec_X_value_t* cvec_X_get(const cvec_X* self, i_valraw raw); // return NULL if not found -cvec_X_iter_t cvec_X_bsearch(const cvec_X* self, i_valraw raw); -cvec_X_iter_t cvec_X_bsearch_in(cvec_X_iter_t i1, cvec_X_iter_t i2, i_valraw raw); +cvec_X_iter cvec_X_find(const cvec_X* self, i_valraw raw); +cvec_X_iter cvec_X_find_in(cvec_X_iter i1, cvec_X_iter i2, i_valraw raw); +cvec_X_value* cvec_X_get(const cvec_X* self, i_valraw raw); // return NULL if not found +cvec_X_iter cvec_X_bsearch(const cvec_X* self, i_valraw raw); +cvec_X_iter cvec_X_bsearch_in(cvec_X_iter i1, cvec_X_iter i2, i_valraw raw); void cvec_X_sort(cvec_X* self); -void cvec_X_sort_range(cvec_X_iter_t i1, cvec_X_iter_t i2, +void cvec_X_sort_range(cvec_X_iter i1, cvec_X_iter i2, int(*cmp)(const i_val*, const i_val*)); -cvec_X_iter_t cvec_X_begin(const cvec_X* self); -cvec_X_iter_t cvec_X_end(const cvec_X* self); -void cvec_X_next(cvec_X_iter_t* iter); +cvec_X_iter cvec_X_begin(const cvec_X* self); +cvec_X_iter cvec_X_end(const cvec_X* self); +void cvec_X_next(cvec_X_iter* iter); -cvec_X_rawvalue_t cvec_X_value_toraw(cvec_X_value_t* pval); -cvec_X_value_t cvec_X_value_clone(cvec_X_value_t val); +cvec_X_rawvalue cvec_X_value_toraw(cvec_X_value* pval); +cvec_X_value cvec_X_value_clone(cvec_X_value val); ``` ## Types -| Type name | Type definition | Used to represent... | -|:---------------------|:------------------------------------|:-----------------------| -| `cvec_X` | `struct { cvec_X_value_t* data; }` | The cvec type | -| `cvec_X_value_t` | `i_val` | The cvec value type | -| `cvec_X_rawvalue_t` | `i_valraw` | The raw value type | -| `cvec_X_iter_t` | `struct { cvec_X_value_t* ref; }` | The iterator type | +| Type name | Type definition | Used to represent... | +|:-------------------|:----------------------------------|:-----------------------| +| `cvec_X` | `struct { cvec_X_value* data; }` | The cvec type | +| `cvec_X_value` | `i_val` | The cvec value type | +| `cvec_X_rawvalue` | `i_valraw` | The raw value type | +| `cvec_X_iter` | `struct { cvec_X_value* ref; }` | The iterator type | ## Examples ```c #define i_val int -#define i_tag i #include <stc/cvec.h> #include <stdio.h> @@ -107,29 +106,28 @@ cvec_X_value_t cvec_X_value_clone(cvec_X_value_t val); int main() { // Create a vector containing integers - cvec_i vec = cvec_i_init(); - - // Add two integers to vector - cvec_i_push_back(&vec, 25); - cvec_i_push_back(&vec, 13); - - // Append a set of numbers - c_apply(cvec_i, push_back, &vec, {7, 5, 16, 8}); - - printf("initial:"); - c_foreach (k, cvec_i, vec) { - printf(" %d", *k.ref); + c_auto (cvec_int, vec) + { + // Add two integers to vector + cvec_int_push_back(&vec, 25); + cvec_int_push_back(&vec, 13); + + // Append a set of numbers + c_apply(cvec_int, push_back, &vec, {7, 5, 16, 8}); + + printf("initial:"); + c_foreach (k, cvec_int, vec) { + printf(" %d", *k.ref); + } + + // Sort the vector + cvec_int_sort(&vec); + + printf("\nsorted:"); + c_foreach (k, cvec_int, vec) { + printf(" %d", *k.ref); + } } - - // Sort the vector - cvec_i_sort(&vec); - - printf("\nsorted:"); - c_foreach (k, cvec_i, vec) { - printf(" %d", *k.ref); - } - - cvec_i_del(&vec); } ``` Output: diff --git a/examples/advanced.c b/examples/advanced.c index 0466e0da..1c5da926 100644 --- a/examples/advanced.c +++ b/examples/advanced.c @@ -57,7 +57,7 @@ int main() cmap_vk_emplace_or_assign(&vikings, bjorn, 10); VikingRaw einar = {"Einar", "Norway"}; - cmap_vk_value_t *e = cmap_vk_find(&vikings, einar).ref; + cmap_vk_value *e = cmap_vk_find(&vikings, einar).ref; e->second += 3; // add 3 hp points to Einar cmap_vk_emplace(&vikings, einar, 0).ref->second += 5; // add 5 more to Einar diff --git a/examples/astar.c b/examples/astar.c index 651886e9..04c18113 100644 --- a/examples/astar.c +++ b/examples/astar.c @@ -107,7 +107,7 @@ astar(cstr* maze, int width) int new_cost = *csmap_pcost_at(&costs, current);
if (maze->str[point_index(&next)] != '#')
{
- csmap_pcost_value_t *cost = csmap_pcost_get(&costs, next);
+ csmap_pcost_value *cost = csmap_pcost_get(&costs, next);
if (cost == NULL || new_cost < cost->second)
{
csmap_pcost_insert(&costs, next, new_cost);
diff --git a/examples/csmap_erase.c b/examples/csmap_erase.c index 993f1837..bbb69a35 100644 --- a/examples/csmap_erase.c +++ b/examples/csmap_erase.c @@ -47,8 +47,8 @@ int main() puts("Starting data of map m2 is:"); printmap(m2); - mymap_iter_t it1 = mymap_advance(mymap_begin(&m2), 1); - mymap_iter_t it2 = mymap_find(&m2, mymap_back(&m2)->first); + mymap_iter it1 = mymap_advance(mymap_begin(&m2), 1); + mymap_iter it2 = mymap_find(&m2, mymap_back(&m2)->first); // The 2nd member function removes elements // in the range [First, Last) mymap_erase_range(&m2, it1, it2); diff --git a/examples/csmap_find.c b/examples/csmap_find.c index 39ffd975..977ae6ca 100644 --- a/examples/csmap_find.c +++ b/examples/csmap_find.c @@ -7,12 +7,12 @@ #define i_tag istr #include <stc/csmap.h> -#define i_val csmap_istr_rawvalue_t +#define i_val csmap_istr_rawvalue #define i_cmp c_no_compare #define i_tag istr #include <stc/cvec.h> -void print_elem(csmap_istr_rawvalue_t p) { +void print_elem(csmap_istr_rawvalue p) { printf("(%d, %s) ", p.first, p.second); } @@ -29,11 +29,10 @@ void print_elem(csmap_istr_rawvalue_t p) { using_print_collection(csmap_istr) using_print_collection(cvec_istr) - -void findit(csmap_istr c, csmap_istr_key_t val) +void findit(csmap_istr c, csmap_istr_key val) { printf("Trying find() on value %d\n", val); - csmap_istr_iter_t result = csmap_istr_find(&c, val); // prefer contains() or get() + csmap_istr_iter result = csmap_istr_find(&c, val); // prefer contains() or get() if (result.ref != csmap_istr_end(&c).ref) { printf("Element found: "); print_elem(csmap_istr_value_toraw(result.ref)); puts(""); } else { @@ -50,7 +49,7 @@ int main() puts("The starting map m1 is (key, value):"); print_collection_csmap_istr(m1); - typedef cvec_istr_value_t pair; + typedef cvec_istr_value pair; cvec_istr_emplace_back(&v, (pair){43, "Tc"}); cvec_istr_emplace_back(&v, (pair){41, "Nb"}); cvec_istr_emplace_back(&v, (pair){46, "Pd"}); diff --git a/examples/csmap_insert.c b/examples/csmap_insert.c index 939f2eca..3e908164 100644 --- a/examples/csmap_insert.c +++ b/examples/csmap_insert.c @@ -14,7 +14,7 @@ #define i_tag istr // Map of int => cstr
#include <stc/csmap.h>
-#define i_val csmap_ii_rawvalue_t
+#define i_val csmap_ii_rawvalue
#define i_cmp c_no_compare
#define i_tag ii
#include <stc/cvec.h>
@@ -42,9 +42,9 @@ int main() print_ii(m1);
// intentionally attempt a duplicate, single element
- csmap_ii_result_t ret = csmap_ii_insert(&m1, 1, 111);
+ csmap_ii_result ret = csmap_ii_insert(&m1, 1, 111);
if (!ret.inserted) {
- csmap_ii_value_t pr = *ret.ref;
+ csmap_ii_value pr = *ret.ref;
puts("Insert failed, element with key value 1 already exists.");
printf(" The existing element is (%d, %d)\n", pr.first, pr.second);
}
@@ -63,7 +63,7 @@ int main() // The templatized version inserting a jumbled range
c_auto (csmap_ii, m2)
c_auto (cvec_ii, v) {
- typedef cvec_ii_value_t ipair;
+ typedef cvec_ii_value ipair;
cvec_ii_push_back(&v, (ipair){43, 294});
cvec_ii_push_back(&v, (ipair){41, 262});
cvec_ii_push_back(&v, (ipair){45, 330});
@@ -83,7 +83,7 @@ int main() // The templatized versions move-constructing elements
c_auto (csmap_istr, m3) {
- csmap_istr_value_t ip1 = {475, cstr_lit("blue")}, ip2 = {510, cstr_lit("green")};
+ csmap_istr_value ip1 = {475, cstr_lit("blue")}, ip2 = {510, cstr_lit("green")};
// single element
csmap_istr_insert(&m3, ip1.first, cstr_move(&ip1.second));
diff --git a/examples/csset_erase.c b/examples/csset_erase.c index 6104a2b2..95145ed8 100644 --- a/examples/csset_erase.c +++ b/examples/csset_erase.c @@ -13,7 +13,7 @@ int main() puts("");
int val = 64;
- csset_int_iter_t it;
+ csset_int_iter it;
printf("Show values >= %d:\n", val);
it = csset_int_lower_bound(&set, val);
diff --git a/examples/demos.c b/examples/demos.c index ab1a95ff..49ac8486 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -59,7 +59,7 @@ void vectordemo1() void vectordemo2()
{
printf("\nVECTORDEMO2\n");
- c_autovar (cvec_str names = cvec_str_init(), cvec_str_del(&names)) {
+ c_auto (cvec_str, names) {
cvec_str_emplace_back(&names, "Mary");
cvec_str_emplace_back(&names, "Joe");
cvec_str_emplace_back(&names, "Chris");
@@ -79,8 +79,7 @@ void vectordemo2() void listdemo1()
{
printf("\nLISTDEMO1\n");
- c_autovar (clist_ix nums = clist_ix_init(), clist_ix_del(&nums))
- c_autovar (clist_ix nums2 = clist_ix_init(), clist_ix_del(&nums2))
+ c_auto (clist_ix, nums, nums2)
{
for (int i = 0; i < 10; ++i)
clist_ix_push_back(&nums, i);
@@ -95,7 +94,7 @@ void listdemo1() *clist_ix_find(&nums, 104).ref += 50;
clist_ix_remove(&nums, 103);
- clist_ix_iter_t it = clist_ix_begin(&nums);
+ clist_ix_iter it = clist_ix_begin(&nums);
clist_ix_erase_range(&nums, clist_ix_advance(it, 5), clist_ix_advance(it, 15));
clist_ix_pop_front(&nums);
clist_ix_push_back(&nums, -99);
@@ -145,14 +144,14 @@ void mapdemo1() void mapdemo2()
{
printf("\nMAPDEMO2\n");
- c_autovar (cmap_si nums = cmap_si_init(), cmap_si_del(&nums))
+ c_auto (cmap_si, nums)
{
cmap_si_emplace_or_assign(&nums, "Hello", 64);
cmap_si_emplace_or_assign(&nums, "Groovy", 121);
cmap_si_emplace_or_assign(&nums, "Groovy", 200); // overwrite previous
// iterate the map:
- for (cmap_si_iter_t i = cmap_si_begin(&nums); i.ref != cmap_si_end(&nums).ref; cmap_si_next(&i))
+ for (cmap_si_iter i = cmap_si_begin(&nums); i.ref != cmap_si_end(&nums).ref; cmap_si_next(&i))
printf("long: %s: %d\n", i.ref->first.str, i.ref->second);
// or rather use the short form:
@@ -172,7 +171,7 @@ void mapdemo3() cmap_str_emplace(&table, "Map", "test");
cmap_str_emplace(&table, "Make", "my");
cmap_str_emplace(&table, "Sunny", "day");
- cmap_str_iter_t it = cmap_str_find(&table, "Make");
+ cmap_str_iter it = cmap_str_find(&table, "Make");
c_foreach (i, cmap_str, table)
printf("entry: %s: %s\n", i.ref->first.str, i.ref->second.str);
printf("size %zu: remove: Make: %s\n", cmap_str_size(table), it.ref->second.str);
diff --git a/examples/ex_gauss2.c b/examples/ex_gauss2.c index a57251bc..b3890ecf 100644 --- a/examples/ex_gauss2.c +++ b/examples/ex_gauss2.c @@ -22,7 +22,6 @@ int main() // Create and init histogram map with defered destruct
c_auto (csmap_int, mhist)
- c_auto (cstr, bar)
{
c_forrange (N) {
int index = (int) round( stc64_normalf(&rng, &dist) );
@@ -30,6 +29,7 @@ int main() }
// Print the gaussian bar chart
+ c_auto (cstr, bar)
c_foreach (i, csmap_int, mhist) {
size_t n = (size_t) (i.ref->second * StdDev * Scale * 2.5 / (float)N);
if (n > 0) {
diff --git a/examples/list.c b/examples/list.c index 30923e8b..d0d377f3 100644 --- a/examples/list.c +++ b/examples/list.c @@ -44,7 +44,7 @@ int main() { clist_fx_insert(&list, clist_fx_begin(&list), 5); // same as push_front()
clist_fx_push_back(&list, 500);
clist_fx_push_front(&list, 1964);
- clist_fx_iter_t it = clist_fx_begin(&list);
+ clist_fx_iter it = clist_fx_begin(&list);
printf("Full: ");
c_foreach (i, clist_fx, list)
printf(" %g", *i.ref);
diff --git a/examples/list_erase.c b/examples/list_erase.c index c1e5ab61..e2db62d5 100644 --- a/examples/list_erase.c +++ b/examples/list_erase.c @@ -11,11 +11,11 @@ int main () {
c_apply(clist_i, push_back, &L, {10, 20, 30, 40, 50});
// 10 20 30 40 50
- clist_i_iter_t it = clist_i_begin(&L); // ^
+ clist_i_iter it = clist_i_begin(&L); // ^
clist_i_next(&it);
it = clist_i_erase_at(&L, it); // 10 30 40 50
// ^
- clist_i_iter_t end = clist_i_end(&L); //
+ clist_i_iter end = clist_i_end(&L); //
clist_i_next(&it);
it = clist_i_erase_range(&L, it, end); // 10 30
// ^
diff --git a/examples/list_splice.c b/examples/list_splice.c index 517cbcce..f1049288 100644 --- a/examples/list_splice.c +++ b/examples/list_splice.c @@ -22,7 +22,7 @@ int main () print_ilist("list1:", list1); print_ilist("list2:", list2); - clist_i_iter_t it = clist_i_advance(clist_i_begin(&list1), 2); + clist_i_iter it = clist_i_advance(clist_i_begin(&list1), 2); it = clist_i_splice(&list1, it, &list2); puts("After splice"); diff --git a/examples/mapmap.c b/examples/mapmap.c index 184a7a7d..047132d1 100644 --- a/examples/mapmap.c +++ b/examples/mapmap.c @@ -19,7 +19,7 @@ void add(csmap_conf* map, const char* section, const char* entry, const char* va bool contains(csmap_conf* map, const char* section, const char* entry)
{
- csmap_conf_value_t *val = csmap_conf_get(map, section);
+ csmap_conf_value *val = csmap_conf_get(map, section);
return val && csmap_sect_get(&val->second, entry);
}
diff --git a/examples/mmap.c b/examples/mmap.c index 8ecaa6f5..e3c876ce 100644 --- a/examples/mmap.c +++ b/examples/mmap.c @@ -56,7 +56,7 @@ int main() print(mmap);
// find and erase a specific entry
- clist_str_iter_t pos;
+ clist_str_iter pos;
c_foreach (e, csmap_mult, mmap)
if ((pos = clist_str_find(&e.ref->second, "bar")).ref != clist_str_end(&e.ref->second).ref) {
clist_str_erase_at(&e.ref->second, pos);
diff --git a/examples/new_deq.c b/examples/new_deq.c index 7d30343f..0b41b167 100644 --- a/examples/new_deq.c +++ b/examples/new_deq.c @@ -36,25 +36,26 @@ int point_compare(const Point* a, const Point* b) { int main()
{
- cdeq_i32 vec = cdeq_i32_init();
- cdeq_i32_push_back(&vec, 123);
- cdeq_i32_del(&vec);
-
- cdeq_float fvec = cdeq_float_init();
- cdeq_float_push_back(&fvec, 123.3);
- cdeq_float_del(&fvec);
-
- cdeq_pnt pvec = cdeq_pnt_init();
- cdeq_pnt_push_back(&pvec, (Point){42, 14});
- cdeq_pnt_push_back(&pvec, (Point){32, 94});
- cdeq_pnt_push_front(&pvec, (Point){62, 81});
- cdeq_pnt_sort(&pvec);
- c_foreach (i, cdeq_pnt, pvec)
- printf(" (%d %d)", i.ref->x, i.ref->y);
- puts("");
- cdeq_pnt_del(&pvec);
-
- cdeq_str svec = cdeq_str_init();
- cdeq_str_emplace_back(&svec, "Hello, friend");
- cdeq_str_del(&svec);
+ c_auto (cdeq_i32, vec)
+ {
+ cdeq_i32_push_back(&vec, 123);
+ }
+ c_auto (cdeq_float, fvec)
+ {
+ cdeq_float_push_back(&fvec, 123.3);
+ }
+ c_auto (cdeq_pnt, pvec)
+ {
+ cdeq_pnt_push_back(&pvec, (Point){42, 14});
+ cdeq_pnt_push_back(&pvec, (Point){32, 94});
+ cdeq_pnt_push_front(&pvec, (Point){62, 81});
+ cdeq_pnt_sort(&pvec);
+ c_foreach (i, cdeq_pnt, pvec)
+ printf(" (%d %d)", i.ref->x, i.ref->y);
+ puts("");
+ }
+ c_auto (cdeq_str, svec)
+ {
+ cdeq_str_emplace_back(&svec, "Hello, friend");
+ }
}
\ No newline at end of file diff --git a/examples/new_pque.c b/examples/new_pque.c index 8335e46e..94a12fbd 100644 --- a/examples/new_pque.c +++ b/examples/new_pque.c @@ -30,36 +30,36 @@ int Point_cmp(const Point* a, const Point* b) { int main()
{
- cstack_int istk = cstack_int_init();
- cstack_int_push(&istk, 123);
- cstack_int_push(&istk, 321);
- // print
- c_foreach (i, cstack_int, istk)
- printf(" %d", *i.ref);
- cstack_int_del(&istk);
- puts("");
-
- cpque_pnt pque = cpque_pnt_init();
- cpque_pnt_push(&pque, (Point){23, 80});
- cpque_pnt_push(&pque, (Point){12, 32});
- cpque_pnt_push(&pque, (Point){54, 74});
- cpque_pnt_push(&pque, (Point){12, 62});
- // print
- while (!cpque_pnt_empty(pque)) {
- cpque_pnt_value_t *v = cpque_pnt_top(&pque);
- printf(" (%d,%d)", v->x, v->y);
- cpque_pnt_pop(&pque);
+ c_auto (cstack_int, istk)
+ {
+ cstack_int_push(&istk, 123);
+ cstack_int_push(&istk, 321);
+ // print
+ c_foreach (i, cstack_int, istk)
+ printf(" %d", *i.ref);
+ puts("");
+ }
+ c_auto (cpque_pnt, pque)
+ {
+ cpque_pnt_push(&pque, (Point){23, 80});
+ cpque_pnt_push(&pque, (Point){12, 32});
+ cpque_pnt_push(&pque, (Point){54, 74});
+ cpque_pnt_push(&pque, (Point){12, 62});
+ // print
+ while (!cpque_pnt_empty(pque)) {
+ cpque_pnt_value *v = cpque_pnt_top(&pque);
+ printf(" (%d,%d)", v->x, v->y);
+ cpque_pnt_pop(&pque);
+ }
+ puts("");
+ }
+ c_auto (cpque_int, ique)
+ {
+ cpque_int_push(&ique, 123);
+ cpque_int_push(&ique, 321);
+ // print
+ for (int i=0; i<cpque_int_size(ique); ++i)
+ printf(" %d", ique.data[i]);
+ puts("");
}
- // free
- cpque_pnt_del(&pque);
- puts("");
-
- cpque_int ique = cpque_int_init();
- cpque_int_push(&ique, 123);
- cpque_int_push(&ique, 321);
- // print
- for (int i=0; i<cpque_int_size(ique); ++i)
- printf(" %d", ique.data[i]);
- cpque_int_del(&ique);
- puts("");
}
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 <string.h>
#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 <ctype.h>
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
|
