CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
SmallFlatMap.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <sfl/small_flat_map.hpp>
7#include <sfl/small_flat_multimap.hpp>
8#include <sfl/small_unordered_flat_map.hpp>
9#include <sfl/small_unordered_flat_multimap.hpp>
10
11namespace CeresEngine {
12
29 template<typename Key, typename T, std::size_t N, typename Compare = std::less<>, typename RawAllocator = DefaultAllocator>
30 using SmallFlatMap = sfl::small_flat_map<Key, T, N, Compare, StdAllocator<std::pair<Key, T>, RawAllocator>>;
31
49 template<typename Key, typename T, std::size_t N, typename Compare = std::less<>, typename RawAllocator = DefaultAllocator>
50 using SmallFlatMultimap = sfl::small_flat_multimap<Key, T, N, Compare, StdAllocator<std::pair<Key, T>, RawAllocator>>;
51
68 template<typename Key, typename T, std::size_t N, typename KeyEqual = std::equal_to<>, typename RawAllocator = DefaultAllocator>
69 using SmallUnorderedFlatMap = sfl::small_unordered_flat_map<Key, T, N, KeyEqual, StdAllocator<std::pair<Key, T>, RawAllocator>>;
70
90 template<typename Key, typename T, std::size_t N, typename KeyEqual = std::equal_to<>, typename RawAllocator = DefaultAllocator>
91 using SmallUnorderedFlatMultimap = sfl::small_unordered_flat_multimap<Key, T, N, KeyEqual, StdAllocator<std::pair<Key, T>, RawAllocator>>;
92
93} // namespace CeresEngine
94
95template<typename Key, typename T, std::size_t N, typename Compare, typename RawAllocator>
96struct std::hash<CeresEngine::SmallFlatMap<Key, T, N, Compare, RawAllocator>> {
98
99 [[nodiscard]] size_t operator()(const ValueType& value) {
100 size_t hash = 0;
101 for(const auto& entry : value) {
102 CeresEngine::combine(hash, entry);
103 }
104 return hash;
105 }
106};
107
108template<typename Key, typename T, std::size_t N, typename Compare, typename RawAllocator>
109struct std::hash<CeresEngine::SmallFlatMultimap<Key, T, N, Compare, RawAllocator>> {
111
112 [[nodiscard]] size_t operator()(const ValueType& value) {
113 size_t hash = 0;
114 for(const auto& entry : value) {
115 CeresEngine::combine(hash, entry);
116 }
117 return hash;
118 }
119};
120
121template<typename Key, typename T, std::size_t N, typename KeyEqual, typename RawAllocator>
122struct std::hash<CeresEngine::SmallUnorderedFlatMap<Key, T, N, KeyEqual, RawAllocator>> {
124
125 [[nodiscard]] size_t operator()(const ValueType& value) {
126 size_t hash = 0;
127 for(const auto& entry : value) {
128 CeresEngine::combine(hash, entry);
129 }
130 return hash;
131 }
132};
133
134template<typename Key, typename T, std::size_t N, typename KeyEqual, typename RawAllocator>
135struct std::hash<CeresEngine::SmallUnorderedFlatMultimap<Key, T, N, KeyEqual, RawAllocator>> {
137
138 [[nodiscard]] size_t operator()(const ValueType& value) {
139 size_t hash = 0;
140 for(const auto& entry : value) {
141 CeresEngine::combine(hash, entry);
142 }
143 return hash;
144 }
145};
Definition Application.hpp:19
sfl::small_unordered_flat_multimap< Key, T, N, KeyEqual, StdAllocator< std::pair< Key, T >, RawAllocator > > SmallUnorderedFlatMultimap
SmallUnorderedFlatMultimap is an unordered associative container similar to HashMultimap.
Definition SmallFlatMap.hpp:91
sfl::small_unordered_flat_map< Key, T, N, KeyEqual, StdAllocator< std::pair< Key, T >, RawAllocator > > SmallUnorderedFlatMap
SmallUnorderedFlatMap is an unordered associative container similar to HashMap.
Definition SmallFlatMap.hpp:69
constexpr void combine(std::size_t &seed, const T &v)
Generates a new hash for the provided type using the default standard hasher and combines it with a p...
Definition Hash.hpp:32
sfl::small_flat_map< Key, T, N, Compare, StdAllocator< std::pair< Key, T >, RawAllocator > > SmallFlatMap
SmallFlatMap is a sorted associative container similar to Map.
Definition SmallFlatMap.hpp:30
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
sfl::small_flat_multimap< Key, T, N, Compare, StdAllocator< std::pair< Key, T >, RawAllocator > > SmallFlatMultimap
SmallFlatMultimap is a sorted associative container similar to Multimap.
Definition SmallFlatMap.hpp:50