BLT/include/blt/std/hashmap.h

64 lines
1.7 KiB
C
Raw Normal View History

/*
* Created by Brett on 31/03/23.
* Licensed under GNU General Public License V3.0
* See LICENSE file for license detail
*/
#ifndef BLT_HASH_MAP_H
#define BLT_HASH_MAP_H
2023-09-13 16:49:56 -04:00
namespace blt
{
2023-09-13 16:49:56 -04:00
// template<typename K, typename V, typename Hash = std::hash<K>, typename Eq = std::equal_to<K>>
// class hashmap
// {
// private:
//
// public:
//
// };
2023-09-13 16:49:56 -04:00
}
#ifndef HASHMAP
#if defined __has_include && __has_include(<parallel_hashmap/phmap.h>)
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap_fwd_decl.h>
namespace blt
{
template<class K, class V,
class Hash = phmap::priv::hash_default_hash <K>,
class Eq = phmap::priv::hash_default_eq <K>,
class Alloc = phmap::priv::Allocator <phmap::priv::Pair<const K, V>>>
using hashmap_t = phmap::flat_hash_map<K, V, Hash, Eq, Alloc>;
template<class T,
class Hash = phmap::priv::hash_default_hash <T>,
class Eq = phmap::priv::hash_default_eq <T>,
class Alloc = phmap::priv::Allocator <T>>
using hashset_t = phmap::flat_hash_set<T, Hash, Eq, Alloc>;
}
#else
namespace blt {
#include <unordered_map>
#include <unordered_set>
template<typename K, typename V,
typename Hash = std::hash<K>,
typename Eq = std::equal_to<K>,
typename Alloc = std::allocator<std::pair<const K, V>>>
using hashmap_t = std::unordered_map<K, V, Hash, Eq, Alloc>;
template<typename K,
typename Hash = std::hash<K>,
typename Eq = std::equal_to<K>,
typename Alloc = std::allocator<K>>
using hashset_t = std::unordered_set<K, Hash, Eq, Alloc>;
}
#endif
#endif
#endif //BLT_HASH_MAP_H