Add IDMap::Clear() which removes all items.
Includes unit tests.
[email protected]
Review URL: https://chromiumcodereview.appspot.com/11266017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164742 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/base/id_map.h b/base/id_map.h
index bb9f05bb..d3fc7b8 100644
--- a/base/id_map.h
+++ b/base/id_map.h
@@ -92,6 +92,17 @@
}
}
+ void Clear() {
+ DCHECK(CalledOnValidThread());
+ if (iteration_depth_ == 0) {
+ Releaser<OS, 0>::release_all(&data_);
+ } else {
+ for (typename HashTable::iterator i = data_.begin();
+ i != data_.end(); ++i)
+ removed_ids_.insert(i->first);
+ }
+ }
+
bool IsEmpty() const {
DCHECK(CalledOnValidThread());
return size() == 0u;