diff options
| author | Tyge Løvset <[email protected]> | 2021-04-15 15:15:02 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-04-15 15:15:02 +0200 |
| commit | 6b55c6fee03d6a1d846eb1b05e810f1841ac7ae2 (patch) | |
| tree | c9b6c13d01f41a91ac8dc7301953f433cc1ba2d7 | |
| parent | 673b1911f8d3d74199ec9d5144fb4540b1b5ebc3 (diff) | |
| download | STC-modified-6b55c6fee03d6a1d846eb1b05e810f1841ac7ae2.tar.gz STC-modified-6b55c6fee03d6a1d846eb1b05e810f1841ac7ae2.zip | |
NB! Changed API: *_erase_at(container, it) --> *_erase_it(container, it). cvec and cdeq insert_at() swapped with insert(). Docs update.
| -rw-r--r-- | README.md | 55 | ||||
| -rw-r--r-- | benchmarks/others/clist_v1.h | 14 | ||||
| -rw-r--r-- | benchmarks/others/csmap_v1.h | 2 | ||||
| -rw-r--r-- | docs/cdeq_api.md | 22 | ||||
| -rw-r--r-- | docs/clist_api.md | 30 | ||||
| -rw-r--r-- | docs/cmap_api.md | 6 | ||||
| -rw-r--r-- | docs/cpque_api.md | 2 | ||||
| -rw-r--r-- | docs/cqueue_api.md | 2 | ||||
| -rw-r--r-- | docs/cset_api.md | 6 | ||||
| -rw-r--r-- | docs/csmap_api.md | 4 | ||||
| -rw-r--r-- | docs/csptr_api.md | 5 | ||||
| -rw-r--r-- | docs/csset_api.md | 4 | ||||
| -rw-r--r-- | docs/cstack_api.md | 2 | ||||
| -rw-r--r-- | docs/cvec_api.md | 31 | ||||
| -rw-r--r-- | examples/csset_erase.c | 2 | ||||
| -rw-r--r-- | examples/demos.c | 6 | ||||
| -rw-r--r-- | examples/list_erase.c | 2 | ||||
| -rw-r--r-- | stc/cdeq.h | 26 | ||||
| -rw-r--r-- | stc/clist.h | 12 | ||||
| -rw-r--r-- | stc/cmap.h | 6 | ||||
| -rw-r--r-- | stc/cpque.h | 8 | ||||
| -rw-r--r-- | stc/csmap.h | 6 | ||||
| -rw-r--r-- | stc/csptr.h | 5 | ||||
| -rw-r--r-- | stc/cvec.h | 34 |
24 files changed, 147 insertions, 145 deletions
@@ -7,9 +7,8 @@ Introduction ------------
A modern, templated, user-friendly, fast, fully type-safe, and customizable container library for C99,
with a uniform API across the containers, and is similar to the c++ standard library containers API.
-
-Please read [this blog](https://iafisher.com/blog/2020/06/type-safe-generics-in-c) by Ian Fisher for
-an introduction to type-safe generic data structures in C.
+For an introduction to templated containers, please read the blog by Ian Fisher on
+[type-safe generic data structures in C](https://iafisher.com/blog/2020/06/type-safe-generics-in-c).
STC is a compact, header-only library with the all the major "standard" data containers, except for
the multi-map/set variants:
@@ -130,11 +129,11 @@ int main(void) { *i3.ref, *i4.ref,
i5.ref->first, i5.ref->second);
// erase the elements found
- 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);
+ 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);
printf("After erasing elements found:");
printf("\n set:"); c_foreach (i, cset_i, set) printf(" %d", *i.ref);
@@ -195,26 +194,18 @@ with **emplace**, e.g. **cvec_X_emplace_back()**. This is a convenient alternati **cvec_X_push_back()** when dealing non-trivial container elements, e.g. smart pointers or
elements using dynamic memory.
-| Move and insert element | Construct element in-place | Container |
-|:--------------------------|:-----------------------------|:--------------------------------|
-| insert() | emplace() | cmap, cset, csmap, csset, clist |
-| insert_or_assign(), put() | emplace_or_assign() | cmap, csmap |
-| push() | emplace() | cstack, cqueue, cpque |
-| push_back() | emplace_back() | cvec, cdeq, clist |
-| push_front() | emplace_front() | cdeq, clist |
-
-For containers of integral or trivial element types, **emplace** and corresponding non-emplace
-methods are identical, so the following does not apply for those.
-
The **emplace** methods ***construct*** or ***clone*** their own copy of the element to be added.
-In contrast, the non-emplace methods requires elements to be explicitly constructed or cloned before adding them.
-
-A few of the differences between STC and c++ STL maps methods are:
-
-| STC maps | C++ STL maps |
-|:-------------------------------------|:------------------------------|
-| insert(Key, Mapped) | insert(Value) |
-| emplace_or_assign(RawKey, RawMapped) | N/A |
+In contrast, the non-emplace methods requires elements to be explicitly constructed or cloned
+before adding them. For containers of integral or trivial element types, **emplace** and
+corresponding non-emplace methods are identical, so the following does not apply for those.
+
+| Move and insert element | Construct element in-place | Container |
+|:--------------------------|:-----------------------------|:--------------------------------------------|
+| insert() | emplace() | cmap, cset, csmap, csset, cvec, cdeq, clist |
+| insert_or_assign(), put() | emplace_or_assign() | cmap, csmap |
+| push() | emplace() | cstack, cqueue, cpque |
+| push_back() | emplace_back() | cvec, cdeq, clist |
+| push_front() | emplace_front() | cdeq, clist |
Strings are the most commonly used non-trivial data type. STC containers have proper pre-defined
**using**-declarations for cstr-elements, so they are fail-safe to use both with the **emplace**
@@ -261,6 +252,16 @@ it = cmap_str_find(&map, "Hello"); Apart from strings, maps and sets are normally used with trivial value types. However, the
last example on the **cmap** page demonstrates how to specify a map with non-trivial keys.
+Erase methods
+-------------
+| Name | Description | Container |
+|:--------------------------|:-----------------------------|:--------------------------------------------|
+| erase() | key based | csmap, csset, cmap, cset |
+| erase_it() | iterator based | csmap, csset, cmap, cset, cvec, cdeq, clist |
+| erase_range() | iterator based | csmap, csset, cvec, cdeq, clist |
+| erase_n() | index based | cvec, cdeq |
+| remove() | remove all matching values | clist |
+
Memory efficiency
-----------------
- **cstr**, **cvec**: Type size: one pointer. The size and capacity is stored as part of the heap allocation that also holds the vector elements.
diff --git a/benchmarks/others/clist_v1.h b/benchmarks/others/clist_v1.h index ae70dacf..c1f76d0b 100644 --- a/benchmarks/others/clist_v1.h +++ b/benchmarks/others/clist_v1.h @@ -114,7 +114,7 @@ STC_API size_t _clist_size(const clist_void* self); clist_##X##_clear(clist_##X* self) {clist_##X##_del(self);} \
\
STC_API void \
- clist_##X##_emplace_n(clist_##X *self, const clist_##X##_rawvalue_t arr[], size_t size); \
+ clist_##X##_emplace_n(clist_##X *self, const clist_##X##_rawvalue_t arr[], size_t n); \
STC_API void \
clist_##X##_push_back(clist_##X* self, Value value); \
STC_INLINE void \
@@ -188,7 +188,7 @@ STC_API size_t _clist_size(const clist_void* self); } \
\
STC_API clist_##X##_iter_t \
- clist_##X##_find_before_in_range(const clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish, RawValue val); \
+ clist_##X##_find_before_in(const clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish, RawValue val); \
STC_API clist_##X##_iter_t \
clist_##X##_find_before(const clist_##X* self, RawValue val); \
STC_API clist_##X##_iter_t \
@@ -234,8 +234,8 @@ STC_API size_t _clist_size(const clist_void* self); if (!self->last) self->last = entry; \
} \
STC_DEF void \
- clist_##X##_emplace_n(clist_##X *self, const clist_##X##_rawvalue_t arr[], size_t size) { \
- for (size_t i=0; i<size; ++i) clist_##X##_push_back(self, valueFromRaw(arr[i])); \
+ clist_##X##_emplace_n(clist_##X *self, const clist_##X##_rawvalue_t arr[], size_t n) { \
+ for (size_t i=0; i<n; ++i) clist_##X##_push_back(self, valueFromRaw(arr[i])); \
} \
\
STC_DEF clist_##X##_iter_t \
@@ -259,7 +259,7 @@ STC_API size_t _clist_size(const clist_void* self); } \
\
STC_DEF clist_##X##_iter_t \
- clist_##X##_find_before_in_range(const clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish, RawValue val) { \
+ clist_##X##_find_before_in(const clist_##X* self, clist_##X##_iter_t first, clist_##X##_iter_t finish, RawValue val) { \
clist_##X##_iter_t i = first; \
for (clist_##X##_next(&i); i.ref != finish.ref; clist_##X##_next(&i)) { \
RawValue r = valueToRaw(i.ref); \
@@ -270,12 +270,12 @@ STC_API size_t _clist_size(const clist_void* self); } \
STC_DEF clist_##X##_iter_t \
clist_##X##_find_before(const clist_##X* self, RawValue val) { \
- clist_##X##_iter_t it = clist_##X##_find_before_in_range(self, clist_##X##_before_begin(self), clist_##X##_end(self), val); \
+ clist_##X##_iter_t it = clist_##X##_find_before_in(self, clist_##X##_before_begin(self), clist_##X##_end(self), val); \
return it; \
} \
STC_DEF clist_##X##_iter_t \
clist_##X##_find(const clist_##X* self, RawValue val) { \
- clist_##X##_iter_t it = clist_##X##_find_before_in_range(self, clist_##X##_before_begin(self), clist_##X##_end(self), val); \
+ clist_##X##_iter_t it = clist_##X##_find_before_in(self, clist_##X##_before_begin(self), clist_##X##_end(self), val); \
if (it.ref != clist_##X##_end(self).ref) clist_##X##_next(&it); \
return it; \
} \
diff --git a/benchmarks/others/csmap_v1.h b/benchmarks/others/csmap_v1.h index b81d7554..1b1b8244 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_at(C##X* self, C##X##_iter_t pos) { \
+ C##X##_erase_it(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 03843fcf..b07ee2b0 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -54,27 +54,27 @@ void cdeq_X_push_front(cdeq_X* self, Value value); void cdeq_X_push_back(cdeq_X* self, Value value); void cdeq_X_emplace_front(cdeq_X* self, RawValue raw); void cdeq_X_emplace_back(cdeq_X* self, RawValue raw); -void cdeq_X_emplace_n(cdeq_X *self, const cdeq_X_rawvalue_t arr[], size_t size); +void cdeq_X_emplace_n(cdeq_X *self, const cdeq_X_rawvalue_t arr[], size_t n); void cdeq_X_pop_front(cdeq_X* self); -void cdeq_X_pop_back(cdeq_X* self); +void cdeq_X_pop_back(cdeq_X* self); -cdeq_X_iter_t cdeq_X_emplace(cdeq_X* self, size_t idx, RawValue raw); -cdeq_X_iter_t cdeq_X_emplace_at(cdeq_X* self, cdeq_X_iter_t pos, RawValue raw); -cdeq_X_iter_t cdeq_X_insert(cdeq_X* self, size_t idx, Value value); -cdeq_X_iter_t cdeq_X_insert_at(cdeq_X* self, cdeq_X_iter_t pos, Value value); -cdeq_X_iter_t cdeq_X_insert_range(cdeq_X* self, cdeq_X_iter_t pos, +cdeq_X_iter_t cdeq_X_emplace(cdeq_X* self, cdeq_X_iter_t it, RawValue raw); +cdeq_X_iter_t cdeq_X_emplace_at(cdeq_X* self, size_t idx, RawValue raw); +cdeq_X_iter_t cdeq_X_insert(cdeq_X* self, cdeq_X_iter_t it, Value value); +cdeq_X_iter_t cdeq_X_insert_at(cdeq_X* self, size_t idx, Value value); +cdeq_X_iter_t cdeq_X_insert_range(cdeq_X* self, cdeq_X_iter_t it, cdeq_X_iter_t first, cdeq_X_iter_t finish); -cdeq_X_iter_t cdeq_X_insert_range_p(cdeq_X* self, cdeq_X_value_t* pos, +cdeq_X_iter_t cdeq_X_insert_range_p(cdeq_X* self, cdeq_X_value_t* it, const cdeq_X_value_t* pfirst, const cdeq_X_value_t* pfinish); -cdeq_X_iter_t cdeq_X_erase(cdeq_X* self, size_t idx, size_t n); -cdeq_X_iter_t cdeq_X_erase_at(cdeq_X* self, cdeq_X_iter_t pos); +cdeq_X_iter_t cdeq_X_erase_it(cdeq_X* self, cdeq_X_iter_t it); cdeq_X_iter_t cdeq_X_erase_range(cdeq_X* self, cdeq_X_iter_t first, cdeq_X_iter_t finish); cdeq_X_iter_t cdeq_X_erase_range_p(cdeq_X* self, cdeq_X_value_t* pfirst, cdeq_X_value_t* pfinish); +cdeq_X_iter_t cdeq_X_erase_n(cdeq_X* self, size_t idx, size_t n); cdeq_X_iter_t cdeq_X_find(const cdeq_X* self, RawValue raw); -cdeq_X_iter_t cdeq_X_find_in_range(cdeq_X_iter_t i1, cdeq_X_iter_t i2, RawValue raw); +cdeq_X_iter_t cdeq_X_find_in(cdeq_X_iter_t i1, cdeq_X_iter_t i2, RawValue raw); void cdeq_X_sort(cdeq_X* self); void cdeq_X_sort_range(cdeq_X_iter_t i1, cdeq_X_iter_t i2, int(*cmp)(const cdeq_X_value_t*, const cdeq_X_value_t*)); diff --git a/docs/clist_api.md b/docs/clist_api.md index d1219046..6477eea7 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_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. +- `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. - 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 @@ -48,10 +48,10 @@ clist_X clist_X_init(void); clist_X clist_X_clone(clist_X list); void clist_X_clear(clist_X* self); -void clist_X_del(clist_X* self); // destructor +void clist_X_del(clist_X* self); // destructor bool clist_X_empty(clist_X list); -size_t clist_X_count(clist_X list); // size() in O(n) time +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); @@ -60,26 +60,26 @@ void clist_X_push_front(clist_X* self, Value value); void clist_X_emplace_front(clist_X* self, RawValue raw); void clist_X_pop_front(clist_X* self); -void clist_X_push_back(clist_X* self, Value value); // note: no pop_back(). -void clist_X_emplace_back(clist_X* self, RawValue raw); -void clist_X_emplace_n(clist_X *self, const clist_X_rawvalue_t arr[], size_t size); +void clist_X_push_back(clist_X* self, Value value); // note no pop_back(). +void clist_X_emplace_back(clist_X* self, RawValue raw); // note no emplace_back(). +void clist_X_emplace_n(clist_X *self, const clist_X_rawvalue_t arr[], size_t n); -clist_X_iter_t clist_X_insert(clist_X* self, clist_X_iter_t it, Value value); // return iter to new elem; End allowed +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_at(clist_X* self, clist_X_iter_t it); // return iter after it +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_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 +size_t clist_X_remove(clist_X* self, RawValue raw); // removes all elements equal to raw void clist_X_splice(clist_X* self, clist_X_iter_t it, clist_X* other); -void clist_X_splice_range(clist_X* self, clist_X_iter_t it, // see std::list::splice() docs +void clist_X_splice_range(clist_X* self, clist_X_iter_t it, // see std::list::splice() docs clist_X* other, clist_X_iter_t it1, clist_X_iter_t it2); // split out [it1, it2) from self, and return as a clist clist_X clist_X_split(clist_X* self, clist_X_iter_t it1, clist_X_iter_t it2); clist_X_iter_t clist_X_find(const clist_X* self, RawValue raw); -clist_X_iter_t clist_X_find_in_range(const clist_X* self, - clist_X_iter_t it1, clist_X_iter_t it2, RawValue raw); +clist_X_iter_t clist_X_find_in(const clist_X* self, + clist_X_iter_t it1, clist_X_iter_t it2, RawValue raw); void clist_X_sort(clist_X* self); @@ -139,7 +139,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_at()* and *erase_range()*: +Use of *erase_it()* and *erase_range()*: ```c // erasing from clist #include <stc/clist.h> @@ -153,7 +153,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_at(&L, it); // 10 30 40 50 + it = clist_i_erase_it(&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 aec048e6..39550a19 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -63,10 +63,10 @@ cmap_X_result_t cmap_X_put(cmap_X* self, Key key, Mapped mapped); cmap_X_result_t cmap_X_emplace(cmap_X* self, RawKey rkey, RawMapped rmapped); // no change if rkey in map cmap_X_result_t cmap_X_emplace_or_assign(cmap_X* self, RawKey rkey, RawMapped rmapped); // always update rmapped -void cmap_X_emplace_n(cmap_X* self, const cmap_X_rawvalue_t arr[], size_t size); +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); -cmap_X_iter_t cmap_X_erase_at(cmap_X* self, cmap_X_iter_t pos); +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 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/cpque_api.md b/docs/cpque_api.md index 822b4ad5..261c2909 100644 --- a/docs/cpque_api.md +++ b/docs/cpque_api.md @@ -37,7 +37,7 @@ const cpque_X_value_t* cpque_X_top(const cpque_X* self); 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_emplace_n(cpque_X *self, const cpque_X_rawvalue_t arr[], size_t size); +void cpque_X_emplace_n(cpque_X *self, const cpque_X_rawvalue_t arr[], size_t n); void cpque_X_pop(cpque_X* self); void cpque_X_erase_at(cpque_X* self, size_t idx); diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md index 2d9b113c..7a18a9b4 100644 --- a/docs/cqueue_api.md +++ b/docs/cqueue_api.md @@ -32,7 +32,7 @@ cqueue_X_value_t* cqueue_X_back(const cqueue_X* self); void cqueue_X_push(cqueue_X* self, cqueue_X_value_t value); void cqueue_X_emplace(cqueue_X* self, cqueue_X_rawvalue_t raw); -void cqueue_X_emplace_n(cqueue_X *self, const cqueue_X_rawvalue_t arr[], size_t size); +void cqueue_X_emplace_n(cqueue_X *self, const cqueue_X_rawvalue_t arr[], size_t n); void cqueue_X_pop(cqueue_X* self); diff --git a/docs/cset_api.md b/docs/cset_api.md index dfdad074..848c6c63 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -43,10 +43,10 @@ bool cset_X_contains(const cset_X* self, RawKey rkey); cset_X_result_t cset_X_insert(cset_X* self, Key key);
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 size);
+void cset_X_emplace_n(cset_X* self, const RawKey arr[], size_t n);
-size_t cset_X_erase(cset_X* self, RawKey rkey);
-cset_X_iter_t cset_X_erase_at(cset_X* self, cset_X_iter_t pos);
+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
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 758bce09..dca919fb 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -62,10 +62,10 @@ csmap_X_result_t csmap_X_put(csmap_X* self, Key key, Mapped mapped); csmap_X_result_t csmap_X_emplace(csmap_X* self, RawKey rkey, RawMapped rmapped); // no change if rkey in map csmap_X_result_t csmap_X_emplace_or_assign(csmap_X* self, RawKey rkey, RawMapped rmapped); // always update rmapped -void csmap_X_emplace_n(csmap_X* self, const csmap_X_rawvalue_t arr[], size_t size); +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_at(csmap_X* self, csmap_X_iter_t it); // returns iter after it +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_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/csptr_api.md b/docs/csptr_api.md index 9669d97b..e1670bb2 100644 --- a/docs/csptr_api.md +++ b/docs/csptr_api.md @@ -39,7 +39,7 @@ The *csptr_X_compare()*, *csptr_X_equals()* and *csptr_X_del()* methods are defi csptr_X csptr_X_from(csptr_X_value_t* ptr); // constructor csptr_X csptr_X_make(csptr_X_value_t val); // make_shared void csptr_X_reset(csptr_X* self); -void csptr_X_reset_to(csptr_X* self, csptr_X_value_t* ptr); +void csptr_X_reset_with(csptr_X* self, csptr_X_value_t* ptr); csptr_X csptr_X_clone(csptr_X sptr); // share the pointer (increase use count) void csptr_X_move(csptr_X* self); // transfer ownership instead of sharing. @@ -49,10 +49,11 @@ int csptr_X_compare(csptr_X* x, csptr_X* y); bool csptr_X_equals(csptr_X* x, csptr_X* y); ``` -## Types +## Types and constants | 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` | `Value` | The csptr element type | | `atomic_count_t` | `long` | The reference counter | diff --git a/docs/csset_api.md b/docs/csset_api.md index 67e3c6a7..54a0ece9 100644 --- a/docs/csset_api.md +++ b/docs/csset_api.md @@ -41,10 +41,10 @@ bool csset_X_contains(const csset_X* self, RawKey rkey); csset_X_result_t csset_X_insert(csset_X* self, Key key);
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 size);
+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_at(csset_X* self, csset_X_iter_t it); // return iter after it
+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_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/cstack_api.md b/docs/cstack_api.md index 06163518..e892ac8e 100644 --- a/docs/cstack_api.md +++ b/docs/cstack_api.md @@ -32,7 +32,7 @@ cstack_X_value_t* cstack_X_top(const cstack_X* self); void cstack_X_push(cstack_X* self, cstack_X_value_t value); void cstack_X_emplace(cstack_X* self, cstack_X_rawvalue_t raw); -void cstack_X_emplace_n(cstack_X *self, const cstack_X_rawvalue_t arr[], size_t size); +void cstack_X_emplace_n(cstack_X *self, const cstack_X_rawvalue_t arr[], size_t n); void cstack_X_pop(cstack_X* self); diff --git a/docs/cvec_api.md b/docs/cvec_api.md index 6f495cae..d945e5e2 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -55,35 +55,34 @@ cvec_X_value_t* cvec_X_back(const cvec_X* self); void cvec_X_push_back(cvec_X* self, Value value); void cvec_X_emplace_back(cvec_X* self, RawValue raw); -void cvec_X_emplace_n(cvec_X *self, const cvec_X_rawvalue_t arr[], size_t size); +void cvec_X_emplace_n(cvec_X *self, const cvec_X_rawvalue_t arr[], size_t n); void cvec_X_pop_back(cvec_X* self); -cvec_X_iter_t cvec_X_insert(cvec_X* self, size_t idx, Value value); -cvec_X_iter_t cvec_X_insert_at(cvec_X* self, cvec_X_iter_t pos, Value value); -cvec_X_iter_t cvec_X_insert_range(cvec_X* self, cvec_X_iter_t pos, - cvec_X_iter_t first, cvec_X_iter_t finish); -cvec_X_iter_t cvec_X_insert_range_p(cvec_X* self, cvec_X_value_t* pos, - const cvec_X_value_t* pfirst, const cvec_X_value_t* pfinish); -cvec_X_iter_t cvec_X_emplace(cvec_X* self, size_t idx, RawValue raw); -cvec_X_iter_t cvec_X_emplace_at(cvec_X* self, cvec_X_iter_t pos, RawValue raw); +cvec_X_iter_t cvec_X_insert(cvec_X* self, cvec_X_iter_t it, Value value); +cvec_X_iter_t cvec_X_insert_at(cvec_X* self, size_t idx, Value value); +cvec_X_iter_t cvec_X_insert_range(cvec_X* self, cvec_X_iter_t it, + cvec_X_iter_t i1, cvec_X_iter_t i2); -cvec_X_iter_t cvec_X_erase(cvec_X* self, size_t idx, size_t n); -cvec_X_iter_t cvec_X_erase_at(cvec_X* self, cvec_X_iter_t pos); -cvec_X_iter_t cvec_X_erase_range(cvec_X* self, cvec_X_iter_t first, cvec_X_iter_t finish); -cvec_X_iter_t cvec_X_erase_range_p(cvec_X* self, cvec_X_value_t* pfirst, cvec_X_value_t* pfinish); +cvec_X_iter_t cvec_X_emplace(cvec_X* self, cvec_X_iter_t it, RawValue raw); +cvec_X_iter_t cvec_X_emplace_at(cvec_X* self, size_t idx, RawValue raw); + +cvec_X_iter_t cvec_X_erase_it(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); cvec_X_iter_t cvec_X_find(const cvec_X* self, RawValue raw); -cvec_X_iter_t cvec_X_find_in_range(cvec_X_iter_t i1, cvec_X_iter_t i2, RawValue raw); +cvec_X_iter_t cvec_X_find_in(cvec_X_iter_t i1, cvec_X_iter_t i2, RawValue raw); cvec_X_iter_t cvec_X_bsearch(const cvec_X* self, RawValue raw); -cvec_X_iter_t cvec_X_bsearch_in_range(cvec_X_iter_t i1, cvec_X_iter_t i2, RawValue raw); +cvec_X_iter_t cvec_X_bsearch_in(cvec_X_iter_t i1, cvec_X_iter_t i2, RawValue raw); + void cvec_X_sort(cvec_X* self); void cvec_X_sort_range(cvec_X_iter_t i1, cvec_X_iter_t i2, int(*cmp)(const cvec_X_value_t*, const cvec_X_value_t*)); 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* it); +void cvec_X_next(cvec_X_iter_t* iter); size_t cvec_X_index(const cvec_X vec, cvec_X_iter_t it); cvec_X_value_t cvec_X_value_clone(cvec_X_value_t val); diff --git a/examples/csset_erase.c b/examples/csset_erase.c index 9a05290d..96bc4c98 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_at(&set, it);
+ while (it.ref) it = csset_i_erase_it(&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 14bf20d4..f6f1a6cf 100644 --- a/examples/demos.c +++ b/examples/demos.c @@ -46,10 +46,10 @@ void vectordemo1() cvec_ix_push_back(&bignums, i * i);
printf("erase - %d: %zu\n", 3, bignums.data[3]);
- cvec_ix_erase(&bignums, 3, 1); // erase index 3
+ cvec_ix_erase_n(&bignums, 3, 1); // erase index 3
cvec_ix_pop_back(&bignums); // erase the last
- cvec_ix_erase(&bignums, 0, 1); // erase the first
+ cvec_ix_erase_n(&bignums, 0, 1); // erase the first
for (size_t i = 0; i < cvec_ix_size(bignums); ++i) {
printf("%zu: %zu\n", i, bignums.data[i]);
@@ -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_at(&table, it);
+ cmap_str_erase_it(&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 6e70b103..fd68b250 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_at(&L, it); // 10 30 40 50
+ it = clist_i_erase_it(&L, it); // 10 30 40 50
// ^
clist_i_iter_t end = clist_i_end(&L); //
clist_i_next(&it);
@@ -90,8 +90,8 @@ typedef int (*c_cmp_fn)(const void*, const void*); CX##_value_t* CX##_back(const CX* self) \
{return self->data + cdeq_rep_(self)->size - 1;} \
STC_INLINE \
- CX##_value_t* CX##_at(const CX* self, size_t i) \
- {assert(i < cdeq_rep_(self)->size); return self->data + i;} \
+ CX##_value_t* CX##_at(const CX* self, size_t idx) \
+ {assert(idx < cdeq_rep_(self)->size); return self->data + idx;} \
\
STC_INLINE CX \
CX##_with_size(size_t size, Value null_val) { \
@@ -120,20 +120,20 @@ typedef int (*c_cmp_fn)(const void*, const void*); return CX##_insert_range_p(self, it.ref, first.ref, finish.ref); \
} \
STC_INLINE CX##_iter_t \
- CX##_insert_at(CX* self, CX##_iter_t it, Value value) { \
+ CX##_insert(CX* self, CX##_iter_t it, Value value) { \
return CX##_insert_range_p(self, it.ref, &value, &value + 1); \
} \
STC_INLINE CX##_iter_t \
- CX##_insert(CX* self, size_t idx, Value value) { \
+ CX##_insert_at(CX* self, size_t idx, Value value) { \
return CX##_insert_range_p(self, self->data + idx, &value, &value + 1); \
} \
STC_INLINE CX##_iter_t \
- CX##_emplace_at(CX* self, CX##_iter_t it, RawValue raw) { \
- return CX##_insert_at(self, it, valueFromRaw(raw)); \
+ CX##_emplace(CX* self, CX##_iter_t it, RawValue raw) { \
+ return CX##_insert(self, it, valueFromRaw(raw)); \
} \
STC_INLINE CX##_iter_t \
- CX##_emplace(CX* self, size_t idx, RawValue raw) { \
- return CX##_insert(self, idx, valueFromRaw(raw)); \
+ CX##_emplace_at(CX* self, size_t idx, RawValue raw) { \
+ return CX##_insert_at(self, idx, valueFromRaw(raw)); \
} \
\
STC_API CX##_iter_t \
@@ -144,11 +144,11 @@ typedef int (*c_cmp_fn)(const void*, const void*); return CX##_erase_range_p(self, first.ref, finish.ref); \
} \
STC_INLINE CX##_iter_t \
- CX##_erase_at(CX* self, CX##_iter_t it) { \
+ CX##_erase_it(CX* self, CX##_iter_t it) { \
return CX##_erase_range_p(self, it.ref, it.ref + 1); \
} \
STC_INLINE CX##_iter_t \
- CX##_erase(CX* self, size_t idx, size_t n) { \
+ CX##_erase_n(CX* self, size_t idx, size_t n) { \
return CX##_erase_range_p(self, self->data + idx, self->data + idx + n); \
} \
\
@@ -166,10 +166,10 @@ typedef int (*c_cmp_fn)(const void*, const void*); CX##_index(CX deq, CX##_iter_t it) {return it.ref - deq.data;} \
\
STC_API CX##_iter_t \
- CX##_find_in_range(CX##_iter_t first, CX##_iter_t finish, RawValue raw); \
+ CX##_find_in(CX##_iter_t first, CX##_iter_t finish, RawValue raw); \
STC_INLINE CX##_iter_t \
CX##_find(const CX* self, RawValue raw) { \
- return CX##_find_in_range(CX##_begin(self), CX##_end(self), 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); \
@@ -314,7 +314,7 @@ static inline double _maxf(double x, double y) {return x > y ? x : y;} } \
\
STC_DEF CX##_iter_t \
- CX##_find_in_range(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
+ CX##_find_in(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
for (; i1.ref != i2.ref; ++i1.ref) { \
RawValue r = valueToRaw(i1.ref); \
if (valueCompareRaw(&raw, &r) == 0) return i1; \
diff --git a/stc/clist.h b/stc/clist.h index 66a42a2d..a2f7668c 100644 --- a/stc/clist.h +++ b/stc/clist.h @@ -121,18 +121,18 @@ STC_API size_t _clist_size(const clist_VOID* self); 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 size); \
+ 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_at(CX* self, CX##_iter_t it); \
+ 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 void 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_range(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
+ STC_API CX##_iter_t CX##_find_in(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val); \
\
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;} \
@@ -169,7 +169,7 @@ STC_API size_t _clist_size(const clist_VOID* self); \
STC_INLINE CX##_iter_t \
CX##_find(const CX* self, RawValue val) { \
- return CX##_find_in_range(self, CX##_begin(self), CX##_end(self), val); \
+ return CX##_find_in(self, CX##_begin(self), CX##_end(self), val); \
} \
\
_c_implement_clist(CX, Value, valueCompareRaw, valueDel, valueFromRaw, valueToRaw, RawValue) \
@@ -222,7 +222,7 @@ STC_API size_t _clist_size(const clist_VOID* self); } \
\
STC_DEF CX##_iter_t \
- CX##_erase_at(CX* self, CX##_iter_t it) { \
+ CX##_erase_it(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); \
@@ -239,7 +239,7 @@ STC_API size_t _clist_size(const clist_VOID* self); } \
\
STC_DEF CX##_iter_t \
- CX##_find_in_range(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val) { \
+ CX##_find_in(const CX* self, CX##_iter_t it1, CX##_iter_t it2, RawValue val) { \
c_foreach_4 (it, CX, it1, it2) { \
RawValue r = valueToRaw(it.ref); \
if (valueCompareRaw(&r, &val) == 0) return it; \
@@ -293,9 +293,9 @@ STC_INLINE uint64_t c_default_hash64(const void* data, size_t ignored) } \
\
STC_INLINE CX##_iter_t \
- CX##_erase_at(CX* self, CX##_iter_t pos) { \
- CX##_erase_entry(self, pos.ref); \
- CX##_next(&pos); return pos; \
+ CX##_erase_it(CX* self, CX##_iter_t it) { \
+ CX##_erase_entry(self, it.ref); \
+ CX##_next(&it); return it; \
} \
\
_c_implement_chash(CX, C, Key, Mapped, keyEqualsRaw, keyHashRaw, \
diff --git a/stc/cpque.h b/stc/cpque.h index 05a2295b..9bc365c2 100644 --- a/stc/cpque.h +++ b/stc/cpque.h @@ -72,7 +72,7 @@ STC_INLINE bool CX##_empty(CX pq) {return ctype##_empty(pq);} \
\
STC_API void CX##_make_heap(CX* self); \
- STC_API void CX##_erase_at(CX* self, size_t i); \
+ STC_API void CX##_erase_at(CX* self, size_t idx); \
STC_INLINE \
const CX##_value_t* CX##_top(const CX* self) {return &self->data[0];} \
STC_INLINE void CX##_pop(CX* self) {CX##_erase_at(self, 0);} \
@@ -114,11 +114,11 @@ } \
\
STC_API void \
- CX##_erase_at(CX* self, size_t i) { \
+ CX##_erase_at(CX* self, size_t idx) { \
size_t n = CX##_size(*self) - 1; \
- self->data[i] = self->data[n]; \
+ self->data[idx] = self->data[n]; \
ctype##_pop_back(self); \
- CX##_sift_down_(self->data - 1, i + 1, n); \
+ CX##_sift_down_(self->data - 1, idx + 1, n); \
} \
\
STC_API void \
diff --git a/stc/csmap.h b/stc/csmap.h index 74298dad..6b58c6a3 100644 --- a/stc/csmap.h +++ b/stc/csmap.h @@ -188,7 +188,7 @@ struct csmap_rep { size_t root, disp, head, size, cap; void* nodes[]; }; 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_at(CX* self, CX##_iter_t pos); \
+ 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 CX##_result_t CX##_insert_entry_(CX* self, RawKey rkey); \
\
@@ -500,7 +500,7 @@ static struct csmap_rep _csmap_inits = {0, 0, 0, 0}; } \
\
STC_DEF CX##_iter_t \
- CX##_erase_at(CX* self, CX##_iter_t it) { \
+ CX##_erase_it(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 +511,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_at(self, it1); \
+ if (!it2.ref) { while (it1.ref) it1 = CX##_erase_it(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); \
diff --git a/stc/csptr.h b/stc/csptr.h index 6c2f1a36..d4f81e5d 100644 --- a/stc/csptr.h +++ b/stc/csptr.h @@ -143,10 +143,11 @@ typedef long atomic_count_t; self->use_count = NULL, self->get = NULL; \
} \
\
- STC_INLINE void \
- CX##_reset_to(CX* self, CX##_value_t* p) { \
+ STC_INLINE CX##_value_t* \
+ CX##_reset_with(CX* self, CX##_value_t* p) { \
CX##_del(self); \
*self = CX##_from(p); \
+ return self->get; \
} \
\
STC_INLINE int \
@@ -108,20 +108,20 @@ typedef int (*c_cmp_fn)(const void*, const void*); return CX##_insert_range_p(self, it.ref, it1.ref, it2.ref); \
} \
STC_INLINE CX##_iter_t \
- CX##_insert_at(CX* self, CX##_iter_t it, Value value) { \
+ CX##_insert(CX* self, CX##_iter_t it, Value value) { \
return CX##_insert_range_p(self, it.ref, &value, &value + 1); \
} \
STC_INLINE CX##_iter_t \
- CX##_insert(CX* self, size_t idx, Value value) { \
+ CX##_insert_at(CX* self, size_t idx, Value value) { \
return CX##_insert_range_p(self, self->data + idx, &value, &value + 1); \
} \
STC_INLINE CX##_iter_t \
- CX##_emplace_at(CX* self, CX##_iter_t it, RawValue raw) { \
- return CX##_insert_at(self, it, valueFromRaw(raw)); \
+ CX##_emplace(CX* self, CX##_iter_t it, RawValue raw) { \
+ return CX##_insert(self, it, valueFromRaw(raw)); \
} \
STC_INLINE CX##_iter_t \
- CX##_emplace(CX* self, size_t idx, RawValue raw) { \
- return CX##_insert(self, idx, valueFromRaw(raw)); \
+ CX##_emplace_at(CX* self, size_t idx, RawValue raw) { \
+ return CX##_insert_at(self, idx, valueFromRaw(raw)); \
} \
\
STC_API CX##_iter_t \
@@ -132,11 +132,11 @@ typedef int (*c_cmp_fn)(const void*, const void*); return CX##_erase_range_p(self, it1.ref, it2.ref); \
} \
STC_INLINE CX##_iter_t \
- CX##_erase_at(CX* self, CX##_iter_t it) { \
+ CX##_erase_it(CX* self, CX##_iter_t it) { \
return CX##_erase_range_p(self, it.ref, it.ref + 1); \
} \
STC_INLINE CX##_iter_t \
- CX##_erase(CX* self, size_t idx, size_t n) { \
+ CX##_erase_n(CX* self, size_t idx, size_t n) { \
return CX##_erase_range_p(self, self->data + idx, self->data + idx + n); \
} \
\
@@ -146,9 +146,9 @@ typedef int (*c_cmp_fn)(const void*, const void*); CX##_back(const CX* self) {return self->data + _cvec_rep(self)->size - 1;} \
\
STC_INLINE CX##_value_t* \
- CX##_at(const CX* self, size_t i) { \
- assert(i < _cvec_rep(self)->size); \
- return self->data + i; \
+ CX##_at(const CX* self, size_t idx) { \
+ assert(idx < _cvec_rep(self)->size); \
+ return self->data + idx; \
} \
\
STC_INLINE CX##_iter_t \
@@ -165,17 +165,17 @@ typedef int (*c_cmp_fn)(const void*, const void*); CX##_index(CX vec, CX##_iter_t it) {return it.ref - vec.data;} \
\
STC_API CX##_iter_t \
- CX##_find_in_range(CX##_iter_t it1, CX##_iter_t it2, RawValue raw); \
+ 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_range(CX##_begin(self), CX##_end(self), raw); \
+ return CX##_find_in(CX##_begin(self), CX##_end(self), raw); \
} \
\
STC_API CX##_iter_t \
- CX##_bsearch_in_range(CX##_iter_t i1, CX##_iter_t i2, RawValue raw); \
+ 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_range(CX##_begin(self), CX##_end(self), raw); \
+ return CX##_bsearch_in(CX##_begin(self), CX##_end(self), raw); \
} \
STC_INLINE void \
CX##_sort_range(CX##_iter_t i1, CX##_iter_t i2, \
@@ -293,7 +293,7 @@ static struct cvec_rep _cvec_inits = {0, 0}; } \
\
STC_DEF CX##_iter_t \
- CX##_find_in_range(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
+ CX##_find_in(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
for (; i1.ref != i2.ref; ++i1.ref) { \
RawValue r = valueToRaw(i1.ref); \
if (valueCompareRaw(&raw, &r) == 0) return i1; \
@@ -301,7 +301,7 @@ static struct cvec_rep _cvec_inits = {0, 0}; return i2; \
} \
STC_DEF CX##_iter_t \
- CX##_bsearch_in_range(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
+ CX##_bsearch_in(CX##_iter_t i1, CX##_iter_t i2, RawValue raw) { \
CX##_iter_t mid, last = i2; \
while (i1.ref != i2.ref) { \
mid.ref = i1.ref + ((i2.ref - i1.ref)>>1); \
|
