1.1 --- a/src/cx/map.h Thu May 23 20:31:37 2024 +0200 1.2 +++ b/src/cx/map.h Thu May 23 20:43:04 2024 +0200 1.3 @@ -166,7 +166,7 @@ 1.4 */ 1.5 __attribute__((__nonnull__)) 1.6 static inline void cxMapStoreObjects(CxMap *map) { 1.7 - map->base.store_pointer = false; 1.8 + map->collection.store_pointer = false; 1.9 } 1.10 1.11 /** 1.12 @@ -183,8 +183,8 @@ 1.13 */ 1.14 __attribute__((__nonnull__)) 1.15 static inline void cxMapStorePointers(CxMap *map) { 1.16 - map->base.store_pointer = true; 1.17 - map->base.elem_size = sizeof(void *); 1.18 + map->collection.store_pointer = true; 1.19 + map->collection.elem_size = sizeof(void *); 1.20 } 1.21 1.22 1.23 @@ -209,6 +209,17 @@ 1.24 map->cl->clear(map); 1.25 } 1.26 1.27 +/** 1.28 + * Returns the number of elements in this map. 1.29 + * 1.30 + * @param map the map 1.31 + * @return the number of stored elements 1.32 + */ 1.33 +__attribute__((__nonnull__)) 1.34 +static inline size_t cxMapSize(CxMap const *map) { 1.35 + return map->collection.size; 1.36 +} 1.37 + 1.38 1.39 // TODO: set-like map operations (union, intersect, difference) 1.40 1.41 @@ -1053,7 +1064,7 @@ 1.42 CxMap *map, 1.43 CxHashKey key 1.44 ) { 1.45 - return map->cl->remove(map, key, !map->base.store_pointer); 1.46 + return map->cl->remove(map, key, !map->collection.store_pointer); 1.47 } 1.48 1.49 /** 1.50 @@ -1069,7 +1080,7 @@ 1.51 CxMap *map, 1.52 cxstring key 1.53 ) { 1.54 - return map->cl->remove(map, cx_hash_key_cxstr(key), !map->base.store_pointer); 1.55 + return map->cl->remove(map, cx_hash_key_cxstr(key), !map->collection.store_pointer); 1.56 } 1.57 1.58 /** 1.59 @@ -1085,7 +1096,7 @@ 1.60 CxMap *map, 1.61 cxmutstr key 1.62 ) { 1.63 - return map->cl->remove(map, cx_hash_key_cxstr(key), !map->base.store_pointer); 1.64 + return map->cl->remove(map, cx_hash_key_cxstr(key), !map->collection.store_pointer); 1.65 } 1.66 1.67 /** 1.68 @@ -1101,7 +1112,7 @@ 1.69 CxMap *map, 1.70 char const *key 1.71 ) { 1.72 - return map->cl->remove(map, cx_hash_key_str(key), !map->base.store_pointer); 1.73 + return map->cl->remove(map, cx_hash_key_str(key), !map->collection.store_pointer); 1.74 } 1.75 1.76 /**