FTEQW
Documentation of the FTE engine source tree.
hash.h
Go to the documentation of this file.
1//=============================
2//David's hash tables
3//string based.
4
5#ifndef HASH_H__
6#define HASH_H__
7
8#define Hash_BytesForBuckets(b) (sizeof(bucket_t*)*(b))
9
10#define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1,s2)) //saves about 2-6 out of 120 - expansion of idea from fastqcc
11typedef struct bucket_s {
12 void *data;
13 union {
14 const char *string;
15 unsigned int value;
16 } key;
17 struct bucket_s *next;
19typedef struct hashtable_s {
20 unsigned int numbuckets;
23
24void Hash_InitTable(hashtable_t *table, unsigned int numbucks, void *mem); //mem must be 0 filled. (memset(mem, 0, size))
25void *Hash_Enumerate(hashtable_t *table, void (*callback) (void *ctx, void *data), void *ctx);
26unsigned int Hash_Key(const char *name, unsigned int modulus);
27void *Hash_GetIdx(hashtable_t *table, unsigned int idx);
28void *Hash_Get(hashtable_t *table, const char *name);
29void *Hash_GetInsensitive(hashtable_t *table, const char *name);
30void *Hash_GetInsensitiveBucket(hashtable_t *table, const char *name);
31void *Hash_GetKey(hashtable_t *table, unsigned int key);
32void *Hash_GetNext(hashtable_t *table, const char *name, void *old);
33void *Hash_GetNextInsensitive(hashtable_t *table, const char *name, void *old);
34void *Hash_GetNextKey(hashtable_t *table, unsigned int key, void *old);
35void *Hash_Add(hashtable_t *table, const char *name, void *data, bucket_t *buck);
36void *Hash_AddInsensitive(hashtable_t *table, const char *name, void *data, bucket_t *buck);
37void Hash_Remove(hashtable_t *table, const char *name);
38void Hash_RemoveData(hashtable_t *table, const char *name, void *data);
39void Hash_RemoveDataInsensitive(hashtable_t *table, const char *name, void *data);
40void Hash_RemoveBucket(hashtable_t *table, const char *name, bucket_t *data);
41void Hash_RemoveKey(hashtable_t *table, unsigned int key);
42void Hash_RemoveDataKey(hashtable_t *table, unsigned int key, void *data);
43void *Hash_AddKey(hashtable_t *table, unsigned int key, void *data, bucket_t *buck);
44
45#endif
void dNearCallback * callback
Definition: com_phys_ode.c:655
static EGLSurface EGLSurface EGLContext ctx
Definition: gl_videgl.c:47
float old
Definition: gl_vidlinuxglx.c:1365
GLuint GLcharARB * name
Definition: glquake.h:155
void * Hash_GetNext(hashtable_t *table, const char *name, void *old)
Definition: hash.c:183
void * Hash_GetNextKey(hashtable_t *table, unsigned int key, void *old)
Definition: hash.c:156
void * Hash_GetIdx(hashtable_t *table, unsigned int idx)
Definition: hash.c:71
void * Hash_GetKey(hashtable_t *table, unsigned int key)
Definition: hash.c:139
void Hash_RemoveBucket(hashtable_t *table, const char *name, bucket_t *data)
Definition: hash.c:334
void Hash_RemoveData(hashtable_t *table, const char *name, void *data)
Definition: hash.c:319
void Hash_RemoveDataInsensitive(hashtable_t *table, const char *name, void *data)
Definition: hash.c:304
void Hash_Remove(hashtable_t *table, const char *name)
Definition: hash.c:277
void Hash_RemoveDataKey(hashtable_t *table, unsigned int key, void *data)
Definition: hash.c:351
void * Hash_GetInsensitive(hashtable_t *table, const char *name)
Definition: hash.c:107
struct hashtable_s hashtable_t
void * Hash_AddKey(hashtable_t *table, unsigned int key, void *data, bucket_t *buck)
Definition: hash.c:265
void * Hash_Enumerate(hashtable_t *table, void(*callback)(void *ctx, void *data), void *ctx)
Definition: hash.c:27
void * Hash_AddInsensitive(hashtable_t *table, const char *name, void *data, bucket_t *buck)
Definition: hash.c:254
unsigned int Hash_Key(const char *name, unsigned int modulus)
Definition: hash.c:49
void * Hash_GetNextInsensitive(hashtable_t *table, const char *name, void *old)
Definition: hash.c:211
void * Hash_Add(hashtable_t *table, const char *name, void *data, bucket_t *buck)
Definition: hash.c:243
struct bucket_s bucket_t
void * Hash_GetInsensitiveBucket(hashtable_t *table, const char *name)
Definition: hash.c:123
void Hash_RemoveKey(hashtable_t *table, unsigned int key)
Definition: hash.c:366
void * Hash_Get(hashtable_t *table, const char *name)
Definition: hash.c:91
void Hash_InitTable(hashtable_t *table, unsigned int numbucks, void *mem)
Definition: hash.c:21
char ** data
Definition: p_script.c:63
int idx
Definition: pr_lua.c:221
Definition: hash.h:11
unsigned int value
Definition: hash.h:15
struct bucket_s * next
Definition: hash.h:17
const char * string
Definition: hash.h:14
union bucket_s::@336 key
void * data
Definition: hash.h:12
Definition: hash.h:19
unsigned int numbuckets
Definition: hash.h:20
bucket_t ** bucket
Definition: hash.h:21