summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-04-23 20:18:16 +0200
committerTyge Løvset <[email protected]>2021-04-23 20:18:16 +0200
commitb64b213895957de9eed31797295ccbd412ae8e71 (patch)
treeb8ca0c3c15c613816fbe3dc2f28f2bcdd63e05be
parent7b85cf6e734fe312dd4b762282ff33010fe24bf3 (diff)
downloadSTC-modified-b64b213895957de9eed31797295ccbd412ae8e71.tar.gz
STC-modified-b64b213895957de9eed31797295ccbd412ae8e71.zip
API: Reverted to C_X_erase_at() instead of C_X_erase_it(). Sorry for the mess. Internal reorder of STC_API methods.
-rw-r--r--README.md12
-rw-r--r--benchmarks/others/csmap_v1.h2
-rw-r--r--docs/cdeq_api.md2
-rw-r--r--docs/clist_api.md10
-rw-r--r--docs/cmap_api.md4
-rw-r--r--docs/cset_api.md2
-rw-r--r--docs/csmap_api.md4
-rw-r--r--docs/csset_api.md2
-rw-r--r--docs/cvec_api.md2
-rw-r--r--examples/csset_erase.c2
-rw-r--r--examples/demos.c2
-rw-r--r--examples/list_erase.c2
-rw-r--r--stc/cdeq.h54
-rw-r--r--stc/clist.h91
-rw-r--r--stc/cmap.h20
-rw-r--r--stc/csmap.h34
-rw-r--r--stc/cvec.h33
17 files changed, 140 insertions, 138 deletions
diff --git a/README.md b/README.md
index d6724d38..a4bf12ad 100644
--- a/README.md
+++ b/README.md
@@ -129,11 +129,11 @@ int main(void) {
*i3.ref, *i4.ref,
i5.ref->first, i5.ref->second);
// erase the elements found
- cset_i_erase_it(&set, i1);
- cvec_p_erase_it(&vec, i2);
- cdeq_i_erase_it(&deq, i3);
- clist_i_erase_it(&lst, i4);
- csmap_i_erase_it(&map, i5);
+ cset_i_erase_at(&set, i1);
+ cvec_p_erase_at(&vec, i2);
+ cdeq_i_erase_at(&deq, i3);
+ clist_i_erase_at(&lst, i4);
+ csmap_i_erase_at(&map, i5);
printf("After erasing elements found:");
printf("\n set:"); c_foreach (i, cset_i, set) printf(" %d", *i.ref);
@@ -257,7 +257,7 @@ Erase methods
| Name | Description | Container |
|:--------------------------|:-----------------------------|:--------------------------------------------|
| erase() | key based | csmap, csset, cmap, cset, cstr |
-| erase_it() | iterator based | csmap, csset, cmap, cset, cvec, cdeq, clist |
+| erase_at() | iterator based | csmap, csset, cmap, cset, cvec, cdeq, clist |
| erase_range() | iterator based | csmap, csset, cvec, cdeq, clist |
| erase_n() | index based | cvec, cdeq, cstr |
| remove() | remove all matching values | clist |
diff --git a/benchmarks/others/csmap_v1.h b/benchmarks/others/csmap_v1.h
index 1b1b8244..b81d7554 100644
--- a/benchmarks/others/csmap_v1.h
+++ b/benchmarks/others/csmap_v1.h
@@ -308,7 +308,7 @@ int main(void) {
self->size -= erased; return erased; \
} \
STC_INLINE size_t \
- C##X##_erase_it(C##X* self, C##X##_iter_t pos) { \
+ C##X##_erase_at(C##X* self, C##X##_iter_t pos) { \
return C##X##_erase(self, keyToRaw(KEY_REF_##C(pos.ref))); \
} \
\
diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md
index d4de155b..cea4f571 100644
--- a/docs/cdeq_api.md
+++ b/docs/cdeq_api.md
@@ -66,7 +66,7 @@ cdeq_X_iter_t cdeq_X_insert_at(cdeq_X* self, size_t idx, const Value arr[]
cdeq_X_iter_t cdeq_X_emplace(cdeq_X* self, cdeq_X_iter_t it, RawValue raw);
void cdeq_X_emplace_n(cdeq_X *self, const RawValue arr[], size_t n); // emplace_back only
-cdeq_X_iter_t cdeq_X_erase_it(cdeq_X* self, cdeq_X_iter_t it);
+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_t cdeq_X_erase_n(cdeq_X* self, size_t idx, size_t n);
diff --git a/docs/clist_api.md b/docs/clist_api.md
index 035c5dcf..5c59be8a 100644
--- a/docs/clist_api.md
+++ b/docs/clist_api.md
@@ -15,8 +15,8 @@ However, an iterator to a succesive element can both be dereferenced and advance
iterator is in a valid state. This implies:
- `clist_X_insert(&L, clist_X_fwd(it,1), x)` is identical to *std::forward_list* `L.insert_after(it, x)`.
-- `clist_X_erase_it(&L, clist_X_fwd(it,1))` is identical to *std::forward_list* `L.erase_after(it)`.
-- Iterators returned from *clist_X_insert()* and *clist_X_erase_it()* are always valid.
+- `clist_X_erase_at(&L, clist_X_fwd(it,1))` is identical to *std::forward_list* `L.erase_after(it)`.
+- Iterators returned from *clist_X_insert()* and *clist_X_erase_at()* are always valid.
- Elements can be safely removed from a list via multiple iterators if done back to front order.
See the c++ class [std::list](https://en.cppreference.com/w/cpp/container/list) for similar API and
@@ -67,7 +67,7 @@ void clist_X_emplace_n(clist_X *self, const clist_X_rawvalue_t ar
clist_X_iter_t clist_X_insert(clist_X* self, clist_X_iter_t it, Value value); // return iter to new elem
clist_X_iter_t clist_X_emplace(clist_X* self, clist_X_iter_t it, RawValue raw);
-clist_X_iter_t clist_X_erase_it(clist_X* self, clist_X_iter_t it); // return iter after it
+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);
size_t clist_X_remove(clist_X* self, RawValue raw); // removes all elements equal to raw
@@ -138,7 +138,7 @@ sorted: 1 2 3 4 5 6 7 8 9 10 20 30 40 50 60 70 80 90
```
### Example 2
-Use of *erase_it()* and *erase_range()*:
+Use of *erase_at()* and *erase_range()*:
```c
// erasing from clist
#include <stc/clist.h>
@@ -152,7 +152,7 @@ int main ()
// 10 20 30 40 50
clist_i_iter_t it = clist_i_begin(&L); // ^
clist_i_next(&it);
- it = clist_i_erase_it(&L, it); // 10 30 40 50
+ it = clist_i_erase_at(&L, it); // 10 30 40 50
// ^
clist_i_iter_t end = clist_i_end(&L); //
clist_i_next(&it);
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 2f056479..78aecfa9 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -10,7 +10,7 @@ hashing (aka open addressing) with linear probing, and without leaving tombstone
***Iterator invalidation***: References and iterators are invalidated after erase. No iterators are invalidated after insert,
unless the hash-table need to be extended. The hash table size can be reserved prior to inserts if the total max size is known.
The order of elements is preserved after erase and insert. This makes it possible to erase individual elements while iterating
-through the container by using the returned iterator from *erase_it()*, which references the next element.
+through the container by using the returned iterator from *erase_at()*, which references the next element.
See the c++ class [std::unordered_map](https://en.cppreference.com/w/cpp/container/unordered_map) for a functional description.
@@ -75,7 +75,7 @@ cmap_X_result_t cmap_X_emplace_or_assign(cmap_X* self, RawKey rkey, RawMappe
void cmap_X_emplace_n(cmap_X* self, const cmap_X_rawvalue_t arr[], size_t n);
size_t cmap_X_erase(cmap_X* self, RawKey rkey); // return 0 or 1
-cmap_X_iter_t cmap_X_erase_it(cmap_X* self, cmap_X_iter_t it); // return iter after it
+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_t cmap_X_begin(const cmap_X* self);
diff --git a/docs/cset_api.md b/docs/cset_api.md
index f28c4714..a1265ee8 100644
--- a/docs/cset_api.md
+++ b/docs/cset_api.md
@@ -47,7 +47,7 @@ cset_X_result_t cset_X_emplace(cset_X* self, RawKey rkey);
void cset_X_emplace_n(cset_X* self, const RawKey arr[], size_t n);
size_t cset_X_erase(cset_X* self, RawKey rkey); // return 0 or 1
-cset_X_iter_t cset_X_erase_it(cset_X* self, cset_X_iter_t it); // return iter after it
+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_t cset_X_begin(const cset_X* self);
diff --git a/docs/csmap_api.md b/docs/csmap_api.md
index 6aa341cd..5717c287 100644
--- a/docs/csmap_api.md
+++ b/docs/csmap_api.md
@@ -8,7 +8,7 @@ using the comparison function *keyCompare*. Search, removal, and insertion opera
***Iterator invalidation***: Iterators are invalidated after insert and erase. References are only invalidated
after erase. It is possible to erase individual elements while iterating through the container by using the
-returned iterator from *erase_it()*, which references the next element. Alternatively *erase_range()* can be used.
+returned iterator from *erase_at()*, which references the next element. Alternatively *erase_range()* can be used.
See the c++ class [std::map](https://en.cppreference.com/w/cpp/container/map) for a functional description.
@@ -69,7 +69,7 @@ csmap_X_result_t csmap_X_emplace_or_assign(csmap_X* self, RawKey rkey, RawMap
void csmap_X_emplace_n(csmap_X* self, const csmap_X_rawvalue_t arr[], size_t n);
size_t csmap_X_erase(csmap_X* self, RawKey rkey);
-csmap_X_iter_t csmap_X_erase_it(csmap_X* self, csmap_X_iter_t it); // returns iter after it
+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_t csmap_X_begin(const csmap_X* self);
diff --git a/docs/csset_api.md b/docs/csset_api.md
index 54a0ece9..500e38e4 100644
--- a/docs/csset_api.md
+++ b/docs/csset_api.md
@@ -44,7 +44,7 @@ csset_X_result_t csset_X_emplace(csset_X* self, RawKey rkey);
void csset_X_emplace_n(csset_X* self, const RawKey arr[], size_t n);
size_t csset_X_erase(csset_X* self, RawKey rkey);
-csset_X_iter_t csset_X_erase_it(csset_X* self, csset_X_iter_t it); // return iter after it
+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_t csset_X_begin(const csset_X* self);
diff --git a/docs/cvec_api.md b/docs/cvec_api.md
index 2f084704..0171f3e7 100644
--- a/docs/cvec_api.md
+++ b/docs/cvec_api.md
@@ -65,7 +65,7 @@ cvec_X_iter_t cvec_X_insert_at(cvec_X* self, size_t idx, const Value[] arr
cvec_X_iter_t cvec_X_emplace(cvec_X* self, cvec_X_iter_t it, RawValue raw);
void cvec_X_emplace_n(cvec_X *self, const RawValue arr[], size_t n); // emplace_back only
-cvec_X_iter_t cvec_X_erase_it(cvec_X* self, cvec_X_iter_t it);
+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 i1, cvec_X_iter_t i2);
cvec_X_iter_t cvec_X_erase_n(cvec_X* self, size_t idx, size_t n);
diff --git a/examples/csset_erase.c b/examples/csset_erase.c
index 96bc4c98..9a05290d 100644
--- a/examples/csset_erase.c
+++ b/examples/csset_erase.c
@@ -15,7 +15,7 @@ int main()
c_foreach (k, csset_i, it, csset_i_end(&set)) printf(" %d", *k.ref); puts("");
printf("Erase values >= %d:\n", val);
- while (it.ref) it = csset_i_erase_it(&set, it);
+ while (it.ref) it = csset_i_erase_at(&set, it);
c_foreach (k, csset_i, set) printf(" %d", *k.ref); puts("");
val = 35;
diff --git a/examples/demos.c b/examples/demos.c
index f6f1a6cf..1eb74525 100644
--- a/examples/demos.c
+++ b/examples/demos.c
@@ -170,7 +170,7 @@ void mapdemo3()
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);
//cmap_str_erase(&table, "Make");
- cmap_str_erase_it(&table, it);
+ cmap_str_erase_at(&table, it);
printf("size %zu\n", cmap_str_size(table));
c_foreach (i, cmap_str, table)
diff --git a/examples/list_erase.c b/examples/list_erase.c
index fd68b250..6e70b103 100644
--- a/examples/list_erase.c
+++ b/examples/list_erase.c
@@ -10,7 +10,7 @@ int main ()
// 10 20 30 40 50
clist_i_iter_t it = clist_i_begin(&L); // ^
clist_i_next(&it);
- it = clist_i_erase_it(&L, it); // 10 30 40 50
+ it = clist_i_erase_at(&L, it); // 10 30 40 50
// ^
clist_i_iter_t end = clist_i_end(&L); //
clist_i_next(&it);
diff --git a/stc/cdeq.h b/stc/cdeq.h
index 7fa661d9..fda469e5 100644
--- a/stc/cdeq.h
+++ b/stc/cdeq.h
@@ -46,7 +46,6 @@
struct cdeq_rep { size_t size, cap; void* base[]; };
#define cdeq_rep_(self) c_container_of((self)->_base, struct cdeq_rep, base)
-typedef int (*c_cmp_fn)(const void*, const void*);
#define _c_using_cdeq(CX, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
@@ -58,24 +57,27 @@ typedef int (*c_cmp_fn)(const void*, const void*);
\
STC_API CX CX##_init(void); \
STC_API CX CX##_clone(CX deq); \
- STC_INLINE bool CX##_empty(CX deq) {return !cdeq_rep_(&deq)->size;} \
- STC_INLINE size_t CX##_size(CX deq) {return cdeq_rep_(&deq)->size;} \
- STC_INLINE size_t CX##_capacity(CX deq) {return cdeq_rep_(&deq)->cap;} \
- STC_INLINE Value CX##_value_fromraw(RawValue raw) \
- {return valueFromRaw(raw);} \
- STC_INLINE Value CX##_value_clone(Value val) \
- {return valueFromRaw(valueToRaw(&val));} \
STC_API void CX##_clear(CX* self); \
STC_API void CX##_del(CX* self); \
STC_API void CX##_expand_(CX* self, size_t n, bool at_front); \
STC_API void CX##_resize(CX* self, size_t size, Value fill_val); \
- STC_INLINE void CX##_reserve(CX* self, size_t n) \
- {CX##_expand_(self, (n - cdeq_rep_(self)->size)*0.65, false);} \
- STC_INLINE void CX##_swap(CX* a, CX* b) {c_swap(CX, *a, *b);} \
-\
+ STC_API CX##_iter_t CX##_find_in(CX##_iter_t p1, CX##_iter_t p2, RawValue raw); \
+ STC_API int CX##_value_compare(const CX##_value_t* x, const CX##_value_t* y); \
STC_API void CX##_emplace_n(CX *self, const CX##_rawvalue_t arr[], size_t n); \
STC_API void CX##_push_back(CX* self, Value value); \
STC_API void CX##_push_front(CX* self, Value value); \
+ STC_API CX##_iter_t CX##_erase_range_p(CX* self, CX##_value_t* p1, CX##_value_t* p2); \
+ STC_API CX##_iter_t CX##_insert_range_p(CX* self, CX##_value_t* pos, const CX##_value_t* p1, \
+ const CX##_value_t* p2, bool clone); \
+ STC_INLINE bool CX##_empty(CX deq) {return !cdeq_rep_(&deq)->size;} \
+ STC_INLINE size_t CX##_size(CX deq) {return cdeq_rep_(&deq)->size;} \
+ STC_INLINE size_t CX##_capacity(CX deq) {return cdeq_rep_(&deq)->cap;} \
+ STC_INLINE void CX##_swap(CX* a, CX* b) {c_swap(CX, *a, *b);} \
+ STC_INLINE Value CX##_value_fromraw(RawValue raw) {return valueFromRaw(raw);} \
+ STC_INLINE Value CX##_value_clone(Value val) \
+ {return valueFromRaw(valueToRaw(&val));} \
+ STC_INLINE void CX##_reserve(CX* self, size_t n) \
+ {CX##_expand_(self, (n - cdeq_rep_(self)->size)*0.65, false);} \
STC_INLINE void CX##_emplace_back(CX* self, RawValue raw) \
{CX##_push_back(self, valueFromRaw(raw));} \
STC_INLINE void CX##_emplace_front(CX* self, RawValue raw) \
@@ -112,9 +114,6 @@ typedef int (*c_cmp_fn)(const void*, const void*);
CX##_del(self); *self = x; \
} \
\
- STC_API CX##_iter_t \
- CX##_insert_range_p(CX* self, CX##_value_t* pos, const CX##_value_t* p1, \
- const CX##_value_t* p2, bool clone); \
STC_INLINE CX##_iter_t \
CX##_insert(CX* self, CX##_iter_t it, Value value) { \
it = CX##_insert_range_p(self, it.ref, &value, &value + 1, false); \
@@ -133,15 +132,12 @@ typedef int (*c_cmp_fn)(const void*, const void*);
return CX##_insert_range_p(self, self->data + idx, arr, arr + n, true); \
} \
\
- STC_API CX##_iter_t \
- CX##_erase_range_p(CX* self, CX##_value_t* p1, CX##_value_t* p2); \
-\
STC_INLINE CX##_iter_t \
CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2) { \
return CX##_erase_range_p(self, it1.ref, it2.ref); \
} \
STC_INLINE CX##_iter_t \
- CX##_erase_it(CX* self, CX##_iter_t it) { \
+ CX##_erase_at(CX* self, CX##_iter_t it) { \
return CX##_erase_range_p(self, it.ref, it.ref + 1); \
} \
STC_INLINE CX##_iter_t \
@@ -157,28 +153,28 @@ typedef int (*c_cmp_fn)(const void*, const void*);
CX##_end(const CX* self) { \
CX##_iter_t it = {self->data + cdeq_rep_(self)->size}; return it; \
} \
+\
STC_INLINE void \
CX##_next(CX##_iter_t* it) {++it->ref;} \
STC_INLINE size_t \
CX##_index(CX deq, CX##_iter_t it) {return it.ref - deq.data;} \
\
- STC_API CX##_iter_t \
- CX##_find_in(CX##_iter_t p1, CX##_iter_t p2, RawValue raw); \
STC_INLINE CX##_iter_t \
CX##_find(const CX* self, RawValue raw) { \
return CX##_find_in(CX##_begin(self), CX##_end(self), raw); \
} \
- STC_API int \
- CX##_value_compare(const CX##_value_t* x, const CX##_value_t* y); \
+\
STC_INLINE void \
CX##_sort_range(CX##_iter_t i1, CX##_iter_t i2, \
int(*cmp)(const CX##_value_t*, const CX##_value_t*)) { \
- qsort(i1.ref, i2.ref - i1.ref, sizeof(CX##_value_t), (c_cmp_fn) cmp); \
+ qsort(i1.ref, i2.ref - i1.ref, sizeof *i1.ref, (int(*)(const void*, const void*)) cmp); \
} \
+\
STC_INLINE void \
CX##_sort(CX* self) { \
CX##_sort_range(CX##_begin(self), CX##_end(self), CX##_value_compare); \
} \
+\
_c_implement_cdeq(CX, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
struct stc_trailing_semicolon
@@ -188,8 +184,8 @@ typedef int (*c_cmp_fn)(const void*, const void*);
static struct cdeq_rep _cdeq_inits = {0, 0};
#define _cdeq_nfront(self) ((self)->data - (self)->_base)
-static inline double _minf(double x, double y) {return x < y ? x : y;}
-static inline double _maxf(double x, double y) {return x > y ? x : y;}
+static inline float c_minf(float x, float y) {return x < y ? x : y;}
+static inline float c_maxf(float x, float y) {return x > y ? x : y;}
#define _c_implement_cdeq(CX, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
\
@@ -241,8 +237,8 @@ static inline double _maxf(double x, double y) {return x > y ? x : y;}
return; \
} \
size_t unused = cap - (len + n); \
- size_t pos = at_front ? _maxf(unused*0.5, (float) unused - nback) + n \
- : _minf(unused*0.5, nfront); \
+ size_t pos = (size_t) (at_front ? c_maxf(unused*0.5f, unused - nback) + n \
+ : c_minf(unused*0.5f, nfront)); \
self->data = (CX##_value_t *) memmove(self->_base + pos, self->data, len*sizeof(Value)); \
} \
\
@@ -262,6 +258,7 @@ static inline double _maxf(double x, double y) {return x > y ? x : y;}
*--self->data = value; \
++cdeq_rep_(self)->size; \
} \
+\
STC_DEF void \
CX##_push_back(CX* self, Value value) { \
if (_cdeq_nfront(self) + cdeq_rep_(self)->size == cdeq_rep_(self)->cap) \
@@ -317,6 +314,7 @@ static inline double _maxf(double x, double y) {return x > y ? x : y;}
} \
return i2; \
} \
+\
STC_DEF int \
CX##_value_compare(const CX##_value_t* x, const CX##_value_t* y) { \
RawValue rx = valueToRaw(x); \
diff --git a/stc/clist.h b/stc/clist.h
index d998dbe5..a3b836fb 100644
--- a/stc/clist.h
+++ b/stc/clist.h
@@ -64,7 +64,7 @@
#define using_clist_4(X, Value, valueCompare, valueDel) \
using_clist_5(X, Value, valueCompare, valueDel, c_no_clone)
#define using_clist_5(X, Value, valueCompare, valueDel, valueClone) \
- using_clist_7(X, Value, valueCompare, valueDel, valueClone, c_trivial_toraw, Value)
+ _c_using_clist(clist_##X, Value, valueCompare, valueDel, valueClone, c_trivial_toraw, Value)
#define using_clist_7(X, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
_c_using_clist(clist_##X, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue)
@@ -85,12 +85,12 @@
} CX; \
\
typedef struct { \
- CX##_node_t *const*_last, *_prev; \
+ CX##_node_t *const*_last, *prev; \
CX##_value_t *ref; \
} CX##_iter_t
_c_using_clist_types(clist_VOID, int);
-STC_API size_t _clist_size(const clist_VOID* self);
+STC_API size_t _clist_count(const clist_VOID* self);
#define _clist_node(CX, vp) c_container_of(vp, CX##_node_t, value)
@@ -99,43 +99,46 @@ STC_API size_t _clist_size(const clist_VOID* self);
_c_using_clist_types(CX, Value); \
typedef RawValue CX##_rawvalue_t; \
\
+ STC_API CX CX##_clone(CX list); \
+ STC_API void CX##_del(CX* self); \
+ STC_API void CX##_push_back(CX* self, Value value); \
+ STC_API void CX##_push_front(CX* self, Value value); \
+ STC_API CX##_iter_t CX##_insert(CX* self, CX##_iter_t it, Value value); \
+ STC_API void CX##_emplace_n(CX *self, const CX##_rawvalue_t arr[], size_t n); \
+ STC_API CX##_iter_t CX##_erase_at(CX* self, CX##_iter_t it); \
+ STC_API CX##_iter_t CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2); \
+ STC_API size_t CX##_remove(CX* self, RawValue val); \
+ STC_API CX##_iter_t CX##_splice(CX* self, CX##_iter_t it, CX* other); \
+ STC_API CX CX##_split(CX* self, CX##_iter_t it1, CX##_iter_t it2); \
+ STC_API void CX##_sort(CX* self); \
+ STC_API CX##_iter_t CX##_find_in(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
+ STC_API CX##_node_t* CX##_erase_after_(CX* self, CX##_node_t* node); \
+\
STC_INLINE CX CX##_init(void) {CX lst = {NULL}; return lst;} \
STC_INLINE bool CX##_empty(CX lst) {return lst.last == NULL;} \
STC_INLINE size_t CX##_count(CX lst) \
- {return _clist_size((const clist_VOID*) &lst);} \
- STC_API void CX##_del(CX* self); \
- STC_API CX CX##_clone(CX list); \
+ {return _clist_count((const clist_VOID*) &lst);} \
STC_INLINE void CX##_clear(CX* self) {CX##_del(self);} \
STC_INLINE Value CX##_value_clone(Value val) \
{return valueFromRaw(valueToRaw(&val));} \
STC_INLINE Value CX##_value_fromraw(RawValue raw) \
{return valueFromRaw(raw);} \
-\
- STC_API void CX##_push_back(CX* self, Value value); \
- STC_API void CX##_push_front(CX* self, Value value); \
+ STC_INLINE void CX##_pop_front(CX* self) \
+ {CX##_erase_after_(self, self->last);} \
STC_INLINE void CX##_emplace_back(CX* self, RawValue raw) \
{CX##_push_back(self, valueFromRaw(raw));} \
STC_INLINE void CX##_emplace_front(CX* self, RawValue raw) \
{CX##_push_front(self, valueFromRaw(raw));} \
- STC_API CX##_iter_t CX##_insert(CX* self, CX##_iter_t it, Value value); \
STC_INLINE \
CX##_iter_t CX##_emplace(CX* self, CX##_iter_t it, RawValue raw) \
{return CX##_insert(self, it, valueFromRaw(raw));} \
- STC_API void CX##_emplace_n(CX *self, const CX##_rawvalue_t arr[], size_t n); \
-\
- STC_API CX##_node_t* CX##_erase_after_(CX* self, CX##_node_t* node); \
- STC_INLINE void CX##_pop_front(CX* self) {CX##_erase_after_(self, self->last);} \
- STC_API CX##_iter_t CX##_erase_it(CX* self, CX##_iter_t it); \
- STC_API CX##_iter_t CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2); \
- STC_API size_t CX##_remove(CX* self, RawValue val); \
-\
- STC_API CX##_iter_t CX##_splice(CX* self, CX##_iter_t it, CX* other); \
- STC_API CX CX##_split(CX* self, CX##_iter_t it1, CX##_iter_t it2); \
- STC_API void CX##_sort(CX* self); \
- STC_API CX##_iter_t CX##_find_in(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
+ STC_INLINE CX##_value_t* CX##_front(const CX* self) {return &self->last->next->value;} \
+ STC_INLINE CX##_value_t* CX##_back(const CX* self) {return &self->last->value;} \
\
- STC_INLINE Value* CX##_front(const CX* self) {return &self->last->next->value;} \
- STC_INLINE Value* CX##_back(const CX* self) {return &self->last->value;} \
+ STC_INLINE CX##_iter_t \
+ CX##_iter(const CX* self, CX##_node_t* prev) { \
+ CX##_iter_t it = {&self->last, prev, &prev->next->value}; return it; \
+ } \
\
STC_INLINE CX##_iter_t \
CX##_begin(const CX* self) { \
@@ -150,7 +153,7 @@ STC_API size_t _clist_size(const clist_VOID* self);
\
STC_INLINE void \
CX##_next(CX##_iter_t* it) { \
- CX##_node_t* node = it->_prev = _clist_node(CX, it->ref); \
+ CX##_node_t* node = it->prev = _clist_node(CX, it->ref); \
it->ref = (node == *it->_last ? NULL : &node->next->value); \
} \
\
@@ -211,10 +214,10 @@ STC_API size_t _clist_size(const clist_VOID* self);
\
STC_DEF CX##_iter_t \
CX##_insert(CX* self, CX##_iter_t it, Value value) { \
- CX##_node_t* node = it.ref ? it._prev : self->last; \
+ CX##_node_t* node = it.ref ? it.prev : self->last; \
_c_clist_insert_after(self, CX, node, value); \
if (!self->last || !it.ref) { \
- it._prev = self->last ? self->last : entry; \
+ it.prev = self->last ? self->last : entry; \
self->last = entry; \
} \
it.ref = &entry->value; \
@@ -222,16 +225,16 @@ STC_API size_t _clist_size(const clist_VOID* self);
} \
\
STC_DEF CX##_iter_t \
- CX##_erase_it(CX* self, CX##_iter_t it) { \
+ CX##_erase_at(CX* self, CX##_iter_t it) { \
CX##_node_t *node = _clist_node(CX, it.ref); \
it.ref = (node == self->last) ? NULL : &node->next->value; \
- CX##_erase_after_(self, it._prev); \
+ CX##_erase_after_(self, it.prev); \
return it; \
} \
\
STC_DEF CX##_iter_t \
CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2) { \
- CX##_node_t *node = it1.ref ? it1._prev : NULL, \
+ CX##_node_t *node = it1.ref ? it1.prev : NULL, \
*done = it2.ref ? _clist_node(CX, it2.ref) : NULL; \
while (node && node->next != done) \
node = CX##_erase_after_(self, node); \
@@ -277,11 +280,11 @@ STC_API size_t _clist_size(const clist_VOID* self);
if (!self->last) \
self->last = other->last; \
else if (other->last) { \
- CX##_node_t *p = it.ref ? it._prev : self->last, *next = p->next; \
- it._prev = other->last; \
- p->next = it._prev->next; \
- it._prev->next = next; \
- if (!it.ref) self->last = it._prev; \
+ CX##_node_t *p = it.ref ? it.prev : self->last, *next = p->next; \
+ it.prev = other->last; \
+ p->next = it.prev->next; \
+ it.prev->next = next; \
+ if (!it.ref) self->last = it.prev; \
} \
other->last = NULL; return it; \
} \
@@ -290,24 +293,24 @@ STC_API size_t _clist_size(const clist_VOID* self);
CX##_split(CX* self, CX##_iter_t it1, CX##_iter_t it2) { \
CX list = {NULL}; \
if (it1.ref == it2.ref) return list; \
- CX##_node_t *p1 = it1._prev, \
- *p2 = it2.ref ? it2._prev : self->last; \
+ CX##_node_t *p1 = it1.prev, \
+ *p2 = it2.ref ? it2.prev : self->last; \
p1->next = p2->next, p2->next = _clist_node(CX, it1.ref); \
if (self->last == p2) self->last = (p1 == p2) ? NULL : p1; \
list.last = p2; \
return list; \
} \
\
- STC_INLINE int \
- CX##_sort_compare(const void* x, const void* y) { \
- RawValue a = valueToRaw(&((CX##_node_t *) x)->value); \
- RawValue b = valueToRaw(&((CX##_node_t *) y)->value); \
+ STC_DEF int \
+ CX##_sort_cmp_(const clist_VOID_node_t* x, const clist_VOID_node_t* y) { \
+ RawValue a = valueToRaw(&((const CX##_node_t *) x)->value); \
+ RawValue b = valueToRaw(&((const CX##_node_t *) y)->value); \
return valueCompareRaw(&a, &b); \
} \
STC_DEF void \
CX##_sort(CX* self) { \
if (self->last) \
- self->last = (CX##_node_t *) _clist_mergesort((clist_VOID_node_t *) self->last->next, CX##_sort_compare); \
+ self->last = (CX##_node_t *) _clist_mergesort((clist_VOID_node_t *) self->last->next, CX##_sort_cmp_); \
}
@@ -319,7 +322,7 @@ STC_API size_t _clist_size(const clist_VOID* self);
/* +: set self->last based on node */
STC_DEF size_t
-_clist_size(const clist_VOID* self) {
+_clist_count(const clist_VOID* self) {
const clist_VOID_node_t *node = self->last;
if (!node) return 0;
size_t n = 1;
@@ -331,7 +334,7 @@ _clist_size(const clist_VOID* self) {
* 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_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;
int insize = 1, nmerges, psize, qsize, i;
diff --git a/stc/cmap.h b/stc/cmap.h
index 9baefe83..77311da6 100644
--- a/stc/cmap.h
+++ b/stc/cmap.h
@@ -180,27 +180,27 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored)
uint8_t* _hx; \
} CX##_iter_t; \
\
+ STC_API CX CX##_with_capacity(size_t cap); \
+ STC_API CX CX##_clone(CX map); \
+ STC_API void CX##_del(CX* self); \
+ STC_API void CX##_clear(CX* self); \
+ STC_API void CX##_reserve(CX* self, size_t capacity); \
STC_API chash_bucket_t CX##_bucket_(const CX* self, const CX##_rawkey_t* rkeyptr); \
STC_API CX##_result_t CX##_insert_entry_(CX* self, RawKey rkey); \
+ STC_API CX##_iter_t CX##_find(const CX* self, RawKey rkey); \
+ STC_API void CX##_erase_entry(CX* self, CX##_value_t* val); \
\
STC_INLINE CX CX##_init(void) {CX m = _cmap_inits; return m;} \
- STC_API CX CX##_with_capacity(size_t cap); \
- STC_API CX CX##_clone(CX map); \
- STC_API void CX##_reserve(CX* self, size_t capacity); \
STC_INLINE void CX##_shrink_to_fit(CX* self) {CX##_reserve(self, self->size);} \
STC_INLINE void CX##_max_load_factor(CX* self, float ml) {self->max_load_factor = ml;} \
- STC_API void CX##_del(CX* self); \
- STC_API void CX##_clear(CX* self); \
STC_INLINE bool CX##_empty(CX m) {return m.size == 0;} \
- STC_INLINE size_t CX##_size(CX m) {return (size_t) m.size;} \
- STC_INLINE size_t CX##_bucket_count(CX map) {return (size_t) map.bucket_count;} \
+ STC_INLINE size_t CX##_size(CX m) {return m.size;} \
+ STC_INLINE size_t CX##_bucket_count(CX map) {return map.bucket_count;} \
STC_INLINE size_t CX##_capacity(CX map) \
{return (size_t) (map.bucket_count * map.max_load_factor);} \
STC_INLINE void CX##_swap(CX *map1, CX *map2) {c_swap(CX, *map1, *map2);} \
- STC_API CX##_iter_t CX##_find(const CX* self, RawKey rkey); \
STC_INLINE bool CX##_contains(const CX* self, RawKey rkey) \
{return self->size && self->_hashx[CX##_bucket_(self, &rkey).idx];} \
- STC_API void CX##_erase_entry(CX* self, CX##_value_t* val); \
\
STC_INLINE CX##_value_t \
CX##_value_clone(CX##_value_t val) { \
@@ -288,7 +288,7 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored)
} \
\
STC_INLINE CX##_iter_t \
- CX##_erase_it(CX* self, CX##_iter_t it) { \
+ CX##_erase_at(CX* self, CX##_iter_t it) { \
CX##_erase_entry(self, it.ref); \
if (*it._hx == 0) CX##_next(&it); \
return it; \
diff --git a/stc/csmap.h b/stc/csmap.h
index 74c6fd39..fa9d05e0 100644
--- a/stc/csmap.h
+++ b/stc/csmap.h
@@ -178,19 +178,21 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; };
STC_API CX CX##_clone(CX tree); \
STC_API void CX##_del(CX* self); \
STC_API void CX##_reserve(CX* self, size_t cap); \
- STC_INLINE bool CX##_empty(CX tree) {return _csmap_rep(&tree)->size == 0;} \
- STC_INLINE size_t CX##_size(CX tree) {return _csmap_rep(&tree)->size;} \
- STC_INLINE size_t CX##_capacity(CX tree) {return _csmap_rep(&tree)->cap;} \
- STC_INLINE void CX##_clear(CX* self) {CX##_del(self); *self = CX##_init();} \
- STC_INLINE void CX##_swap(CX* a, CX* b) {c_swap(CX, *a, *b);} \
STC_API CX##_value_t* CX##_find_it(const CX* self, RawKey rkey, CX##_iter_t* out); \
STC_API CX##_iter_t CX##_lower_bound(const CX* self, RawKey rkey); \
STC_API CX##_value_t* CX##_front(const CX* self); \
STC_API CX##_value_t* CX##_back(const CX* self); \
STC_API int CX##_erase(CX* self, RawKey rkey); \
- STC_API CX##_iter_t CX##_erase_it(CX* self, CX##_iter_t it); \
+ STC_API CX##_iter_t CX##_erase_at(CX* self, CX##_iter_t it); \
STC_API CX##_iter_t CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2); \
STC_API CX##_result_t CX##_insert_entry_(CX* self, RawKey rkey); \
+ STC_API void CX##_next(CX##_iter_t* it); \
+\
+ STC_INLINE bool CX##_empty(CX tree) {return _csmap_rep(&tree)->size == 0;} \
+ STC_INLINE size_t CX##_size(CX tree) {return _csmap_rep(&tree)->size;} \
+ STC_INLINE size_t CX##_capacity(CX tree) {return _csmap_rep(&tree)->cap;} \
+ STC_INLINE void CX##_clear(CX* self) {CX##_del(self); *self = CX##_init();} \
+ STC_INLINE void CX##_swap(CX* a, CX* b) {c_swap(CX, *a, *b);} \
\
STC_INLINE CX \
CX##_with_capacity(size_t size) { \
@@ -256,9 +258,10 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; };
else {keyDel(&key); mappedDel(&res.ref->second);} \
res.ref->second = mapped; return res; \
} \
+\
STC_INLINE CX##_result_t \
- CX##_put(CX* self, Key k, Mapped m) { \
- return CX##_insert_or_assign(self, k, m); \
+ CX##_put(CX* self, Key key, Mapped mapped) { \
+ return CX##_insert_or_assign(self, key, mapped); \
} \
\
STC_INLINE CX##_result_t \
@@ -275,9 +278,6 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; };
return &CX##_find_it(self, rkey, &it)->second; \
}) \
\
- STC_API void \
- CX##_next(CX##_iter_t* it); \
-\
STC_INLINE CX##_iter_t \
CX##_begin(const CX* self) { \
CX##_iter_t it; it._d = self->nodes, it._top = 0; \
@@ -285,6 +285,7 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; };
if (it._tn) CX##_next(&it); \
return it; \
} \
+\
STC_INLINE CX##_iter_t \
CX##_end(const CX* self) {\
CX##_iter_t it; it.ref = NULL; return it; \
@@ -316,6 +317,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
while (d[tn].link[0]) tn = d[tn].link[0]; \
return &d[tn].value; \
} \
+\
STC_DEF CX##_value_t* \
CX##_back(const CX* self) { \
CX##_node_t *d = self->nodes; \
@@ -419,7 +421,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
return tn; \
} \
\
- static inline CX##_size_t \
+ STC_DEF CX##_size_t \
CX##_insert_entry_i_(CX* self, CX##_size_t tn, const CX##_rawkey_t* rkey, CX##_result_t* res) { \
CX##_size_t up[64], tx = tn; \
CX##_node_t* d = self->nodes; \
@@ -453,7 +455,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
return res; \
} \
\
- static CX##_size_t \
+ STC_DEF CX##_size_t \
CX##_erase_r_(CX##_node_t *d, CX##_size_t tn, const CX##_rawkey_t* rkey, int *erased) { \
if (tn == 0) return 0; \
RawKey raw = keyToRaw(KEY_REF_##C(&d[tn].value)); \
@@ -500,7 +502,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
} \
\
STC_DEF CX##_iter_t \
- CX##_erase_it(CX* self, CX##_iter_t it) { \
+ CX##_erase_at(CX* self, CX##_iter_t it) { \
CX##_rawkey_t raw = keyToRaw(KEY_REF_##C(it.ref)), nxt; \
CX##_next(&it); \
if (it.ref) nxt = keyToRaw(KEY_REF_##C(it.ref)); \
@@ -511,7 +513,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
\
STC_DEF CX##_iter_t \
CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2) { \
- if (!it2.ref) { while (it1.ref) it1 = CX##_erase_it(self, it1); \
+ if (!it2.ref) { while (it1.ref) it1 = CX##_erase_at(self, it1); \
return it1; } \
CX##_key_t k1 = *KEY_REF_##C(it1.ref), k2 = *KEY_REF_##C(it2.ref); \
CX##_rawkey_t r1 = keyToRaw(&k1); \
@@ -541,7 +543,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0};
return clone; \
} \
\
- static void \
+ STC_DEF void \
CX##_del_r_(CX##_node_t* d, CX##_size_t tn) { \
if (tn) { \
CX##_del_r_(d, d[tn].link[0]); \
diff --git a/stc/cvec.h b/stc/cvec.h
index b378be0f..2092913f 100644
--- a/stc/cvec.h
+++ b/stc/cvec.h
@@ -58,18 +58,23 @@ typedef int (*c_cmp_fn)(const void*, const void*);
\
STC_API CX CX##_init(void); \
STC_API CX CX##_clone(CX vec); \
- STC_INLINE size_t CX##_size(CX vec) { return _cvec_rep(&vec)->size; } \
- STC_INLINE size_t CX##_capacity(CX vec) { return _cvec_rep(&vec)->cap; } \
- STC_INLINE bool CX##_empty(CX vec) {return !_cvec_rep(&vec)->size;} \
- STC_INLINE Value CX##_value_fromraw(RawValue raw) {return valueFromRaw(raw);} \
- STC_API int CX##_value_compare(const CX##_value_t* x, const CX##_value_t* y); \
- STC_INLINE void CX##_clear(CX* self); \
STC_API void CX##_del(CX* self); \
+ STC_API void CX##_clear(CX* self); \
STC_API void CX##_reserve(CX* self, size_t cap); \
STC_API void CX##_resize(CX* self, size_t size, Value fill_val); \
- STC_INLINE void CX##_swap(CX* a, CX* b) {c_swap(CX, *a, *b);} \
+ STC_API int CX##_value_compare(const CX##_value_t* x, const CX##_value_t* y); \
+ STC_API CX##_iter_t CX##_find_in(CX##_iter_t it1, CX##_iter_t it2, RawValue raw); \
+ STC_API CX##_iter_t CX##_bsearch_in(CX##_iter_t it1, CX##_iter_t it2, RawValue raw); \
STC_API void CX##_emplace_n(CX *self, const CX##_rawvalue_t arr[], size_t size); \
STC_API void CX##_push_back(CX* self, Value value); \
+ STC_API CX##_iter_t CX##_erase_range_p(CX* self, CX##_value_t* p1, CX##_value_t* p2); \
+ STC_API CX##_iter_t CX##_insert_range_p(CX* self, CX##_value_t* pos, const CX##_value_t* p1, \
+ const CX##_value_t* p2, bool clone); \
+ STC_INLINE size_t CX##_size(CX vec) { return _cvec_rep(&vec)->size; } \
+ STC_INLINE size_t CX##_capacity(CX vec) { return _cvec_rep(&vec)->cap; } \
+ STC_INLINE bool CX##_empty(CX vec) {return !_cvec_rep(&vec)->size;} \
+ STC_INLINE Value CX##_value_fromraw(RawValue raw) {return valueFromRaw(raw);} \
+ STC_INLINE void CX##_swap(CX* a, CX* b) {c_swap(CX, *a, *b);} \
STC_INLINE void CX##_emplace_back(CX* self, RawValue raw) \
{CX##_push_back(self, valueFromRaw(raw));} \
STC_INLINE void CX##_pop_back(CX* self) \
@@ -100,8 +105,6 @@ typedef int (*c_cmp_fn)(const void*, const void*);
return valueFromRaw(valueToRaw(&val)); \
} \
\
- STC_API CX##_iter_t CX##_insert_range_p(CX* self, CX##_value_t* pos, const CX##_value_t* p1, \
- const CX##_value_t* p2, bool clone); \
STC_INLINE CX##_iter_t \
CX##_insert(CX* self, CX##_iter_t it, Value value) { \
it = CX##_insert_range_p(self, it.ref, &value, &value + 1, false); \
@@ -120,15 +123,12 @@ typedef int (*c_cmp_fn)(const void*, const void*);
return CX##_insert_range_p(self, self->data + idx, arr, arr + n, true); \
} \
\
- STC_API CX##_iter_t \
- CX##_erase_range_p(CX* self, CX##_value_t* p1, CX##_value_t* p2); \
-\
STC_INLINE CX##_iter_t \
CX##_erase_range(CX* self, CX##_iter_t it1, CX##_iter_t it2) { \
return CX##_erase_range_p(self, it1.ref, it2.ref); \
} \
STC_INLINE CX##_iter_t \
- CX##_erase_it(CX* self, CX##_iter_t it) { \
+ CX##_erase_at(CX* self, CX##_iter_t it) { \
return CX##_erase_range_p(self, it.ref, it.ref + 1); \
} \
STC_INLINE CX##_iter_t \
@@ -160,15 +160,11 @@ typedef int (*c_cmp_fn)(const void*, const void*);
STC_INLINE size_t \
CX##_index(CX vec, CX##_iter_t it) {return it.ref - vec.data;} \
\
- STC_API CX##_iter_t \
- CX##_find_in(CX##_iter_t it1, CX##_iter_t it2, RawValue raw); \
STC_INLINE CX##_iter_t \
CX##_find(const CX* self, RawValue raw) { \
return CX##_find_in(CX##_begin(self), CX##_end(self), raw); \
} \
\
- STC_API CX##_iter_t \
- CX##_bsearch_in(CX##_iter_t i1, CX##_iter_t i2, RawValue raw); \
STC_INLINE CX##_iter_t \
CX##_bsearch(const CX* self, RawValue raw) { \
return CX##_bsearch_in(CX##_begin(self), CX##_end(self), raw); \
@@ -216,6 +212,7 @@ static struct cvec_rep _cvec_inits = {0, 0};
rep->size = 0; \
} \
} \
+\
STC_DEF void \
CX##_del(CX* self) { \
CX##_clear(self); \
@@ -235,6 +232,7 @@ static struct cvec_rep _cvec_inits = {0, 0};
rep->cap = cap; \
} \
} \
+\
STC_DEF void \
CX##_resize(CX* self, size_t len, Value null_val) { \
CX##_reserve(self, len); \
@@ -296,6 +294,7 @@ static struct cvec_rep _cvec_inits = {0, 0};
} \
return i2; \
} \
+\
STC_DEF CX##_iter_t \
CX##_bsearch_in(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
CX##_iter_t mid, last = i2; \