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 /include/stc | |
| 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.
Diffstat (limited to 'include/stc')
| -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 |
9 files changed, 22 insertions, 31 deletions
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); }
|
