author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
7318
diff
changeset
|
3 |
/** @file queue.h Simple Queue/Hash implementations. */ |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
4 |
|
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
5 |
#ifndef QUEUE_H |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
6 |
#define QUEUE_H |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
7 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
8 |
//#define NOFREE |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
9 |
//#define QUEUE_DEBUG |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
10 |
//#define HASH_DEBUG |
1661
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1093
diff
changeset
|
11 |
//#define HASH_STATS |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
12 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
13 |
|
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6105
diff
changeset
|
14 |
struct Queue; |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
15 |
typedef bool Queue_PushProc(Queue *q, void *item, int priority); |
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
16 |
typedef void* Queue_PopProc(Queue *q); |
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
17 |
typedef bool Queue_DeleteProc(Queue *q, void* item, int priority); |
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
18 |
typedef void Queue_ClearProc(Queue *q, bool free_values); |
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
19 |
typedef void Queue_FreeProc(Queue *q, bool free_values); |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
20 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
21 |
struct InsSortNode { |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
22 |
void *item; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
23 |
int priority; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
24 |
InsSortNode* next; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
25 |
}; |
3012
5e79c183a4bf
(svn r3592) Miscellaneous smaller changes, most notably replacing sizeof(type) by sizeof(*variable)
tron
parents:
2186
diff
changeset
|
26 |
|
5e79c183a4bf
(svn r3592) Miscellaneous smaller changes, most notably replacing sizeof(type) by sizeof(*variable)
tron
parents:
2186
diff
changeset
|
27 |
struct BinaryHeapNode { |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
28 |
void *item; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
29 |
int priority; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
30 |
}; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
31 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
32 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
33 |
struct Queue{ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
34 |
/* |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
35 |
* Pushes an element into the queue, at the appropriate place for the queue. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
36 |
* Requires the queue pointer to be of an appropriate type, of course. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
37 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
38 |
Queue_PushProc *push; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
39 |
/* |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
40 |
* Pops the first element from the queue. What exactly is the first element, |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
41 |
* is defined by the exact type of queue. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
42 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
43 |
Queue_PopProc *pop; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
44 |
/* |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
45 |
* Deletes the item from the queue. priority should be specified if |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
46 |
* known, which speeds up the deleting for some queue's. Should be -1 |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
47 |
* if not known. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
48 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
49 |
Queue_DeleteProc *del; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
50 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
51 |
/* Clears the queue, by removing all values from it. It's state is |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
52 |
* effectively reset. If free_items is true, each of the items cleared |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
53 |
* in this way are free()'d. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
54 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
55 |
Queue_ClearProc *clear; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
56 |
/* Frees the queue, by reclaiming all memory allocated by it. After |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
57 |
* this it is no longer usable. If free_items is true, any remaining |
201
c40d343115f8
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight
parents:
110
diff
changeset
|
58 |
* items are free()'d too. |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
59 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
60 |
Queue_FreeProc *free; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
61 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
62 |
union { |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
63 |
struct { |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
64 |
InsSortNode *first; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
65 |
} inssort; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
66 |
struct { |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
67 |
uint max_size; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
68 |
uint size; |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
69 |
uint blocks; ///< The amount of blocks for which space is reserved in elements |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
70 |
BinaryHeapNode **elements; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
71 |
} binaryheap; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
72 |
} data; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
73 |
}; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
74 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
75 |
|
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
76 |
/** |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
77 |
* Insertion Sorter |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
78 |
*/ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
79 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
80 |
/* Initializes a inssort and allocates internal memory. There is no maximum |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
81 |
* size */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
82 |
void init_InsSort(Queue *q); |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
83 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
84 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
85 |
/* |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
86 |
* Binary Heap |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
87 |
* For information, see: |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
88 |
* http://www.policyalmanac.org/games/binaryHeaps.htm |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
89 |
*/ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
90 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
91 |
/* The amount of elements that will be malloc'd at a time */ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
92 |
#define BINARY_HEAP_BLOCKSIZE_BITS 10 |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
93 |
|
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
94 |
/** Initializes a binary heap and allocates internal memory for maximum of |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
95 |
* max_size elements */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
96 |
void init_BinaryHeap(Queue *q, uint max_size); |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
97 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
98 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
99 |
/* |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
100 |
* Hash |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
101 |
*/ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
102 |
struct HashNode { |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
103 |
uint key1; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
104 |
uint key2; |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
105 |
void *value; |
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
106 |
HashNode *next; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
107 |
}; |
1661
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1093
diff
changeset
|
108 |
/** |
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1093
diff
changeset
|
109 |
* Generates a hash code from the given key pair. You should make sure that |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
110 |
* the resulting range is clearly defined. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
111 |
*/ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
112 |
typedef uint Hash_HashProc(uint key1, uint key2); |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6105
diff
changeset
|
113 |
struct Hash { |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
114 |
/* The hash function used */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
115 |
Hash_HashProc *hash; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
116 |
/* The amount of items in the hash */ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
117 |
uint size; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
118 |
/* The number of buckets allocated */ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
119 |
uint num_buckets; |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
120 |
/* A pointer to an array of num_buckets buckets. */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
121 |
HashNode *buckets; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
122 |
/* A pointer to an array of numbuckets booleans, which will be true if |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
123 |
* there are any Nodes in the bucket */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
124 |
bool *buckets_in_use; |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6105
diff
changeset
|
125 |
}; |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
126 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
127 |
/* Call these function to manipulate a hash */ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
128 |
|
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
129 |
/** Deletes the value with the specified key pair from the hash and returns |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
130 |
* that value. Returns NULL when the value was not present. The value returned |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
131 |
* is _not_ free()'d! */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
132 |
void *Hash_Delete(Hash *h, uint key1, uint key2); |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
133 |
/** Sets the value associated with the given key pair to the given value. |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
134 |
* Returns the old value if the value was replaced, NULL when it was not yet present. */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
135 |
void *Hash_Set(Hash *h, uint key1, uint key2, void *value); |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
136 |
/** Gets the value associated with the given key pair, or NULL when it is not |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
137 |
* present. */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
138 |
void *Hash_Get(const Hash *h, uint key1, uint key2); |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
139 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
140 |
/* Call these function to create/destroy a hash */ |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
141 |
|
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
142 |
/** Builds a new hash in an existing struct. Make sure that hash() always |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
143 |
* returns a hash less than num_buckets! Call delete_hash after use */ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
144 |
void init_Hash(Hash *h, Hash_HashProc *hash, uint num_buckets); |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
145 |
/** |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
146 |
* Deletes the hash and cleans up. Only cleans up memory allocated by new_Hash |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
147 |
* & friends. If free is true, it will call free() on all the values that |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
148 |
* are left in the hash. |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
149 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
150 |
void delete_Hash(Hash *h, bool free_values); |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
151 |
/** |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
152 |
* Cleans the hash, but keeps the memory allocated |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
153 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
154 |
void clear_Hash(Hash *h, bool free_values); |
6352
938ab8f48e5d
(svn r9391) -Documentation : correct Doxygen of comments and @file inclusion. Time for P and Q files
belugas
parents:
6248
diff
changeset
|
155 |
/** |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
156 |
* Gets the current size of the Hash |
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
157 |
*/ |
7318
632cd0497770
(svn r10673) -Cleanup: some assorted style cleanups. Primarily type* var -> type *var.
rubidium
parents:
6352
diff
changeset
|
158 |
uint Hash_Size(const Hash *h); |
110
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
159 |
|
a22a6b07904b
(svn r111) -Fix: converted all linebreaks to UNIX-linebreak (\n)
truelight
parents:
107
diff
changeset
|
160 |
#endif /* QUEUE_H */ |