2 #ifndef SYDEVS_RANGE_H_
3 #define SYDEVS_RANGE_H_
64 constexpr
range(
const range&) =
default;
66 range(range&&) =
default;
93 , stop_limit_(std::numeric_limits<
int64>::max())
102 : start_limit_(start_limit)
103 , stop_limit_(stop_limit)
113 return start_limit_ + (after_ ? 2*
int64(stride_ > 0) - 1 : 0);
119 return stop_limit_ + (before_ ? 2*
int64(stride_ < 0) - 1 : 0);
131 return range(limit, stop_limit_, stride_,
false, before_);
137 return range(limit, stop_limit_, stride_,
true, before_);
143 return range(start_limit_, limit, stride_, after_,
false);
149 return range(start_limit_, limit, stride_, after_,
true);
155 return range(start_limit_,
156 (stride_ > 0 && stride < 0 && stop_limit_ == std::numeric_limits<int64>::max()) ? std::numeric_limits<int64>::min() :
157 (stride_ < 0 && stride > 0 && stop_limit_ == std::numeric_limits<int64>::min()) ? std::numeric_limits<int64>::max() :
A data type which represents a range of array indices along a single dimension.
Definition: range.h:51
~range()=default
Destructor.
constexpr range start_after(int64 limit) const
Returns a new range object starting immediate after limit.
Definition: range.h:135
range & operator=(const range &)=default
Copy assignment.
constexpr range()
Constructs a range object representing a sequence that starts at 0 and increases by 1...
Definition: range.h:91
constexpr range stop_before(int64 limit) const
Returns a new range object stopping immediate before limit.
Definition: range.h:147
constexpr int64 stop() const
Returns the last possible index in the sequence.
Definition: range.h:117
constexpr range stop_at(int64 limit) const
Returns a new range object stopping at limit.
Definition: range.h:141
constexpr range start_at(int64 limit) const
Returns a new range object starting at limit.
Definition: range.h:129
constexpr int64 stride() const
Returns the increment between sequence indices.
Definition: range.h:123
int64_t int64
Definition: number_types.h:14
constexpr int64 start() const
Returns the first index in the sequence.
Definition: range.h:111
constexpr range stride_by(int64 stride) const
Returns a new range object incremending by stride.
Definition: range.h:153