e07f8fadb838dcd599922996f8b077333134d56d
[mono.git] / mono / metadata / mono-hash.h
1 /*
2  * mono-hash.c: GC-aware hashtable, based on Eglib's Hashtable
3  *
4  * Authors:
5  *   Paolo Molaro (lupus@xamarin.com)
6  *
7  * Copyright 2013 Xamarin Inc (http://www.xamarin.com)
8  */
9
10 #ifndef __MONO_G_HASH_H__
11 #define __MONO_G_HASH_H__
12
13 #include <mono/metadata/mono-gc.h>
14
15 MONO_BEGIN_DECLS
16 /* do not change the values of this enum */
17 typedef enum {
18         MONO_HASH_KEY_GC = 1,
19         MONO_HASH_VALUE_GC = 2,
20         MONO_HASH_KEY_VALUE_GC = MONO_HASH_KEY_GC | MONO_HASH_VALUE_GC,
21 } MonoGHashGCType;
22
23 typedef struct _MonoGHashTable MonoGHashTable;
24
25 MONO_API MonoGHashTable *mono_g_hash_table_new_type (GHashFunc hash_func, GEqualFunc key_equal_func, MonoGHashGCType type, MonoGCRootSource source, const char *msg);
26 MONO_API guint    mono_g_hash_table_size            (MonoGHashTable *hash);
27 MONO_API gpointer mono_g_hash_table_lookup          (MonoGHashTable *hash, gconstpointer key);
28 MONO_API gboolean mono_g_hash_table_lookup_extended (MonoGHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
29 MONO_API void     mono_g_hash_table_foreach         (MonoGHashTable *hash, GHFunc func, gpointer user_data);
30 MONO_API gpointer mono_g_hash_table_find            (MonoGHashTable *hash, GHRFunc predicate, gpointer user_data);
31 MONO_API gboolean mono_g_hash_table_remove          (MonoGHashTable *hash, gconstpointer key);
32 MONO_API guint    mono_g_hash_table_foreach_remove  (MonoGHashTable *hash, GHRFunc func, gpointer user_data);
33 MONO_API void     mono_g_hash_table_destroy         (MonoGHashTable *hash);
34 MONO_API void     mono_g_hash_table_insert          (MonoGHashTable *h, gpointer k, gpointer v);
35 MONO_API void     mono_g_hash_table_replace         (MonoGHashTable *h, gpointer k, gpointer v);
36 MONO_API void     mono_g_hash_table_print_stats     (MonoGHashTable *table);
37
38 MONO_END_DECLS
39 #endif /* __MONO_G_HASH_H__ */