CNum 0.2.1
CPU-optimized ML library for C++
Loading...
Searching...
No Matches
StrideView.h
Go to the documentation of this file.
1#ifndef STRIDE_VIEW_H
2#define STRIDE_VIEW_H
4#include <ranges>
5
7 template <typename T>
9 private:
10 T *_ptr;
11 size_t _stride;
12
13 public:
14 /// @brief Overloaded default constructor
15 StrideIterator(T *ptr = nullptr, size_t stride = 1);
16
18
20
28 bool operator!=(const StrideIterator &other);
29 };
30
31 template <typename T>
32 class StrideView {
33 private:
34 T *_ptr;
35 size_t _stride, _range;
36 StrideIterator<T> _begin, _end;
37
38 public:
43 StrideView(T *ptr = nullptr, size_t stride = 1, size_t range = 0);
44
48
51 StrideIterator<T> end() const;
52
56
59 size_t size() const;
60 };
61
62#include "CNum/DataStructs/Views/StrideView.tpp"
63#include "CNum/DataStructs/Views/StrideIterator.tpp"
64};
65
66#endif
A bit mask used for representing subsets of elements in a container.
Definition BinaryMask.h:22
StrideIterator & operator++()
Increment iterator.
Definition StrideView.h:14
bool operator!=(const StrideIterator &other)
Does not equal comparison (by address).
Definition StrideView.h:21
StrideIterator(T *ptr=nullptr, size_t stride=1)
Overloaded default constructor.
Definition StrideView.h:3
T operator*()
Dereference iterator.
Definition StrideView.h:8
StrideIterator< T > begin() const
Get an iterator to the beginning of a view.
Definition StrideView.h:11
BinaryMask operator<=(T val)
Create a binary mask of values less than or equal to another.
Definition StrideView.h:19
StrideView(T *ptr=nullptr, size_t stride=1, size_t range=0)
Overloaded default constructor.
Definition StrideView.h:3
StrideIterator< T > end() const
Get an iterator to the end of the view.
Definition StrideView.h:15
size_t size() const
Get the number of elements in the stride view (n_strides in the view).
Definition StrideView.h:24
The views for CNum DataStructs.
Definition StrideView.h:6