Huge refactor: use util::hash_table instead of std::unordered everywhere
This commit is contained in:
parent
e79266d7e2
commit
22a57f91db
23 changed files with 53 additions and 61 deletions
|
|
@ -1,8 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/app/events.hpp>
|
||||
|
||||
#include <unordered_set>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
namespace psemek::app
|
||||
{
|
||||
|
|
@ -13,8 +12,8 @@ namespace psemek::app
|
|||
bool focus = true;
|
||||
geom::point<int, 2> mouse = {0, 0};
|
||||
int wheel = 0;
|
||||
std::unordered_set<mouse_button> mouse_button_down;
|
||||
std::unordered_set<keycode> key_down;
|
||||
util::hash_set<mouse_button> mouse_button_down;
|
||||
util::hash_set<keycode> key_down;
|
||||
};
|
||||
|
||||
inline void apply(event_state & state, resize_event const & event)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/geom/vector.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/io/stream.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::fonts
|
||||
{
|
||||
|
|
@ -25,7 +25,7 @@ namespace psemek::fonts
|
|||
std::string name;
|
||||
geom::vector<int, 2> size;
|
||||
int baseline;
|
||||
std::unordered_map<char32_t, glyph_data> glyphs;
|
||||
util::hash_map<char32_t, glyph_data> glyphs;
|
||||
float sdf_scale = 0.f;
|
||||
|
||||
// Parse JSON font info generated by BMFont or msdf-bmfont
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
#include <psemek/fonts/font.hpp>
|
||||
#include <psemek/fonts/bmfont.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::fonts
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
#include <psemek/fonts/font.hpp>
|
||||
#include <psemek/fonts/kerned_font.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::fonts
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <psemek/geom/box.hpp>
|
||||
#include <psemek/geom/simplex.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
|
@ -170,7 +171,7 @@ namespace psemek::geom
|
|||
return e;
|
||||
};
|
||||
|
||||
std::unordered_map<edge, Index> midpoints;
|
||||
util::hash_map<edge, Index> midpoints;
|
||||
|
||||
auto add_midpoint = [&](Index i0, Index i1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
#include <psemek/geom/affine_transform.hpp>
|
||||
#include <psemek/geom/easing.hpp>
|
||||
#include <psemek/util/hstring.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
|
@ -20,7 +20,7 @@ namespace psemek::gfx
|
|||
struct gltf_asset
|
||||
{
|
||||
using extra = std::variant<float, std::vector<float>, std::string>;
|
||||
using extras_map = std::unordered_map<util::hstring, extra>;
|
||||
using extras_map = util::hash_map<util::hstring, extra>;
|
||||
|
||||
struct node
|
||||
{
|
||||
|
|
@ -182,8 +182,8 @@ namespace psemek::gfx
|
|||
std::vector<buffer> buffers;
|
||||
std::vector<light> lights; // KHR_lights_punctual
|
||||
|
||||
std::unordered_map<std::string, std::size_t> node_index; // node by name
|
||||
std::unordered_map<std::string, std::size_t> material_index; // material by name
|
||||
util::hash_map<std::string, std::size_t> node_index; // node by name
|
||||
util::hash_map<std::string, std::size_t> material_index; // material by name
|
||||
|
||||
struct animation_and_channel
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@
|
|||
|
||||
#include <psemek/util/assert.hpp>
|
||||
#include <psemek/util/span.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <cstddef>
|
||||
#include <type_traits>
|
||||
#include <cmath>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
|
@ -348,7 +346,7 @@ namespace psemek::gfx
|
|||
}
|
||||
|
||||
using pose_ref = util::span<bone_transform<float> const>;
|
||||
using pose_library = std::unordered_map<std::string_view, pose_ref>;
|
||||
using pose_library = util::hash_map<std::string_view, pose_ref>;
|
||||
|
||||
struct imported_mesh
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
#include <psemek/gfx/color.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
static std::unordered_map<std::string_view, color_rgba> const named_colors
|
||||
static util::hash_map<std::string_view, color_rgba> const named_colors
|
||||
{
|
||||
{"black", {0, 0, 0, 255}},
|
||||
{"white", {255, 255, 255, 255}},
|
||||
|
|
|
|||
|
|
@ -3,11 +3,9 @@
|
|||
#include <psemek/gfx/array.hpp>
|
||||
#include <psemek/gfx/buffer.hpp>
|
||||
#include <psemek/util/hstring.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/io/memory_stream.hpp>
|
||||
|
||||
#include <stdexcept>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
||||
|
|
@ -75,7 +73,7 @@ namespace psemek::gfx
|
|||
std::vector<gfx::texture_2d> textures_;
|
||||
std::vector<gfx::buffer> buffers_;
|
||||
std::vector<std::unique_ptr<drawable_impl>> drawables_;
|
||||
std::unordered_map<util::hstring, mesh_data> meshes_;
|
||||
util::hash_map<util::hstring, mesh_data> meshes_;
|
||||
};
|
||||
|
||||
gltf_mesh_impl::gltf_mesh_impl(gltf_asset const & asset, std::function<util::blob(std::string const &)> uri_loader)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <psemek/geom/rotation.hpp>
|
||||
#include <psemek/geom/translation.hpp>
|
||||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/exception.hpp>
|
||||
#include <psemek/io/memory_stream.hpp>
|
||||
#include <psemek/log/log.hpp>
|
||||
|
|
@ -70,7 +71,7 @@ namespace psemek::gfx
|
|||
throw util::exception(util::to_string("Unknown accessor component type: ", type));
|
||||
}
|
||||
|
||||
static std::unordered_set<std::string> supported_extensions =
|
||||
static util::hash_set<std::string> const supported_extensions =
|
||||
{
|
||||
"KHR_lights_punctual",
|
||||
"KHR_materials_emissive_strength"
|
||||
|
|
|
|||
|
|
@ -27,10 +27,10 @@
|
|||
|
||||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/util/hash.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/exception.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::gfx
|
||||
{
|
||||
|
|
@ -1046,7 +1046,7 @@ void main(){}
|
|||
|
||||
struct bin
|
||||
{
|
||||
std::unordered_map<std::tuple<std::uint32_t, material const *>, objects_bucket> buckets;
|
||||
util::hash_map<std::tuple<std::uint32_t, material const *>, objects_bucket> buckets;
|
||||
geom::box<float, 3> bbox;
|
||||
bool contains_near_clip = false;
|
||||
float camera_separation;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <psemek/log/log.hpp>
|
||||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/util/exception.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <boost/stacktrace/stacktrace.hpp>
|
||||
|
||||
#include <chrono>
|
||||
|
|
@ -9,7 +10,6 @@
|
|||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <vector>
|
||||
|
|
@ -24,7 +24,7 @@ namespace psemek::log
|
|||
std::atomic<std::size_t> max_thread_name_length = 3;
|
||||
|
||||
std::mutex thread_names_mutex;
|
||||
std::unordered_map<std::thread::id, std::string> thread_names;
|
||||
util::hash_map<std::thread::id, std::string> thread_names;
|
||||
|
||||
std::mutex sinks_mutex;
|
||||
std::vector<std::unique_ptr<sink>> sinks;
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
#include <psemek/util/function.hpp>
|
||||
#include <psemek/util/array.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/geom/box.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <optional>
|
||||
|
||||
namespace psemek::pcg
|
||||
|
|
@ -68,7 +68,7 @@ namespace psemek::pcg
|
|||
private:
|
||||
int const chunk_size_;
|
||||
generator_func generator_;
|
||||
mutable std::unordered_map<geom::vector<int, N>, util::array<T, N>> chunks_;
|
||||
mutable util::hash_map<geom::vector<int, N>, util::array<T, N>> chunks_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
#include <psemek/util/function.hpp>
|
||||
#include <psemek/util/array.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <psemek/geom/vector.hpp>
|
||||
#include <psemek/geom/box.hpp>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <optional>
|
||||
|
||||
namespace psemek::pcg
|
||||
|
|
@ -101,7 +101,7 @@ namespace psemek::pcg
|
|||
|
||||
private:
|
||||
int const grid_size_;
|
||||
mutable std::unordered_map<geom::vector<int, N>, geom::vector<T, N>> grid_;
|
||||
mutable util::hash_map<geom::vector<int, N>, geom::vector<T, N>> grid_;
|
||||
generator_func gen_;
|
||||
|
||||
geom::vector<T, N> grid_at(geom::vector<int, N> const & c) const
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
#include <psemek/rs/registry.hpp>
|
||||
|
||||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include <mutex>
|
||||
#include <atomic>
|
||||
#include <optional>
|
||||
|
||||
namespace psemek::rs
|
||||
{
|
||||
|
|
@ -34,7 +33,7 @@ namespace psemek::rs
|
|||
|
||||
auto & name_map()
|
||||
{
|
||||
static std::unordered_map<std::string_view, id> instance;
|
||||
static util::hash_map<std::string_view, id> instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,10 @@
|
|||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/util/type_name.hpp>
|
||||
#include <psemek/util/function.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/exception.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <typeindex>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::ui::impl
|
||||
{
|
||||
|
|
@ -92,7 +91,7 @@ namespace psemek::ui::impl
|
|||
impl->set_children_token(typed_value.children.subscribe([this, impl = impl.get()](std::vector<typename Type::element> const & children_values){
|
||||
impl->release_child_tokens();
|
||||
|
||||
std::unordered_map<key, std::unique_ptr<component>> child_by_key;
|
||||
util::hash_map<key, std::unique_ptr<component>> child_by_key;
|
||||
|
||||
auto old_children = impl->release_children();
|
||||
{
|
||||
|
|
@ -159,7 +158,7 @@ namespace psemek::ui::impl
|
|||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<std::type_index, util::function<std::unique_ptr<component>(std::unique_ptr<component>, std::any const &)>> type_factories_;
|
||||
util::hash_map<std::type_index, util::function<std::unique_ptr<component>(std::unique_ptr<component>, std::any const &)>> type_factories_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <typeindex>
|
||||
#include <any>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
|
@ -34,7 +35,7 @@ namespace psemek::util
|
|||
void remove();
|
||||
|
||||
private:
|
||||
std::unordered_map<std::type_index, std::any> storage_;
|
||||
util::hash_map<std::type_index, std::any> storage_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <psemek/util/range.hpp>
|
||||
#include <psemek/util/hash.hpp>
|
||||
#include <psemek/util/hstring.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/exception.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
|
@ -18,8 +19,6 @@
|
|||
#include <functional>
|
||||
#include <optional>
|
||||
|
||||
#include <experimental/type_traits>
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
||||
|
|
@ -710,17 +709,17 @@ namespace psemek::util
|
|||
|
||||
private:
|
||||
std::vector<std::unique_ptr<ecs_detail::species_base>> species_;
|
||||
std::unordered_map<util::hstring, ecs_detail::species_handle> species_by_name_;
|
||||
util::hash_map<util::hstring, ecs_detail::species_handle> species_by_name_;
|
||||
|
||||
std::unordered_map<std::type_index, std::vector<util::function<void(void const *)>>> event_subscribers_;
|
||||
util::hash_map<std::type_index, std::vector<util::function<void(void const *)>>> event_subscribers_;
|
||||
|
||||
std::vector<util::function<void(species_handle)>> species_constructors_;
|
||||
|
||||
std::vector<util::function<void(entity_handle)>> constructors_;
|
||||
std::unordered_map<ecs_detail::species_handle, std::vector<util::function<void(entity_handle)>>> private_constructors_;
|
||||
util::hash_map<ecs_detail::species_handle, std::vector<util::function<void(entity_handle)>>> private_constructors_;
|
||||
|
||||
std::vector<util::function<void(entity_handle)>> destructors_;
|
||||
std::unordered_map<ecs_detail::species_handle, std::vector<util::function<void(entity_handle)>>> private_destructors_;
|
||||
util::hash_map<ecs_detail::species_handle, std::vector<util::function<void(entity_handle)>>> private_destructors_;
|
||||
};
|
||||
|
||||
template <typename ... Components>
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
#include <psemek/util/to_string.hpp>
|
||||
#include <psemek/util/type_name.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/exception.hpp>
|
||||
|
||||
#include <string_view>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <optional>
|
||||
#include <unordered_map>
|
||||
#include <string_view>
|
||||
#include <iostream>
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
|
@ -104,7 +104,7 @@ namespace psemek::util
|
|||
} \
|
||||
} \
|
||||
inline std::optional<name> BOOST_PP_CAT(name, _from_string)(::std::string_view str) { \
|
||||
static const ::std::unordered_map<::std::string_view, name> map = { \
|
||||
static const ::psemek::util::hash_map<::std::string_view, name> map = { \
|
||||
BOOST_PP_SEQ_FOR_EACH(psemek_declare_enum_detail_from_string, name, values) \
|
||||
}; \
|
||||
auto it = map.find(str); if (it == map.end()) return std::nullopt; return it->second; \
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/util/functional.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/util/at.hpp>
|
||||
|
||||
#include <list>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace psemek::util
|
||||
{
|
||||
|
|
@ -79,7 +79,7 @@ namespace psemek::util
|
|||
// list_ contains non-removable items first, then all removable items
|
||||
std::list<value_type> list_;
|
||||
iterator removable_begin_ = list_.end();
|
||||
std::unordered_map<Key, iterator> map_;
|
||||
util::hash_map<Key, iterator> map_;
|
||||
|
||||
iterator find_safe(Key const & key);
|
||||
const_iterator find_safe(Key const & key) const;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/util/hstring.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
#include <optional>
|
||||
|
||||
namespace psemek::util
|
||||
|
|
@ -82,7 +82,7 @@ namespace psemek::util
|
|||
|
||||
private:
|
||||
std::vector<object> objects_;
|
||||
std::unordered_map<util::hstring, Index> name_map_;
|
||||
util::hash_map<util::hstring, Index> name_map_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
|
|
@ -30,7 +31,7 @@ namespace psemek::util
|
|||
}
|
||||
|
||||
private:
|
||||
std::unordered_map<T, index, Hash> value_to_index_;
|
||||
util::hash_map<T, index, Hash> value_to_index_;
|
||||
std::vector<T> index_to_value_;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include <psemek/random/generator.hpp>
|
||||
#include <psemek/random/uniform_sphere.hpp>
|
||||
#include <psemek/gfx/pixmap.hpp>
|
||||
#include <psemek/util/hash_table.hpp>
|
||||
#include <psemek/io/file_stream.hpp>
|
||||
|
||||
using namespace psemek;
|
||||
|
|
@ -198,7 +199,7 @@ std::optional<bool> parse_bool(std::string const & str)
|
|||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
std::unordered_map<std::string, std::string> values;
|
||||
util::hash_map<std::string, std::string> values;
|
||||
values["dim"] = "2";
|
||||
values["sizex"] = "256";
|
||||
values["sizey"] = "256";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue