Align libgc vcxproj with makefile.
[mono.git] / mono / utils / mono-value-hash.h
1 /**
2  * \file
3  * A hash table which only stores values in the hash nodes.
4  *
5  * Author:
6  *   Mark Probst (mark.probst@gmail.com)
7  *   Zoltan Varga (vargaz@gmail.com)
8  *
9  * (C) 2008 Novell, Inc.
10  *
11  */
12 #ifndef __MONO_UTILS_MONO_VALUE_HASH__
13 #define __MONO_UTILS_MONO_VALUE_HASH__
14
15 #include <glib.h>
16 #include "mono-compiler.h"
17
18 G_BEGIN_DECLS
19
20 /*
21  * This is a hash table with the following features/restrictions:
22  * - Keys are not stored in the table, instead a function must be supplied which 
23  *   computes them from the value.
24  * - Values are assumed to be normal pointers, i.e. their lowest 2-3 bits should be
25  *   zero.
26  * - NULL values are not allowed.
27  * - It uses internal probing instead of chaining.
28  * - The above restrictions mean that this hash table will be somewhat slower than
29  *   hash tables which store the key (or even the key hash) in the hash nodes. But
30  *   it also means that each hash node has a size of one machine word, instead of
31  * 4 in GHashTable.
32  * - Removal of entries is not supported, as it is not needed by the runtime right 
33  *   now.
34  */
35
36 typedef struct _MonoValueHashTable MonoValueHashTable;
37
38 typedef gpointer (*MonoValueHashKeyExtractFunc) (gpointer value);
39
40 MonoValueHashTable* mono_value_hash_table_new (GHashFunc hash_func,
41                                                                                            GEqualFunc key_equal_func,
42                                                                                            MonoValueHashKeyExtractFunc key_extract);
43
44 void
45 mono_value_hash_table_destroy (MonoValueHashTable *table);
46
47 gpointer
48 mono_value_hash_table_lookup (MonoValueHashTable *table, gconstpointer key);
49
50 /* The key pointer is actually only passed here to check a debugging
51    assertion and to make the API look more familiar. */
52 void
53 mono_value_hash_table_insert (MonoValueHashTable *table,
54                                  gpointer key, gpointer value);
55
56 G_END_DECLS
57
58 #endif