Add new StringHashMap container (bug 5878 part 1, r=ds).
This commit is contained in:
@@ -131,6 +131,10 @@ class HashMap : public AllocPolicy
|
||||
return table_.add(i);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
table_.clear();
|
||||
}
|
||||
|
||||
size_t estimateMemoryUse() const {
|
||||
return table_.estimateMemoryUse();
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user