stl_wrappers.h 898 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/memtablerep.h"
  10. #include "rocksdb/slice.h"
  11. #include "util/coding.h"
  12. namespace ROCKSDB_NAMESPACE {
  13. namespace stl_wrappers {
  14. class Base {
  15. protected:
  16. const MemTableRep::KeyComparator& compare_;
  17. explicit Base(const MemTableRep::KeyComparator& compare)
  18. : compare_(compare) {}
  19. };
  20. struct Compare : private Base {
  21. explicit Compare(const MemTableRep::KeyComparator& compare) : Base(compare) {}
  22. inline bool operator()(const char* a, const char* b) const {
  23. return compare_(a, b) < 0;
  24. }
  25. };
  26. }
  27. } // namespace ROCKSDB_NAMESPACE