summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cdeq.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-01-19 19:27:07 +0100
committerTyge Løvset <[email protected]>2023-01-19 19:27:07 +0100
commit5aa48d538569463ffeda976d21f79edc5f276be4 (patch)
tree6bbd87bc9e5041b2c3b69e14ec175536b8418630 /include/stc/cdeq.h
parent0c4c4f8bba17562735b67b2923cd23c773aa53a7 (diff)
downloadSTC-modified-5aa48d538569463ffeda976d21f79edc5f276be4.tar.gz
STC-modified-5aa48d538569463ffeda976d21f79edc5f276be4.zip
Add a from_n() method to containers (and put_n() to maps), to support new initialization.
Diffstat (limited to 'include/stc/cdeq.h')
-rw-r--r--include/stc/cdeq.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index 1fe52548..b555da63 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -48,7 +48,10 @@ STC_API void _cx_memb(_clear)(_cx_self* self);
STC_API void _cx_memb(_drop)(_cx_self* self);
STC_API _cx_value* _cx_memb(_push)(_cx_self* self, i_key value);
STC_API void _cx_memb(_shrink_to_fit)(_cx_self *self);
-
+STC_INLINE void _cx_memb(_put_n)(_cx_self* self, const _cx_raw* raw, size_t n)
+ { while (n--) _cx_memb(_push)(self, i_keyfrom(*raw++)); }
+STC_INLINE _cx_self _cx_memb(_from_n)(const _cx_raw* raw, size_t n)
+ { _cx_self cx = {0}; _cx_memb(_put_n)(&cx, raw, n); return cx; }
#if !defined _i_queue
#if !defined i_no_emplace
STC_API _cx_iter _cx_memb(_emplace_range)(_cx_self* self, _cx_value* pos,