Tatooine
vertex_handle.h
Go to the documentation of this file.
1#ifndef TATOOINE_DETAIL_RECTILINEAR_GRID_VERTEX_HANDLE_H
2#define TATOOINE_DETAIL_RECTILINEAR_GRID_VERTEX_HANDLE_H
3//==============================================================================
4#include <array>
5#include <tatooine/concepts.h>
6//==============================================================================
8//==============================================================================
9template <std::size_t NumDimensions>
11 private:
12 std::array<std::size_t, NumDimensions> m_indices;
13 std::size_t m_plain_index;
14
15 public:
16 static constexpr std::size_t num_dimensions() { return NumDimensions; }
17 //----------------------------------------------------------------------------
18 constexpr vertex_handle(integral auto const... is)
19 : m_indices{static_cast<std::size_t>(is)...} {
20 }
21 //----------------------------------------------------------------------------
22 template <integral Int>
23 constexpr vertex_handle(std::array<Int, num_dimensions()> const& is,
24 std::size_t const plain_index)
26 //----------------------------------------------------------------------------
27 constexpr vertex_handle(std::array<std::size_t, num_dimensions()> const& is,
28 std::size_t const plain_index)
30 //----------------------------------------------------------------------------
31 constexpr auto indices() const -> auto const& { return m_indices; }
32 constexpr auto indices() -> auto& { return m_indices; }
33 //----------------------------------------------------------------------------
34 constexpr auto index(std::size_t const i) const -> auto const& { return m_indices[i]; }
35 constexpr auto index(std::size_t const i) -> auto& { return m_indices[i]; }
36 //----------------------------------------------------------------------------
37 constexpr auto plain_index() const -> auto const& { return m_plain_index; }
38 constexpr auto plain_index() -> auto& { return m_plain_index; }
39 //----------------------------------------------------------------------------
40 constexpr auto operator==(vertex_handle const& other) const {
41 return m_plain_index == other.m_plain_index;
42 }
43 //----------------------------------------------------------------------------
44 constexpr auto operator!=(vertex_handle const& other) const {
45 return m_plain_index != other.m_plain_index;
46 }
47 //--------------------------------------------------------------------------
48 constexpr auto operator<(vertex_handle const& other) const -> bool {
49 return m_plain_index < other.m_plain_index;
50 }
51 //--------------------------------------------------------------------------
52 constexpr auto operator<=(vertex_handle const& other) const -> bool {
53 return m_plain_index <= other.m_plain_index;
54 }
55 //--------------------------------------------------------------------------
56 constexpr auto operator>(vertex_handle const& other) const -> bool {
57 return m_plain_index > other.m_plain_index;
58 }
59 //--------------------------------------------------------------------------
60 constexpr auto operator>=(vertex_handle const& other) const -> bool {
61 return m_plain_index >= other.m_plain_index;
62 }
63};
64//==============================================================================
65} // namespace tatooine
66//==============================================================================
68#endif
Definition: concepts.h:21
Definition: cell_container.h:15
auto end(vertex_container< Dimensions... > const &c)
Definition: vertex_container.h:142
auto begin(vertex_container< Dimensions... > const &c)
Definition: vertex_container.h:137
constexpr auto operator>(vertex_handle const &other) const -> bool
Definition: vertex_handle.h:56
constexpr auto plain_index() -> auto &
Definition: vertex_handle.h:38
constexpr auto operator==(vertex_handle const &other) const
Definition: vertex_handle.h:40
constexpr auto operator!=(vertex_handle const &other) const
Definition: vertex_handle.h:44
constexpr auto plain_index() const -> auto const &
Definition: vertex_handle.h:37
constexpr vertex_handle(integral auto const ... is)
Definition: vertex_handle.h:18
constexpr vertex_handle(std::array< std::size_t, num_dimensions()> const &is, std::size_t const plain_index)
Definition: vertex_handle.h:27
constexpr auto operator<(vertex_handle const &other) const -> bool
Definition: vertex_handle.h:48
constexpr auto index(std::size_t const i) -> auto &
Definition: vertex_handle.h:35
constexpr auto operator<=(vertex_handle const &other) const -> bool
Definition: vertex_handle.h:52
static constexpr std::size_t num_dimensions()
Definition: vertex_handle.h:16
constexpr auto indices() -> auto &
Definition: vertex_handle.h:32
std::size_t m_plain_index
Definition: vertex_handle.h:13
constexpr auto index(std::size_t const i) const -> auto const &
Definition: vertex_handle.h:34
constexpr auto indices() const -> auto const &
Definition: vertex_handle.h:31
constexpr vertex_handle(std::array< Int, num_dimensions()> const &is, std::size_t const plain_index)
Definition: vertex_handle.h:23
std::array< std::size_t, NumDimensions > m_indices
Definition: vertex_handle.h:12
constexpr auto operator>=(vertex_handle const &other) const -> bool
Definition: vertex_handle.h:60