UFO: Alien Invasion
Loading...
Searching...
No Matches
hashtable.h
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24*/
25
26/*
27 use:
28
29 hashTable* t = HASH_NewTable ();
30
31 HASH_Insert ("A1", 123);
32 HASH_Insert ("A2", 234);
33 HASH_Insert ("A3", 345);
34
35*/
36
37#pragma once
38
39#ifndef HASHTABLE_H
40#define HASHTABLE_H
41
42// forward declarations
43struct memPool_t;
44
46struct hashTable_s;
47
49typedef unsigned short int HASH_INDEX;
51typedef unsigned short int (*hashTable_hash) (const void* key, int len);
53typedef int (*hashTable_compare) (const void* key1, int len1, const void* key2, int len2);
54
60
61bool HASH_Insert (hashTable_s* t, const void* key, int nkey, const void* value, int nvalue);
62void* HASH_Remove (hashTable_s* t, const void* key, int nkey);
63void HASH_Clear (hashTable_s* t);
64void* HASH_Get (hashTable_s* t, const void* key, int nkey);
65int HASH_Count (hashTable_s* t);
66
67#ifdef __DEBUG__
68bool HASH_test ();
69#endif // __DEBUG__
70
71#endif // HASHTABLE_H
72
73
unsigned int key
Definition cl_input.cpp:64
int HASH_Count(hashTable_s *t)
Returns the number of entries in the hash table.
int(* hashTable_compare)(const void *key1, int len1, const void *key2, int len2)
Definition hashtable.h:53
void HASH_Clear(hashTable_s *t)
Clears the hash table.
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
unsigned short int(* hashTable_hash)(const void *key, int len)
Definition hashtable.h:51
hashTable_s * HASH_CloneTable(hashTable_s *source)
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
bool HASH_Insert(hashTable_s *t, const void *key, int nkey, const void *value, int nvalue)
Inserts a new value with given key into the hash table.
void HASH_DeleteTable(hashTable_s **t)
Deletes a hash table and sets the pointer to NULL.
unsigned short int HASH_INDEX
Definition hashtable.h:49
void * HASH_Remove(hashTable_s *t, const void *key, int nkey)
Removes an existing value with given key from the hash table.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
QGL_EXTERN GLuint GLchar GLuint * len
Definition r_gl.h:99
The hash table structure, contains an array of buckets being indexed by the hash function.
Definition hashtable.cpp:96
bool duplicateOverwrite
hashBucket_s * table[HASH_TABLE_SIZE]
Definition hashtable.cpp:98