3 /* Hashtable - a general purpose hash table
5 ** Copyright 2001 pinc Software. All Rights Reserved.
6 ** Released under the terms of the MIT license.
10 #include "SupportDefs.h"
13 #define HASH_EMPTY_NONE 0
14 #define HASH_EMPTY_FREE 1
15 #define HASH_EMPTY_DELETE 2
20 Hashtable(int capacity
= 100, float loadFactor
= 0.75);
23 void SetHashFunction(uint32 (*func
)(const void *));
24 void SetCompareFunction(bool (*func
)(const void *, const void *));
27 bool ContainsKey(const void *key
);
28 void *GetValue(const void *key
);
30 bool Put(const void *key
, void *value
);
31 void *Remove(const void *key
);
33 status_t
GetNextEntry(void **value
);
36 void MakeEmpty(int8 keyMode
= HASH_EMPTY_NONE
,int8 valueMode
= HASH_EMPTY_NONE
);
43 Entry(Entry
*_next
, const void *_key
, void *_value
)
44 : next(_next
), key(_key
), value(_value
) {}
52 Entry
*GetHashEntry(const void *key
);
54 int32 fCapacity
,fCount
,fThreshold
,fModCount
;
57 uint32 (*fHashFunc
)(const void *);
58 bool (*fCompareFunc
)(const void *, const void *);
61 Entry
*fIteratorEntry
;