summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2021-03-06 10:17:29 +0100
committerTyge Løvset <[email protected]>2021-03-06 10:17:29 +0100
commit7188a160ac084b65de07c26797fd74e29fd8b0b8 (patch)
tree90443fd2a7d049ec39f6c98ab8a8aace38a21ae4 /examples
parentc84c79691da8dfd0852bf515b69b121754fc3826 (diff)
downloadSTC-modified-7188a160ac084b65de07c26797fd74e29fd8b0b8.tar.gz
STC-modified-7188a160ac084b65de07c26797fd74e29fd8b0b8.zip
Cleanups and internal renames. Backported csmap_v1.h in examples to match csmap.h
Diffstat (limited to 'examples')
-rw-r--r--examples/csmap_v1.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/examples/csmap_v1.h b/examples/csmap_v1.h
index 1678c76f..b209e25b 100644
--- a/examples/csmap_v1.h
+++ b/examples/csmap_v1.h
@@ -230,14 +230,6 @@ int main(void) {
} \
return res; \
} \
- STC_INLINE C##_##X##_result_t \
- C##_##X##_emplace_or_assign(C##_##X* self, RawKey rkey MAP_ONLY_##C(, RawMapped rmapped)) { \
- C##_##X##_result_t res = C##_##X##_insert_entry_(self, rkey); \
- if (res.second) *KEY_REF_##C(res.first) = keyFromRaw(rkey); \
- MAP_ONLY_##C( else mappedDel(&res.first->second); \
- res.first->second = mappedFromRaw(rmapped); ) \
- return res; \
- } \
STC_INLINE void \
C##_##X##_emplace_n(C##_##X* self, const C##_##X##_rawvalue_t arr[], size_t n) { \
for (size_t i=0; i<n; ++i) SET_ONLY_##C( C##_##X##_emplace(self, arr[i]); ) \
@@ -256,9 +248,20 @@ int main(void) {
STC_INLINE C##_##X##_result_t \
C##_##X##_insert_or_assign(C##_##X* self, Key key, Mapped mapped) { \
C##_##X##_result_t res = C##_##X##_insert_entry_(self, keyToRaw(&key)); \
- if (res.second) res.first->first = key; else keyDel(&key); \
- mappedDel(&res.first->second); res.first->second = mapped; \
- return res; \
+ if (res.second) res.first->first = key; \
+ else {keyDel(&key); mappedDel(&res.first->second);} \
+ res.first->second = mapped; return res; \
+ } \
+ STC_INLINE C##_##X##_result_t \
+ C##_##X##_put(C##_##X* self, Key k, Mapped m) { \
+ return C##_##X##_insert_or_assign(self, k, m); \
+ } \
+ STC_INLINE C##_##X##_result_t \
+ C##_##X##_emplace_or_assign(C##_##X* self, RawKey rkey, RawMapped rmapped) { \
+ C##_##X##_result_t res = C##_##X##_insert_entry_(self, rkey); \
+ if (res.second) res.first->first = keyFromRaw(rkey); \
+ else mappedDel(&res.first->second); \
+ res.first->second = mappedFromRaw(rmapped); return res; \
} \
STC_INLINE C##_##X##_mapped_t* \
C##_##X##_at(const C##_##X* self, RawKey rkey) { \