nfx-containers 0.6.0
Modern C++20 header-only library providing high-performance hash containers with Robin Hood and perfect hashing
Loading...
Searching...
No Matches
TransparentHashMap.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2025 nfx
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
31
32#pragma once
33
34#include <nfx/Hashing.h>
35
36#include <cstddef>
37#include <cstdint>
38#include <functional>
39#include <string>
40#include <type_traits>
41#include <unordered_map>
42
43namespace nfx::containers
44{
45 //=====================================================================
46 // TransparentHashMap class
47 //=====================================================================
48
56 template <typename TKey,
57 typename TValue,
58 typename Hash = hashing::Hasher<uint32_t>,
59 typename KeyEqual = std::equal_to<>>
60 class TransparentHashMap final : public std::unordered_map<TKey, TValue, Hash, KeyEqual>
61 {
62 using Base = std::unordered_map<TKey, TValue, Hash, KeyEqual>;
63
64 public:
65 //----------------------------------------------
66 // Type aliases
67 //----------------------------------------------
68
70 using key_type = TKey;
71
73 using mapped_type = TValue;
74
76 using value_type = std::pair<const TKey, TValue>;
77
79 using hasher = Hash;
80
82 using key_equal = KeyEqual;
83
85 using size_type = size_t;
86
88 using difference_type = std::ptrdiff_t;
89
90 //----------------------------------------------
91 // Inherited Constructors
92 //----------------------------------------------
93
94 using Base::Base;
95 };
96} // namespace nfx::containers
Generic unordered map with transparent lookup.
KeyEqual key_equal
Type alias for key equality comparator.
TKey key_type
Type alias for key type.
TValue mapped_type
Type alias for mapped value type.
std::ptrdiff_t difference_type
Type alias for difference type.
Hash hasher
Type alias for hasher type.
std::pair< const TKey, TValue > value_type
Type alias for value type (pair<const Key, Value>).
size_t size_type
Type alias for size type.