5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
14 #include <dos/notify.h>
15 #include <exec/nodes.h>
16 #include <exec/lists.h>
21 struct NotifyRequest
*nr
;
25 typedef struct _HashTable
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
);
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
,
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
));
67 * Purpose: Free the resources held by a HashTable.
69 * Input: HashTable *ht -- the hash table the resources of which to free
74 void HashTable_delete(struct rambase
*rambase
, HashTable
*ht
);
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
88 void HashTable_insert(struct rambase
*rambase
, HashTable
*ht
, void *key
,
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
102 void HashTable_remove(struct rambase
*rambase
, HashTable
*ht
, void *key
);
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
,
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 */