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
TransparentHashSet.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_set>
42
43namespace nfx::containers
44{
45 //=====================================================================
46 // TransparentHashSet class
47 //=====================================================================
48
56 template <typename TKey,
57 typename Hash = hashing::Hasher<uint32_t>,
58 typename KeyEqual = std::equal_to<>>
59 class TransparentHashSet final : public std::unordered_set<TKey, Hash, KeyEqual>
60 {
61 using Base = std::unordered_set<TKey, Hash, KeyEqual>;
62
63 public:
64 //----------------------------------------------
65 // Type aliases
66 //----------------------------------------------
67
69 using key_type = TKey;
70
72 using value_type = TKey;
73
75 using hasher = Hash;
76
78 using key_equal = KeyEqual;
79
81 using size_type = size_t;
82
84 using difference_type = std::ptrdiff_t;
85
86 //----------------------------------------------
87 // Inherited Constructors
88 //----------------------------------------------
89
90 using Base::Base;
91 };
92} // namespace nfx::containers
Generic unordered set with transparent lookup support.
KeyEqual key_equal
Type alias for key equality comparator.
TKey value_type
Type alias for value type (same as key_type for sets).
std::ptrdiff_t difference_type
Type alias for difference type.
size_t size_type
Type alias for size type.
Hash hasher
Type alias for hasher type.
TKey key_type
Type alias for key type.