|
Stratax 0.3.1
|
Describes a signed, strided half-open index range. More...
#include <Slice.hpp>
Public Types | |
| using | size_type = std::size_t |
| Unsigned type used for the number of selected indices. | |
| using | difference_type = std::ptrdiff_t |
| Signed type used for bounds and step values. | |
Public Member Functions | |
| Slice (difference_type start, difference_type stop, difference_type step=1) | |
| Constructs a slice from raw half-open bounds and a step. | |
| difference_type | start () const noexcept |
| Returns the raw inclusive start bound. | |
| difference_type | stop () const noexcept |
| Returns the raw exclusive stop bound. | |
| difference_type | step () const noexcept |
| Returns the nonzero signed step. | |
| size_type | size () const noexcept |
| Returns the number of indices described by the raw range. | |
| bool | empty () const noexcept |
| Reports whether the raw range selects no indices. | |
| bool | operator== (const Slice &other) const noexcept |
| Compares two slices by their stored bounds and step. | |
Describes a signed, strided half-open index range.
Slice stores raw [start, stop) bounds and a nonzero step. A positive step selects values while they are less than stop; a negative step selects values while they are greater than stop. Bounds are not normalized or clamped by this class because normalization depends on the dimension being sliced.
| using stratax::core::Slice::difference_type = std::ptrdiff_t |
| using stratax::core::Slice::size_type = std::size_t |
|
inline |
Constructs a slice from raw half-open bounds and a step.
The values are stored unchanged. In particular, negative bounds are not converted relative to a container extent during construction.
| start | First index in the range when the range is non-empty. |
| stop | Exclusive boundary that terminates the range. |
| step | Nonzero increment between consecutive indices. |
| Exceptions::IndexError | If step is zero. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Returns the number of indices described by the raw range.
A positive-step slice is empty when start() >= stop(). A negative-step slice is empty when start() <= stop(). Otherwise the result is the ceiling of the directed distance divided by the absolute step.
This calculation does not normalize bounds against a container extent.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |