1 | /* |
2 | * Copyright © 2018 Google, Inc. |
3 | * |
4 | * This is part of HarfBuzz, a text shaping library. |
5 | * |
6 | * Permission is hereby granted, without written agreement and without |
7 | * license or royalty fees, to use, copy, modify, and distribute this |
8 | * software and its documentation for any purpose, provided that the |
9 | * above copyright notice and the following two paragraphs appear in |
10 | * all copies of this software. |
11 | * |
12 | * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR |
13 | * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES |
14 | * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN |
15 | * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
16 | * DAMAGE. |
17 | * |
18 | * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, |
19 | * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
20 | * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS |
21 | * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO |
22 | * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
23 | * |
24 | * Google Author(s): Behdad Esfahbod |
25 | */ |
26 | |
27 | #if !defined(HB_H_IN) && !defined(HB_NO_SINGLE_HEADER_ERROR) |
28 | #error "Include <hb.h> instead." |
29 | #endif |
30 | |
31 | #ifndef HB_MAP_H |
32 | #define HB_MAP_H |
33 | |
34 | #include "hb-common.h" |
35 | #include "hb-set.h" |
36 | |
37 | HB_BEGIN_DECLS |
38 | |
39 | |
40 | /** |
41 | * HB_MAP_VALUE_INVALID: |
42 | * |
43 | * Unset #hb_map_t value. |
44 | * |
45 | * Since: 1.7.7 |
46 | */ |
47 | #define HB_MAP_VALUE_INVALID HB_CODEPOINT_INVALID |
48 | |
49 | /** |
50 | * hb_map_t: |
51 | * |
52 | * Data type for holding integer-to-integer hash maps. |
53 | * |
54 | **/ |
55 | typedef struct hb_map_t hb_map_t; |
56 | |
57 | |
58 | HB_EXTERN hb_map_t * |
59 | hb_map_create (void); |
60 | |
61 | HB_EXTERN hb_map_t * |
62 | hb_map_get_empty (void); |
63 | |
64 | HB_EXTERN hb_map_t * |
65 | hb_map_reference (hb_map_t *map); |
66 | |
67 | HB_EXTERN void |
68 | hb_map_destroy (hb_map_t *map); |
69 | |
70 | HB_EXTERN hb_bool_t |
71 | hb_map_set_user_data (hb_map_t *map, |
72 | hb_user_data_key_t *key, |
73 | void * data, |
74 | hb_destroy_func_t destroy, |
75 | hb_bool_t replace); |
76 | |
77 | HB_EXTERN void * |
78 | hb_map_get_user_data (const hb_map_t *map, |
79 | hb_user_data_key_t *key); |
80 | |
81 | |
82 | /* Returns false if allocation has failed before */ |
83 | HB_EXTERN hb_bool_t |
84 | hb_map_allocation_successful (const hb_map_t *map); |
85 | |
86 | HB_EXTERN hb_map_t * |
87 | hb_map_copy (const hb_map_t *map); |
88 | |
89 | HB_EXTERN void |
90 | hb_map_clear (hb_map_t *map); |
91 | |
92 | HB_EXTERN hb_bool_t |
93 | hb_map_is_empty (const hb_map_t *map); |
94 | |
95 | HB_EXTERN unsigned int |
96 | hb_map_get_population (const hb_map_t *map); |
97 | |
98 | HB_EXTERN hb_bool_t |
99 | hb_map_is_equal (const hb_map_t *map, |
100 | const hb_map_t *other); |
101 | |
102 | HB_EXTERN unsigned int |
103 | hb_map_hash (const hb_map_t *map); |
104 | |
105 | HB_EXTERN void |
106 | hb_map_set (hb_map_t *map, |
107 | hb_codepoint_t key, |
108 | hb_codepoint_t value); |
109 | |
110 | HB_EXTERN hb_codepoint_t |
111 | hb_map_get (const hb_map_t *map, |
112 | hb_codepoint_t key); |
113 | |
114 | HB_EXTERN void |
115 | hb_map_del (hb_map_t *map, |
116 | hb_codepoint_t key); |
117 | |
118 | HB_EXTERN hb_bool_t |
119 | hb_map_has (const hb_map_t *map, |
120 | hb_codepoint_t key); |
121 | |
122 | HB_EXTERN void |
123 | hb_map_update (hb_map_t *map, |
124 | const hb_map_t *other); |
125 | |
126 | /* Pass -1 in for idx to get started. */ |
127 | HB_EXTERN hb_bool_t |
128 | hb_map_next (const hb_map_t *map, |
129 | int *idx, |
130 | hb_codepoint_t *key, |
131 | hb_codepoint_t *value); |
132 | |
133 | HB_EXTERN void |
134 | hb_map_keys (const hb_map_t *map, |
135 | hb_set_t *keys); |
136 | |
137 | HB_EXTERN void |
138 | hb_map_values (const hb_map_t *map, |
139 | hb_set_t *values); |
140 | |
141 | HB_END_DECLS |
142 | |
143 | #endif /* HB_MAP_H */ |
144 | |