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) cmake_minimum_required(VERSION 3.5)
include(cmake/color.cmake) 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_TEST_VERSION 0.0.1)
set(BLT_TARGET BLT) set(BLT_TARGET BLT)

View File

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

View File

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

View File

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

View File

@ -27,18 +27,21 @@ namespace blt
#include <parallel_hashmap/phmap.h> #include <parallel_hashmap/phmap.h>
#include <parallel_hashmap/phmap_fwd_decl.h> #include <parallel_hashmap/phmap_fwd_decl.h>
namespace blt
{
template<class K, class V, template<class K, class V,
class Hash = phmap::priv::hash_default_hash <K>, class Hash = phmap::priv::hash_default_hash <K>,
class Eq = phmap::priv::hash_default_eq <K>, class Eq = phmap::priv::hash_default_eq <K>,
class Alloc = phmap::priv::Allocator <phmap::priv::Pair<const K, V>>> class Alloc = phmap::priv::Allocator <phmap::priv::Pair<const K, V>>>
using HASHMAP = phmap::flat_hash_map<K, V, Hash, Eq, Alloc>; using hashmap_t = phmap::flat_hash_map<K, V, Hash, Eq, Alloc>;
template<class T, template<class T,
class Hash = phmap::priv::hash_default_hash <T>, class Hash = phmap::priv::hash_default_hash <T>,
class Eq = phmap::priv::hash_default_eq <T>, class Eq = phmap::priv::hash_default_eq <T>,
class Alloc = phmap::priv::Allocator <T>> class Alloc = phmap::priv::Allocator <T>>
using HASHSET = phmap::flat_hash_set<T, Hash, Eq, Alloc>; using hashset_t = phmap::flat_hash_set<T, Hash, Eq, Alloc>;
}
#else #else
namespace blt {
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
@ -46,13 +49,14 @@ template<typename K, typename V,
typename Hash = std::hash<K>, typename Hash = std::hash<K>,
typename Eq = std::equal_to<K>, typename Eq = std::equal_to<K>,
typename Alloc = std::allocator<std::pair<const K, V>>> typename Alloc = std::allocator<std::pair<const K, V>>>
using HASHMAP = std::unordered_map<K, V, Hash, Eq, Alloc>; using hashmap_t = std::unordered_map<K, V, Hash, Eq, Alloc>;
template<typename K, template<typename K,
typename Hash = std::hash<K>, typename Hash = std::hash<K>,
typename Eq = std::equal_to<K>, typename Eq = std::equal_to<K>,
typename Alloc = std::allocator<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
#endif #endif

View File

@ -211,7 +211,7 @@ namespace blt
* ---------------------------- * ----------------------------
*/ */
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) void _internal::startInterval(const std::string& profile_name, const std::string& interval_name)
{ {