From eeb090c9cb78b3f4808ca5479c1ca8cf62082bee Mon Sep 17 00:00:00 2001 From: "pkasting@chromium.org" Date: Fri, 2 Oct 2009 20:40:56 +0000 Subject: Add a Clear() function to MRUCache. This will be useful in my MemoryPurger class. Technically you can call ShrinkToSize(0), but that's both less clear and slower. BUG=23400 TEST=none Review URL: http://codereview.chromium.org/257024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27892 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/mru_cache.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'chrome/common/mru_cache.h') diff --git a/chrome/common/mru_cache.h b/chrome/common/mru_cache.h index 02e7242..9190d9d 100644 --- a/chrome/common/mru_cache.h +++ b/chrome/common/mru_cache.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -137,6 +137,15 @@ class MRUCacheBase { Erase(rbegin()); } + // Deletes everything from the cache. + void Clear() { + for (typename PayloadList::iterator i(ordering_.begin()); + i != ordering_.end(); ++i) + deletor_(i->second); + index_.clear(); + ordering_.clear(); + } + // Returns the number of elements in the cache. size_type size() const { // We don't use ordering_.size() for the return value because -- cgit v1.1