src/cx/map.h

changeset 1426
3a89b31f0724
parent 1424
563033aa998c
child 1429
6e0c3a8a914a
--- a/src/cx/map.h	Wed Oct 15 22:45:21 2025 +0200
+++ b/src/cx/map.h	Thu Oct 16 19:57:47 2025 +0200
@@ -189,19 +189,12 @@
      * shall only allocate memory instead of adding an existing value to the map.
      * Returns a pointer to the allocated memory or @c NULL if allocation fails.
      */
-    void *(*put)(
-            CxMap *map,
-            CxHashKey key,
-            void *value
-    );
+    void *(*put)(CxMap *map, CxHashKey key, void *value);
 
     /**
      * Returns an element.
      */
-    void *(*get)(
-            const CxMap *map,
-            CxHashKey key
-    );
+    void *(*get)(const CxMap *map, CxHashKey key);
 
     /**
      * Removes an element.
@@ -213,11 +206,7 @@
      * The function SHALL return zero when the @p key was found and
      * non-zero, otherwise. 
      */
-    int (*remove)(
-            CxMap *map,
-            CxHashKey key,
-            void *targetbuf
-    );
+    int (*remove)(CxMap *map, CxHashKey key, void *targetbuf);
 
     /**
      * Creates an iterator for this map.
@@ -233,8 +222,7 @@
  * You can use this as a placeholder for initializing CxMap pointers
  * for which you do not want to reserve memory right from the beginning.
  */
-cx_attr_export
-extern CxMap *const cxEmptyMap;
+CX_EXPORT extern CxMap *const cxEmptyMap;
 
 /**
  * Deallocates the memory of the specified map.
@@ -243,8 +231,7 @@
  *
  * @param map the map to be freed
  */
-cx_attr_export
-void cxMapFree(CxMap *map);
+CX_EXPORT void cxMapFree(CxMap *map);
 
 
 /**
@@ -255,9 +242,7 @@
  * @param map the map to be cleared
  */
 cx_attr_nonnull
-static inline void cxMapClear(CxMap *map) {
-    map->cl->clear(map);
-}
+CX_EXPORT void cxMapClear(CxMap *map);
 
 /**
  * Returns the number of elements in this map.
@@ -266,9 +251,7 @@
  * @return the number of stored elements
  */
 cx_attr_nonnull
-static inline size_t cxMapSize(const CxMap *map) {
-    return map->collection.size;
-}
+CX_EXPORT size_t cxMapSize(const CxMap *map);
 
 /**
  * Creates a value iterator for a map.
@@ -284,10 +267,7 @@
  * @return an iterator for the currently stored values
  */
 cx_attr_nodiscard
-static inline CxMapIterator cxMapIteratorValues(const CxMap *map) {
-    if (map == NULL) map = cxEmptyMap;
-    return map->cl->iterator(map, CX_MAP_ITERATOR_VALUES);
-}
+CX_EXPORT CxMapIterator cxMapIteratorValues(const CxMap *map);
 
 /**
  * Creates a key iterator for a map.
@@ -302,10 +282,7 @@
  * @return an iterator for the currently stored keys
  */
 cx_attr_nodiscard
-static inline CxMapIterator cxMapIteratorKeys(const CxMap *map) {
-    if (map == NULL) map = cxEmptyMap;
-    return map->cl->iterator(map, CX_MAP_ITERATOR_KEYS);
-}
+CX_EXPORT CxMapIterator cxMapIteratorKeys(const CxMap *map);
 
 /**
  * Creates an iterator for a map.
@@ -322,11 +299,7 @@
  * @see cxMapIteratorValues()
  */
 cx_attr_nodiscard
-static inline CxMapIterator cxMapIterator(const CxMap *map) {
-    if (map == NULL) map = cxEmptyMap;
-    return map->cl->iterator(map, CX_MAP_ITERATOR_PAIRS);
-}
-
+CX_EXPORT CxMapIterator cxMapIterator(const CxMap *map);
 
 /**
  * Creates a mutating iterator over the values of a map.
@@ -342,8 +315,7 @@
  * @return an iterator for the currently stored values
  */
 cx_attr_nodiscard
-cx_attr_export
-CxMapIterator cxMapMutIteratorValues(CxMap *map);
+CX_EXPORT CxMapIterator cxMapMutIteratorValues(CxMap *map);
 
 /**
  * Creates a mutating iterator over the keys of a map.
@@ -358,8 +330,7 @@
  * @return an iterator for the currently stored keys
  */
 cx_attr_nodiscard
-cx_attr_export
-CxMapIterator cxMapMutIteratorKeys(CxMap *map);
+CX_EXPORT CxMapIterator cxMapMutIteratorKeys(CxMap *map);
 
 /**
  * Creates a mutating iterator for a map.
@@ -376,8 +347,7 @@
  * @see cxMapMutIteratorValues()
  */
 cx_attr_nodiscard
-cx_attr_export
-CxMapIterator cxMapMutIterator(CxMap *map);
+CX_EXPORT CxMapIterator cxMapMutIterator(CxMap *map);
 
 /**
  * Puts a key/value-pair into the map.
@@ -400,13 +370,7 @@
  * @see cxMapPut()
  */
 cx_attr_nonnull
-static inline int cx_map_put(
-        CxMap *map,
-        CxHashKey key,
-        void *value
-) {
-    return map->cl->put(map, key, value) == NULL;
-}
+CX_EXPORT int cx_map_put(CxMap *map, CxHashKey key, void *value);
 
 /**
  * Puts a key/value-pair into the map.
@@ -450,12 +414,7 @@
  * @see cxMapEmplace()
  */
 cx_attr_nonnull
-static inline void *cx_map_emplace(
-        CxMap *map,
-        CxHashKey key
-) {
-    return map->cl->put(map, key, NULL);
-}
+CX_EXPORT void *cx_map_emplace(CxMap *map, CxHashKey key);
 
 /**
  * Allocates memory for a value in the map associated with the specified key.
@@ -490,14 +449,8 @@
  * @return the value
  * @see cxMapGet()
  */
-cx_attr_nonnull
-cx_attr_nodiscard
-static inline void *cx_map_get(
-        const CxMap *map,
-        CxHashKey key
-) {
-    return map->cl->get(map, key);
-}
+cx_attr_nonnull cx_attr_nodiscard
+CX_EXPORT void *cx_map_get(const CxMap *map, CxHashKey key);
 
 /**
  * Retrieves a value by using a key.
@@ -529,13 +482,7 @@
  * @see cxMapRemoveAndGet()
  */
 cx_attr_nonnull_arg(1)
-static inline int cx_map_remove(
-        CxMap *map,
-        CxHashKey key,
-        void *targetbuf
-) {
-    return map->cl->remove(map, key, targetbuf);
-}
+CX_EXPORT int cx_map_remove(CxMap *map, CxHashKey key, void *targetbuf);
 
 /**
  * Removes a key/value-pair from the map by using the key.

mercurial