#include <Segment.h>
Bounds of a closed index interval.
The lower and upper bounds are named front
and back
to match Segment
wording. This also avoids confusion when working with table segments, where the lower bound is upward the upper bound.
Static Public Member Functions | |
static Segment | fromSize (long front, long size) |
Create a segment specified by a lower bound and size. | |
static Segment | whole () |
Create a maximal segment (from index 0 to max). | |
Public Member Functions | |
long | size () const |
Get the number of elements. | |
Public Attributes | |
long | front |
The lower bound. | |
long | back |
The upper bound. | |
Related Functions | |
(Note that these are not member functions.) | |
bool | operator== (const Segment &lhs, const Segment &rhs) |
Check whether two segments are equal. | |
bool | operator!= (const Segment &lhs, const Segment &rhs) |
Check whether two segments are different. | |
Segment & | operator+= (Segment &lhs, long rhs) |
Add a scalar. | |
Segment & | operator-= (Segment &lhs, long rhs) |
Subtract a scalar. | |
Segment & | operator++ (Segment &lhs) |
Add 1. | |
Segment & | operator-- (Segment &lhs) |
Subtract 1. | |
Segment | operator++ (Segment &lhs, int) |
Return the current segment and then add 1. | |
Segment | operator-- (Segment &lhs, int) |
Return the current segment and then subtract 1. | |
Segment | operator+ (const Segment &rhs) |
Identity. | |
Segment | operator- (const Segment &rhs) |
Change the sign of each coordinate. | |
Segment | operator+ (const Segment &lhs, long rhs) |
Add a segment and a scalar. | |
Segment | operator- (const Segment &lhs, long rhs) |
Subtract a segment and a scalar. | |