UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
hashtable.h
Go to the documentation of this file.
1
5
6
/*
7
Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, 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
43
struct
memPool_t
;
44
46
struct
hashTable_s
;
47
49
typedef
unsigned
short
int
HASH_INDEX
;
51
typedef
unsigned
short
int
(*
hashTable_hash
) (
const
void
*
key
,
int
len
);
53
typedef
int
(*
hashTable_compare
) (
const
void
* key1,
int
len1,
const
void
* key2,
int
len2);
54
55
hashTable_s
*
HASH_NewTable
(
bool
ownsKeys
,
bool
ownsValues
,
bool
duplicateOverwrite
);
56
hashTable_s
*
HASH_NewTable
(
bool
ownsKeys
,
bool
ownsValues
,
bool
duplicateOverwrite
,
hashTable_hash
h,
hashTable_compare
c);
57
hashTable_s
*
HASH_NewTable
(
bool
ownsKeys
,
bool
ownsValues
,
bool
duplicateOverwrite
,
hashTable_hash
h,
hashTable_compare
c,
memPool_t
* keys,
memPool_t
* values,
memPool_t
*
table
);
58
hashTable_s
*
HASH_CloneTable
(
hashTable_s
* source);
59
void
HASH_DeleteTable
(
hashTable_s
** t);
60
61
bool
HASH_Insert
(
hashTable_s
* t,
const
void
*
key
,
int
nkey,
const
void
* value,
int
nvalue);
62
void
*
HASH_Remove
(
hashTable_s
* t,
const
void
*
key
,
int
nkey);
63
void
HASH_Clear
(
hashTable_s
* t);
64
void
*
HASH_Get
(
hashTable_s
* t,
const
void
*
key
,
int
nkey);
65
int
HASH_Count
(
hashTable_s
* t);
66
67
#ifdef __DEBUG__
68
bool
HASH_test ();
69
#endif
// __DEBUG__
70
71
#endif
// HASHTABLE_H
72
73
key
unsigned int key
Definition
cl_input.cpp:64
HASH_Count
int HASH_Count(hashTable_s *t)
Returns the number of entries in the hash table.
Definition
hashtable.cpp:481
hashTable_compare
int(* hashTable_compare)(const void *key1, int len1, const void *key2, int len2)
Definition
hashtable.h:53
HASH_Clear
void HASH_Clear(hashTable_s *t)
Clears the hash table.
Definition
hashtable.cpp:460
HASH_Get
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
Definition
hashtable.cpp:467
hashTable_hash
unsigned short int(* hashTable_hash)(const void *key, int len)
Definition
hashtable.h:51
HASH_CloneTable
hashTable_s * HASH_CloneTable(hashTable_s *source)
Definition
hashtable.cpp:336
HASH_NewTable
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
Definition
hashtable.cpp:287
HASH_Insert
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.
Definition
hashtable.cpp:369
HASH_DeleteTable
void HASH_DeleteTable(hashTable_s **t)
Deletes a hash table and sets the pointer to NULL.
Definition
hashtable.cpp:351
HASH_INDEX
unsigned short int HASH_INDEX
Definition
hashtable.h:49
HASH_Remove
void * HASH_Remove(hashTable_s *t, const void *key, int nkey)
Removes an existing value with given key from the hash table.
Definition
hashtable.cpp:429
int
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
len
QGL_EXTERN GLuint GLchar GLuint * len
Definition
r_gl.h:99
hashTable_s
The hash table structure, contains an array of buckets being indexed by the hash function.
Definition
hashtable.cpp:96
hashTable_s::ownsKeys
bool ownsKeys
Definition
hashtable.cpp:104
hashTable_s::duplicateOverwrite
bool duplicateOverwrite
Definition
hashtable.cpp:109
hashTable_s::table
hashBucket_s * table[HASH_TABLE_SIZE]
Definition
hashtable.cpp:98
hashTable_s::ownsValues
bool ownsValues
Definition
hashtable.cpp:106
memPool_t
Definition
mem.cpp:55
src
common
hashtable.h
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0