src/ucx/cx/hash_map.h

changeset 490
d218607f5a7e
parent 415
d938228c382e
child 504
c094afcdfb27
--- a/src/ucx/cx/hash_map.h	Sat Mar 25 17:18:51 2023 +0100
+++ b/src/ucx/cx/hash_map.h	Fri May 05 18:02:11 2023 +0200
@@ -44,16 +44,7 @@
 #endif
 
 /** Internal structure for an element of a hash map. */
-struct cx_hash_map_element_s {
-    /** The value data. */
-    void *data;
-
-    /** A pointer to the next element in the current bucket. */
-    struct cx_hash_map_element_s *next;
-
-    /** The corresponding key. */
-    CxHashKey key;
-};
+struct cx_hash_map_element_s;
 
 /**
  * Internal structure for a hash map.
@@ -79,21 +70,42 @@
  *
  * If \p buckets is zero, an implementation defined default will be used.
  *
+ * If \p item_size is CX_STORE_POINTERS, the created map will be created as if
+ * cxMapStorePointers() was called immediately after creation.
+ *
  * @note Iterators provided by this hash map implementation provide the remove operation.
  * The index value of an iterator is the incremented when the iterator advanced without removal.
  * In other words, when the iterator is finished, \c index==size .
  *
  * @param allocator the allocator to use
+ * @param itemsize the size of one element
  * @param buckets the initial number of buckets in this hash map
  * @return a pointer to the new hash map
  */
 __attribute__((__nonnull__, __warn_unused_result__))
 CxMap *cxHashMapCreate(
-        CxAllocator *allocator,
+        CxAllocator const *allocator,
+        size_t itemsize,
         size_t buckets
 );
 
 /**
+ * Creates a new hash map with a default number of buckets.
+ *
+ * If \p item_size is CX_STORE_POINTERS, the created map will be created as if
+ * cxMapStorePointers() was called immediately after creation.
+ *
+ * @note Iterators provided by this hash map implementation provide the remove operation.
+ * The index value of an iterator is the incremented when the iterator advanced without removal.
+ * In other words, when the iterator is finished, \c index==size .
+ *
+ * @param itemsize the size of one element
+ * @return a pointer to the new hash map
+ */
+#define cxHashMapCreateSimple(itemsize) \
+    cxHashMapCreate(cxDefaultAllocator, itemsize, 0)
+
+/**
  * Increases the number of buckets, if necessary.
  *
  * The load threshold is \c 0.75*buckets. If the element count exceeds the load

mercurial