1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
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).
5 
6 #pragma once
7 
8 namespace ROCKSDB_NAMESPACE {
9 // A comparator to be used in std::set
10 struct SetComparator {
SetComparatorSetComparator11   explicit SetComparator() : user_comparator_(BytewiseComparator()) {}
SetComparatorSetComparator12   explicit SetComparator(const Comparator* user_comparator)
13       : user_comparator_(user_comparator ? user_comparator
14                                          : BytewiseComparator()) {}
operatorSetComparator15   bool operator()(const Slice& lhs, const Slice& rhs) const {
16     return user_comparator_->Compare(lhs, rhs) < 0;
17   }
18 
19  private:
20   const Comparator* user_comparator_;
21 };
22 }  // namespace ROCKSDB_NAMESPACE
23