A range or interval of labels defined by a start and a size. More...
Public Member Functions | |
constexpr | labelRange () noexcept |
Default construct an empty range (0,0) More... | |
constexpr | labelRange (const label len) noexcept |
Construct a range with specified length, starting at zero (0,len) More... | |
labelRange (const label beg, const label len) noexcept | |
Construct a range from start/length, no checks. More... | |
labelRange (const label beg, const label len, const bool adjustStart) noexcept | |
Construct a range from start/size, enforces non-negative size. More... | |
labelRange (const MinMax< label > &range) noexcept | |
labelRange (Istream &is) | |
Construct from Istream. More... | |
label | min () const noexcept |
The (inclusive) lower value of the range - same as first(), start() More... | |
label | max () const noexcept |
The (inclusive) upper value of the range - same as last() More... | |
label | before () const noexcept |
The value before the start of the range. More... | |
label | after () const noexcept |
The value after the last element in the range. More... | |
void | adjust () noexcept |
Adjust the start to avoid negative indices. More... | |
void | reset (const label beg, const label end, const bool adjustStart) noexcept |
Reset start and length, enforces non-negative size. More... | |
List< label > | labels () const |
Return list of labels corresponding to the range. More... | |
bool | overlaps (const labelRange &range, bool touches=false) const |
Return true if the ranges overlap. More... | |
labelRange | join (const labelRange &range) const |
Return a joined range, squashing any gaps in between. More... | |
labelRange | subset (const labelRange &range) const |
Calculate the intersection of the range with another. More... | |
labelRange | subset (const label start, const label size) const |
Calculate the intersection with the given start/size range. More... | |
labelRange | subset0 (const label size) const |
Calculate the intersection with the given 0/size range. More... | |
bool | valid () const noexcept |
Deprecated(2020-09) True if range is non-empty. More... | |
![]() | |
constexpr | IntRange () noexcept |
Default construct an empty range (0,0) More... | |
constexpr | IntRange (const label len) noexcept |
Construct a range with specified length, starting at zero (0,len) More... | |
constexpr | IntRange (const label beg, const label len) noexcept |
Construct a range from start/length, no checks. More... | |
label | start () const noexcept |
The (inclusive) lower value of the range. More... | |
label & | start () noexcept |
Non-const access to start of the range. More... | |
label | size () const noexcept |
The size of the range. More... | |
label & | size () noexcept |
Non-const access to size of the range. More... | |
bool | empty () const noexcept |
True if range is empty (zero-sized) More... | |
label | first () const noexcept |
The (inclusive) lower value of the range. Same as start() More... | |
label | last () const noexcept |
The (inclusive) upper value of the range. More... | |
void | clear () noexcept |
Reset to zero start and zero size. More... | |
void | reset (const label beg, const label len) noexcept |
Reset start and length, no checks. More... | |
void | setStart (const label i) noexcept |
Set the start position, no checks. More... | |
void | setSize (const label n) noexcept |
Change the size, no checks. Identical to resize() More... | |
void | resize (const label n) noexcept |
Change the size, no checks. Identical to setSize() More... | |
void | clampSize () noexcept |
Enforce non-negative size. More... | |
bool | found (const label value) const noexcept |
True if the (global) value is located within the range. More... | |
constexpr label | operator[] (const label i) const noexcept |
Offset dereference, without bounds checking. More... | |
bool | operator() (const label value) const noexcept |
True if the global value is located within the range. More... | |
label | operator++ () noexcept |
Increase the size by 1. More... | |
label | operator++ (int) noexcept |
label | operator+= (const label n) noexcept |
Increase the size by n. More... | |
label | operator-- () noexcept |
Decrease the size by 1, but never below 0. More... | |
label | operator-- (int) noexcept |
label | operator-= (const label n) noexcept |
Decrease the size by n, but never below 0. More... | |
operator bool () const noexcept | |
True if range is non-empty. More... | |
const_iterator | at (const label i) const |
const_iterator | begin () const noexcept |
A const_iterator set to the beginning of the range. More... | |
const_iterator | cbegin () const noexcept |
A const_iterator set to the beginning of the range. More... | |
const_iterator | cend () const noexcept |
A const_iterator set to 1 beyond the end of the range. More... | |
const_iterator | end () const noexcept |
A const_iterator set to 1 beyond the end of the range. More... | |
const_reverse_iterator | rbegin () const noexcept |
A const_reverse_iterator set to 1 before the end of range. More... | |
const_reverse_iterator | crbegin () const noexcept |
A const_reverse_iterator set to 1 before the end of range. More... | |
const_reverse_iterator | rend () const noexcept |
A const_reverse_iterator set to 1 before the begin of range. More... | |
const_reverse_iterator | crend () const noexcept |
A const_reverse_iterator set to 1 before the begin of range. More... | |
Static Public Attributes | |
static int | debug |
Debugging. More... | |
Additional Inherited Members | |
![]() | |
typedef label | value_type |
Type of values the range contains. More... | |
typedef label | size_type |
The type that can represent the size of the range. More... | |
![]() | |
label | rend_value () const noexcept |
The value 1 before the start of the range. More... | |
label | end_value () const noexcept |
The value 1 beyond the end of the range. More... | |
A range or interval of labels defined by a start and a size.
Definition at line 55 of file labelRange.H.
|
inlineconstexprnoexcept |
Default construct an empty range (0,0)
Definition at line 31 of file labelRangeI.H.
|
inlineexplicitconstexprnoexcept |
Construct a range with specified length, starting at zero (0,len)
Definition at line 37 of file labelRangeI.H.
|
inlinenoexcept |
Construct a range from start/length, no checks.
Definition at line 43 of file labelRangeI.H.
|
inlinenoexcept |
Construct a range from start/size, enforces non-negative size.
Optionally adjust the start to avoid any negative indices.
Definition at line 55 of file labelRangeI.H.
|
explicitnoexcept |
Construct from a min/max range, enforces non-negative size. Does not adjust the start.
Passing an invalid min/max range results in an empty labelRange
Definition at line 44 of file labelRange.C.
References Foam::noexcept, and range.
|
explicit |
Construct from Istream.
Definition at line 56 of file labelRange.C.
|
inlinenoexcept |
The (inclusive) lower value of the range - same as first(), start()
Definition at line 77 of file labelRangeI.H.
|
inlinenoexcept |
The (inclusive) upper value of the range - same as last()
Definition at line 83 of file labelRangeI.H.
|
inlinenoexcept |
The value before the start of the range.
Definition at line 89 of file labelRangeI.H.
References IntRange< IntType >::rend_value().
|
inlinenoexcept |
The value after the last element in the range.
This is identical to the value of cend()
Definition at line 95 of file labelRangeI.H.
References IntRange< IntType >::end_value().
Referenced by bitSet::set(), Foam::BitOps::set(), and bitSet::unset().
|
noexcept |
Adjust the start to avoid negative indices.
The size is decreased accordingly, but will never become negative. Eg, adjusting (-10, 15) becomes (0,5). adjusting (-20, 15) becomes (0,0)
Definition at line 81 of file labelRange.C.
Referenced by bitSet::set(), and Foam::BitOps::set().
|
inlinenoexcept |
Reset start and length, enforces non-negative size.
Optionally adjust the start to avoid any negative indices.
Definition at line 101 of file labelRangeI.H.
Referenced by labelRanges::remove().
Foam::List< Foam::label > labels | ( | ) | const |
Return list of labels corresponding to the range.
Same as Foam::identity()
Definition at line 66 of file labelRange.C.
References UList< T >::begin(), and UList< T >::end().
bool overlaps | ( | const labelRange & | range, |
bool | touches = false |
||
) | const |
Return true if the ranges overlap.
Optional test for ranges that also just touch each other
Definition at line 96 of file labelRange.C.
References range.
Referenced by labelRanges::add().
Foam::labelRange join | ( | const labelRange & | range | ) | const |
Return a joined range, squashing any gaps in between.
A prior overlaps() check can be used to avoid squashing gaps.
Definition at line 119 of file labelRange.C.
References IntRange< IntType >::clampSize(), Foam::max(), Foam::min(), and range.
Referenced by labelRanges::add().
Foam::labelRange subset | ( | const labelRange & | range | ) | const |
Calculate the intersection of the range with another.
If there is no intersection, it returns an empty range with zero for start/size.
Definition at line 144 of file labelRange.C.
References Foam::max(), Foam::min(), and range.
Foam::labelRange subset | ( | const label | start, |
const label | size | ||
) | const |
Calculate the intersection with the given start/size range.
If there is no intersection, it returns an empty range with zero for start/size.
Definition at line 161 of file labelRange.C.
References Foam::max(), and Foam::min().
Foam::labelRange subset0 | ( | const label | size | ) | const |
Calculate the intersection with the given 0/size range.
If there is no intersection, it returns an empty range with zero for start/size.
Definition at line 182 of file labelRange.C.
References Foam::max(), and Foam::min().
Referenced by UList< T >::validateRange().
|
inlinenoexcept |
Deprecated(2020-09) True if range is non-empty.
Definition at line 183 of file labelRange.H.
|
static |