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