| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // This file contains a template for a Most Recently Used cache that allows | 5 // This file contains a template for a Most Recently Used cache that allows |
| 6 // constant-time access to items using a key, but easy identification of the | 6 // constant-time access to items using a key, but easy identification of the |
| 7 // least-recently-used items for removal. Each key can only be associated with | 7 // least-recently-used items for removal. Each key can only be associated with |
| 8 // one payload item at a time. | 8 // one payload item at a time. |
| 9 // | 9 // |
| 10 // The key object will be stored twice, so it should support efficient copying. | 10 // The key object will be stored twice, so it should support efficient copying. |
| 11 // | 11 // |
| 12 // NOTE: While all operations are O(1), this code is written for | 12 // NOTE: While all operations are O(1), this code is written for |
| 13 // legibility rather than optimality. If future profiling identifies this as | 13 // legibility rather than optimality. If future profiling identifies this as |
| 14 // a bottleneck, there is room for smaller values of 1 in the O(1). :] | 14 // a bottleneck, there is room for smaller values of 1 in the O(1). :] |
| 15 | 15 |
| 16 #ifndef BASE_CONTAINERS_MRU_CACHE_H_ | 16 #ifndef BASE_CONTAINERS_MRU_CACHE_H_ |
| 17 #define BASE_CONTAINERS_MRU_CACHE_H_ | 17 #define BASE_CONTAINERS_MRU_CACHE_H_ |
| 18 | 18 |
| 19 #include <list> | 19 #include <list> |
| 20 #include <map> | 20 #include <map> |
| 21 #include <utility> | 21 #include <utility> |
| 22 | 22 |
| 23 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 24 #include "base/hash_tables.h" | 24 #include "base/containers/hash_tables.h" |
| 25 #include "base/logging.h" | 25 #include "base/logging.h" |
| 26 | 26 |
| 27 namespace base { | 27 namespace base { |
| 28 | 28 |
| 29 // MRUCacheBase ---------------------------------------------------------------- | 29 // MRUCacheBase ---------------------------------------------------------------- |
| 30 | 30 |
| 31 // This template is used to standardize map type containers that can be used | 31 // This template is used to standardize map type containers that can be used |
| 32 // by MRUCacheBase. This level of indirection is necessary because of the way | 32 // by MRUCacheBase. This level of indirection is necessary because of the way |
| 33 // that template template params and default template params interact. | 33 // that template template params and default template params interact. |
| 34 template <class KeyType, class ValueType> | 34 template <class KeyType, class ValueType> |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 virtual ~HashingMRUCache() { | 296 virtual ~HashingMRUCache() { |
| 297 } | 297 } |
| 298 | 298 |
| 299 private: | 299 private: |
| 300 DISALLOW_COPY_AND_ASSIGN(HashingMRUCache); | 300 DISALLOW_COPY_AND_ASSIGN(HashingMRUCache); |
| 301 }; | 301 }; |
| 302 | 302 |
| 303 } // namespace base | 303 } // namespace base |
| 304 | 304 |
| 305 #endif // BASE_CONTAINERS_MRU_CACHE_H_ | 305 #endif // BASE_CONTAINERS_MRU_CACHE_H_ |
| OLD | NEW |