summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-10 20:06:14 +0200
committerTyge Løvset <[email protected]>2022-04-10 20:06:14 +0200
commit2e781ef2c6956d9b4e11f08bdd23477c3b34ee2f (patch)
treef0298c2301594991a398fbab692bc8f1d5832ad5 /include
parent0500c38d693c9157e522dd7198982b9c7aeb8651 (diff)
downloadSTC-modified-2e781ef2c6956d9b4e11f08bdd23477c3b34ee2f.tar.gz
STC-modified-2e781ef2c6956d9b4e11f08bdd23477c3b34ee2f.zip
Fixed regression bug: cqueue_pop() did pop_back(), fixed to do pop_front().
Removed pop() functions in clist and cdeq as they are no standard. push() will push_back() for both.
Diffstat (limited to 'include')
-rw-r--r--include/stc/cdeq.h10
-rw-r--r--include/stc/cqueue.h6
2 files changed, 11 insertions, 5 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 5113af8c..c510b3e0 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -88,9 +88,7 @@ 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 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)
+STC_INLINE void _cx_memb(_pop_front)(_cx_self* self) // == _pop() when _i_queue
{ i_valdrop(self->data); ++self->data; --cdeq_rep_(self)->size; }
STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self)
{ return self->data + cdeq_rep_(self)->size - 1; }
@@ -107,7 +105,9 @@ STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, intptr_t offs)
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 void _cx_memb(_pop_back)(_cx_self* self)
+ { _cx_value* p = &self->data[--cdeq_rep_(self)->size]; i_valdrop(p); }
STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, const size_t idx) {
assert(idx < cdeq_rep_(self)->size);
@@ -295,7 +295,7 @@ _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*
+STC_DEF _cx_value* // push back
_cx_memb(_push)(_cx_self* self, i_val value) {
struct cdeq_rep* r = cdeq_rep_(self);
if (_cdeq_nfront(self) + r->size == r->cap) {
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h
index aa3b8d2a..92cf4c49 100644
--- a/include/stc/cqueue.h
+++ b/include/stc/cqueue.h
@@ -57,5 +57,11 @@ int main() {
#define _i_prefix cqueue_
#endif
#define _i_queue
+#define _emplace_back _emplace
+#define _pop_front _pop
+
#include "cdeq.h"
+
+#undef _emplace_back
+#undef _pop_front
#undef _i_queue