]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/table/iter_heap.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
9 #include "rocksdb/comparator.h"
10 #include "table/iterator_wrapper.h"
14 // When used with std::priority_queue, this comparison functor puts the
15 // iterator with the max/largest key on top.
16 class MaxIteratorComparator
{
18 MaxIteratorComparator(const Comparator
* comparator
) :
19 comparator_(comparator
) {}
21 bool operator()(IteratorWrapper
* a
, IteratorWrapper
* b
) const {
22 return comparator_
->Compare(a
->key(), b
->key()) < 0;
25 const Comparator
* comparator_
;
28 // When used with std::priority_queue, this comparison functor puts the
29 // iterator with the min/smallest key on top.
30 class MinIteratorComparator
{
32 MinIteratorComparator(const Comparator
* comparator
) :
33 comparator_(comparator
) {}
35 bool operator()(IteratorWrapper
* a
, IteratorWrapper
* b
) const {
36 return comparator_
->Compare(a
->key(), b
->key()) > 0;
39 const Comparator
* comparator_
;
42 } // namespace rocksdb