Monado OpenXR Runtime
u_hashmap.h
Go to the documentation of this file.
1// Copyright 2019, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief Hashmap for integer values header.
6 * @author Jakob Bornecrantz <jakob@collabora.com>
7 * @author Korcan Hussein <korcan.hussein@collabora.com>
8 * @ingroup aux_util
9 */
10
11#pragma once
12
13#include "xrt/xrt_compiler.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19
20/*!
21 * @struct u_hashmap_int
22 * @ingroup aux_util
23 *
24 * A simple uint64_t key to a void pointer hashmap.
25 */
26struct u_hashmap_int;
27
28typedef void (*u_hashmap_int_callback)(void *item, void *priv);
29typedef void (*u_hashmap_int_foreach_callback)(uint64_t key, const void *value, void *priv_ctx);
30
31int
32u_hashmap_int_create(struct u_hashmap_int **out_hashmap);
33
34int
35u_hashmap_int_destroy(struct u_hashmap_int **hmi);
36
37int
38u_hashmap_int_find(struct u_hashmap_int *hmi, uint64_t key, void **out_item);
39
40int
41u_hashmap_int_insert(struct u_hashmap_int *hmi, uint64_t key, void *value);
42
43int
44u_hashmap_int_erase(struct u_hashmap_int *hmi, uint64_t key);
45
46/*!
47 * Is the hash map empty?
48 */
49bool
50u_hashmap_int_empty(const struct u_hashmap_int *hmi);
51
52/*!
53 * iterators through each [key,item] pairs of hash map
54 * @param hmi hash map to iterate
55 * @param cb callback invoked for each [key,item] pair + a user context.
56 * @param priv_ctx user provided context, passed into `cb`
57 * @ingroup aux_util
58 */
59void
60u_hashmap_int_for_each(const struct u_hashmap_int *hmi, u_hashmap_int_foreach_callback cb, void *priv_ctx);
61
62/*!
63 * First clear the hashmap and then call the given callback with each item that
64 * was in the hashmap.
65 *
66 * @ingroup aux_util
67 */
68void
69u_hashmap_int_clear_and_call_for_each(struct u_hashmap_int *hmi, u_hashmap_int_callback cb, void *priv);
70
71
72#ifdef __cplusplus
73}
74#endif
void u_hashmap_int_for_each(const struct u_hashmap_int *hmi, u_hashmap_int_foreach_callback cb, void *priv_ctx)
iterators through each [key,item] pairs of hash map
Definition: u_hashmap.cpp:84
void u_hashmap_int_clear_and_call_for_each(struct u_hashmap_int *hmi, u_hashmap_int_callback cb, void *priv)
First clear the hashmap and then call the given callback with each item that was in the hashmap.
Definition: u_hashmap.cpp:94
A simple uint64_t key to a void pointer hashmap.
Definition: u_hashmap.cpp:24
bool u_hashmap_int_empty(const struct u_hashmap_int *hmi)
Is the hash map empty?
Definition: u_hashmap.cpp:78
Header holding common defines.