Sync to the latest version.

Can be broken or partially implemented.
This commit is contained in:
2024-04-23 23:45:43 +03:00
parent ec499b6cfc
commit 692b5b4297
26 changed files with 785 additions and 60 deletions

View File

@@ -1,7 +1,7 @@
#ifndef BHLIB_HASHMAP_H
#define BHLIB_HASHMAP_H
#include <bh/bh.h>
#include "bh.h"
typedef struct bh_hashmap_s bh_hashmap_t;
@@ -15,9 +15,6 @@ typedef struct bh_hashmap_s bh_hashmap_t;
* hashmap object.
* @return If the function fails, the return value is NULL.
*
* @warning The quality of the supplied hash function will affect performance
* of the hashmap.
*
* @sa bh_hashmap_free, bh_hashmap_reserve, bh_hashmap_insert
*/
bh_hashmap_t *bh_hashmap_new(bh_equal_cb_t equal,
@@ -37,7 +34,7 @@ void bh_hashmap_free(bh_hashmap_t *hashmap);
*
* @param hashmap Valid pointer to the hashmap object.
*
* @warning Clearing the hashmap does invalidate iterators.
* @warning Calling this function will invalidate iterators.
*
* @sa bh_hashmap_remove
*/
@@ -52,7 +49,7 @@ void bh_hashmap_clear(bh_hashmap_t *hashmap);
* @return If the function succeeds, the return value is zero.
* @return If the function fails, the return value is non-zero.
*
* @warning Reserving hashmap space does invalidate iterators.
* @warning Calling this function will invalidate iterators.
*
* @sa bh_hashmap_capacity, bh_hashmap_insert
*/
@@ -70,9 +67,9 @@ int bh_hashmap_reserve(bh_hashmap_t *hashmap,
* @return If the function fails, the return value is non-zero.
*
* @warning Inserted element is owned by the caller of the function.
* @warning Inserting elements into the hashmap does invalidate iterators.
* @warning Calling this function will invalidate iterators.
*
* @sa bbh_hashmap_remove, bh_hashmap_at
* @sa bh_hashmap_remove, bh_hashmap_at
*/
int bh_hashmap_insert(bh_hashmap_t *hashmap,
void *key,
@@ -84,7 +81,7 @@ int bh_hashmap_insert(bh_hashmap_t *hashmap,
* @param hashmap Valid pointer to the hashmap object.
* @param key Key.
*
* @warning Removing elements from the hashmap does invalidate iterators.
* @warning Calling this function will invalidate iterators.
*
* @sa bh_hashmap_insert, bh_hashmap_at
*/
@@ -96,15 +93,12 @@ void bh_hashmap_remove(bh_hashmap_t *hashmap,
*
* @param hashmap Valid pointer to the hashmap.
* @param key Key.
* @param exists Pointer to the exists flag (optional).
* @param exists Optional pointer to the exists flag.
*
* @return If the function succeeds, the return value is a valid pointer to
* the element value.
* @return If the function fails, the return value is NULL.
*
* @note If the hashmap does not contain any element with the key, the
* function will fail.
*
* @sa bh_hashmap_empty, bh_hashmap_insert
*/
void *bh_hashmap_at(bh_hashmap_t *hashmap,
@@ -205,7 +199,7 @@ void *bh_hashmap_iter_next(bh_hashmap_t *hashmap,
* @param hashmap Valid pointer to the hashmap object.
* @param key Valid iterator.
*
* @warning Removing elements from the hashmap does invalidate iterators.
* @warning Calling this function will invalidate iterators.
*
* @sa bh_hashmap_insert, bh_hashmap_at
*/