IntRange< IntType > Class Template Reference

An interval of (signed) integers defined by a start and a size. More...

Inheritance diagram for IntRange< IntType >:

Classes

class  const_iterator
 Random-access input iterator with const access. More...
 
class  const_reverse_iterator
 Random-access reverse input iterator with const access. More...
 
struct  ge0
 Unary predicate for greater-equal 0 (int values) More...
 
struct  gt0
 Unary predicate for greater than 0 (int values) More...
 
struct  le0
 Unary predicate for less-equal 0 (int values) More...
 
struct  lt0
 Unary predicate for less than 0 (int values) More...
 

Public Types

typedef IntType value_type
 Type of values the range contains. More...
 
typedef IntType size_type
 The type that can represent the size of the range. More...
 

Public Member Functions

constexpr IntRange () noexcept
 Default construct an empty range (0,0) More...
 
constexpr IntRange (const IntType len) noexcept
 Construct a range with specified length, starting at zero (0,len) More...
 
constexpr IntRange (const IntType beg, const IntType len) noexcept
 Construct a range from start/length, no checks. More...
 
bool empty () const noexcept
 True if range is empty (zero-sized) More...
 
bool good () const noexcept
 True if range has size greater than zero. More...
 
IntType size () const noexcept
 The size of the range. More...
 
IntType & size () noexcept
 Non-const access to size of the range. More...
 
IntType start () const noexcept
 The (inclusive) lower value of the range. More...
 
IntType & start () noexcept
 Non-const access to start of the range. More...
 
IntType min () const noexcept
 The (inclusive) lower value of the range, same as start(), begin_value() More...
 
IntType max () const noexcept
 The (inclusive) upper value of the range, same as rbegin_value(). Ill-defined for an empty range. More...
 
void reset () noexcept
 Reset to zero start and zero size. More...
 
void reset (const IntType beg, const IntType len) noexcept
 Reset start and length, no checks. More...
 
void clear () noexcept
 Same as reset() - reset to zero start and zero size. More...
 
void setStart (const IntType i) noexcept
 Set the start position, no checks. More...
 
void setSize (const IntType n) noexcept
 Change the size, no checks. Identical to resize() More...
 
void resize (const IntType n) noexcept
 Change the size, no checks. Identical to setSize() More...
 
void clampSize () noexcept
 Enforce non-negative size. More...
 
bool contains (const IntType value) const noexcept
 True if the (global) value is within the range. More...
 
bool found (const IntType val) const noexcept
 True if the (global) value is within the range. More...
 
const_iterator at (const IntType i) const
 Return const_iterator to a position within the range, with bounds checking. More...
 
constexpr IntType operator[] (const IntType i) const noexcept
 Offset dereference, without bounds checking. More...
 
bool operator() (const IntType i) const noexcept
 True if the global value is located within the range. More...
 
IntType operator++ () noexcept
 Increase the size by 1. More...
 
IntType operator++ (int) noexcept
 
IntType operator+= (const IntType n) noexcept
 Increase the size by n. More...
 
IntType operator-- () noexcept
 Decrease the size by 1, but never below 0. More...
 
IntType operator-- (int) noexcept
 
IntType operator-= (const IntType n) noexcept
 Decrease the size by n, but never below 0. More...
 
 operator bool () const noexcept
 True if range has size greater than zero. Same as good() More...
 
IntType begin_value () const noexcept
 The value at the beginning of the range - same as min(), start() More...
 
IntType end_value () const noexcept
 The value 1 beyond the end of the range. More...
 
IntType rbegin_value () const noexcept
 The max value of the range. More...
 
IntType rend_value () const noexcept
 The value 1 before the begin of range. More...
 
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...
 

Detailed Description

template<class IntType>
class Foam::IntRange< IntType >

An interval of (signed) integers defined by a start and a size.

Note
Only a minimum of IO operators are defined, to avoid incurring too many dependencies or cyclic dependencies.
Source files

Definition at line 59 of file IntRange.H.

Member Typedef Documentation

◆ value_type

typedef IntType value_type

Type of values the range contains.

Definition at line 83 of file IntRange.H.

◆ size_type

typedef IntType size_type

The type that can represent the size of the range.

Definition at line 88 of file IntRange.H.

Constructor & Destructor Documentation

◆ IntRange() [1/3]

constexpr IntRange ( )
inlinenoexcept

Default construct an empty range (0,0)

Definition at line 24 of file IntRangeI.H.

◆ IntRange() [2/3]

constexpr IntRange ( const IntType  len)
inlineexplicitnoexcept

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

Definition at line 33 of file IntRangeI.H.

◆ IntRange() [3/3]

constexpr IntRange ( const IntType  beg,
const IntType  len 
)
inlinenoexcept

Construct a range from start/length, no checks.

Definition at line 44 of file IntRangeI.H.

Member Function Documentation

◆ empty()

bool empty ( ) const
inlinenoexcept

True if range is empty (zero-sized)

Definition at line 184 of file IntRange.H.

Referenced by Foam::BitOps::set(), bitSet::set(), ensightFaces::sort(), ensightCells::sort(), and bitSet::unset().

Here is the caller graph for this function:

◆ good()

bool good ( ) const
inlinenoexcept

True if range has size greater than zero.

Definition at line 189 of file IntRange.H.

◆ size() [1/2]

◆ size() [2/2]

IntType& size ( )
inlinenoexcept

Non-const access to size of the range.

Definition at line 199 of file IntRange.H.

◆ start() [1/2]

IntType start ( ) const
inlinenoexcept

◆ start() [2/2]

IntType& start ( )
inlinenoexcept

Non-const access to start of the range.

Definition at line 209 of file IntRange.H.

◆ min()

IntType min ( ) const
inlinenoexcept

The (inclusive) lower value of the range, same as start(), begin_value()

Definition at line 215 of file IntRange.H.

Referenced by labelRange::join(), labelRange::overlaps(), labelRanges::remove(), and labelRange::subset().

Here is the caller graph for this function:

◆ max()

IntType max ( ) const
inlinenoexcept

The (inclusive) upper value of the range, same as rbegin_value(). Ill-defined for an empty range.

Definition at line 221 of file IntRange.H.

Referenced by labelRange::join(), labelRange::overlaps(), labelRanges::remove(), and labelRange::subset().

Here is the caller graph for this function:

◆ reset() [1/2]

void reset ( )
inlinenoexcept

Reset to zero start and zero size.

Definition at line 397 of file IntRangeI.H.

Referenced by IntRange< label >::clear().

Here is the caller graph for this function:

◆ reset() [2/2]

void reset ( const IntType  beg,
const IntType  len 
)
inlinenoexcept

Reset start and length, no checks.

Definition at line 405 of file IntRangeI.H.

◆ clear()

void clear ( )
inlinenoexcept

Same as reset() - reset to zero start and zero size.

Definition at line 239 of file IntRange.H.

Referenced by cyclicAMIGAMGInterfaceField::ready(), and cyclicACMIGAMGInterfaceField::ready().

Here is the caller graph for this function:

◆ setStart()

void setStart ( const IntType  i)
inlinenoexcept

Set the start position, no checks.

Definition at line 416 of file IntRangeI.H.

◆ setSize()

void setSize ( const IntType  n)
inlinenoexcept

Change the size, no checks. Identical to resize()

Definition at line 423 of file IntRangeI.H.

◆ resize()

void resize ( const IntType  n)
inlinenoexcept

Change the size, no checks. Identical to setSize()

Definition at line 430 of file IntRangeI.H.

◆ clampSize()

void clampSize ( )
inlinenoexcept

Enforce non-negative size.

Definition at line 437 of file IntRangeI.H.

Referenced by labelRange::join(), IntRange< label >::operator--(), IntRange< label >::operator-=(), and labelRanges::remove().

Here is the caller graph for this function:

◆ contains()

bool contains ( const IntType  value) const
inlinenoexcept

True if the (global) value is within the range.

Definition at line 444 of file IntRangeI.H.

Referenced by IntRange< label >::found(), decomposedBlockData::gatherSlaveData(), and IntRange< label >::operator()().

Here is the caller graph for this function:

◆ found()

bool found ( const IntType  val) const
inlinenoexcept

True if the (global) value is within the range.

Definition at line 272 of file IntRange.H.

◆ at()

Foam::IntRange< IntType >::const_iterator at ( const IntType  i) const
inline

Return const_iterator to a position within the range, with bounds checking.

Returns
iterator at the requested position, or end() for out-of-bounds

Definition at line 324 of file IntRangeI.H.

◆ operator[]()

constexpr IntType operator[] ( const IntType  i) const
inlinenoexcept

Offset dereference, without bounds checking.

Definition at line 458 of file IntRangeI.H.

◆ operator()()

bool operator() ( const IntType  i) const
inlinenoexcept

True if the global value is located within the range.

Behaviour identical to contains() - usable as a predicate

Definition at line 296 of file IntRange.H.

◆ operator++() [1/2]

IntType operator++ ( )
inlinenoexcept

Increase the size by 1.

Definition at line 466 of file IntRangeI.H.

◆ operator++() [2/2]

IntType operator++ ( int  )
inlinenoexcept

Definition at line 474 of file IntRangeI.H.

◆ operator+=()

IntType operator+= ( const IntType  n)
inlinenoexcept

Increase the size by n.

Definition at line 503 of file IntRangeI.H.

◆ operator--() [1/2]

IntType operator-- ( )
inlinenoexcept

Decrease the size by 1, but never below 0.

Definition at line 482 of file IntRangeI.H.

◆ operator--() [2/2]

IntType operator-- ( int  )
inlinenoexcept

Definition at line 492 of file IntRangeI.H.

◆ operator-=()

IntType operator-= ( const IntType  n)
inlinenoexcept

Decrease the size by n, but never below 0.

Definition at line 512 of file IntRangeI.H.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

True if range has size greater than zero. Same as good()

Definition at line 323 of file IntRange.H.

◆ begin_value()

IntType begin_value ( ) const
inlinenoexcept

The value at the beginning of the range - same as min(), start()

Definition at line 57 of file IntRangeI.H.

Referenced by IntRange< label >::begin(), IntRange< label >::cbegin(), bitSet::set(), and bitSet::unset().

Here is the caller graph for this function:

◆ end_value()

IntType end_value ( ) const
inlinenoexcept

The value 1 beyond the end of the range.

Definition at line 64 of file IntRangeI.H.

Referenced by IntRange< label >::cend(), IntRange< label >::end(), decomposedBlockData::gatherSlaveData(), Foam::BitOps::set(), bitSet::set(), and bitSet::unset().

Here is the caller graph for this function:

◆ rbegin_value()

IntType rbegin_value ( ) const
inlinenoexcept

The max value of the range.

Definition at line 71 of file IntRangeI.H.

Referenced by IntRange< label >::crbegin(), and IntRange< label >::rbegin().

Here is the caller graph for this function:

◆ rend_value()

IntType rend_value ( ) const
inlinenoexcept

The value 1 before the begin of range.

Definition at line 78 of file IntRangeI.H.

Referenced by IntRange< label >::crend(), and IntRange< label >::rend().

Here is the caller graph for this function:

◆ begin()

Foam::IntRange< IntType >::const_iterator begin ( ) const
inlinenoexcept

A const_iterator set to the beginning of the range.

Definition at line 332 of file IntRangeI.H.

◆ cbegin()

Foam::IntRange< IntType >::const_iterator cbegin ( ) const
inlinenoexcept

A const_iterator set to the beginning of the range.

Definition at line 340 of file IntRangeI.H.

◆ cend()

Foam::IntRange< IntType >::const_iterator cend ( ) const
inlinenoexcept

A const_iterator set to 1 beyond the end of the range.

Definition at line 356 of file IntRangeI.H.

◆ end()

Foam::IntRange< IntType >::const_iterator end ( ) const
inlinenoexcept

A const_iterator set to 1 beyond the end of the range.

Definition at line 348 of file IntRangeI.H.

◆ rbegin()

Foam::IntRange< IntType >::const_reverse_iterator rbegin ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the end of range.

Definition at line 364 of file IntRangeI.H.

◆ crbegin()

Foam::IntRange< IntType >::const_reverse_iterator crbegin ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the end of range.

Definition at line 372 of file IntRangeI.H.

◆ rend()

Foam::IntRange< IntType >::const_reverse_iterator rend ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the begin of range.

Definition at line 380 of file IntRangeI.H.

◆ crend()

Foam::IntRange< IntType >::const_reverse_iterator crend ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the begin of range.

Definition at line 388 of file IntRangeI.H.


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