StripeIterator.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <cstddef>
7 #include <limits>
8 
9 template <size_t>
10 class Index;
11 
12 /*!
13  * \ingroup DataStructuresGroup
14  * \brief Iterates over the 1-dimensional stripes with info on how to
15  * iterate over the current stripe
16  */
18  public:
19  /// Construct from the grid points in each direction and which dimension the
20  /// stripes are in.
21  template <size_t Dim>
22  StripeIterator(const Index<Dim>& extents, size_t stripe_dim);
23 
24  /// Returns `true` if the iterator is valid
25  explicit operator bool() const noexcept { return offset_ < size_; }
26 
27  /// Increment to the next stripe.
28  StripeIterator& operator++();
29 
30  /// Offset into DataVector for first element of stripe.
31  size_t offset() const noexcept { return offset_; }
32 
33  /// Stride of elements in DataVector for the stripe.
34  size_t stride() const noexcept { return stride_; }
35 
36  private:
37  size_t offset_ = std::numeric_limits<size_t>::max();
38  size_t size_ = std::numeric_limits<size_t>::max();
39  size_t stride_ = std::numeric_limits<size_t>::max();
40  size_t stride_count_ = std::numeric_limits<size_t>::max();
41  size_t jump_ = std::numeric_limits<size_t>::max();
42 };
Iterates over the 1-dimensional stripes with info on how to iterate over the current stripe...
Definition: StripeIterator.hpp:17
StripeIterator & operator++()
Increment to the next stripe.
Definition: StripeIterator.cpp:23
size_t stride() const noexcept
Stride of elements in DataVector for the stripe.
Definition: StripeIterator.hpp:34
T max(T... args)
An integer multi-index.
Definition: Index.hpp:28
size_t offset() const noexcept
Offset into DataVector for first element of stripe.
Definition: StripeIterator.hpp:31
StripeIterator(const Index< Dim > &extents, size_t stripe_dim)
Construct from the grid points in each direction and which dimension the stripes are in...
Definition: StripeIterator.cpp:14