diff -r 35bcb3216c0d -r 6bbbf219251d src/cx/map.h --- a/src/cx/map.h Thu May 23 20:31:37 2024 +0200 +++ b/src/cx/map.h Thu May 23 20:43:04 2024 +0200 @@ -166,7 +166,7 @@ */ __attribute__((__nonnull__)) static inline void cxMapStoreObjects(CxMap *map) { - map->base.store_pointer = false; + map->collection.store_pointer = false; } /** @@ -183,8 +183,8 @@ */ __attribute__((__nonnull__)) static inline void cxMapStorePointers(CxMap *map) { - map->base.store_pointer = true; - map->base.elem_size = sizeof(void *); + map->collection.store_pointer = true; + map->collection.elem_size = sizeof(void *); } @@ -209,6 +209,17 @@ map->cl->clear(map); } +/** + * Returns the number of elements in this map. + * + * @param map the map + * @return the number of stored elements + */ +__attribute__((__nonnull__)) +static inline size_t cxMapSize(CxMap const *map) { + return map->collection.size; +} + // TODO: set-like map operations (union, intersect, difference) @@ -1053,7 +1064,7 @@ CxMap *map, CxHashKey key ) { - return map->cl->remove(map, key, !map->base.store_pointer); + return map->cl->remove(map, key, !map->collection.store_pointer); } /** @@ -1069,7 +1080,7 @@ CxMap *map, cxstring key ) { - return map->cl->remove(map, cx_hash_key_cxstr(key), !map->base.store_pointer); + return map->cl->remove(map, cx_hash_key_cxstr(key), !map->collection.store_pointer); } /** @@ -1085,7 +1096,7 @@ CxMap *map, cxmutstr key ) { - return map->cl->remove(map, cx_hash_key_cxstr(key), !map->base.store_pointer); + return map->cl->remove(map, cx_hash_key_cxstr(key), !map->collection.store_pointer); } /** @@ -1101,7 +1112,7 @@ CxMap *map, char const *key ) { - return map->cl->remove(map, cx_hash_key_str(key), !map->base.store_pointer); + return map->cl->remove(map, cx_hash_key_str(key), !map->collection.store_pointer); } /**