1.1 --- a/src/cx/hash_map.h Wed May 18 16:26:32 2022 +0200 1.2 +++ b/src/cx/hash_map.h Thu May 19 14:30:20 2022 +0200 1.3 @@ -46,7 +46,11 @@ 1.4 /** Internal structure for a key within a hash map. */ 1.5 struct cx_hash_map_key_s { 1.6 /** The key data. */ 1.7 - CxDataPtr data; 1.8 + unsigned char *data; 1.9 + /** 1.10 + * The key data length. 1.11 + */ 1.12 + size_t len; 1.13 /** The hash value of the key data. */ 1.14 unsigned hash; 1.15 }; 1.16 @@ -63,14 +67,39 @@ 1.17 struct cx_hash_map_key_s key; 1.18 }; 1.19 1.20 +/** 1.21 + * Internal structure for a hash map. 1.22 + */ 1.23 +struct cx_hash_map_s { 1.24 + /** 1.25 + * Base structure for maps. 1.26 + */ 1.27 + struct cx_map_s base; 1.28 + /** 1.29 + * The buckets of this map, each containing a linked list of elements. 1.30 + */ 1.31 + struct cx_hash_map_element_s **buckets; 1.32 + /** 1.33 + * The number of buckets. 1.34 + */ 1.35 + size_t bucket_count; 1.36 +}; 1.37 + 1.38 1.39 /** 1.40 - * Creates a new hash map with the specified size using a UcxAllocator. 1.41 + * Creates a new hash map with the specified number of buckets. 1.42 + * 1.43 + * If \p buckets is zero, an implementation defined default will be used. 1.44 + * 1.45 + * @note Iterators provided by this hash map implementation do provide the remove operation, because 1.46 + * a remove never causes an immediate rehashing. The iterators are also position-aware in the sense 1.47 + * that the index is initialized with zero and incremented when the iterator advances. 1.48 * 1.49 * @param allocator the allocator to use 1.50 * @param buckets the initial number of buckets in this hash map 1.51 * @return a pointer to the new hash map 1.52 */ 1.53 +__attribute__((__nonnull__, __warn_unused_result__)) 1.54 CxMap *cxHashMapCreate( 1.55 CxAllocator *allocator, 1.56 size_t buckets