| 86 cx_attr_nodiscard cx_attr_malloc cx_attr_dealloc(cxMapFree, 1) |
86 cx_attr_nodiscard cx_attr_malloc cx_attr_dealloc(cxMapFree, 1) |
| 87 CX_EXPORT CxMap *cxHashMapCreate(const CxAllocator *allocator, |
87 CX_EXPORT CxMap *cxHashMapCreate(const CxAllocator *allocator, |
| 88 size_t itemsize, size_t buckets); |
88 size_t itemsize, size_t buckets); |
| 89 |
89 |
| 90 /** |
90 /** |
| 91 * Creates a new hash map with a default number of buckets. |
|
| 92 * |
|
| 93 * If @p elem_size is #CX_STORE_POINTERS, the created map stores pointers instead of |
|
| 94 * copies of the added elements. |
|
| 95 * |
|
| 96 * @note Iterators provided by this hash map implementation provide the remove operation. |
|
| 97 * The index value of an iterator is incremented when the iterator advanced without |
|
| 98 * removing an entry. |
|
| 99 * In other words, when the iterator is finished, @c index==size . |
|
| 100 * |
|
| 101 * @param itemsize (@c size_t) the size of one element |
|
| 102 * @return (@c CxMap*) a pointer to the new hash map |
|
| 103 */ |
|
| 104 #define cxHashMapCreateSimple(itemsize) cxHashMapCreate(NULL, itemsize, 0) |
|
| 105 |
|
| 106 /** |
|
| 107 * Increases the number of buckets, if necessary. |
91 * Increases the number of buckets, if necessary. |
| 108 * |
92 * |
| 109 * The load threshold is @c 0.75*buckets. If the element count exceeds the load |
93 * The load threshold is @c 0.75*buckets. If the element count exceeds the load |
| 110 * threshold, the map will be rehashed. Otherwise, no action is performed, and |
94 * threshold, the map will be rehashed. Otherwise, no action is performed, and |
| 111 * this function simply returns 0. |
95 * this function simply returns 0. |