tess
0.4.0
Performance-first tile and path simulation substrate
Toggle main menu visibility
Loading...
Searching...
No Matches
path_view.h
1
#pragma once
2
3
#include <tess/core/shape.h>
4
5
#include <cstddef>
6
#include <span>
7
#include <vector>
8
9
namespace
tess {
10
21
class
PathView
{
22
public
:
24
constexpr
PathView
() noexcept = default;
25
27
constexpr
PathView
(std::
span
<const
Coord3
> nodes) noexcept : nodes_(nodes) {}
28
30
PathView
(
const
std::vector<Coord3>& nodes) noexcept : nodes_(nodes) {}
31
33
PathView
(std::vector<Coord3>&&) =
delete
;
34
38
PathView
(
const
std::vector<Coord3>&&) =
delete
;
39
41
[[nodiscard]]
constexpr
auto
size
() const noexcept -> std::
size_t
{
42
return
nodes_.size();
43
}
44
45
[[nodiscard]]
constexpr
auto
empty
() const noexcept ->
bool
{
46
return
nodes_.empty();
47
}
48
49
[[nodiscard]]
constexpr
auto
operator[]
(std::size_t index)
const
noexcept
50
->
const
Coord3
& {
51
return
nodes_[index];
52
}
53
54
[[nodiscard]]
constexpr
auto
front
() const noexcept -> const
Coord3
& {
55
return
nodes_.front();
56
}
57
58
[[nodiscard]]
constexpr
auto
back
() const noexcept -> const
Coord3
& {
59
return
nodes_.back();
60
}
61
62
[[nodiscard]]
constexpr
auto
begin
() const noexcept {
return
nodes_.begin(); }
63
65
[[nodiscard]]
constexpr
auto
end
() const noexcept {
return
nodes_.end(); }
66
70
[[nodiscard]]
constexpr
auto
data
() const noexcept -> const
Coord3
* {
71
return
nodes_.data();
72
}
73
75
[[nodiscard]]
constexpr
auto
span
() const noexcept
76
-> std::
span
<const
Coord3
> {
77
return
nodes_;
78
}
79
86
[[nodiscard]]
constexpr
auto
suffix
(std::size_t offset)
const
noexcept
87
->
PathView
{
88
const
auto
clamped = offset < nodes_.size() ? offset : nodes_.size();
89
return
PathView
{nodes_.subspan(clamped)};
90
}
91
92
private
:
93
std::span<const Coord3> nodes_{};
94
};
95
96
}
// namespace tess
tess::PathView::span
constexpr auto span() const noexcept -> std::span< const Coord3 >
Definition
path_view.h:75
tess::PathView::PathView
PathView(const std::vector< Coord3 > &&)=delete
tess::PathView::back
constexpr auto back() const noexcept -> const Coord3 &
Definition
path_view.h:58
tess::PathView::PathView
constexpr PathView() noexcept=default
tess::PathView::empty
constexpr auto empty() const noexcept -> bool
Definition
path_view.h:45
tess::PathView::front
constexpr auto front() const noexcept -> const Coord3 &
Definition
path_view.h:54
tess::PathView::size
constexpr auto size() const noexcept -> std::size_t
Definition
path_view.h:41
tess::PathView::data
constexpr auto data() const noexcept -> const Coord3 *
Definition
path_view.h:70
tess::PathView::operator[]
constexpr auto operator[](std::size_t index) const noexcept -> const Coord3 &
Definition
path_view.h:49
tess::PathView::PathView
PathView(const std::vector< Coord3 > &nodes) noexcept
Definition
path_view.h:30
tess::PathView::begin
constexpr auto begin() const noexcept
Definition
path_view.h:62
tess::PathView::PathView
PathView(std::vector< Coord3 > &&)=delete
tess::PathView::end
constexpr auto end() const noexcept
Definition
path_view.h:65
tess::PathView::suffix
constexpr auto suffix(std::size_t offset) const noexcept -> PathView
Definition
path_view.h:86
tess::Coord3
Definition
shape.h:30
include
tess
path
path_view.h
Generated by
1.17.0