summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/stc/cdeq.h8
-rw-r--r--include/stc/clist.h7
-rw-r--r--include/stc/cmap.h8
-rw-r--r--include/stc/csmap.h6
-rw-r--r--include/stc/cvec.h14
5 files changed, 31 insertions, 12 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index ab454247..2cdedcd8 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -112,7 +112,7 @@ STC_INLINE void _cx_memb(_pop_back)(_cx_self* self) {
i_valdel(p);
}
-STC_INLINE _cx_value* _cx_memb(_at)(const _cx_self* self, size_t idx) {
+STC_INLINE const _cx_value* _cx_memb(_at)(const _cx_self* self, size_t idx) {
assert(idx < cdeq_rep_(self)->size);
return self->data + idx;
}
@@ -175,13 +175,17 @@ _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)(_cx_self* self, i_valraw raw)
+ { return (_cx_value *) _cx_memb(_get)(self, raw); }
+
STC_INLINE void
_cx_memb(_sort_range)(_cx_iter i1, _cx_iter i2,
int(*_cmp_)(const _cx_value*, const _cx_value*)) {
diff --git a/include/stc/clist.h b/include/stc/clist.h
index a97c9526..5ae56634 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -166,11 +166,16 @@ _cx_memb(_find)(const _cx_self* self, i_valraw val) {
return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val);
}
-STC_INLINE _cx_value*
+STC_INLINE const _cx_value*
_cx_memb(_get)(const _cx_self* self, i_valraw val) {
return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val).ref;
}
+STC_INLINE _cx_value*
+_cx_memb(_mutget)(_cx_self* self, i_valraw val) {
+ return _cx_memb(_find_in)(_cx_memb(_begin)(self), _cx_memb(_end)(self), val).ref;
+}
+
// -------------------------- IMPLEMENTATION -------------------------
#if !defined(STC_HEADER) || defined(STC_IMPLEMENTATION) || defined(i_imp)
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 0c5aab4e..cccf3199 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -117,7 +117,7 @@ cx_MAP_ONLY(
return _cx_memb(_insert_or_assign)(self, key, mapped);
}
- STC_INLINE _cx_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);
assert(self->_hashx[b.idx]);
@@ -169,13 +169,17 @@ _cx_memb(_find)(const _cx_self* self, i_keyraw rkey) {
return c_make(_cx_iter){self->table+idx, self->_hashx+idx};
}
-STC_INLINE _cx_value*
+STC_INLINE const _cx_value*
_cx_memb(_get)(const _cx_self* self, i_keyraw rkey) {
_cx_size idx;
return self->size && self->_hashx[idx = _cx_memb(_bucket_)(self, &rkey).idx] ?
self->table + idx : NULL;
}
+STC_INLINE _cx_value*
+_cx_memb(_mutget)(const _cx_self* self, i_keyraw rkey)
+ { return (_cx_value*) _cx_memb(_get)(self, rkey); }
+
STC_INLINE _cx_iter
_cx_memb(_begin)(const _cx_self* self) {
_cx_iter it = {self->table, self->_hashx};
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index 3319d435..4eedb60d 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -114,7 +114,9 @@ STC_INLINE void _cx_memb(_clear)(_cx_self* self) { _cx_memb(_del)(self);
STC_INLINE void _cx_memb(_swap)(_cx_self* a, _cx_self* b) { c_swap(_cx_self, *a, *b); }
STC_INLINE bool _cx_memb(_contains)(const _cx_self* self, i_keyraw rkey)
{ _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it) != NULL; }
-STC_INLINE _cx_value* _cx_memb(_get)(const _cx_self* self, i_keyraw rkey)
+STC_INLINE const _cx_value* _cx_memb(_get)(const _cx_self* self, i_keyraw rkey)
+ { _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); }
+STC_INLINE _cx_value* _cx_memb(_mutget)(_cx_self* self, i_keyraw rkey)
{ _cx_iter it; return _cx_memb(_find_it)(self, rkey, &it); }
STC_INLINE _cx_self
@@ -156,7 +158,7 @@ cx_MAP_ONLY(
_cx_memb(_put)(_cx_self* self, i_key key, i_val mapped)
{ return _cx_memb(_insert_or_assign)(self, key, mapped); }
- STC_INLINE _cx_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; }
)
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*)) {