src/cx/hash_map.h

changeset 550
89b2a83728b1
parent 549
d7f0b5a9a985
child 559
8603709932b9
--- a/src/cx/hash_map.h	Wed May 18 16:26:32 2022 +0200
+++ b/src/cx/hash_map.h	Thu May 19 14:30:20 2022 +0200
@@ -46,7 +46,11 @@
 /** Internal structure for a key within a hash map. */
 struct cx_hash_map_key_s {
     /** The key data. */
-    CxDataPtr data;
+    unsigned char *data;
+    /**
+     * The key data length.
+     */
+    size_t len;
     /** The hash value of the key data. */
     unsigned hash;
 };
@@ -63,14 +67,39 @@
     struct cx_hash_map_key_s key;
 };
 
+/**
+ * Internal structure for a hash map.
+ */
+struct cx_hash_map_s {
+    /**
+     * Base structure for maps.
+     */
+    struct cx_map_s base;
+    /**
+     * The buckets of this map, each containing a linked list of elements.
+     */
+    struct cx_hash_map_element_s **buckets;
+    /**
+     * The number of buckets.
+     */
+    size_t bucket_count;
+};
+
 
 /**
- * Creates a new hash map with the specified size using a UcxAllocator.
+ * Creates a new hash map with the specified number of buckets.
+ *
+ * If \p buckets is zero, an implementation defined default will be used.
+ *
+ * @note Iterators provided by this hash map implementation do provide the remove operation, because
+ * a remove never causes an immediate rehashing. The iterators are also position-aware in the sense
+ * that the index is initialized with zero and incremented when the iterator advances.
  *
  * @param allocator the allocator to use
  * @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,
         size_t buckets

mercurial