diff options
| -rw-r--r-- | examples/csmap_ex.c | 5 | ||||
| -rw-r--r-- | stc/csmap.h | 4 |
2 files changed, 6 insertions, 3 deletions
diff --git a/examples/csmap_ex.c b/examples/csmap_ex.c index 14d21b67..dac82339 100644 --- a/examples/csmap_ex.c +++ b/examples/csmap_ex.c @@ -32,7 +32,10 @@ int main(int argc, char **argv) puts("");
csmap_i_iter_t it;
- printf("min/max: %d -- %d: %d\n\n", csmap_i_front(&map)->first, csmap_i_back(&map)->first, csmap_i_find(&map, 500000, &it) != NULL);
+ printf("min/max: %d -- %d: %d: %zu\n\n", csmap_i_front(&map)->first,
+ csmap_i_back(&map)->first,
+ csmap_i_find(&map, 500000, &it) != NULL,
+ csmap_i_size(map));
c_foreach (i, csmap_i, it, csmap_i_end(&map))
printf("-- %d: %d\n", i.ref->first, i.ref->second);
diff --git a/stc/csmap.h b/stc/csmap.h index e64d1204..b4a215c6 100644 --- a/stc/csmap.h +++ b/stc/csmap.h @@ -350,7 +350,7 @@ STC_API void cbst_next(csmap___iter_t *it, size_t offset); C##_##X##_insert_key(C##_##X* self, RawKey rkey) { \
C##_##X##_result_t res = {NULL, false}; \
self->root = C##_##X##_insert_key_r_(self->root, &rkey, &res); \
- if (res.second) ++self->size; \
+ self->size += res.second; \
return res; \
} \
\
@@ -439,7 +439,7 @@ cbst_split(csmap___node_t *tn) { STC_DEF void
cbst_next(csmap___iter_t *it, size_t offset) {
csmap___node_t *tn = it->_tn;
- if (tn->level || it->_top) {
+ if (it->_top || tn->level) {
while (tn->level) {
it->_st[it->_top++] = tn;
tn = tn->link[0];
|
