Loading...
Searching...
No Matches
labelRange Class Reference

A range or interval of labels defined by a start and a size. More...

#include <labelRange.H>

Inheritance diagram for labelRange:
Collaboration diagram for labelRange:

Public Types

typedef label value_type
 Type of values the range contains.
typedef label size_type
 The type that can represent the size of the range.
Public Types inherited from IntRange< label >
typedef label value_type
 Type of values the range contains.
typedef label size_type
 The type that can represent the size of the range.
using const_iterator
 Input iterator with const access.
using const_reverse_iterator
 Reverse input iterator with const access.

Public Member Functions

 labelRange (const labelRange &) noexcept=default
 Copy construct.
 labelRange (labelRange &&) noexcept=default
 Move construct.
labelRangeoperator= (const labelRange &) noexcept=default
 Copy assignment.
labelRangeoperator= (labelRange &&) noexcept=default
 Move assignment.
constexpr labelRange () noexcept
 Default construct an empty range (0,0).
constexpr labelRange (label len) noexcept
 Construct a range with specified length, starting at zero (0,len).
 labelRange (label beg, label len) noexcept
 Construct a range from start/length. Applies clamp on length.
 labelRange (label beg, label len, bool adjustStart) noexcept
 Construct a range from start/size, enforces non-negative size.
 labelRange (const MinMax< label > &range) noexcept
 Construct from a min/max range (both inclusive), enforces non-negative size.
 labelRange (const Pair< label > &start_end) noexcept
 Construct from start (inclusive) and end (exclusive) values, enforces non-negative size.
template<class IntT, class = std::enable_if_t <std::is_integral_v<IntT> && (sizeof(IntT) <= sizeof(value_type))>>
 labelRange (const IntRange< IntT > &rhs) noexcept
 Implicit construct from an IntRange with the same or lower representation (no checks for signed vs unsigned).
 labelRange (Istream &is)
 Construct from Istream. Read a bracketed (start size) tuple.
void adjust () noexcept
 Adjust the start to avoid negative indices.
void reset (label beg, label len, bool adjustStart) noexcept
 Reset start and length, enforces non-negative size.
bool overlaps (const labelRange &range, bool touches=false) const
 Return true if the ranges overlap.
labelRange join (const labelRange &range) const
 Return a joined range, squashing any gaps in between.
labelRange subset (const labelRange &range) const
 Calculate the intersection of the range with another.
labelRange subset (label start, label size) const
 Calculate the intersection with the given start/size range.
labelRange subset0 (label len) const
 Calculate the intersection with the given 0/size range.
template<class IntT, class = std::enable_if_t <std::is_integral_v<IntT> && (sizeof(IntT) <= sizeof(value_type))>>
void operator= (const IntRange< IntT > &rhs) noexcept
 Assign from an IntRange with the same or lower representation (no checks for signed vs unsigned).
bool valid () const noexcept
 Deprecated(2020-09) True if range has size greater than zero.
Public Member Functions inherited from IntRange< label >
constexpr IntRange () noexcept
 Default construct an empty range (0,0).
bool empty () const noexcept
 True if range is empty (zero-sized).
bool good () const noexcept
 True if range has size greater than zero.
label size () const noexcept
 The size of the range.
label start () const noexcept
 The (inclusive) lower value of the range.
label min () const noexcept
 The (inclusive) lower value of the range, same as start(), begin_value().
label max () const noexcept
 The (inclusive) upper value of the range, same as rbegin_value(). Ill-defined for an empty range.
void clear () noexcept
 Reset to (0,0).
void reset () noexcept
 Reset to (0,0).
void setStart (label i) noexcept
 Set the start position, no checks.
void setSize (label n) noexcept
 Change the size, no checks. Identical to resize().
void resize (label n) noexcept
 Change the size, no checks. Identical to setSize().
void clampSize () noexcept
 Enforce non-negative size.
bool contains (label value) const noexcept
 True if the (global) value is within the range.
bool found (label val) const noexcept
 True if the (global) value is within the range.
const_iterator at (label i) const
 Return const_iterator to a position within the range, with bounds checking.
constexpr label operator[] (label i) const noexcept
 Offset dereference, without bounds checking.
bool operator() (label i) const noexcept
 True if the global value is located within the range.
label operator++ () noexcept
 Increase the size by 1.
label operator+= (label n) noexcept
 Increase the size by n.
label operator-- () noexcept
 Decrease the size by 1, but never below 0.
label operator-= (label n) noexcept
 Decrease the size by n, but never below 0.
 operator bool () const noexcept
 True if range has size greater than zero. Same as good().
label begin_value () const noexcept
 The value at the beginning of the range - same as min(), start().
label end_value () const noexcept
 The value 1 beyond the end of the range.
label rbegin_value () const noexcept
 The max value of the range.
label rend_value () const noexcept
 The value 1 before the begin of range.
const_iterator begin () const noexcept
 A const_iterator set to the beginning of the range.
const_iterator cbegin () const noexcept
 A const_iterator set to the beginning of the range.
const_iterator cend () const noexcept
 A const_iterator set to 1 beyond the end of the range.
const_iterator end () const noexcept
 A const_iterator set to 1 beyond the end of the range.
const_reverse_iterator rbegin () const noexcept
 A const_reverse_iterator set to 1 before the end of range.
const_reverse_iterator crbegin () const noexcept
 A const_reverse_iterator set to 1 before the end of range.
const_reverse_iterator rend () const noexcept
 A const_reverse_iterator set to 1 before the begin of range.
const_reverse_iterator crend () const noexcept
 A const_reverse_iterator set to 1 before the begin of range.

Static Public Attributes

static int debug
 Debugging.

Detailed Description

A range or interval of labels defined by a start and a size.

Source files

Definition at line 63 of file labelRange.H.

Member Typedef Documentation

◆ value_type

typedef label value_type

Type of values the range contains.

Definition at line 74 of file labelRange.H.

◆ size_type

typedef label size_type

The type that can represent the size of the range.

Definition at line 79 of file labelRange.H.

Constructor & Destructor Documentation

◆ labelRange() [1/10]

labelRange ( const labelRange & )
defaultnoexcept

Copy construct.

References labelRange().

Referenced by join(), labelRange(), labelRange(), labelRange(), labelRange(), labelRange(), operator=(), operator=(), overlaps(), subset(), and subset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ labelRange() [2/10]

labelRange ( labelRange && )
defaultnoexcept

Move construct.

References labelRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ labelRange() [3/10]

labelRange ( )
inlineconstexprnoexcept

Default construct an empty range (0,0).

Definition at line 24 of file labelRangeI.H.

References IntRange< label >::IntRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ labelRange() [4/10]

labelRange ( label len)
inlineexplicitconstexprnoexcept

Construct a range with specified length, starting at zero (0,len).

Definition at line 30 of file labelRangeI.H.

References IntRange< label >::IntRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ labelRange() [5/10]

labelRange ( label beg,
label len )
inlinenoexcept

Construct a range from start/length. Applies clamp on length.

Definition at line 36 of file labelRangeI.H.

References IntRange< label >::clampSize(), IntRange< label >::IntRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ labelRange() [6/10]

labelRange ( label beg,
label len,
bool adjustStart )
inlinenoexcept

Construct a range from start/size, enforces non-negative size.

Optionally adjust the start to avoid any negative indices.

See also
adjust()

Definition at line 44 of file labelRangeI.H.

References adjust(), IntRange< label >::clampSize(), IntRange< label >::IntRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ labelRange() [7/10]

labelRange ( const MinMax< label > & range)
explicitnoexcept

Construct from a min/max range (both inclusive), enforces non-negative size.

Passing an invalid range results in an empty labelRange

References labelRange(), Foam::noexcept, and range.

Here is the call graph for this function:

◆ labelRange() [8/10]

labelRange ( const Pair< label > & start_end)
explicitnoexcept

Construct from start (inclusive) and end (exclusive) values, enforces non-negative size.

Passing an invalid range results in an empty labelRange

References labelRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ labelRange() [9/10]

template<class IntT, class = std::enable_if_t <std::is_integral_v<IntT> && (sizeof(IntT) <= sizeof(value_type))>>
labelRange ( const IntRange< IntT > & rhs)
inlinenoexcept

Implicit construct from an IntRange with the same or lower representation (no checks for signed vs unsigned).

Definition at line 174 of file labelRange.H.

References IntRange< label >::IntRange(), labelRange(), Foam::noexcept, Foam::rhs(), IntRange< label >::size(), and IntRange< label >::start().

Here is the call graph for this function:

◆ labelRange() [10/10]

labelRange ( Istream & is)
explicit

Construct from Istream. Read a bracketed (start size) tuple.

Member Function Documentation

◆ operator=() [1/3]

labelRange & operator= ( const labelRange & )
defaultnoexcept

Copy assignment.

References labelRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ operator=() [2/3]

labelRange & operator= ( labelRange && )
defaultnoexcept

Move assignment.

References labelRange(), and Foam::noexcept.

Here is the call graph for this function:

◆ adjust()

void adjust ( )
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)

References IntRange< label >::IntRange(), Foam::noexcept, and reset().

Referenced by labelRange(), reset(), Foam::BitOps::set(), Foam::BitOps::set(), and bitSet::set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset()

void reset ( label beg,
label len,
bool adjustStart )
inlinenoexcept

Reset start and length, enforces non-negative size.

Optionally adjust the start to avoid any negative indices.

Definition at line 66 of file labelRangeI.H.

References adjust(), IntRange< label >::clampSize(), and IntRange< IntType >::reset().

Referenced by adjust().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ overlaps()

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

References labelRange(), overlaps(), and range.

Referenced by overlaps().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ join()

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.

References join(), labelRange(), and range.

Referenced by join().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subset() [1/2]

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.

References labelRange(), range, and subset().

Referenced by subset(), and subset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subset() [2/2]

labelRange subset ( label start,
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.

References labelRange(), IntRange< label >::size(), IntRange< label >::start(), subset(), and subset0().

Here is the call graph for this function:

◆ subset0()

Foam::labelRange subset0 ( label len) const
inline

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 87 of file labelRangeI.H.

References Foam::subset().

Referenced by subset(), Foam::subsetAdjacency(), and UList< T >::validateRange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [3/3]

template<class IntT, class = std::enable_if_t <std::is_integral_v<IntT> && (sizeof(IntT) <= sizeof(value_type))>>
void operator= ( const IntRange< IntT > & rhs)
inlinenoexcept

Assign from an IntRange with the same or lower representation (no checks for signed vs unsigned).

Definition at line 264 of file labelRange.H.

References IntRange< label >::IntRange(), Foam::noexcept, IntRange< IntType >::reset(), and Foam::rhs().

Here is the call graph for this function:

◆ valid()

bool valid ( ) const
inlinenoexcept

Deprecated(2020-09) True if range has size greater than zero.

Deprecated
(2020-09) - use bool operator - or good()

Definition at line 278 of file labelRange.H.

References IntRange< label >::good(), and Foam::noexcept.

Here is the call graph for this function:

Member Data Documentation

◆ debug

int debug
static

Debugging.

Definition at line 97 of file labelRange.H.


The documentation for this class was generated from the following files: