ucx/map.c

changeset 870
e167cf006213
parent 845
f3ab28ed22e5
child 943
9b5948aa5b90
--- a/ucx/map.c	Tue Oct 21 12:34:17 2025 +0200
+++ b/ucx/map.c	Tue Oct 21 16:20:51 2025 +0200
@@ -51,7 +51,7 @@
         cx_attr_unused enum cx_map_iterator_type type
 ) {
     CxMapIterator iter = {0};
-    iter.map.c = map;
+    iter.map = (CxMap*) map;
     iter.base.valid = cx_empty_map_iter_valid;
     return iter;
 }
@@ -84,25 +84,43 @@
 
 // </editor-fold>
 
-CxMapIterator cxMapMutIteratorValues(CxMap *map) {
+void cxMapClear(CxMap *map) {
+    map->cl->clear(map);
+}
+
+size_t cxMapSize(const CxMap *map) {
+    return map->collection.size;
+}
+
+CxMapIterator cxMapIteratorValues(const CxMap *map) {
     if (map == NULL) map = cxEmptyMap;
-    CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
-    it.base.mutating = true;
-    return it;
+    return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
+}
+
+CxMapIterator cxMapIteratorKeys(const CxMap *map) {
+    if (map == NULL) map = cxEmptyMap;
+    return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
 }
 
-CxMapIterator cxMapMutIteratorKeys(CxMap *map) {
+CxMapIterator cxMapIterator(const CxMap *map) {
     if (map == NULL) map = cxEmptyMap;
-    CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
-    it.base.mutating = true;
-    return it;
+    return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
+}
+
+int cx_map_put(CxMap *map, CxHashKey key, void *value) {
+    return map->cl->put(map, key, value) == NULL;
 }
 
-CxMapIterator cxMapMutIterator(CxMap *map) {
-    if (map == NULL) map = cxEmptyMap;
-    CxMapIterator it = map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
-    it.base.mutating = true;
-    return it;
+void *cx_map_emplace(CxMap *map, CxHashKey key) {
+    return map->cl->put(map, key, NULL);
+}
+
+void *cx_map_get(const CxMap *map, CxHashKey key) {
+    return map->cl->get(map, key);
+}
+
+int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf) {
+    return map->cl->remove(map, key, targetbuf);
 }
 
 void cxMapFree(CxMap *map) {

mercurial