diff options
| author | Tyge Løvset <[email protected]> | 2022-04-09 20:58:11 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-09 20:58:11 +0200 |
| commit | 17e620fe3b3c42134a1139245c6590816c1ca6bf (patch) | |
| tree | 9d5a35ac4ec66c83e4ca927c21e8013b13b1275d | |
| parent | 9e1ea5d14fb1835eb1ad1e45c8e8f02c9072ca57 (diff) | |
| download | STC-modified-17e620fe3b3c42134a1139245c6590816c1ca6bf.tar.gz STC-modified-17e620fe3b3c42134a1139245c6590816c1ca6bf.zip | |
- Switched from .._put() to .._push() as the "generic" method to add element to any container.
- Changed clist_X_insert()/emplace() to clist_X_insert_at()/emplace_at() to make it consistent with cvec/cdeq.
- Updated documentation.
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | benchmarks/misc/sso_bench2.cpp | 13 | ||||
| -rw-r--r-- | docs/cdeq_api.md | 10 | ||||
| -rw-r--r-- | docs/clist_api.md | 6 | ||||
| -rw-r--r-- | docs/cmap_api.md | 4 | ||||
| -rw-r--r-- | docs/cpque_api.md | 1 | ||||
| -rw-r--r-- | docs/cqueue_api.md | 1 | ||||
| -rw-r--r-- | docs/cset_api.md | 2 | ||||
| -rw-r--r-- | docs/csmap_api.md | 2 | ||||
| -rw-r--r-- | docs/csset_api.md | 2 | ||||
| -rw-r--r-- | docs/cstack_api.md | 1 | ||||
| -rw-r--r-- | docs/cvec_api.md | 11 | ||||
| -rw-r--r-- | examples/list.c | 2 | ||||
| -rw-r--r-- | include/stc/alt/csmap.h | 4 | ||||
| -rw-r--r-- | include/stc/cdeq.h | 17 | ||||
| -rw-r--r-- | include/stc/clist.h | 10 | ||||
| -rw-r--r-- | include/stc/cmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cpque.h | 3 | ||||
| -rw-r--r-- | include/stc/cqueue.h | 6 | ||||
| -rw-r--r-- | include/stc/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cstack.h | 3 | ||||
| -rw-r--r-- | include/stc/cvec.h | 6 |
22 files changed, 59 insertions, 63 deletions
@@ -316,13 +316,13 @@ container. `i_valfrom/i_valfrom` are defined, the **emplace** functions are *not* available (or needed), as it can easier lead to mistakes. -| non-emplace: Move | emplace: Embedded copy | Container | -|:--------------------------|:-----------------------------|:--------------------------------------------| -| insert() | emplace() | cmap, csmap, cset, csset, cdeq, clist, cvec | -| insert_or_assign(), put() | emplace_or_assign() | cmap, csmap | -| push() | emplace() | cqueue, cpque, cstack, cdeq, cvec | -| push_back() | emplace_back() | cdeq, clist, cvec | -| push_front() | emplace_front() | cdeq, clist | +| non-emplace: Move | emplace: Embedded copy | Container | +|:---------------------------|:-----------------------------|:--------------------------------------------| +| insert() | emplace() | cmap, csmap, cset, csset | +| insert_or_assign(), push() | emplace_or_assign() | cmap, csmap | +| push() | emplace() | cqueue, cpque, cstack | +| push_back(), push() | emplace_back() | cdeq, clist, cvec | +| push_front() | emplace_front() | cdeq, clist | Strings are the most commonly used non-trivial data type. STC containers have proper pre-defined definitions for cstr container elements, so they are fail-safe to use both with the **emplace** diff --git a/benchmarks/misc/sso_bench2.cpp b/benchmarks/misc/sso_bench2.cpp index 64ef6b12..87b701b5 100644 --- a/benchmarks/misc/sso_bench2.cpp +++ b/benchmarks/misc/sso_bench2.cpp @@ -3,6 +3,7 @@ #include <vector> #include <chrono> #define STC_USE_SSO 1 +#define i_type svec #define i_val_str #include <stc/cstack.h> @@ -46,14 +47,14 @@ void addRandomString_STD(std::vector<std::string>& vec, const int length) { vec.push_back(s); } -void addRandomString_STC(cstack_str& vec, const int length) { +void addRandomString_STC(svec& vec, const int length) { cstr s = cstr_with_size(length, 0); char* p = cstr_data(&s); for (int i = 0; i < length; ++i) { p[i] = CHARS[romutrio() & 63]; } cstr_append_s(&s, s); - cstack_str_push(&vec, s); + svec_push(&vec, s); } template <class L, typename R> @@ -85,10 +86,10 @@ int main() { sromutrio(1234); std::cerr << "\nlength\ttime\tSTC string\n"; for (int k = 0; k < 4; k++) { - cstack_str vec = cstack_str_with_capacity(BENCHMARK_SIZE); + svec vec = svec_with_capacity(BENCHMARK_SIZE); benchmark(vec, 0, addRandomString_STC); std::cout << '\t' << cstr_str(&vec.data[0]) << '\n'; - cstack_str_drop(&vec); + svec_drop(&vec); } sromutrio(1234); @@ -102,10 +103,10 @@ int main() { sromutrio(1234); std::cerr << "\nlength\ttime\tSTC string\n"; for (int length = 1; length <= MAX_STRING_LENGTH; length++) { - cstack_str vec = cstack_str_with_capacity(BENCHMARK_SIZE); + svec vec = svec_with_capacity(BENCHMARK_SIZE); benchmark(vec, length, addRandomString_STC); std::cout << '\t' << cstr_str(&vec.data[0]) << '\n'; - cstack_str_drop(&vec); + svec_drop(&vec); } std::cerr << "size std::string : " << sizeof(std::string) << std::endl diff --git a/docs/cdeq_api.md b/docs/cdeq_api.md index b884c62d..6749c5fd 100644 --- a/docs/cdeq_api.md +++ b/docs/cdeq_api.md @@ -51,18 +51,22 @@ cdeq_X_value* cdeq_X_emplace_front(cdeq_X* self, i_valraw raw); void cdeq_X_pop_front(cdeq_X* self); cdeq_X_value* cdeq_X_push_back(cdeq_X* self, i_val value); +cdeq_X_value* cdeq_X_push(cdeq_X* self, i_val value); // alias for push_back() cdeq_X_value* cdeq_X_emplace_back(cdeq_X* self, i_valraw raw); -void cdeq_X_pop_back(cdeq_X* self); +void cdeq_X_pop_back(cdeq_X* self); +void cdeq_X_pop(cdeq_X* self); // alias for pop_back() 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 cdeq_X_insert_range_p(cdeq_X* self, i_val* pos, + const i_val* p1, const i_val* p2); 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(cdeq_X* self, cdeq_X_iter it, // will clone + cdeq_X_iter it1, cdeq_X_iter it2); cdeq_X_iter cdeq_X_emplace_range_p(cdeq_X* self, i_val* pos, const i_val* p1, const i_val* p2); diff --git a/docs/clist_api.md b/docs/clist_api.md index bbb17796..c22d7bae 100644 --- a/docs/clist_api.md +++ b/docs/clist_api.md @@ -55,11 +55,11 @@ void clist_X_emplace_front(clist_X* self, i_valraw raw); 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_put(clist_X* self, i_val value); // alias for push_back(). +void clist_X_push(clist_X* self, i_val value); // alias for push_back(). void clist_X_emplace_back(clist_X* self, 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 clist_X_insert_at(clist_X* self, clist_X_iter it, i_val value); // return iter to new elem +clist_X_iter clist_X_emplace_at(clist_X* self, clist_X_iter it, i_valraw raw); 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); diff --git a/docs/cmap_api.md b/docs/cmap_api.md index 7f855041..ea0556b7 100644 --- a/docs/cmap_api.md +++ b/docs/cmap_api.md @@ -66,7 +66,7 @@ cmap_X_iter cmap_X_find(const cmap_X* self, i_keyraw rkey); 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 cmap_X_push(cmap_X* self, i_key key, i_val mapped); // alias for insert_or_assign 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 @@ -107,7 +107,7 @@ bool c_memcmp_eq(const i_keyraw* a, const i_keyraw* b); // | `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_result` | `struct { cmap_X_value *ref; bool inserted; }` | Result of insert/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 055d2065..97ac70f5 100644 --- a/docs/cpque_api.md +++ b/docs/cpque_api.md @@ -42,7 +42,6 @@ i_val* cpque_X_top(const cpque_X* self); void cpque_X_make_heap(cpque_X* self); // heapify the vector. void cpque_X_push(cpque_X* self, i_val value); -void cpque_X_put(cpque_X* self, i_val value); // alias for push() void cpque_X_emplace(cpque_X* self, i_valraw raw); // converts from raw void cpque_X_pop(cpque_X* self); diff --git a/docs/cqueue_api.md b/docs/cqueue_api.md index 75105928..0ecae014 100644 --- a/docs/cqueue_api.md +++ b/docs/cqueue_api.md @@ -35,7 +35,6 @@ cqueue_X_value* cqueue_X_front(const cqueue_X* self); cqueue_X_value* cqueue_X_back(const cqueue_X* self); cqueue_X_value* cqueue_X_push(cqueue_X* self, i_val value); -cqueue_X_value* cqueue_X_put(cqueue_X* self, i_val value); // alias for push() cqueue_X_value* cqueue_X_emplace(cqueue_X* self, i_valraw raw); void cqueue_X_pop(cqueue_X* self); diff --git a/docs/cset_api.md b/docs/cset_api.md index 56c2669c..a7970baf 100644 --- a/docs/cset_api.md +++ b/docs/cset_api.md @@ -46,7 +46,7 @@ cset_X_value* cset_X_get_mut(cset_X* self, i_keyraw rkey); cset_X_iter cset_X_find(const cset_X* self, i_keyraw rkey);
cset_X_result cset_X_insert(cset_X* self, i_key key);
-cset_X_result cset_X_put(cset_X* self, i_key key); // alias for insert()
+cset_X_result cset_X_push(cset_X* self, i_key key); // alias for insert()
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
diff --git a/docs/csmap_api.md b/docs/csmap_api.md index e6f5515c..91818624 100644 --- a/docs/csmap_api.md +++ b/docs/csmap_api.md @@ -62,7 +62,7 @@ csmap_X_value* csmap_X_back(const csmap_X* self); 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); // alias for insert_or_assign() +csmap_X_result csmap_X_push(csmap_X* self, i_key key, i_val mapped); // alias for insert_or_assign() 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 diff --git a/docs/csset_api.md b/docs/csset_api.md index 0329a9df..b1bad3bc 100644 --- a/docs/csset_api.md +++ b/docs/csset_api.md @@ -42,7 +42,7 @@ csset_X_value* csset_X_find_it(const csset_X* self, i_keyraw rkey, csset_X csset_X_iter csset_X_lower_bound(const csset_X* self, i_keyraw rkey); // find closest entry >= rkey
csset_X_result csset_X_insert(csset_X* self, i_key key);
-csset_X_result csset_X_put(csset_X* self, i_key key); // alias for insert()
+csset_X_result csset_X_push(csset_X* self, i_key key); // alias for insert()
csset_X_result csset_X_emplace(csset_X* self, i_keyraw rkey);
size_t csset_X_erase(csset_X* self, i_keyraw rkey);
diff --git a/docs/cstack_api.md b/docs/cstack_api.md index e6348489..634f9ee7 100644 --- a/docs/cstack_api.md +++ b/docs/cstack_api.md @@ -41,7 +41,6 @@ i_val* cstack_X_top(const cstack_X* self); const i_val* cstack_X_at(const cstack_X* self, size_t idx); i_val* cstack_X_push(cstack_X* self, i_val value); -i_val* cstack_X_put(cstack_X* self, i_val value); // alias for push i_val* cstack_X_emplace(cstack_X* self, i_valraw raw); void cstack_X_pop(cstack_X* self); diff --git a/docs/cvec_api.md b/docs/cvec_api.md index a1ac6a4f..9dcffdc7 100644 --- a/docs/cvec_api.md +++ b/docs/cvec_api.md @@ -60,18 +60,21 @@ cvec_X_value* cvec_X_back(const cvec_X* self); cvec_X_value* 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_push(cvec_X* self, i_val value); // alias for push_back void cvec_X_pop_back(cvec_X* self); -cvec_X_value* cvec_X_put(cvec_X* self, i_val value); // alias for push_back void cvec_X_pop(cvec_X* self); // alias for pop_back 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_n(cvec_X* self, size_t idx, const i_val[] arr, size_t n); // move n values cvec_X_iter cvec_X_insert_at(cvec_X* self, cvec_X_iter it, i_val value); // move value +cvec_X_iter cvec_X_insert_range_p(cvec_X* self, i_val* pos, + const i_val* p1, const i_val* p2); +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(cvec_X* self, cvec_X_iter it, // will clone + cvec_X_iter it1, cvec_X_iter it2); cvec_X_iter cvec_X_emplace_range_p(cvec_X* self, i_val* pos, const i_val* p1, const i_val* p2); diff --git a/examples/list.c b/examples/list.c index cbf282a5..2d672cf3 100644 --- a/examples/list.c +++ b/examples/list.c @@ -41,7 +41,7 @@ int main() { puts("");
clist_fx_remove(&list, 30);
- clist_fx_insert(&list, clist_fx_begin(&list), 5); // same as push_front()
+ clist_fx_insert_at(&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 it = clist_fx_begin(&list);
diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h index 0b989e22..d603ccbf 100644 --- a/include/stc/alt/csmap.h +++ b/include/stc/alt/csmap.h @@ -38,7 +38,7 @@ int main(void) { 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_push(&m, 5, 'd'); // update
csmap_mx_erase(&m, 8);
c_foreach (i, csmap_mx, m)
@@ -148,7 +148,7 @@ int main(void) { } \
\
STC_INLINE _cx_result \
- _cx_memb(_put)(_cx_self* self, i_key key, i_val mapped) { \
+ _cx_memb(_push)(_cx_self* self, i_key key, i_val mapped) { \
return _cx_memb(_insert_or_assign)(self, key, mapped); \
} \
\
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h index c0b6b05c..351e2244 100644 --- a/include/stc/cdeq.h +++ b/include/stc/cdeq.h @@ -46,7 +46,7 @@ STC_API _cx_self _cx_memb(_with_capacity)(const size_t n); STC_API bool _cx_memb(_reserve)(_cx_self* self, const size_t n);
STC_API void _cx_memb(_clear)(_cx_self* self);
STC_API void _cx_memb(_drop)(_cx_self* self);
-STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value);
+STC_API _cx_value* _cx_memb(_push)(_cx_self* self, i_val value);
STC_API void _cx_memb(_shrink_to_fit)(_cx_self *self);
#if !defined _i_queue
#if !defined _i_no_clone
@@ -72,7 +72,7 @@ STC_API _cx_iter _cx_memb(_insert_range_p)(_cx_self* self, _cx_value* pos STC_API _cx_self _cx_memb(_clone)(_cx_self cx);
#if !defined _i_no_emplace
STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, i_valraw raw)
- { return _cx_memb(_push_back)(self, i_valfrom(raw)); }
+ { return _cx_memb(_push)(self, i_valfrom(raw)); }
#endif
STC_INLINE i_val _cx_memb(_value_clone)(i_val val)
{ return i_valfrom(i_valto(&val)); }
@@ -88,8 +88,8 @@ STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) {c_swap(_cx_se STC_INLINE i_val _cx_memb(_value_fromraw)(i_valraw raw) { return i_valfrom(raw); }
STC_INLINE i_valraw _cx_memb(_value_toraw)(_cx_value* pval) { return i_valto(pval); }
-STC_INLINE _cx_value* _cx_memb(_put)(_cx_self* self, i_val value)
- { return _cx_memb(_push_back)(self, value); }
+STC_INLINE void _cx_memb(_pop)(_cx_self* self)
+ { _cx_value* p = &self->data[--cdeq_rep_(self)->size]; i_valdrop(p); }
STC_INLINE void _cx_memb(_pop_front)(_cx_self* self)
{ i_valdrop(self->data); ++self->data; --cdeq_rep_(self)->size; }
STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self)
@@ -105,10 +105,9 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs) #if !defined _i_queue
-STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) {
- _cx_value* p = &self->data[--cdeq_rep_(self)->size];
- i_valdrop(p);
-}
+STC_INLINE _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value)
+ { return _cx_memb(_push)(self, value); }
+STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) { _cx_memb(_pop)(self); }
STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, const size_t idx) {
assert(idx < cdeq_rep_(self)->size);
@@ -297,7 +296,7 @@ _cx_memb(_reserve)(_cx_self* self, const size_t n) { }
STC_DEF _cx_value*
-_cx_memb(_push_back)(_cx_self* self, i_val value) {
+_cx_memb(_push)(_cx_self* self, i_val value) {
struct cdeq_rep* r = cdeq_rep_(self);
if (_cdeq_nfront(self) + r->size == r->cap) {
_cx_memb(_expand_right_half_)(self, r->size, 1);
diff --git a/include/stc/clist.h b/include/stc/clist.h index 54eb6801..c2df3134 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -93,7 +93,7 @@ STC_API size_t _clist_count(const clist_VOID* self); STC_API void _cx_memb(_drop)(_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(_insert_at)(_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);
#if !c_option(c_no_cmp)
@@ -120,12 +120,12 @@ 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)
{ 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)
- { return _cx_memb(_insert)(self, it, i_valfrom(raw)); }
+STC_INLINE _cx_iter _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_valraw raw)
+ { return _cx_memb(_insert_at)(self, it, i_valfrom(raw)); }
#endif
#endif
-STC_INLINE _cx_value* _cx_memb(_put)(_cx_self* self, i_val value)
+STC_INLINE _cx_value* _cx_memb(_push)(_cx_self* self, i_val value)
{ return _cx_memb(_push_back)(self, value); }
STC_INLINE _cx_self _cx_memb(_init)(void) { return c_make(_cx_self){NULL}; }
STC_INLINE bool _cx_memb(_reserve)(_cx_self* self, size_t n) { return true; }
@@ -217,7 +217,7 @@ _cx_memb(_push_front)(_cx_self* self, i_val value) { }
STC_DEF _cx_iter
-_cx_memb(_insert)(_cx_self* self, _cx_iter it, i_val value) {
+_cx_memb(_insert_at)(_cx_self* self, _cx_iter it, i_val value) {
_cx_node* node = it.ref ? it.prev : self->last;
_c_clist_insert_after(self, _cx_self, node, value);
if (!self->last || !it.ref) {
diff --git a/include/stc/cmap.h b/include/stc/cmap.h index 6fb3974d..3ad53301 100644 --- a/include/stc/cmap.h +++ b/include/stc/cmap.h @@ -171,7 +171,7 @@ _cx_memb(_insert)(_cx_self* self, i_key _key _i_MAP_ONLY(, i_val _mapped)) { }
STC_INLINE _cx_result
-_cx_memb(_put)(_cx_self* self, i_key _key _i_MAP_ONLY(, i_val _mapped)) {
+_cx_memb(_push)(_cx_self* self, i_key _key _i_MAP_ONLY(, i_val _mapped)) {
return _i_SET_ONLY( _cx_memb(_insert)(self, _key) )
_i_MAP_ONLY( _cx_memb(_insert_or_assign)(self, _key, _mapped) );
}
diff --git a/include/stc/cpque.h b/include/stc/cpque.h index c30d1f8b..3fa561ed 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -42,9 +42,6 @@ STC_API void _cx_memb(_make_heap)(_cx_self* self); STC_API void _cx_memb(_erase_at)(_cx_self* self, size_t idx);
STC_API void _cx_memb(_push)(_cx_self* self, _cx_value value);
-STC_INLINE void _cx_memb(_put)(_cx_self* self, _cx_value value)
- { _cx_memb(_push)(self, value); }
-
STC_INLINE _cx_self _cx_memb(_init)(void)
{ return c_make(_cx_self){NULL}; }
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h index 140e08e0..aa3b8d2a 100644 --- a/include/stc/cqueue.h +++ b/include/stc/cqueue.h @@ -57,11 +57,5 @@ int main() { #define _i_prefix cqueue_
#endif
#define _i_queue
-#define _push_back _push
-#define _pop_front _pop
-
#include "cdeq.h"
-
-#undef _push_back
-#undef _pop_front
#undef _i_queue
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index a040203b..87c4de77 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -169,7 +169,7 @@ _cx_memb(_value_drop)(_cx_value* val) { #endif
STC_INLINE _cx_result
-_cx_memb(_put)(_cx_self* self, i_key _key _i_MAP_ONLY(, i_val _mapped)) {
+_cx_memb(_push)(_cx_self* self, i_key _key _i_MAP_ONLY(, i_val _mapped)) {
return _i_SET_ONLY( _cx_memb(_insert)(self, _key) )
_i_MAP_ONLY( _cx_memb(_insert_or_assign)(self, _key, _mapped) );
}
diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 76103139..ba01e116 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -87,9 +87,6 @@ STC_INLINE _cx_value* _cx_memb(_push)(_cx_self* self, _cx_value val) { _cx_value* vp = self->data + self->size++;
*vp = val; return vp;
}
-STC_INLINE _cx_value* _cx_memb(_put)(_cx_self* self, _cx_value val)
- { return _cx_memb(_push)(self, val); }
-
STC_INLINE void _cx_memb(_pop)(_cx_self* self)
{ _cx_value* p = &self->data[--self->size]; i_valdrop(p); }
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index e3a08136..69e95e2b 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -110,6 +110,10 @@ STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* po 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_iter
+_cx_memb(_emplace)(_cx_self* self, const size_t idx, _cx_raw val) {
+ return _cx_memb(_emplace_range_p)(self, self->data + idx, &val, &val + 1);
+}
+STC_INLINE _cx_iter
_cx_memb(_emplace_n)(_cx_self* self, const size_t idx, const _cx_raw arr[], const size_t n) {
return _cx_memb(_emplace_range_p)(self, self->data + idx, arr, arr + n);
}
@@ -132,7 +136,7 @@ STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_s 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(_put)(_cx_self* self, i_val value)
+STC_INLINE _cx_value* _cx_memb(_push)(_cx_self* self, i_val value)
{ return _cx_memb(_push_back)(self, value); }
STC_INLINE void _cx_memb(_pop_back)(_cx_self* self)
{ _cx_value* p = &self->data[--cvec_rep_(self)->size]; i_valdrop(p); }
|
