Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / devs / ram_handler / HashTable.h
blob33eb21977d265ec59945ed87f7089bc314a15969
1 #ifndef _HASHTABLE_H
2 #define _HASHTABLE_H
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc:
9 Lang: English
12 struct rambase;
14 #include <dos/notify.h>
15 #include <exec/nodes.h>
16 #include <exec/lists.h>
18 struct Receiver
20 struct Node node;
21 struct NotifyRequest *nr;
25 typedef struct _HashTable
27 struct List *array;
29 ULONG size;
30 ULONG nElems;
32 ULONG (*hash)(struct rambase *rambase, const void *key);
33 int (*compare)(struct rambase *rambase, const void *key1, const void *key2);
34 void (*delete)(struct rambase *rambase, void *key, struct List *list);
35 } HashTable;
39 /* HashTable_new
41 * Purpose: Create a new hash table.
43 * Input: ULONG size -- number of hash positions in the hash table
44 * ULONG (*hash)(struct rambase *rambase, const void *key)
45 * -- hash function for the elements
46 * int (*compare)(struct rambase *rambase,
47 * const void *key1, const void *key2)
48 * -- comparison function over keys
49 * void (*delete)(struct rambase *rambase,
50 * const void *key, void *data)
51 * -- deletion function for an <key, data> pair
53 * Output: HashTable * -- the new hash table
56 HashTable *HashTable_new(struct rambase *rambase, ULONG size,
57 ULONG (*hash)(struct rambase *rambase,
58 const void *key),
59 int (*compare)(struct rambase *rambase,
60 const void *key1, const void *key2),
61 void (*delete)(struct rambase *rambase,
62 void *key, struct List *list));
65 /* HashTable_delete
67 * Purpose: Free the resources held by a HashTable.
69 * Input: HashTable *ht -- the hash table the resources of which to free
71 * Output: --
74 void HashTable_delete(struct rambase *rambase, HashTable *ht);
77 /* HashTable_insert
79 * Purpose: Insert an element into the hash table
81 * Input: HashTable *ht -- the hash table to insert the element into
82 * void *key -- the key for the element
83 * void *data -- the data for the element
85 * Output: --
88 void HashTable_insert(struct rambase *rambase, HashTable *ht, void *key,
89 struct Receiver *rr);
92 /* HashTable_remove
94 * Purpose: Remove an element from the hash table.
96 * Input: HashTable *ht -- the hash table to remove the element from
97 * void *key -- the key for the element to remove
99 * Output: --
102 void HashTable_remove(struct rambase *rambase, HashTable *ht, void *key);
105 /* HashTable_find
107 * Purpose: Find an element corresponing to a certain key in a hash table.
109 * Input: HashTable *ht -- the hash table search for the element in
110 * void *key -- the key for the element to search for
112 * Output: void * -- the data part of the element or NULL if there
113 * was no element corresponding to 'key'
116 struct List *HashTable_find(struct rambase *rambase, HashTable *ht,
117 const void *key);
120 /* HashTable_size
122 * Purpose: Return the number of elements in a hash table.
124 * Input: HashTable *ht -- the hash table to query the size of
126 * Output: ULONG -- the number of elements in 'ht'
129 inline ULONG HashTable_size(HashTable *ht);
131 #endif /* _HASHTABLE_H */