Add new StringHashMap container (bug 5878 part 1, r=ds).

This commit is contained in:
David Anderson
2013-08-25 01:42:14 -07:00
parent ea3e602835
commit 3b9037397a
4 changed files with 203 additions and 5 deletions
+4
View File
@@ -131,6 +131,10 @@ class HashMap : public AllocPolicy
return table_.add(i);
}
void clear() {
table_.clear();
}
size_t estimateMemoryUse() const {
return table_.estimateMemoryUse();
}
+12
View File
@@ -60,6 +60,10 @@ namespace detail {
destruct();
hash_ = kRemovedHash;
}
void setFree() {
destruct();
hash_ = kFreeHash;
}
void initialize() {
hash_ = kFreeHash;
}
@@ -432,6 +436,14 @@ class HashTable : public AllocPolicy
return true;
}
void clear() {
for (size_t i = 0; i < capacity_; i++) {
table_[i].setFree();
}
ndeleted_ = 0;
nelements_ = 0;
}
size_t estimateMemoryUse() const {
return sizeof(Entry) * capacity_;
}