summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-15 22:08:12 +0200
committerTyge Løvset <[email protected]>2022-04-15 22:08:12 +0200
commitfa261ddd307de9b7bb2965a066fd83b66d8d83a7 (patch)
treef89c186fdaaedb8ab34c223e1a75f4d25db612ab /include
parent99acd2149f3f8996249b3ef82f7490dd098783d7 (diff)
downloadSTC-modified-fa261ddd307de9b7bb2965a066fd83b66d8d83a7.tar.gz
STC-modified-fa261ddd307de9b7bb2965a066fd83b66d8d83a7.zip
Updated README.md docs on template args! Reverted to put() as alias for insert_or_assign() for maps. Reverted/added push_back()/emplace_back()/pop_back() to cstack.
Diffstat (limited to 'include')
-rw-r--r--include/stc/alt/csmap.h2
-rw-r--r--include/stc/cdeq.h15
-rw-r--r--include/stc/clist.h2
-rw-r--r--include/stc/cmap.h15
-rw-r--r--include/stc/cqueue.h2
-rw-r--r--include/stc/csmap.h14
-rw-r--r--include/stc/cstack.h7
-rw-r--r--include/stc/cvec.h6
8 files changed, 27 insertions, 36 deletions
diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h
index a2200028..cb976801 100644
--- a/include/stc/alt/csmap.h
+++ b/include/stc/alt/csmap.h
@@ -148,7 +148,7 @@ int main(void) {
} \
\
STC_INLINE _cx_result \
- _cx_memb(_push)(_cx_self* self, i_key key, i_val mapped) { \
+ _cx_memb(_put)(_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 c510b3e0..e562eaee 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)(_cx_self* self, i_val value);
+STC_API _cx_value* _cx_memb(_push_back)(_cx_self* self, i_val value);
STC_API void _cx_memb(_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)(self, i_valfrom(raw)); }
+ { return _cx_memb(_push_back)(self, i_valfrom(raw)); }
#endif
STC_INLINE i_val _cx_memb(_value_clone)(i_val val)
{ i_valraw r = i_valto((&val)); return i_valfrom(r); }
@@ -103,9 +103,6 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs)
#if !defined _i_queue
-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_value* p = &self->data[--cdeq_rep_(self)->size]; i_valdrop(p); }
@@ -156,10 +153,6 @@ STC_INLINE _cx_value* _cx_memb(_emplace_front)(_cx_self* self, i_valraw raw) {
}
STC_INLINE _cx_iter
-_cx_memb(_emplace)(_cx_self* self, const size_t idx, i_valraw raw) {
- return _cx_memb(_emplace_range_p)(self, self->data + idx, &raw, &raw + 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);
}
@@ -295,8 +288,8 @@ _cx_memb(_reserve)(_cx_self* self, const size_t n) {
return n <= sz || _cx_memb(_expand_right_half_)(self, sz, n - sz);
}
-STC_DEF _cx_value* // push back
-_cx_memb(_push)(_cx_self* self, i_val value) {
+STC_DEF _cx_value*
+_cx_memb(_push_back)(_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 0ff59967..7b56bae4 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -125,8 +125,6 @@ STC_INLINE _cx_iter _cx_memb(_emplace_at)(_cx_self* self, _cx_iter it, i_val
#endif
#endif
-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; }
STC_INLINE bool _cx_memb(_empty)(_cx_self cx) { return cx.last == NULL; }
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 707e26f0..340cba87 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -110,13 +110,15 @@ STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey)
{ return self->size && self->_hashx[_cx_memb(_bucket_)(self, &rkey).idx]; }
#ifndef _i_isset
- #if !defined _i_no_clone
- #if !defined _i_no_emplace
+ #if !defined _i_no_clone && !defined _i_no_emplace
STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped);
#endif
- #endif
STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key _key, i_val _mapped);
+ STC_INLINE _cx_result
+ _cx_memb(_put)(_cx_self* self, i_key _key, i_val _mapped)
+ { return _cx_memb(_insert_or_assign)(self, _key, _mapped); }
+
STC_INLINE const _cx_mapped*
_cx_memb(_at)(const _cx_self* self, i_keyraw rkey) {
chash_bucket_t b = _cx_memb(_bucket_)(self, &rkey);
@@ -137,6 +139,7 @@ _cx_memb(_value_clone)(_cx_value _val) {
_i_MAP_ONLY( i_valraw m = i_valto((&_val.second)); _val.second = i_valfrom(m); )
return _val;
}
+
#if !defined _i_no_emplace
STC_INLINE _cx_result
_cx_memb(_emplace)(_cx_self* self, i_keyraw rkey _i_MAP_ONLY(, i_valraw rmapped)) {
@@ -170,12 +173,6 @@ _cx_memb(_insert)(_cx_self* self, i_key _key _i_MAP_ONLY(, i_val _mapped)) {
return _res;
}
-STC_INLINE _cx_result
-_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) );
-}
-
STC_INLINE _cx_iter
_cx_memb(_find)(const _cx_self* self, i_keyraw rkey) {
_cx_size idx;
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h
index 92cf4c49..18ac6d08 100644
--- a/include/stc/cqueue.h
+++ b/include/stc/cqueue.h
@@ -57,11 +57,13 @@ int main() {
#define _i_prefix cqueue_
#endif
#define _i_queue
+#define _push_back _push
#define _emplace_back _emplace
#define _pop_front _pop
#include "cdeq.h"
+#undef _push_back
#undef _emplace_back
#undef _pop_front
#undef _i_queue
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index af36db6c..be726723 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -156,24 +156,20 @@ _cx_memb(_value_drop)(_cx_value* val) {
}
#ifndef _i_isset
- #if !defined _i_no_clone
- #if !defined _i_no_emplace
+ #if !defined _i_no_clone && !defined _i_no_emplace
STC_API _cx_result _cx_memb(_emplace_or_assign)(_cx_self* self, i_keyraw rkey, i_valraw rmapped);
#endif
- #endif
STC_API _cx_result _cx_memb(_insert_or_assign)(_cx_self* self, i_key key, i_val mapped);
+
+ STC_INLINE _cx_result
+ _cx_memb(_put)(_cx_self* self, i_key _key, i_val _mapped)
+ { return _cx_memb(_insert_or_assign)(self, _key, _mapped); }
STC_INLINE const _cx_mapped*
_cx_memb(_at)(const _cx_self* self, i_keyraw rkey)
{ _cx_iter it; return &_cx_memb(_find_it)(self, rkey, &it)->second; }
#endif
-STC_INLINE _cx_result
-_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) );
-}
-
STC_INLINE _cx_iter
_cx_memb(_find)(const _cx_self* self, i_keyraw rkey) {
_cx_iter it;
diff --git a/include/stc/cstack.h b/include/stc/cstack.h
index c5d77ed1..b3f5d5e2 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -87,8 +87,13 @@ 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(_push_back)(_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); }
+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, size_t idx)
{ assert(idx < self->size); return self->data + idx; }
@@ -97,6 +102,8 @@ STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t idx)
#if !defined _i_no_emplace
STC_INLINE _cx_value* _cx_memb(_emplace)(_cx_self* self, _cx_raw raw)
{ return _cx_memb(_push)(self, i_valfrom(raw)); }
+STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, _cx_raw raw)
+ { return _cx_memb(_push)(self, i_valfrom(raw)); }
#endif
STC_INLINE _cx_self _cx_memb(_clone)(_cx_self v) {
_cx_self out = {(_cx_value *) c_malloc(v.size*sizeof(_cx_value)), v.size, v.size};
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 79506a28..b671413b 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -109,10 +109,8 @@ STC_API _cx_iter _cx_memb(_emplace_range_p)(_cx_self* self, _cx_value* po
const _cx_raw* p1, const _cx_raw* p2);
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_value* _cx_memb(_emplace)(_cx_self* self, i_valraw raw)
+ { return _cx_memb(_push_back)(self, i_valfrom(raw)); }
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);