monado/src/xrt/auxiliary/util/u_hashmap.h

65 lines
1.3 KiB
C
Raw Normal View History

2019-05-07 15:03:38 +00:00
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: BSL-1.0
/*!
* @file
* @brief Hashmap for integer values header.
* @author Jakob Bornecrantz <jakob@collabora.com>
* @ingroup aux_util
*/
#pragma once
#include "xrt/xrt_compiler.h"
#ifdef __cplusplus
extern "C" {
#endif
/*!
* @struct u_hashmap_int
* @ingroup aux_util
*
* A simple uint64_t key to a void pointer hashmap.
*/
struct u_hashmap_int;
typedef void (*u_hashmap_int_callback)(void *item, void *priv);
int
u_hashmap_int_create(struct u_hashmap_int **out_hashmap);
int
2019-08-16 21:56:47 +00:00
u_hashmap_int_destroy(struct u_hashmap_int **hmi);
2019-05-07 15:03:38 +00:00
int
2019-08-16 21:56:47 +00:00
u_hashmap_int_find(struct u_hashmap_int *hmi, uint64_t key, void **out_item);
2019-05-07 15:03:38 +00:00
int
2019-08-16 21:56:47 +00:00
u_hashmap_int_insert(struct u_hashmap_int *hmi, uint64_t key, void *value);
2019-05-07 15:03:38 +00:00
int
2019-08-16 21:56:47 +00:00
u_hashmap_int_erase(struct u_hashmap_int *hmi, uint64_t key);
2019-05-07 15:03:38 +00:00
/*!
* Is the hash map empty?
*/
bool
u_hashmap_int_empty(const struct u_hashmap_int *hmi);
2019-05-07 15:03:38 +00:00
/*!
* First clear the hashmap and then call the given callback with each item that
* was in the hashmap.
*
* @ingroup aux_util
*/
void
2019-08-16 21:56:47 +00:00
u_hashmap_int_clear_and_call_for_each(struct u_hashmap_int *hmi,
2019-05-07 15:03:38 +00:00
u_hashmap_int_callback cb,
void *priv);
#ifdef __cplusplus
}
#endif