diff options
Diffstat (limited to 'src/search-result.cpp')
-rw-r--r-- | src/search-result.cpp | 90 |
1 files changed, 21 insertions, 69 deletions
diff --git a/src/search-result.cpp b/src/search-result.cpp index 2c5b5e53..c2065735 100644 --- a/src/search-result.cpp +++ b/src/search-result.cpp @@ -9,56 +9,6 @@ namespace floormat { -namespace { - -struct off_pair -{ - unsigned val; - bool is_bad; - constexpr bool operator==(const off_pair&) const = default; -}; - -template<unsigned N> constexpr off_pair offset_is_bad(Int x) -{ - switch (x) - { - case Int{-1}: - case Int{ 1}: - case Int{ 0}: - return { (unsigned(Int{1} + x)) << N, false }; - default: - return { (unsigned)-1, true }; - } -} -#if 0 -static_assert((2 | 2 << 8) == (offset_is_bad<0>(Int{1}).val | offset_is_bad<8>(Int{1}).val)); -static_assert((2 | 1 << 8) == (offset_is_bad<0>(Int{1}).val | offset_is_bad<8>(Int{0}).val)); -static_assert((1 | 1 << 8) == (offset_is_bad<0>(Int{0}).val | offset_is_bad<8>(Int{0}).val)); -static_assert((0 | 2 << 8) == (offset_is_bad<0>(Int{-1}).val | offset_is_bad<8>(Int{1}).val)); -static_assert((unsigned)-1 == (offset_is_bad<0>(Int{4242}).val | offset_is_bad<8>(Int{1}).val)); -#endif - -void simplify_path(const std::vector<point>& src, std::vector<path_search_result::pair>& dest) -{ - dest.clear(); - dest.reserve(src.size()); - fm_assert(!src.empty()); - fm_assert(src.size() >= 2); - const auto size = (uint32_t)src.size(); - dest.push_back({src[0], 0}); - - auto last = src[0]; - auto cur = src[1] - src[0]; - size_t len = 1; - - for (auto i = 1u; i < size; i++) - { - - } -} - -} // namespace - Pointer<path_search_result::node> path_search_result::_pool; // NOLINT path_search_result::path_search_result() @@ -108,8 +58,26 @@ path_search_result& path_search_result::operator=(const path_search_result& x) n return *this; } -path_search_result::path_search_result(path_search_result&&) noexcept = default; -path_search_result& path_search_result::operator=(path_search_result&&) noexcept = default; +path_search_result::path_search_result(path_search_result&& other) noexcept +{ + *this = move(other); +} + +path_search_result& path_search_result::operator=(path_search_result&& other) noexcept +{ + if (_node) + { + _node->vec.clear(); + _node->_next = move(_pool); + _pool = move(_node); + } + _node = move(other._node); + _time = other._time; + _cost = other._cost; + _distance = other._distance; + _found = other._found; + return *this; +} size_t path_search_result::size() const { return _node->vec.size(); } path_search_result::node::node() noexcept = default; @@ -122,24 +90,8 @@ bool path_search_result::is_found() const { return _found; } void path_search_result::set_found(bool value) { _found = value; } uint32_t path_search_result::distance() const { return _distance; } void path_search_result::set_distance(uint32_t dist) { _distance = dist; } -bool path_search_result::is_simplified() const { /*fm_assert(!_node->vec.empty());*/ return !_node->vec_.empty(); } -auto path_search_result::simplified_path() -> ArrayView<const pair> -{ - if (!_node->vec_.empty()) - return { _node->vec_.data(), _node->vec_.size() }; - else - { - //fm_assert(!_node->vec.empty()); - simplify_path(_node->vec, _node->vec_); - fm_assert(!_node->vec_.empty()); - return { _node->vec_.data(), _node->vec_.size() }; - } -} - path_search_result::operator bool() const { return !_node->vec.empty(); } - -vector_wrapper<point, vector_wrapper_repr::ref> path_search_result::raw_path() { fm_assert(_node); return {_node->vec}; } -auto path_search_result::raw_simplified_path() -> vector_wrapper<pair, vector_wrapper_repr::ref> { fm_assert(_node); return {_node->vec_}; } ArrayView<const point> path_search_result::path() const { fm_assert(_node); return {_node->vec.data(), _node->vec.size()}; } +vector_wrapper<point, vector_wrapper_repr::ref> path_search_result::raw_path() { fm_assert(_node); return {_node->vec}; } } // namespace floormat |