Hash :
df90bbc5
        
        Author :
  
        
        Date :
2024-07-12T18:04:53
        
      
Refactoring: move angle::HashMap and HashSet to own header Underlying abseil includes pull in a large set of headers Bug: angleproject:42266508 Change-Id: Icee47143a8a59bb0795a054b67c0aa4ddcfca4d4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5704137 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
//
// Copyright 2024 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// hash_containers.h: angle::HashMap and HashSet
#ifndef COMMON_HASH_CONTAINERS_H_
#define COMMON_HASH_CONTAINERS_H_
#if defined(ANGLE_USE_ABSEIL)
#    include "absl/container/flat_hash_map.h"
#    include "absl/container/flat_hash_set.h"
#else
#    include <unordered_map>
#    include <unordered_set>
#endif  // defined(ANGLE_USE_ABSEIL)
namespace angle
{
#if defined(ANGLE_USE_ABSEIL)
template <typename Key,
          typename T,
          class Hash = absl::container_internal::hash_default_hash<Key>,
          class Eq   = absl::container_internal::hash_default_eq<Key>>
using HashMap = absl::flat_hash_map<Key, T, Hash, Eq>;
template <typename Key,
          class Hash = absl::container_internal::hash_default_hash<Key>,
          class Eq   = absl::container_internal::hash_default_eq<Key>>
using HashSet = absl::flat_hash_set<Key, Hash, Eq>;
// Absl has generic lookup unconditionally
#    define ANGLE_HAS_HASH_MAP_GENERIC_LOOKUP 1
#else
template <typename Key,
          typename T,
          class Hash     = std::hash<Key>,
          class KeyEqual = std::equal_to<Key>>
using HashMap = std::unordered_map<Key, T, Hash, KeyEqual>;
template <typename Key, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
using HashSet = std::unordered_set<Key, Hash, KeyEqual>;
#    if __cpp_lib_generic_unordered_lookup >= 201811L
#        define ANGLE_HAS_HASH_MAP_GENERIC_LOOKUP 1
#    else
#        define ANGLE_HAS_HASH_MAP_GENERIC_LOOKUP 0
#    endif
#endif  // defined(ANGLE_USE_ABSEIL)
}  // namespace angle
#endif  // COMMON_HASH_CONTAINERS_H_