]> git.proxmox.com Git - ceph.git/blame - ceph/src/rocksdb/table/iter_heap.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / table / iter_heap.h
CommitLineData
7c673cae 1// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
11fdf7f2
TL
2// This source code is licensed under both the GPLv2 (found in the
3// COPYING file in the root directory) and Apache 2.0 License
4// (found in the LICENSE.Apache file in the root directory).
7c673cae
FG
5//
6
7#pragma once
8
11fdf7f2 9#include "db/dbformat.h"
7c673cae
FG
10#include "table/iterator_wrapper.h"
11
f67539c2 12namespace ROCKSDB_NAMESPACE {
7c673cae
FG
13
14// When used with std::priority_queue, this comparison functor puts the
15// iterator with the max/largest key on top.
16class MaxIteratorComparator {
17 public:
11fdf7f2
TL
18 MaxIteratorComparator(const InternalKeyComparator* comparator)
19 : comparator_(comparator) {}
7c673cae
FG
20
21 bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
22 return comparator_->Compare(a->key(), b->key()) < 0;
23 }
24 private:
11fdf7f2 25 const InternalKeyComparator* comparator_;
7c673cae
FG
26};
27
28// When used with std::priority_queue, this comparison functor puts the
29// iterator with the min/smallest key on top.
30class MinIteratorComparator {
31 public:
11fdf7f2
TL
32 MinIteratorComparator(const InternalKeyComparator* comparator)
33 : comparator_(comparator) {}
7c673cae
FG
34
35 bool operator()(IteratorWrapper* a, IteratorWrapper* b) const {
36 return comparator_->Compare(a->key(), b->key()) > 0;
37 }
38 private:
11fdf7f2 39 const InternalKeyComparator* comparator_;
7c673cae
FG
40};
41
f67539c2 42} // namespace ROCKSDB_NAMESPACE