diff options
author | rtk0c <[email protected]> | 2022-05-30 15:56:29 -0700 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-05-30 15:56:29 -0700 |
commit | 80afa67d2b9f1c0605696a3fd69058544fe12fe4 (patch) | |
tree | 3dfe2a6f45e4f5ca8ad534baf06d76d9c558333b /source/Utils.hpp | |
parent | 0d92ecfdbfc875a099d9e83714b3a2209668fca5 (diff) | |
parent | 7d8bca09b3c4bf1418e758bd3bd0d6f85672153e (diff) |
Changeset: 53
Diffstat (limited to 'source/Utils.hpp')
-rw-r--r-- | source/Utils.hpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/source/Utils.hpp b/source/Utils.hpp deleted file mode 100644 index 9f28aad..0000000 --- a/source/Utils.hpp +++ /dev/null @@ -1,61 +0,0 @@ -#pragma once - -#include <robin_hood.h> -#include <cstdio> -#include <cstring> -#include <filesystem> -#include <glm/glm.hpp> - -namespace Utils { - -enum IoMode { - Read, - WriteTruncate, - WriteAppend, -}; - -FILE* OpenCstdioFile(const std::filesystem::path& path, IoMode mode, bool binary = false); -FILE* OpenCstdioFile(const char* path, IoMode mode, bool binary = false); - -constexpr float Abs(float v) noexcept { - return v < 0.0f ? -v : v; -} - -bool InRangeInclusive(int n, int lower, int upper); -bool LineContains(glm::ivec2 p1, glm::ivec2 p2, glm::ivec2 candidate); - -bool IsColinear(glm::ivec2 p1, glm::ivec2 p2); - -template <class T> -void HashCombine(std::size_t& seed, const T& v) { - seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); -} - -std::string MakeRandomNumberedName(const char* tag); - -} // namespace Utils - -struct StringHash { - using is_transparent = void; - - std::size_t operator()(const std::string& key) const { return robin_hood::hash_bytes(key.c_str(), key.size()); } - std::size_t operator()(std::string_view key) const { return robin_hood::hash_bytes(key.data(), key.size()); } - std::size_t operator()(const char* key) const { return robin_hood::hash_bytes(key, std::strlen(key)); } -}; - -struct StringEqual { - using is_transparent = int; - - bool operator()(std::string_view lhs, const std::string& rhs) const { - const std::string_view view = rhs; - return lhs == view; - } - - bool operator()(const char* lhs, const std::string& rhs) const { - return std::strcmp(lhs, rhs.c_str()) == 0; - } - - bool operator()(const std::string& lhs, const std::string& rhs) const { - return lhs == rhs; - } -}; |