Describes a signed, strided half-open index range.
More...
#include <Slice.hpp>
|
| 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.
|
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.
- Example
Describes a signed, strided half-open index range.
- See also
- stratax::indexing::slice
Definition at line 30 of file Slice.hpp.
◆ difference_type
Signed type used for bounds and step values.
Definition at line 36 of file Slice.hpp.
◆ size_type
Unsigned type used for the number of selected indices.
Definition at line 34 of file Slice.hpp.
◆ Slice()
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.
- Parameters
-
| 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
-
- Complexity
- O(1).
Definition at line 56 of file Slice.hpp.
◆ empty()
| bool stratax::core::Slice::empty |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Reports whether the raw range selects no indices.
- Complexity
- O(1).
Definition at line 111 of file Slice.hpp.
◆ operator==()
| bool stratax::core::Slice::operator== |
( |
const Slice & | other | ) |
const |
|
inlinenodiscardnoexcept |
Compares two slices by their stored bounds and step.
- Parameters
-
| other | Slice to compare with this slice. |
- Returns
- true when start, stop, and step are all equal.
- Complexity
- O(1).
Definition at line 119 of file Slice.hpp.
◆ size()
| size_type stratax::core::Slice::size |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
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.
- Returns
- Number of generated indices.
- Precondition
- Intermediate signed distance and rounding arithmetic must be representable by difference_type.
- Complexity
- O(1).
Definition at line 87 of file Slice.hpp.
◆ start()
Returns the raw inclusive start bound.
- Complexity
- O(1).
Definition at line 67 of file Slice.hpp.
◆ step()
Returns the nonzero signed step.
- Complexity
- O(1).
Definition at line 71 of file Slice.hpp.
◆ stop()
Returns the raw exclusive stop bound.
- Complexity
- O(1).
Definition at line 69 of file Slice.hpp.
The documentation for this class was generated from the following file: