.. _program_listing_file_include_judge_PDJE_RAIL.hpp: Program Listing for File PDJE_RAIL.hpp ====================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include\judge\PDJE_RAIL.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include "PDJE_Rule.hpp" static inline uint64_t splitmix64_mix(uint64_t x) noexcept { x += 0x9e3779b97f4a7c15ULL; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9ULL; x = (x ^ (x >> 27)) * 0x94d049bb133111ebULL; return x ^ (x >> 31); } static inline void hash_combine64(uint64_t &seed, uint64_t v) noexcept { seed = splitmix64_mix(seed ^ v); } template static inline uint64_t h64(const T &v) noexcept { return static_cast(std::hash{}(v)); } namespace std { template <> struct std::hash { std::size_t operator()(const PDJE_JUDGE::RAIL_KEY::KB_MOUSE &rule) const noexcept { uint64_t seed = 0; hash_combine64(seed, h64(rule.Device_Name)); hash_combine64(seed, h64(rule.DeviceKey)); return static_cast(seed); } }; template <> struct std::hash { std::size_t operator()(const PDJE_JUDGE::RAIL_KEY::MIDI &rule) const noexcept { uint64_t seed = 0; hash_combine64(seed, h64(rule.ch)); hash_combine64(seed, h64(rule.port_name)); hash_combine64(seed, h64(rule.pos)); hash_combine64(seed, h64(rule.type)); return static_cast(seed); } }; }; // namespace std namespace PDJE_JUDGE { struct RAIL_DB { std::unordered_map offset; std::unordered_map> meta; std::unordered_map kb_mouse_raildata; std::unordered_map midi_raildata; void Add(const RAIL_KEY::KB_MOUSE &key, const PDJE_Dev_Type &type, const uint64_t &id, const int64_t offset); void Add(const RAIL_KEY::MIDI &key, const uint64_t &id, const int64_t offset); void Delete(const RAIL_KEY::KB_MOUSE &key); void Delete(const RAIL_KEY::MIDI &key); bool Empty(); void Clear(); std::optional GetID(const RAIL_KEY::KB_MOUSE &key); std::optional GetID(const RAIL_KEY::MIDI &key); std::optional> GetMETA(const uint64_t id); }; }; // namespace PDJE_JUDGE