2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2013-10-16 23:59:46 +02:00
|
|
|
//
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2013-10-05 07:32:05 +02:00
|
|
|
#pragma once
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2017-09-11 20:53:22 +02:00
|
|
|
#include "db/dbformat.h"
|
2012-12-26 20:51:36 +01:00
|
|
|
#include "table/iterator_wrapper.h"
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the max/largest key on top.
|
2012-12-26 20:51:36 +01:00
|
|
|
class MaxIteratorComparator {
|
|
|
|
public:
|
2017-09-11 20:53:22 +02:00
|
|
|
MaxIteratorComparator(const InternalKeyComparator* comparator)
|
|
|
|
: comparator_(comparator) {}
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
|
|
|
return comparator_->Compare(a->key(), b->key()) < 0;
|
2012-12-26 20:51:36 +01:00
|
|
|
}
|
|
|
|
private:
|
2017-09-11 20:53:22 +02:00
|
|
|
const InternalKeyComparator* comparator_;
|
2012-12-26 20:51:36 +01:00
|
|
|
};
|
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
// When used with std::priority_queue, this comparison functor puts the
|
|
|
|
// iterator with the min/smallest key on top.
|
2012-12-26 20:51:36 +01:00
|
|
|
class MinIteratorComparator {
|
|
|
|
public:
|
2017-09-11 20:53:22 +02:00
|
|
|
MinIteratorComparator(const InternalKeyComparator* comparator)
|
|
|
|
: comparator_(comparator) {}
|
2012-12-26 20:51:36 +01:00
|
|
|
|
2015-07-06 13:24:09 +02:00
|
|
|
bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
|
2012-12-26 20:51:36 +01:00
|
|
|
return comparator_->Compare(a->key(), b->key()) > 0;
|
|
|
|
}
|
|
|
|
private:
|
2017-09-11 20:53:22 +02:00
|
|
|
const InternalKeyComparator* comparator_;
|
2012-12-26 20:51:36 +01:00
|
|
|
};
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|