From 67f0270a59f0e83b39ac8792a0cf322ea43be39e Mon Sep 17 00:00:00 2001 From: Tyge Løvset Date: Sun, 17 Jan 2021 18:33:55 +0100 Subject: Small tweaks. --- examples/csmap_ex.c | 5 ++++- 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]; -- cgit v1.2.3