hash_containers.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) Facebook, Inc. and its affiliates. 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. // This header establishes compile-time pluggable implementations of hashed
  6. // container structures, so that deployments have the option of minimal
  7. // dependencies with ok performance (e.g. std::unordered_map) or more
  8. // dependencies with optimized performance (e.g. folly::F14FastMap).
  9. #pragma once
  10. #include "rocksdb/rocksdb_namespace.h"
  11. #ifdef USE_FOLLY
  12. #include <folly/container/F14Map.h>
  13. #include <folly/container/F14Set.h>
  14. namespace ROCKSDB_NAMESPACE {
  15. template <typename K, typename V>
  16. using UnorderedMap = folly::F14FastMap<K, V>;
  17. template <typename K, typename V, typename H>
  18. using UnorderedMapH = folly::F14FastMap<K, V, H>;
  19. template <typename K>
  20. using UnorderedSet = folly::F14FastSet<K>;
  21. } // namespace ROCKSDB_NAMESPACE
  22. #else
  23. #include <unordered_map>
  24. #include <unordered_set>
  25. namespace ROCKSDB_NAMESPACE {
  26. template <typename K, typename V>
  27. using UnorderedMap = std::unordered_map<K, V>;
  28. template <typename K, typename V, typename H>
  29. using UnorderedMapH = std::unordered_map<K, V, H>;
  30. template <typename K>
  31. using UnorderedSet = std::unordered_set<K>;
  32. } // namespace ROCKSDB_NAMESPACE
  33. #endif