-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.h
More file actions
79 lines (63 loc) · 1.71 KB
/
tests.h
File metadata and controls
79 lines (63 loc) · 1.71 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <windows.h>
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
#include <math.h>
//#define HASH_TABLE_UNIT_TEST
#ifdef HASH_TABLE_UNIT_TEST
typedef struct _HASH_ENTRY
{
void* pKey;
SIZE_T nKeyLength;
void* pValue;
BOOL bIsFull;
struct _HASH_ENTRY* pNext;
}HASH_ENTRY, * PHASH_ENTRY;
typedef struct _HASH_TABLE
{
PVOID pInternal;
BOOL(*DeleteEntry)(struct _HASH_TABLE* self, PVOID pKey, SIZE_T nKeyLength, BOOL bFreeKey, BOOL bFreeValue);
BOOL(*SetEntry)(struct _HASH_TABLE** self, PVOID pKey, SIZE_T nKeyLength, PVOID pValue);
PVOID(*GetValue)(struct _HASH_TABLE* self, PVOID pKey, SIZE_T nKeyLength);
SIZE_T(*GetNumberOfEntries)(struct _HASH_TABLE* self);
HANDLE(*GetFirstEntry)(struct _HASH_TABLE* self, PHASH_ENTRY* pHashEntry);
BOOL(*GetNextEntry)(HANDLE hIterator, PHASH_ENTRY* pHashEntry);
}HASH_TABLE, * PHASH_TABLE;
BOOL
FreeHashTable(
PHASH_TABLE* pHashTable,
BOOL bFreeKey,
BOOL bFreeValue);
PHASH_TABLE
CreateHashTable(
SIZE_T nNumberOfInitalSlots,
DOUBLE dLoadFactor);
typedef struct _HASH_TABLE_ITERATOR
{
PHASH_TABLE pHashTable;
PHASH_ENTRY pHashEntry;
SIZE_T nIndex;
} HASH_TABLE_ITERATOR, * PHASH_TABLE_ITERATOR;
BOOL
IsPrime(SIZE_T n);
DWORD
_Fnv1aHash32(
PVOID data,
SIZE_T data_length);
SIZE_T
FindClosestPrime(
SIZE_T number);
PHASH_ENTRY
_FindEntry(
struct _HASH_TABLE* self,
PVOID pKey,
SIZE_T nKeyLength);
BOOL
_HashTableGetNextEntry(
PHASH_TABLE_ITERATOR* sIterator,
PHASH_ENTRY* pHashEntry);
PHASH_TABLE_ITERATOR
_HashTableGetFirstEntry(
PHASH_TABLE pHashTable,
PHASH_ENTRY* pHashEntry);
#endif