|
marvin 0.0.1
Pure C++ audio helper library
|
Non owning view into an array-like, with a configurable step size. More...
#include <marvin_StrideView.h>
Classes | |
| class | const_iterator |
| Custom const_iterator for a StrideView. More... | |
| class | iterator |
| Custom iterator for StrideView. More... | |
Public Member Functions | |
| StrideView (T *data, size_t size) | |
| template<std::input_or_output_iterator Iter> requires std::is_same_v<typename Iter::value_type, T> | |
| StrideView (Iter begin, Iter end) | |
| StrideView (std::span< T > arrayLike) | |
| size_t | size () const noexcept |
| T & | operator[] (size_t idx) |
| const T & | operator[] (size_t idx) const |
| iterator | begin () |
| const_iterator | begin () const |
| const_iterator | cbegin () const |
| iterator | end () |
| const_iterator | end () const |
| const_iterator | cend () const |
| std::span< T > | underlying () |
Non owning view into an array-like, with a configurable step size.
Essentially exists because std::ranges::views isn't implemented (or at least isn't widespread) on Apple Clang at the time of writing. A Stride of 2 would mean iterating over the StrideView would return every second value. Stride cannot == 0.
Does not require Stride to be even. Usage Example:
|
inline |
Constructs a StrideView with a T* and size.
| data | A T* to the data to wrap. |
| size | The number of elements to wrap. |
|
inline |
Constructs a StrideView from a start and end iterator. The passed iterators must satisfy std::input_or_output_iterator, and must have a ::value_type typedef that is the same as T.
| begin | The start iterator. |
| end | The sentinel iterator. |
|
inlineexplicit |
Constructs a StrideView with any array-like that can bind to std::span.
| arrayLike | A span to bind to. |
|
inline |
Creates an iterator to the first element in the view.
|
inline |
Creates a const iterator to the first element in the view.
|
inline |
Creates a const iterator to the first element in the view.
|
inline |
Creates a const iterator to the last element in the view.
|
inline |
Creates an iterator to the last element in the view.
|
inline |
Creates a const iterator to the last element in the view.
|
inline |
Subscript operator. The index passed here is with respect to stride - ie if the wrapped array is [0, 1, 2, 3] and Stride == 2, then operator[](1) will return 2.
| idx | The index to retrieve. |
|
inline |
Subscript operator. The index passed here is with respect to stride - ie if the wrapped array is [0, 1, 2, 3] and Stride == 2, then operator[](1) will return 2.
| idx | The index to retrieve. |
|
inlinenodiscardnoexcept |
Retrieves the number of elements in the view (with respect to Stride).
|
inlinenodiscard |
Retrieves the underlying data for the current view.