diff options
author | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 21:36:22 +0000 |
---|---|---|
committer | jsbell@chromium.org <jsbell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-29 21:36:22 +0000 |
commit | fea0b9617466710b4961623de0e7a34846e88cbe (patch) | |
tree | b8dcfb9e8f20bb20fe96ae1460841d8239278e93 /base/id_map.h | |
parent | 8560e31c3608c1c02fb7177cd1a7fc5197eff5a8 (diff) | |
download | chromium_src-fea0b9617466710b4961623de0e7a34846e88cbe.zip chromium_src-fea0b9617466710b4961623de0e7a34846e88cbe.tar.gz chromium_src-fea0b9617466710b4961623de0e7a34846e88cbe.tar.bz2 |
Add IDMap::Clear() which removes all items.
Includes unit tests.
R=brettw@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11266017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@164742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/id_map.h')
-rw-r--r-- | base/id_map.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/base/id_map.h b/base/id_map.h index bb9f05b..d3fc7b8 100644 --- a/base/id_map.h +++ b/base/id_map.h @@ -92,6 +92,17 @@ class IDMap : public base::NonThreadSafe { } } + 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; |