push version 0.12.0. Breaking changes to the hashmap typename, Now blt::hashmap_t and blt::hashset_t

This was done to be more consistent
v1
Brett 2024-02-25 14:39:56 -05:00
parent 61d46de573
commit 9b4d0cc9a8
6 changed files with 36 additions and 32 deletions

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.5)
include(cmake/color.cmake)
set(BLT_VERSION 0.11.3)
set(BLT_VERSION 0.12.0)
set(BLT_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT)

View File

@ -250,8 +250,8 @@ namespace blt::nbt {
BLT_WARN("Tag Type not found!");
return nullptr;
}
static HASHMAP<std::string, tag_t*> toHashmap(const std::vector<tag_t*>& v){
HASHMAP<std::string, tag_t*> tags;
static hashmap_t<std::string, tag_t*> toHashmap(const std::vector<tag_t*>& v){
hashmap_t<std::string, tag_t*> tags;
for (const auto& t : v)
tags[t->getName()] = t;
return tags;
@ -321,12 +321,12 @@ namespace blt::nbt {
}
};
class tag_compound : public tag<HASHMAP<std::string, tag_t*>> {
class tag_compound : public tag<hashmap_t<std::string, tag_t*>> {
public:
tag_compound(): tag(nbt_tag::COMPOUND) {}
tag_compound(const std::string& name, const std::vector<tag_t*>& v): tag(nbt_tag::COMPOUND, name, _internal_::toHashmap(v)) {}
tag_compound(const std::string& name, const std::initializer_list<tag_t*>& v): tag(nbt_tag::COMPOUND, name, _internal_::toHashmap(v)) {}
tag_compound(const std::string& name, const HASHMAP<std::string, tag_t*>& v): tag(nbt_tag::COMPOUND, name, v) {}
tag_compound(const std::string& name, const hashmap_t<std::string, tag_t*>& v): tag(nbt_tag::COMPOUND, name, v) {}
inline void put(tag_t* tag) {
t[tag->getName()] = tag;

View File

@ -332,11 +332,11 @@ namespace blt
friend arg_parse;
private:
// stores dest value not the flag/name!
HASHSET<std::string> found_args;
hashset_t<std::string> found_args;
std::vector<std::string> unrecognized_args;
public:
std::string program_name;
HASHMAP<std::string, arg_data_t> data;
hashmap_t<std::string, arg_data_t> data;
inline arg_data_t& operator[](const std::string& key)
{
@ -384,7 +384,7 @@ namespace blt
std::string postfix;
public:
std::vector<arg_properties_t*> name_associations;
HASHMAP<std::string, arg_properties_t*> flag_associations;
hashmap_t<std::string, arg_properties_t*> flag_associations;
} user_args;
arg_results loaded_args;

View File

@ -116,9 +116,9 @@ namespace blt::parse
private:
std::vector<constructed_vertex_t> vertex_data_;
std::vector<object_data> objects_;
HASHMAP<std::string, material_t> materials_;
hashmap_t<std::string, material_t> materials_;
public:
obj_model_t(std::vector<constructed_vertex_t>&& vertex_data, std::vector<object_data>&& objects, HASHMAP<std::string, material_t>&& mats):
obj_model_t(std::vector<constructed_vertex_t>&& vertex_data, std::vector<object_data>&& objects, hashmap_t<std::string, material_t>&& mats):
vertex_data_(vertex_data), objects_(objects), materials_(mats)
{}
@ -148,11 +148,11 @@ namespace blt::parse
std::vector<normal_t> normals;
// maps between face (constructed vertex) -> vertex indices
HASHMAP<face_t, std::int32_t, face_hash, face_eq> vertex_map;
hashmap_t<face_t, std::int32_t, face_hash, face_eq> vertex_map;
std::vector<constructed_vertex_t> vertex_data;
object_data current_object;
std::vector<object_data> data;
HASHMAP<std::string, material_t> materials;
hashmap_t<std::string, material_t> materials;
size_t current_line = 0;
private:

View File

@ -9,7 +9,7 @@
namespace blt
{
// template<typename K, typename V, typename Hash = std::hash<K>, typename Eq = std::equal_to<K>>
// class hashmap
// {
@ -18,7 +18,7 @@ namespace blt
// public:
//
// };
}
#ifndef HASHMAP
@ -27,32 +27,36 @@ namespace blt
#include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap_fwd_decl.h>
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 = 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 = phmap::flat_hash_set<T, Hash, Eq, Alloc>;
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,
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 = std::unordered_map<K, V, Hash, Eq, Alloc>;
template<typename K,
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 = std::unordered_set<K, Hash, Eq, Alloc>;
using hashset_t = std::unordered_set<K, Hash, Eq, Alloc>;
}
#endif
#endif

View File

@ -210,8 +210,8 @@ namespace blt
* profiler V1 partial backwards compat
* ----------------------------
*/
HASHMAP<std::string, HASHMAP<std::string, interval_t*>> profiles;
hashmap_t<std::string, hashmap_t<std::string, interval_t*>> profiles;
void _internal::startInterval(const std::string& profile_name, const std::string& interval_name)
{