summaryrefslogtreecommitdiffhomepage
path: root/include/stc/cpque.h
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-04-21 13:47:54 +0200
committerTyge Løvset <[email protected]>2022-04-21 13:47:54 +0200
commitd122c77b5a755cd5b3211c26346a84bb2b27cdce (patch)
treea66aba11b04670c84cca9034e7266014e2052e8f /include/stc/cpque.h
parent91385d449d03145cfe8cc91f2704d4b24c63d37e (diff)
downloadSTC-modified-d122c77b5a755cd5b3211c26346a84bb2b27cdce.tar.gz
STC-modified-d122c77b5a755cd5b3211c26346a84bb2b27cdce.zip
Switched to use i_key as primary template type parameter for all containers. Only maps will actually use i_val.
Users can still specify i_val for non-maps, so there are no usability changes, other than the option to use i_key always, which makes the implementation and switching between container types simpler.
Diffstat (limited to 'include/stc/cpque.h')
-rw-r--r--include/stc/cpque.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/include/stc/cpque.h b/include/stc/cpque.h
index 9844fc93..4b330707 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -34,9 +34,9 @@
#include "template.h"
#if !c_option(c_is_fwd)
- _cx_deftypes(_c_cpque_types, _cx_self, i_val);
+ _cx_deftypes(_c_cpque_types, _cx_self, i_key);
#endif
-typedef i_valraw _cx_raw;
+typedef i_keyraw _cx_raw;
STC_API void _cx_memb(_make_heap)(_cx_self* self);
STC_API void _cx_memb(_erase_at)(_cx_self* self, size_t idx);
@@ -59,7 +59,7 @@ STC_INLINE _cx_self _cx_memb(_with_capacity)(const size_t cap) {
return out;
}
-STC_INLINE _cx_self _cx_memb(_with_size)(const size_t size, i_val null) {
+STC_INLINE _cx_self _cx_memb(_with_size)(const size_t size, i_key null) {
_cx_self out = {NULL}; _cx_memb(_reserve)(&out, size);
while (out.size < size) out.data[out.size++] = null;
return out;
@@ -67,7 +67,7 @@ STC_INLINE _cx_self _cx_memb(_with_size)(const size_t size, i_val null) {
STC_INLINE void _cx_memb(_clear)(_cx_self* self) {
size_t i = self->size; self->size = 0;
- while (i--) { i_valdrop((self->data + i)); }
+ while (i--) { i_keydrop((self->data + i)); }
}
STC_INLINE void _cx_memb(_drop)(_cx_self* self)
@@ -95,12 +95,12 @@ STC_INLINE void _cx_memb(_copy)(_cx_self *self, _cx_self other) {
if (self->data == other.data) return;
_cx_memb(_drop)(self); *self = _cx_memb(_clone)(other);
}
-STC_INLINE i_val _cx_memb(_value_clone)(_cx_value val)
- { return i_valclone(val); }
+STC_INLINE i_key _cx_memb(_value_clone)(_cx_value val)
+ { return i_keyclone(val); }
#if !defined _i_no_emplace
STC_INLINE void _cx_memb(_emplace)(_cx_self* self, _cx_raw raw)
- { _cx_memb(_push)(self, i_valfrom(raw)); }
+ { _cx_memb(_push)(self, i_keyfrom(raw)); }
#endif // !_i_no_emplace
#endif // !_i_no_clone
@@ -128,14 +128,14 @@ _cx_memb(_make_heap)(_cx_self* self) {
STC_DEF _cx_self _cx_memb(_clone)(_cx_self q) {
_cx_self out = _cx_memb(_with_capacity)(q.size);
for (; out.size < out.capacity; ++q.data)
- out.data[out.size++] = i_valclone((*q.data));
+ out.data[out.size++] = i_keyclone((*q.data));
return out;
}
#endif
STC_DEF void
_cx_memb(_erase_at)(_cx_self* self, const size_t idx) {
- i_valdrop((self->data + idx));
+ i_keydrop((self->data + idx));
const size_t n = --self->size;
self->data[idx] = self->data[n];
_cx_memb(_sift_down_)(self->data - 1, idx + 1, n);