A range or interval of labels defined by a start and a size. More...
Classes | |
class | const_iterator |
Forward iterator with const access. More... | |
Public Types | |
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... | |
Public Member Functions | |
constexpr | labelRange () noexcept |
An empty range with zero for start/size. More... | |
labelRange (const label start, const label size) noexcept | |
Construct a range from start/size, enforcing non-negative size. More... | |
labelRange (const label start, const label size, const bool adjustStart) noexcept | |
Construct a range from start/size, enforcing non-negative size. More... | |
labelRange (const MinMax< label > &range) noexcept | |
labelRange (Istream &is) | |
Construct from Istream. More... | |
void | setStart (const label i) noexcept |
Change the start position. More... | |
void | resize (const label n) noexcept |
Change the size, enforcing non-negative size. More... | |
void | setSize (const label n) noexcept |
Change the size - alias for resize() More... | |
void | clear () noexcept |
Reset to zero start and zero size. More... | |
bool | empty () const noexcept |
Is the range empty? More... | |
bool | valid () const noexcept |
Is the range non-empty? More... | |
label | start () const noexcept |
The (inclusive) lower value of the range. More... | |
label | size () const noexcept |
The effective size of the range. More... | |
label | before () const noexcept |
The value before the start of the range. More... | |
label | first () const noexcept |
The (inclusive) lower value of the range - same as start() More... | |
label | min () const noexcept |
The (inclusive) lower value of the range - same as start(), first() More... | |
label | last () const noexcept |
The (inclusive) upper value of the range - same as max() More... | |
label | max () const noexcept |
The (inclusive) upper value of the range - same as last() 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... | |
bool | reset (const label start, const label size) noexcept |
Reset start and size, enforcing non-negative size. More... | |
bool | reset (const label start, const label size, const bool adjustStart) noexcept |
Reset start and size, enforcing non-negative size. More... | |
bool | found (const label value) const noexcept |
Return true if the (global) value is located within the range. More... | |
List< label > | labels () const |
Return the range as a list of labels. 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... | |
label | operator[] (const label i) const noexcept |
Return element in the range, without bounds checking. More... | |
bool | operator() (const label value) const noexcept |
Return 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... | |
const_iterator | begin () const |
A const_iterator set to the beginning of the range. More... | |
const_iterator | cbegin () const |
A const_iterator set to the beginning of the range. More... | |
const const_iterator | cend () const |
A const_iterator set to 1 beyond the end of the range. More... | |
const const_iterator | end () const |
A const_iterator set to 1 beyond the end of the range. More... | |
const_iterator | at (const label i) const |
Static Public Member Functions | |
static labelRange | identity (const label len, const label start=0) noexcept |
Static Public Attributes | |
static int | debug |
Debugging. More... | |
static const labelRange | null |
An empty range with start=0, size=0. More... | |
A range or interval of labels defined by a start and a size.
Definition at line 58 of file labelRange.H.
typedef label value_type |
Type of values the range contains.
Definition at line 74 of file labelRange.H.
typedef label size_type |
The type that can represent the size of the range.
Definition at line 77 of file labelRange.H.
|
inlineconstexprnoexcept |
An empty range with zero for start/size.
Definition at line 31 of file labelRangeI.H.
|
inlinenoexcept |
Construct a range from start/size, enforcing non-negative size.
Definition at line 39 of file labelRangeI.H.
|
inlinenoexcept |
Construct a range from start/size, enforcing non-negative size.
Optionally adjust the start to avoid any negative indices.
Definition at line 52 of file labelRangeI.H.
|
explicitnoexcept |
Construct from a min/max range, enforcing non-negative size. Does not adjust the start.
Passing an invalid min/max range results in an empty labelRange
Definition at line 47 of file labelRange.C.
References range.
|
explicit |
Construct from Istream.
Definition at line 60 of file labelRange.C.
|
inlinestaticnoexcept |
An identity range corresponding to (map[i] == i), or with an optional start index, so that (map[i] == i+start)
The parameter order as per the Foam::identity() function.
Definition at line 179 of file labelRangeI.H.
Referenced by ensightCells::classify().
|
inlinenoexcept |
Change the start position.
Definition at line 188 of file labelRangeI.H.
|
inlinenoexcept |
Change the size, enforcing non-negative size.
Definition at line 194 of file labelRangeI.H.
References n.
|
inlinenoexcept |
|
inlinenoexcept |
Reset to zero start and zero size.
Definition at line 208 of file labelRangeI.H.
Referenced by labelRanges::add().
|
inlinenoexcept |
Is the range empty?
Definition at line 214 of file labelRangeI.H.
Referenced by bitSet::set(), ensightFaces::sort(), ensightCells::sort(), and bitSet::unset().
|
inlinenoexcept |
Is the range non-empty?
Definition at line 220 of file labelRangeI.H.
|
inlinenoexcept |
The (inclusive) lower value of the range.
Definition at line 232 of file labelRangeI.H.
Referenced by ensightFaces::classify(), UList< Foam::wordRe >::operator[](), bitSet::set(), bitSet::unset(), and UList< Foam::wordRe >::validateRange().
|
inlinenoexcept |
The effective size of the range.
Definition at line 226 of file labelRangeI.H.
Referenced by UList< Foam::wordRe >::operator[](), and UList< Foam::wordRe >::validateRange().
|
inlinenoexcept |
The value before the start of the range.
Definition at line 238 of file labelRangeI.H.
|
inlinenoexcept |
The (inclusive) lower value of the range - same as start()
Definition at line 244 of file labelRangeI.H.
Referenced by labelRanges::remove(), bitSet::set(), and bitSet::unset().
|
inlinenoexcept |
The (inclusive) lower value of the range - same as start(), first()
Definition at line 250 of file labelRangeI.H.
|
inlinenoexcept |
The (inclusive) upper value of the range - same as max()
Definition at line 256 of file labelRangeI.H.
Referenced by labelRanges::remove().
|
inlinenoexcept |
The (inclusive) upper value of the range - same as last()
Definition at line 262 of file labelRangeI.H.
|
inlinenoexcept |
The value after the last element in the range.
This is identical to the value of cend()
Definition at line 268 of file labelRangeI.H.
Referenced by bitSet::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 85 of file labelRange.C.
Referenced by bitSet::set().
|
inlinenoexcept |
Reset start and size, enforcing non-negative size.
Definition at line 275 of file labelRangeI.H.
Reset start and size, enforcing non-negative size.
Optionally adjust the start to avoid any negative indices.
Definition at line 290 of file labelRangeI.H.
|
inlinenoexcept |
Return true if the (global) value is located within the range.
Definition at line 312 of file labelRangeI.H.
Foam::List< Foam::label > labels | ( | ) | const |
Return the range as a list of labels.
Definition at line 71 of file labelRange.C.
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 102 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 125 of file labelRange.C.
References Foam::stringOps::lower(), Foam::max(), Foam::min(), range, and Foam::stringOps::upper().
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 147 of file labelRange.C.
References Foam::stringOps::lower(), Foam::max(), Foam::min(), range, and Foam::stringOps::upper().
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 165 of file labelRange.C.
References Foam::stringOps::lower(), Foam::max(), Foam::min(), and Foam::stringOps::upper().
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 185 of file labelRange.C.
References Foam::stringOps::lower(), Foam::max(), Foam::min(), and Foam::stringOps::upper().
|
inlinenoexcept |
Return element in the range, without bounds checking.
Definition at line 320 of file labelRangeI.H.
|
inlinenoexcept |
Return true if the global value is located within the range.
Behaviour identical to found() - usable as a predicate
Definition at line 326 of file labelRangeI.H.
References found.
|
inlinenoexcept |
Increase the size by 1.
Definition at line 332 of file labelRangeI.H.
|
inlinenoexcept |
Definition at line 338 of file labelRangeI.H.
|
inlinenoexcept |
|
inlinenoexcept |
Decrease the size by 1, but never below 0.
Definition at line 344 of file labelRangeI.H.
|
inlinenoexcept |
Definition at line 352 of file labelRangeI.H.
|
inlinenoexcept |
Decrease the size by n, but never below 0.
Definition at line 368 of file labelRangeI.H.
References n.
|
inline |
A const_iterator set to the beginning of the range.
The value returned is guaranteed to be the same as start()
Definition at line 145 of file labelRangeI.H.
|
inline |
A const_iterator set to the beginning of the range.
The value returned is guaranteed to be the same as start()
Definition at line 151 of file labelRangeI.H.
|
inline |
A const_iterator set to 1 beyond the end of the range.
The value returned is the same as after()
Definition at line 163 of file labelRangeI.H.
|
inline |
A const_iterator set to 1 beyond the end of the range.
The value returned is the same as after()
Definition at line 157 of file labelRangeI.H.
|
inline |
Return const_iterator to a position within the range, with bounds checking.
Definition at line 170 of file labelRangeI.H.
|
static |
|
static |
An empty range with start=0, size=0.
Definition at line 89 of file labelRange.H.