/src/rocksdb/util/kv_map.h
Line | Count | Source |
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 | | #pragma once |
6 | | |
7 | | #include <map> |
8 | | #include <string> |
9 | | |
10 | | #include "rocksdb/comparator.h" |
11 | | #include "rocksdb/slice.h" |
12 | | #include "util/coding.h" |
13 | | |
14 | | namespace ROCKSDB_NAMESPACE { |
15 | | namespace stl_wrappers { |
16 | | |
17 | | struct LessOfComparator { |
18 | | explicit LessOfComparator(const Comparator* c = BytewiseComparator()) |
19 | 40.2k | : cmp(c) {} |
20 | | |
21 | 4.59M | bool operator()(const std::string& a, const std::string& b) const { |
22 | 4.59M | return cmp->Compare(Slice(a), Slice(b)) < 0; |
23 | 4.59M | } |
24 | 0 | bool operator()(const Slice& a, const Slice& b) const { |
25 | 0 | return cmp->Compare(a, b) < 0; |
26 | 0 | } |
27 | | |
28 | | const Comparator* cmp; |
29 | | }; |
30 | | |
31 | | using KVMap = std::map<std::string, std::string, LessOfComparator>; |
32 | | } // namespace stl_wrappers |
33 | | } // namespace ROCKSDB_NAMESPACE |