1 #ifndef MF_NDARRAY_ITERATOR_H_
2 #define MF_NDARRAY_ITERATOR_H_
15 template<
typename Array>
17 public std::iterator<std::random_access_iterator_tag, typename Array::value_type> {
18 using base = std::iterator<std::random_access_iterator_tag, typename Array::value_type>;
21 using typename base::value_type;
22 using typename base::reference;
23 using typename base::pointer;
28 constexpr
static std::size_t
dimension = Array::dimension;
32 pointer pointer_ =
nullptr;
34 std::ptrdiff_t pointer_step_;
35 std::ptrdiff_t contiguous_length_;
37 void forward_(std::ptrdiff_t);
38 void backward_(std::ptrdiff_t);
55 reference
operator*() const noexcept {
return *pointer_; }
57 reference
operator[](std::ptrdiff_t n)
const {
return *(*
this + n); }
60 {
return a.index() == b.index(); }
62 {
return a.index() != b.index(); }
64 {
return a.index() < b.index(); }
66 {
return a.index() <= b.index(); }
68 {
return a.index() > b.index(); }
70 {
return a.index() >= b.index(); }
73 {
auto copy = it; copy += n;
return copy; }
75 {
auto copy = it; copy += n;
return copy; }
77 {
auto copy = it; copy -= n;
return copy; }
86 template<
typename Array>
87 constexpr std::size_t ndarray_iterator<Array>::dimension;
index_type index() const noexcept
Definition: ndarray_iterator.h:81
friend bool operator==(const ndarray_iterator &a, const ndarray_iterator &b) noexcept
Definition: ndarray_iterator.h:59
pointer operator->() const noexcept
Definition: ndarray_iterator.h:56
typename Array::index_type index_type
Definition: ndarray_iterator.h:25
ndarray_iterator & operator=(const ndarray_iterator &)
Definition: ndarray_iterator.tcc:45
friend bool operator>(const ndarray_iterator &a, const ndarray_iterator &b) noexcept
Definition: ndarray_iterator.h:67
ndarray_iterator & operator+=(std::ptrdiff_t)
Definition: ndarray_iterator.tcc:85
friend bool operator<(const ndarray_iterator &a, const ndarray_iterator &b) noexcept
Definition: ndarray_iterator.h:63
ndarray_iterator & operator-=(std::ptrdiff_t)
Definition: ndarray_iterator.tcc:93
reference operator[](std::ptrdiff_t n) const
Definition: ndarray_iterator.h:57
ndarray_iterator()=default
ndarray_iterator & operator--()
Definition: ndarray_iterator.tcc:70
friend ndarray_iterator operator+(const ndarray_iterator &it, std::ptrdiff_t n)
Definition: ndarray_iterator.h:72
reference operator*() const noexcept
Definition: ndarray_iterator.h:55
coordinates_type coordinates() const noexcept
Definition: ndarray_iterator.h:82
friend ndarray_iterator operator+(std::ptrdiff_t n, const ndarray_iterator &it)
Definition: ndarray_iterator.h:74
friend ndarray_iterator operator-(const ndarray_iterator &it, std::ptrdiff_t n)
Definition: ndarray_iterator.h:76
friend bool operator<=(const ndarray_iterator &a, const ndarray_iterator &b) noexcept
Definition: ndarray_iterator.h:65
ndarray_iterator & operator++()
Definition: ndarray_iterator.tcc:55
friend bool operator!=(const ndarray_iterator &a, const ndarray_iterator &b) noexcept
Definition: ndarray_iterator.h:61
friend std::ptrdiff_t operator-(const ndarray_iterator &a, const ndarray_iterator &b)
Definition: ndarray_iterator.h:78
static constexpr std::size_t dimension
Definition: ndarray_iterator.h:28
Random access iterator which traverses an ndarray_view.
Definition: ndarray_iterator.h:16
typename Array::coordinates_type coordinates_type
Definition: ndarray_iterator.h:26
friend bool operator>=(const ndarray_iterator &a, const ndarray_iterator &b) noexcept
Definition: ndarray_iterator.h:69