diff options
| author | Tyge Løvset <[email protected]> | 2022-09-02 22:09:24 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-09-02 22:09:24 +0200 |
| commit | a2a18a52df4fc10ad453eba7cdfbe2d02a026f0b (patch) | |
| tree | 40073f5fb52292a3965824e086eab379440386af /include | |
| parent | 1fe32468be872bf99698bc899164d56d6b6c80c5 (diff) | |
| download | STC-modified-a2a18a52df4fc10ad453eba7cdfbe2d02a026f0b.tar.gz STC-modified-a2a18a52df4fc10ad453eba7cdfbe2d02a026f0b.zip | |
Removed cstack_X_push_back(), cstack_X_emplace_back(), cstack_X_pop_back().
Added a simple c_erase_if(). Removed deprecated c_apply() macro.
Diffstat (limited to 'include')
| -rw-r--r-- | include/stc/ccommon.h | 17 | ||||
| -rw-r--r-- | include/stc/cstack.h | 6 |
2 files changed, 8 insertions, 15 deletions
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h index 58d74ddf..0c724d55 100644 --- a/include/stc/ccommon.h +++ b/include/stc/ccommon.h @@ -206,14 +206,6 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, *b = (n)*sizeof *b > (BYTES) ? c_alloc_n(type, n) : _c_b \ ; b; b != _c_b ? c_free(b) : (void)0, b = NULL) -// [deprecated] use c_forarray. -#define c_apply(v, action, T, ...) do { \ - typedef T _T; \ - _T _arr[] = __VA_ARGS__, *v = _arr; \ - const _T *_end = v + c_arraylen(_arr); \ - while (v != _end) { action; ++v; } \ -} while (0) - #define c_forarray(T, v, ...) \ for (T _a[] = __VA_ARGS__, *v = _a; v != _a + c_arraylen(_a); ++v) @@ -223,7 +215,6 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, #define c_pair(v) (v)->first, (v)->second #define c_drop(C, ...) do { c_forarray_p(C*, _p, {__VA_ARGS__}) C##_drop(*_p); } while(0) -// it.ref == NULL when not found: #define c_find_if(it, C, cnt, pred) do { \ size_t index = 0; \ for (it = C##_begin(&cnt); it.ref && !(pred); C##_next(&it)) \ @@ -237,6 +228,14 @@ STC_INLINE char* c_strnstrn(const char *s, const char *needle, ++index; \ if (it.ref == _endref) it.ref = NULL; \ } while (0) + +#define c_erase_if(it, C, cnt, pred) do { \ + C##_iter it = C##_begin(&cnt); \ + while (it.ref) \ + if (pred) it = C##_erase_at(&cnt, it); \ + else C##_next(&it); \ +} while (0) + #endif // CCOMMON_H_INCLUDED #undef STC_API diff --git a/include/stc/cstack.h b/include/stc/cstack.h index 9ed2beda..921e6618 100644 --- a/include/stc/cstack.h +++ b/include/stc/cstack.h @@ -133,13 +133,9 @@ 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_keydrop(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; } @@ -149,8 +145,6 @@ STC_INLINE _cx_value* _cx_memb(_at_mut)(_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_keyfrom(raw)); } -STC_INLINE _cx_value* _cx_memb(_emplace_back)(_cx_self* self, _cx_raw raw) - { return _cx_memb(_push)(self, i_keyfrom(raw)); } #endif // !_i_no_emplace #if !defined _i_no_clone |
