Index: runtime/platform/hashmap.h |
diff --git a/runtime/platform/hashmap.h b/runtime/platform/hashmap.h |
index d5a02930f45f4c780c89229ba293f48aba1c231b..b5c938f4c42077414f5bc9d519fed1179a99f603 100644 |
--- a/runtime/platform/hashmap.h |
+++ b/runtime/platform/hashmap.h |
@@ -13,6 +13,8 @@ class HashMap { |
public: |
typedef bool (*MatchFun) (void* key1, void* key2); |
+ typedef void (*ClearFun) (void* value); |
+ |
static bool SamePointerValue(void* key1, void* key2) { |
return key1 == key2; |
} |
@@ -48,6 +50,7 @@ class HashMap { |
// Some clients may not need to use the value slot |
// (e.g. implementers of sets, where the key is the value). |
struct Entry { |
+ Entry() : key(NULL), value(NULL), hash(0) {} |
void* key; |
void* value; |
uint32_t hash; // The full hash value for key. |
@@ -63,8 +66,12 @@ class HashMap { |
// Removes the entry with matching key. |
void Remove(void* key, uint32_t hash); |
- // Empties the hash map (occupancy() == 0). |
- void Clear(); |
+ // Empties the hash map (occupancy() == 0), and calls the function 'clear' on |
+ // each of the values if given. |
+ void Clear(ClearFun clear = NULL); |
+ |
+ // The number of entries stored in the table. |
+ intptr_t size() const { return occupancy_; } |
// The capacity of the table. The implementation |
// makes sure that occupancy is at most 80% of |