SyDEVS
v0.6.7
Multiscale Simulation and Systems Modeling Library
|
A data type which represents a range of array indices along a single dimension. More...
#include <range.h>
Public Member Functions | |
constexpr | range () |
Constructs a range object representing a sequence that starts at 0 and increases by 1. More... | |
constexpr | range (const range &)=default |
Copy constructor. More... | |
range & | operator= (const range &)=default |
Copy assignment. More... | |
range (range &&)=default | |
Move constructor. More... | |
range & | operator= (range &&)=default |
Move assignment. More... | |
~range ()=default | |
Destructor. More... | |
constexpr int64 | start () const |
Returns the first index in the sequence. More... | |
constexpr int64 | stop () const |
Returns the last possible index in the sequence. More... | |
constexpr int64 | stride () const |
Returns the increment between sequence indices. More... | |
constexpr range | start_at (int64 limit) const |
Returns a new range object starting at limit . More... | |
constexpr range | start_after (int64 limit) const |
Returns a new range object starting immediate after limit . More... | |
constexpr range | stop_at (int64 limit) const |
Returns a new range object stopping at limit . More... | |
constexpr range | stop_before (int64 limit) const |
Returns a new range object stopping immediate before limit . More... | |
constexpr range | stride_by (int64 stride) const |
Returns a new range object incremending by stride . More... | |
A data type which represents a range of array indices along a single dimension.
A range
object can be used to create a slice of a multidimensional array (arraynd
) according to an arithmetic sequence of indices along a single dimension.
The arithmetic sequence represented by a range
object starts either at or immediately after a start index, increments according to a given stride, and terminates either at or immediately before a stop index. The stop index is permitted to be the maximum 64-bit signed integer (increasing sequences) or the minimum 64-bit signed integer (decreasing sequences), indicating that the sequence continues until the end of the array.
A range
object is defined using a chain of member function calls, as demonstrated below.
As in the above examples, it is recommended to use start_at
and stop_before
for increasing sequences and start_after
and stop_at
for decreasing sequences. However, as demonstrated below, it is possible to deviate from this convention.
constexpr sydevs::range::range | ( | ) |
Constructs a range
object representing a sequence that starts at 0 and increases by 1.
|
default |
Copy constructor.
|
default |
Move constructor.
|
default |
Destructor.
constexpr int64 sydevs::range::start | ( | ) | const |
Returns the first index in the sequence.
Returns a new range
object starting immediate after limit
.
Returns a new range
object starting at limit
.
constexpr int64 sydevs::range::stop | ( | ) | const |
Returns the last possible index in the sequence.
Returns a new range
object stopping at limit
.
Returns a new range
object stopping immediate before limit
.
constexpr int64 sydevs::range::stride | ( | ) | const |
Returns the increment between sequence indices.
Returns a new range
object incremending by stride
.