diff options
| author | Tyge Løvset <[email protected]> | 2023-05-18 15:39:48 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-05-18 15:48:45 +0200 |
| commit | c54da07eb171455ad182d61a1fb5c4e4520aebbb (patch) | |
| tree | e14e7796f075a37d8dd05ff22bf8bfe4d10b6eee /include/stc/cqueue.h | |
| parent | 50a16934dde8e65bbcf628d6342c1649f7e09365 (diff) | |
| download | STC-modified-c54da07eb171455ad182d61a1fb5c4e4520aebbb.tar.gz STC-modified-c54da07eb171455ad182d61a1fb5c4e4520aebbb.zip | |
Fixing find_in() in cdeq, and add support c_eraseremove_if() for cqueue and cdeq.
Diffstat (limited to 'include/stc/cqueue.h')
| -rw-r--r-- | include/stc/cqueue.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/include/stc/cqueue.h b/include/stc/cqueue.h index 09a747e5..d880d1fd 100644 --- a/include/stc/cqueue.h +++ b/include/stc/cqueue.h @@ -76,17 +76,14 @@ STC_INLINE bool _cx_memb(_empty)(const _cx_self* self) STC_INLINE _cx_raw _cx_memb(_value_toraw)(const _cx_value* pval) { return i_keyto(pval); } -STC_INLINE _cx_value* -_cx_memb(_front)(const _cx_self* self) - { return self->data + self->start; } +STC_INLINE _cx_value* _cx_memb(_front)(const _cx_self* self) + { return self->data + self->start; } -STC_INLINE _cx_value* -_cx_memb(_back)(const _cx_self* self) - { return self->data + ((self->end - 1) & self->capmask); } +STC_INLINE _cx_value* _cx_memb(_back)(const _cx_self* self) + { return self->data + ((self->end - 1) & self->capmask); } -STC_INLINE void -_cx_memb(_pop)(_cx_self* self) { // pop_front - c_ASSERT(!_cx_memb(_empty)(self)); +STC_INLINE void _cx_memb(_pop)(_cx_self* self) { // pop_front + assert(!_cx_memb(_empty)(self)); i_keydrop((self->data + self->start)); self->start = (self->start + 1) & self->capmask; } @@ -97,25 +94,28 @@ STC_INLINE void _cx_memb(_copy)(_cx_self* self, const _cx_self* other) { *self = _cx_memb(_clone)(*other); } -STC_INLINE _cx_iter -_cx_memb(_begin)(const _cx_self* self) { +STC_INLINE _cx_iter _cx_memb(_begin)(const _cx_self* self) { return c_LITERAL(_cx_iter){ _cx_memb(_empty)(self) ? NULL : self->data + self->start, self->start, self }; } -STC_INLINE _cx_iter -_cx_memb(_end)(const _cx_self* self) - { return c_LITERAL(_cx_iter){NULL, self->end, self}; } +STC_INLINE _cx_iter _cx_memb(_end)(const _cx_self* self) + { return c_LITERAL(_cx_iter){.pos=self->end, ._s=self}; } -STC_INLINE void -_cx_memb(_next)(_cx_iter* it) { +STC_INLINE void _cx_memb(_next)(_cx_iter* it) { if (it->pos != it->_s->capmask) { ++it->ref; ++it->pos; } else { it->ref -= it->pos; it->pos = 0; } if (it->pos == it->_s->end) it->ref = NULL; } +STC_INLINE intptr_t _cx_memb(_index)(const _cx_self* self, _cx_iter it) + { return _cdeq_toidx(self, it.pos); } + +STC_INLINE void _cx_memb(_adjust_end_)(_cx_self* self, intptr_t n) + { self->end = (self->end + n) & self->capmask; } + /* -------------------------- IMPLEMENTATION ------------------------- */ #if defined(i_implement) |
