diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-11 10:35:06 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-10-11 13:35:27 +0200 |
commit | ca4544f04cc67c296e58170e76203bc11519d988 (patch) | |
tree | 2dcbe936be206c4e7f95a28525fafff6f7340e5e /src | |
parent | 018755dab3d2a5bb0ead627b6ecad6735a9f0114 (diff) |
add benchmark executable
Diffstat (limited to 'src')
-rw-r--r-- | src/path-search-dijkstra.cpp | 2 | ||||
-rw-r--r-- | src/path-search-result.cpp | 2 | ||||
-rw-r--r-- | src/path-search-result.hpp | 11 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp index 77c3d8b6..a40d79ad 100644 --- a/src/path-search-dijkstra.cpp +++ b/src/path-search-dijkstra.cpp @@ -198,7 +198,7 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o return {}; path_search_result result; - auto& path = result._node->vec; path.clear(); + auto& path = result.path(); path.clear(); indexes[from_] = 0; nodes.push_back({.dist = 0, .coord = from, .offset = from_offset }); diff --git a/src/path-search-result.cpp b/src/path-search-result.cpp index 9e62a30f..26fcd98d 100644 --- a/src/path-search-result.cpp +++ b/src/path-search-result.cpp @@ -69,5 +69,7 @@ auto path_search_result::operator[](size_t index) const -> const pair& fm_debug_assert(index < _node->vec.size()); return data()[index]; } +auto path_search_result::path() -> std::vector<pair>& { fm_assert(_node); return _node->vec; } +auto path_search_result::path() const -> const std::vector<pair>& { fm_assert(_node); return _node->vec; } } // namespace floormat diff --git a/src/path-search-result.hpp b/src/path-search-result.hpp index 90a4ba3d..92484c63 100644 --- a/src/path-search-result.hpp +++ b/src/path-search-result.hpp @@ -8,8 +8,6 @@ namespace floormat { struct path_search_result final { - friend class path_search; - friend struct astar; friend struct test_app; struct pair { global_coords pos; Vector2 offset; }; @@ -18,14 +16,18 @@ struct path_search_result final const pair& operator[](size_t index) const; size_t size() const; + std::vector<pair>& path(); + const std::vector<pair>& path() const; explicit operator ArrayView<const pair>() const; explicit operator bool() const; -private: fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(path_search_result); path_search_result(const path_search_result& x) noexcept; path_search_result& operator=(const path_search_result& x) noexcept; + path_search_result(); + ~path_search_result() noexcept; +private: static constexpr size_t min_length = TILE_MAX_DIM*2; struct node @@ -45,9 +47,6 @@ private: static std::unique_ptr<node> _pool; // NOLINT(*-avoid-non-const-global-variables) - path_search_result(); - ~path_search_result() noexcept; - std::unique_ptr<node> _node; }; |