summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-27 12:41:24 +0200
committerTyge Løvset <[email protected]>2023-04-27 12:41:24 +0200
commitba3f2284731e50100d249cf1d825b8d24efad658 (patch)
tree888fd07f8dac722c913cb3bd7358dd20dafce70c
parent9d5766ae528595050dcfe0db4c1c3c0c058b186c (diff)
downloadSTC-modified-ba3f2284731e50100d249cf1d825b8d24efad658.tar.gz
STC-modified-ba3f2284731e50100d249cf1d825b8d24efad658.zip
removing compiler warning ++.
-rw-r--r--README.md2
-rw-r--r--docs/cmap_api.md4
-rw-r--r--include/stc/algo/filter.h9
-rw-r--r--include/stc/ccommon.h2
-rw-r--r--include/stc/cmap.h2
5 files changed, 9 insertions, 10 deletions
diff --git a/README.md b/README.md
index 65d00324..f571c280 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
STC - Smart Template Containers
===============================
-### [Version 4.2](#version-history)
+### [Version 4.3 beta](#version-history)
---
Description
diff --git a/docs/cmap_api.md b/docs/cmap_api.md
index 94f1c54e..cdb57534 100644
--- a/docs/cmap_api.md
+++ b/docs/cmap_api.md
@@ -9,8 +9,8 @@ hashing (aka open addressing) with linear probing, and without leaving tombstone
***Iterator invalidation***: References and iterators are invalidated after erase. No iterators are invalidated after insert,
unless the hash-table need to be extended. The hash table size can be reserved prior to inserts if the total max size is known.
-The order of elements is preserved after erase and insert. This makes it possible to erase individual elements while iterating
-through the container by using the returned iterator from *erase_at()*, which references the next element.
+The order of elements may not be preserved after erase. It is still possible to erase elements when iterating through
+the container by setting the iterator to the value returned from *erase_at()*, which references the next element. Note that a small number of elements may be visited twice when doing this, but all elements will be visited.
See the c++ class [std::unordered_map](https://en.cppreference.com/w/cpp/container/unordered_map) for a functional description.
diff --git a/include/stc/algo/filter.h b/include/stc/algo/filter.h
index e133577c..db076ae4 100644
--- a/include/stc/algo/filter.h
+++ b/include/stc/algo/filter.h
@@ -89,8 +89,7 @@ int main()
// Use with: clist, cmap, cset, csmap, csset:
#define c_erase_if(it, C, cnt, pred) do { \
C* _cnt = &cnt; \
- intptr_t _index = 0; \
- for (C##_iter it = C##_begin(_cnt); it.ref; ++_index) { \
+ for (C##_iter it = C##_begin(_cnt); it.ref; ) { \
if (pred) it = C##_erase_at(_cnt, it); \
else C##_next(&it); \
} \
@@ -100,11 +99,11 @@ int main()
// Use with: cstack, cvec, cdeq, cqueue:
#define c_eraseremove_if(it, C, cnt, pred) do { \
C* _cnt = &cnt; \
- intptr_t _n = 0, _index = 0; \
+ intptr_t _n = 0; \
C##_iter it = C##_begin(_cnt), _i; \
while (it.ref && !(pred)) \
- C##_next(&it), ++_index; \
- for (_i = it; it.ref; C##_next(&it), ++_index) \
+ C##_next(&it); \
+ for (_i = it; it.ref; C##_next(&it)) \
if (pred) C##_value_drop(it.ref), ++_n; \
else *_i.ref = *it.ref, C##_next(&_i); \
_cnt->_len -= _n; \
diff --git a/include/stc/ccommon.h b/include/stc/ccommon.h
index 4f9fa398..73a3d5ef 100644
--- a/include/stc/ccommon.h
+++ b/include/stc/ccommon.h
@@ -147,7 +147,7 @@ STC_INLINE uint64_t cfasthash(const void* key, intptr_t len) {
case 0: return 1;
}
const uint8_t *x = (const uint8_t*)key;
- uint64_t h = *x << 7, n = (uint64_t)len >> 3;
+ uint64_t h = (uint64_t)*x << 7, n = (uint64_t)len >> 3;
len &= 7;
while (n--) {
memcpy(&u8, x, 8), x += 8;
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 65e4a544..9f21b811 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -422,7 +422,7 @@ _cx_memb(_reserve)(_cx_self* self, const intptr_t _newcap) {
return true;
intptr_t _newbucks = (intptr_t)((float)_newcap / (i_max_load_factor)) + 4;
#if i_expandby == 2
- _newbucks = (intptr_t)next_power_of_2(_newbucks);
+ _newbucks = (intptr_t)next_power_of_2((uint64_t)_newbucks);
#else
_newbucks |= 1;
#endif