116 } |
117 } |
117 |
118 |
118 template<typename T, typename R, typename K> |
119 template<typename T, typename R, typename K> |
119 R* findInMap(std::map<T, R>& map, K&& key) |
120 R* findInMap(std::map<T, R>& map, K&& key) |
120 { |
121 { |
|
122 static_assert(std::is_convertible_v<K, T>, "bad type for key parameter"); |
121 auto pair = map.find(key); |
123 auto pair = map.find(key); |
122 if (pair != map.end()) |
124 if (pair != map.end()) |
123 { |
125 { |
124 return &pair->second; |
126 return &pair->second; |
125 } |
127 } |
302 template<typename T, glm::qualifier Q> |
304 template<typename T, glm::qualifier Q> |
303 constexpr unsigned int qHash(const glm::vec<3, T, Q>& key) |
305 constexpr unsigned int qHash(const glm::vec<3, T, Q>& key) |
304 { |
306 { |
305 return qHash(key.x) ^ rotl10(qHash(key.y)) ^ rotl20(qHash(key.z)); |
307 return qHash(key.x) ^ rotl10(qHash(key.y)) ^ rotl20(qHash(key.z)); |
306 } |
308 } |
|
309 |
|
310 template<typename K, typename V, typename Fn> |
|
311 void forValueInMap(const std::map<K, V>& map, Fn&& fn) |
|
312 { |
|
313 for (const auto& it : map) { |
|
314 fn(it.second); |
|
315 } |
|
316 } |
|
317 |
|
318 inline QString joined(QString value, const QString& separator, const QString& element) |
|
319 { |
|
320 if (not value.isEmpty()) { |
|
321 value += separator; |
|
322 } |
|
323 value += element; |
|
324 return value; |
|
325 } |