Skip to content

Commit

Permalink
Allow custom comparators for the MRUCache
Browse files Browse the repository at this point in the history
//base's MRUCache allowed specifying key and value types, like
an underlying std::map<>, but the default base::MRUCache explicitly
specialized the comparator as std::less<>. Rather than require the
caller to overload std::less<> or operator<, allow the comparator
to be specified as a templated argument.

BUG=665735

Review-Url: https://codereview.chromium.org/2532313002
Cr-Commit-Position: refs/heads/master@{#434850}
  • Loading branch information
sleevi authored and Commit bot committed Nov 29, 2016
1 parent 92109db commit b36da9d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions base/containers/mru_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ class MRUCacheBase {

// A container that does not do anything to free its data. Use this when storing
// value types (as opposed to pointers) in the list.
template <class KeyType, class PayloadType>
class MRUCache : public MRUCacheBase<KeyType, PayloadType, std::less<KeyType>> {
template <class KeyType,
class PayloadType,
class CompareType = std::less<KeyType>>
class MRUCache : public MRUCacheBase<KeyType, PayloadType, CompareType> {
private:
using ParentType = MRUCacheBase<KeyType, PayloadType, std::less<KeyType>>;
using ParentType = MRUCacheBase<KeyType, PayloadType, CompareType>;

public:
// See MRUCacheBase, noting the possibility of using NO_AUTO_EVICT.
Expand Down

0 comments on commit b36da9d

Please sign in to comment.