kv_map.h 922 B

123456789101112131415161718192021222324252627282930313233
  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. #include <map>
  7. #include <string>
  8. #include "rocksdb/comparator.h"
  9. #include "rocksdb/slice.h"
  10. #include "util/coding.h"
  11. namespace ROCKSDB_NAMESPACE {
  12. namespace stl_wrappers {
  13. struct LessOfComparator {
  14. explicit LessOfComparator(const Comparator* c = BytewiseComparator())
  15. : cmp(c) {}
  16. bool operator()(const std::string& a, const std::string& b) const {
  17. return cmp->Compare(Slice(a), Slice(b)) < 0;
  18. }
  19. bool operator()(const Slice& a, const Slice& b) const {
  20. return cmp->Compare(a, b) < 0;
  21. }
  22. const Comparator* cmp;
  23. };
  24. typedef std::map<std::string, std::string, LessOfComparator> KVMap;
  25. }
  26. } // namespace ROCKSDB_NAMESPACE