Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2786)

Unified Diff: base/containers/mru_cache.h

Issue 1515243003: MRUCacheBase - Added Swap method to exchange contents of two MRUCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/containers/mru_cache_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/containers/mru_cache.h
diff --git a/base/containers/mru_cache.h b/base/containers/mru_cache.h
index ed1ad251a2f607ee0b2a8f0384d9368474f4cf54..a21a02034f39b416326b18fa653ad092a1eae587 100644
--- a/base/containers/mru_cache.h
+++ b/base/containers/mru_cache.h
@@ -137,6 +137,20 @@ class MRUCacheBase {
return index_iter->second;
}
+ // Exchanges the contents of |this| by the contents of the |other|.
+ void Swap(MRUCacheBase& other) {
+ ordering_.swap(other.ordering_);
+ index_.swap(other.index_);
+
+ DeletorType temp_deletor(other.deletor_);
Lei Zhang 2015/12/17 23:43:23 Does std::swap() work here and below on line 149?
ramant (doing other things) 2015/12/18 00:32:51 Done.
+ other.deletor_ = deletor_;
+ deletor_ = temp_deletor;
+
+ size_type temp_max_size = other.max_size_;
+ other.max_size_ = max_size_;
+ max_size_ = temp_max_size;
+ }
+
// Erases the item referenced by the given iterator. An iterator to the item
// following it will be returned. The iterator must be valid.
iterator Erase(iterator pos) {
« no previous file with comments | « no previous file | base/containers/mru_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698