| 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_MEMORY_MRU_CACHE_H_ | 16 #ifndef BASE_MEMORY_MRU_CACHE_H_ |
| 17 #define BASE_MEMORY_MRU_CACHE_H_ | 17 #define BASE_MEMORY_MRU_CACHE_H_ |
| 18 #pragma once | |
| 19 | 18 |
| 20 #include <list> | 19 #include <list> |
| 21 #include <map> | 20 #include <map> |
| 22 #include <utility> | 21 #include <utility> |
| 23 | 22 |
| 24 #include "base/basictypes.h" | 23 #include "base/basictypes.h" |
| 25 #include "base/hash_tables.h" | 24 #include "base/hash_tables.h" |
| 26 #include "base/logging.h" | 25 #include "base/logging.h" |
| 27 | 26 |
| 28 namespace base { | 27 namespace base { |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 virtual ~HashingMRUCache() { | 296 virtual ~HashingMRUCache() { |
| 298 } | 297 } |
| 299 | 298 |
| 300 private: | 299 private: |
| 301 DISALLOW_COPY_AND_ASSIGN(HashingMRUCache); | 300 DISALLOW_COPY_AND_ASSIGN(HashingMRUCache); |
| 302 }; | 301 }; |
| 303 | 302 |
| 304 } // namespace base | 303 } // namespace base |
| 305 | 304 |
| 306 #endif // BASE_MEMORY_MRU_CACHE_H_ | 305 #endif // BASE_MEMORY_MRU_CACHE_H_ |
| OLD | NEW |