diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 20:40:56 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-02 20:40:56 +0000 |
commit | eeb090c9cb78b3f4808ca5479c1ca8cf62082bee (patch) | |
tree | db6d2d900e8732c3d57cb434c3a677b061f362f1 /chrome/common/mru_cache.h | |
parent | c60d3a08ee8d9608602808339e4b17d4c23fad8d (diff) | |
download | chromium_src-eeb090c9cb78b3f4808ca5479c1ca8cf62082bee.zip chromium_src-eeb090c9cb78b3f4808ca5479c1ca8cf62082bee.tar.gz chromium_src-eeb090c9cb78b3f4808ca5479c1ca8cf62082bee.tar.bz2 |
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
Diffstat (limited to 'chrome/common/mru_cache.h')
-rw-r--r-- | chrome/common/mru_cache.h | 11 |
1 files changed, 10 insertions, 1 deletions
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 |