Loading...
Searching...
No Matches
IntRange< IntType > Class Template Reference

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

#include <IntRange.H>

Inheritance diagram for IntRange< IntType >:

Classes

struct  gt0
 Unary predicate for greater than 0 (int values). More...
struct  lt0
 Unary predicate for less than 0 (int values). More...
struct  ge0
 Unary predicate for greater-equal 0 (int values). More...
struct  le0
 Unary predicate for less-equal 0 (int values). More...

Public Types

typedef IntType value_type
 Type of values the range contains.
typedef IntType size_type
 The type that can represent the size of the range.
using const_iterator = IndexIterator<IntType>
 Input iterator with const access.
using const_reverse_iterator = ReverseIndexIterator<IntType>
 Reverse input iterator with const access.

Public Member Functions

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

Detailed Description

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

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

Note
Since this range is low-level, the IO operators are defined in the separate IntRangeIO.H header.
Source files

Definition at line 68 of file IntRange.H.

Member Typedef Documentation

◆ value_type

template<class IntType>
typedef IntType value_type

Type of values the range contains.

Definition at line 101 of file IntRange.H.

◆ size_type

template<class IntType>
typedef IntType size_type

The type that can represent the size of the range.

Definition at line 106 of file IntRange.H.

◆ const_iterator

template<class IntType>
using const_iterator = IndexIterator<IntType>

Input iterator with const access.

Definition at line 111 of file IntRange.H.

◆ const_reverse_iterator

template<class IntType>
using const_reverse_iterator = ReverseIndexIterator<IntType>

Reverse input iterator with const access.

Definition at line 116 of file IntRange.H.

Constructor & Destructor Documentation

◆ IntRange() [1/3]

template<class IntType>
IntRange ( )
inlineconstexprnoexcept

Default construct an empty range (0,0).

Definition at line 24 of file IntRangeI.H.

References Foam::noexcept.

◆ IntRange() [2/3]

template<class IntType>
IntRange ( IntType len)
inlineexplicitconstexprnoexcept

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

Definition at line 32 of file IntRangeI.H.

References Foam::noexcept.

◆ IntRange() [3/3]

template<class IntType>
IntRange ( IntType beg,
IntType len )
inlineconstexprnoexcept

Construct a range from start/length, no checks.

Definition at line 40 of file IntRangeI.H.

References Foam::noexcept.

Member Function Documentation

◆ empty()

template<class IntType>
bool empty ( ) const
inlinenoexcept

True if range is empty (zero-sized).

Definition at line 198 of file IntRange.H.

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

Here is the caller graph for this function:

◆ good()

template<class IntType>
bool good ( ) const
inlinenoexcept

True if range has size greater than zero.

Definition at line 203 of file IntRange.H.

◆ size() [1/2]

template<class IntType>
IntType size ( ) const
inlinenoexcept

◆ size() [2/2]

template<class IntType>
IntType & size ( )
inlinenoexcept

Non-const access to size of the range.

Definition at line 213 of file IntRange.H.

◆ start() [1/2]

template<class IntType>
IntType start ( ) const
inlinenoexcept

The (inclusive) lower value of the range.

Definition at line 218 of file IntRange.H.

Referenced by ensightFaces::classify(), UPstream::newCommunicator(), Foam::operator<(), Foam::operator==(), mapDistributeBase::receive(), SubList< T >::reset(), mapDistributeBase::send(), and decomposedBlockData::writeBlocks().

Here is the caller graph for this function:

◆ start() [2/2]

template<class IntType>
IntType & start ( )
inlinenoexcept

Non-const access to start of the range.

Definition at line 223 of file IntRange.H.

◆ min()

template<class IntType>
IntType min ( ) const
inlinenoexcept

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

Definition at line 229 of file IntRange.H.

Referenced by decomposedBlockData::writeBlocks().

Here is the caller graph for this function:

◆ max()

template<class IntType>
IntType max ( ) const
inlinenoexcept

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

Definition at line 235 of file IntRange.H.

Referenced by decomposedBlockData::writeBlocks().

Here is the caller graph for this function:

◆ clear()

template<class IntType>
void clear ( )
inlinenoexcept

Reset to (0,0).

Definition at line 91 of file IntRangeI.H.

References Foam::noexcept.

◆ reset() [1/2]

template<class IntType>
void reset ( )
inlinenoexcept

Reset to (0,0).

Definition at line 99 of file IntRangeI.H.

References Foam::noexcept.

Referenced by UPstream::localNode_parentProcs(), labelRange::operator=(), and labelRange::reset().

Here is the caller graph for this function:

◆ reset() [2/2]

template<class IntType>
void reset ( IntType beg,
IntType len )
inlinenoexcept

Reset start and length, no checks.

Definition at line 107 of file IntRangeI.H.

◆ setStart()

template<class IntType>
void setStart ( IntType i)
inlinenoexcept

Set the start position, no checks.

Definition at line 115 of file IntRangeI.H.

◆ setSize()

template<class IntType>
void setSize ( IntType n)
inlinenoexcept

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

Definition at line 122 of file IntRangeI.H.

References n.

◆ resize()

template<class IntType>
void resize ( IntType n)
inlinenoexcept

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

Definition at line 129 of file IntRangeI.H.

References n.

◆ clampSize()

template<class IntType>
void clampSize ( )
inlinenoexcept

Enforce non-negative size.

Definition at line 136 of file IntRangeI.H.

References Foam::noexcept.

◆ contains()

template<class IntType>
bool contains ( IntType value) const
inlinenoexcept

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

Definition at line 143 of file IntRangeI.H.

Referenced by IntRange< int >::found(), decomposedBlockData::gatherProcData(), UPstream::newCommunicator(), and IntRange< int >::operator()().

Here is the caller graph for this function:

◆ found()

template<class IntType>
bool found ( IntType val) const
inlinenoexcept

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

Definition at line 286 of file IntRange.H.

◆ at()

template<class IntType>
const_iterator at ( 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 298 of file IntRange.H.

◆ operator[]()

template<class IntType>
IntType operator[] ( IntType i) const
inlineconstexprnoexcept

Offset dereference, without bounds checking.

Definition at line 154 of file IntRangeI.H.

◆ operator()()

template<class IntType>
bool operator() ( 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 310 of file IntRange.H.

◆ operator++() [1/2]

template<class IntType>
IntType operator++ ( )
inlinenoexcept

Increase the size by 1.

Definition at line 162 of file IntRangeI.H.

References Foam::noexcept.

◆ operator++() [2/2]

template<class IntType>
IntType operator++ ( int )
inlinenoexcept

Definition at line 170 of file IntRangeI.H.

◆ operator+=()

template<class IntType>
IntType operator+= ( IntType n)
inlinenoexcept

Increase the size by n.

Definition at line 197 of file IntRangeI.H.

References n.

◆ operator--() [1/2]

template<class IntType>
IntType operator-- ( )
inlinenoexcept

Decrease the size by 1, but never below 0.

Definition at line 178 of file IntRangeI.H.

◆ operator--() [2/2]

template<class IntType>
IntType operator-- ( int )
inlinenoexcept

Definition at line 187 of file IntRangeI.H.

◆ operator-=()

template<class IntType>
IntType operator-= ( IntType n)
inlinenoexcept

Decrease the size by n, but never below 0.

Definition at line 206 of file IntRangeI.H.

References n.

◆ operator bool()

template<class IntType>
operator bool ( ) const
inlineexplicitnoexcept

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

Definition at line 337 of file IntRange.H.

◆ begin_value()

template<class IntType>
IntType begin_value ( ) const
inlinenoexcept

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

Definition at line 61 of file IntRangeI.H.

References Foam::noexcept.

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

Here is the caller graph for this function:

◆ end_value()

template<class IntType>
IntType end_value ( ) const
inlinenoexcept

The value 1 beyond the end of the range.

Definition at line 68 of file IntRangeI.H.

References Foam::noexcept.

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

Here is the caller graph for this function:

◆ rbegin_value()

template<class IntType>
IntType rbegin_value ( ) const
inlinenoexcept

The max value of the range.

Definition at line 75 of file IntRangeI.H.

References Foam::noexcept.

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

Here is the caller graph for this function:

◆ rend_value()

template<class IntType>
IntType rend_value ( ) const
inlinenoexcept

The value 1 before the begin of range.

Definition at line 82 of file IntRangeI.H.

References Foam::noexcept.

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

Here is the caller graph for this function:

◆ begin()

template<class IntType>
const_iterator begin ( ) const
inlinenoexcept

A const_iterator set to the beginning of the range.

Definition at line 368 of file IntRange.H.

◆ cbegin()

template<class IntType>
const_iterator cbegin ( ) const
inlinenoexcept

A const_iterator set to the beginning of the range.

Definition at line 373 of file IntRange.H.

◆ cend()

template<class IntType>
const_iterator cend ( ) const
inlinenoexcept

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

Definition at line 378 of file IntRange.H.

◆ end()

template<class IntType>
const_iterator end ( ) const
inlinenoexcept

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

Definition at line 383 of file IntRange.H.

◆ rbegin()

template<class IntType>
const_reverse_iterator rbegin ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the end of range.

Definition at line 392 of file IntRange.H.

◆ crbegin()

template<class IntType>
const_reverse_iterator crbegin ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the end of range.

Definition at line 398 of file IntRange.H.

◆ rend()

template<class IntType>
const_reverse_iterator rend ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the begin of range.

Definition at line 403 of file IntRange.H.

◆ crend()

template<class IntType>
const_reverse_iterator crend ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the begin of range.

Definition at line 408 of file IntRange.H.


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