From fea0b9617466710b4961623de0e7a34846e88cbe Mon Sep 17 00:00:00 2001 From: "jsbell@chromium.org" Date: Mon, 29 Oct 2012 21:36:22 +0000 Subject: 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 --- base/id_map.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'base/id_map.h') 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::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; -- cgit v1.1