diff --git a/src/UDPC_HashMap.c b/src/UDPC_HashMap.c index ef09703..8dc9c5e 100644 --- a/src/UDPC_HashMap.c +++ b/src/UDPC_HashMap.c @@ -305,3 +305,13 @@ void UDPC_HashMap_clear(UDPC_HashMap *hm) UDPC_Deque_clear(hm->overflow); hm->size = 0; } + +uint32_t UDPC_HashMap_get_size(UDPC_HashMap *hm) +{ + return hm->size; +} + +uint32_t UDPC_HashMap_get_capacity(UDPC_HashMap *hm) +{ + return hm->capacity; +} diff --git a/src/UDPC_HashMap.h b/src/UDPC_HashMap.h index c91caeb..e58712c 100644 --- a/src/UDPC_HashMap.h +++ b/src/UDPC_HashMap.h @@ -46,8 +46,9 @@ void UDPC_HashMap_destroy(UDPC_HashMap *hashMap); * Note if size already equals capacity, the hash map's capacity is doubled * with UDPC_HashMap_realloc(). realloc requires rehashing of all items which * may be costly. - * If an item with the same key already exists in the hash map, it will be - * replaced. + * It is possible to insert items with duplicate keys. In that case, the first + * duplicate inserted will be the first returned with get() and first removed + * with remove(). * \return Internally managed pointer to inserted data, NULL on fail */ void* UDPC_HashMap_insert(UDPC_HashMap *hm, uint32_t key, void *data); @@ -70,6 +71,8 @@ void* UDPC_HashMap_get(UDPC_HashMap *hm, uint32_t key); /*! * \brief Resizes the maximum capacity of a hash map * Note on fail, the hash map is unchanged. + * If newCapacity is less than the current size of the hash map, this function + * will fail. * \return non-zero if resizing was successful */ int UDPC_HashMap_realloc(UDPC_HashMap *hm, uint32_t newCapacity); @@ -79,4 +82,8 @@ int UDPC_HashMap_realloc(UDPC_HashMap *hm, uint32_t newCapacity); */ void UDPC_HashMap_clear(UDPC_HashMap *hm); +uint32_t UDPC_HashMap_get_size(UDPC_HashMap *hm); + +uint32_t UDPC_HashMap_get_capacity(UDPC_HashMap *hm); + #endif