* When the number of elements reaches a certain percentage of the table's
* capacity, the table will be resized.
*/
-#ifndef _DALVIK_HASH
-#define _DALVIK_HASH
-
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifndef DALVIK_HASH_H_
+#define DALVIK_HASH_H_
/* compute the hash of an item with a specific type */
typedef u4 (*HashCompute)(const void* item);
*
* When an entry is released, we will call (HashFreeFunc)(entry->data).
*/
-typedef struct HashEntry {
+struct HashEntry {
u4 hashValue;
void* data;
-} HashEntry;
+};
#define HASH_TOMBSTONE ((void*) 0xcbcacccd) // invalid ptr value
*
* This structure should be considered opaque.
*/
-typedef struct HashTable {
+struct HashTable {
int tableSize; /* must be power of 2 */
int numEntries; /* current #of "live" entries */
int numDeadEntries; /* current #of tombstone entries */
HashEntry* pEntries; /* array on heap */
HashFreeFunc freeFunc;
pthread_mutex_t lock;
-} HashTable;
+};
/*
* Create and initialize a HashTable structure, using "initialSize" as
* MyData* data = (MyData*)dvmHashIterData(&iter);
* }
*/
-typedef struct HashIter {
+struct HashIter {
void* data;
HashTable* pHashTable;
int idx;
-} HashIter;
+};
INLINE void dvmHashIterNext(HashIter* pIter) {
int i = pIter->idx +1;
int lim = pIter->pHashTable->tableSize;
void dvmHashTableProbeCount(HashTable* pHashTable, HashCalcFunc calcFunc,
HashCompareFunc cmpFunc);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /*_DALVIK_HASH*/
+#endif // DALVIK_HASH_H_