chromium/third_party/angle/src/common/hash_containers.h

//
// 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)
HashMap;
HashSet;

// Absl has generic lookup unconditionally
#define ANGLE_HAS_HASH_MAP_GENERIC_LOOKUP
#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
#    else
#define ANGLE_HAS_HASH_MAP_GENERIC_LOOKUP
#    endif
#endif  // defined(ANGLE_USE_ABSEIL)

}  // namespace angle

#endif  // COMMON_HASH_CONTAINERS_H_