diff options
| author | Tyge Løvset <[email protected]> | 2021-11-03 11:30:06 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-11-03 11:30:06 +0100 |
| commit | e259ed7807dd9474cc94ba625db4dcd573431362 (patch) | |
| tree | 0e83bf2d49a1f0ec43f9e9b0b74c69ef4fd97a1b /include/stc/cvec.h | |
| parent | 73b1ed7c17b94647438c7e73738bf0820e5d57ad (diff) | |
| download | STC-modified-e259ed7807dd9474cc94ba625db4dcd573431362.tar.gz STC-modified-e259ed7807dd9474cc94ba625db4dcd573431362.zip | |
Changed container_X_get() and container_X_at() to return const value* (or const mapped*). Added container_X_getmut() for mutable version. Updated docs.
Diffstat (limited to 'include/stc/cvec.h')
| -rw-r--r-- | include/stc/cvec.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index 92c8f5bd..2e1dcd6e 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -186,7 +186,7 @@ _cx_memb(_erase_range)(_cx_self* self, _cx_iter it1, _cx_iter it2) { return _cx_memb(_erase_range_p)(self, it1.ref, it2.ref);
}
-STC_INLINE _cx_value*
+STC_INLINE const _cx_value*
_cx_memb(_at)(const _cx_self* self, size_t idx) {
assert(idx < cvec_rep_(self)->size);
return self->data + idx;
@@ -197,17 +197,21 @@ _cx_memb(_find)(const _cx_self* self, i_valraw raw) { return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw);
}
-STC_INLINE _cx_value*
+STC_INLINE const _cx_value*
_cx_memb(_get)(const _cx_self* self, i_valraw raw) {
_cx_iter end = _cx_memb(_end)(self);
_cx_value* val = _cx_memb(_find_in)(_cx_memb(_begin)(self), end, raw).ref;
return val == end.ref ? NULL : val;
}
+STC_INLINE _cx_value*
+_cx_memb(_mutget)(const _cx_self* self, i_valraw raw)
+ { return (_cx_value*) _cx_memb(_get)(self, raw); }
+
STC_INLINE _cx_iter
-_cx_memb(_bsearch)(const _cx_self* self, i_valraw raw) {
- return _cx_memb(_bsearch_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw);
-}
+_cx_memb(_bsearch)(const _cx_self* self, i_valraw raw)
+ { return _cx_memb(_bsearch_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), raw); }
+
STC_INLINE void
_cx_memb(_sort_range)(_cx_iter i1, _cx_iter i2,
int(*_cmp_)(const _cx_value*, const _cx_value*)) {
|
