IntRange< IntType > Class Template Reference

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

Inheritance diagram for IntRange< IntType >:
[legend]

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...
 

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...
 
IntType start () const noexcept
 The (inclusive) lower value of the range. More...
 
IntType size () const noexcept
 The size of the range. More...
 
IntType & start () noexcept
 Non-const access to start of the range. More...
 
IntType & size () noexcept
 Non-const access to size of the range. More...
 
bool empty () const noexcept
 True if range is empty (zero-sized) More...
 
IntType first () const noexcept
 The (inclusive) lower value of the range. Same as start() More...
 
IntType 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 IntType beg, const IntType len) noexcept
 Reset start and length, no checks. 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 found (const IntType value) const noexcept
 True if the (global) value is located within the range. More...
 
constexpr IntType operator[] (const IntType i) const noexcept
 Offset dereference, without bounds checking. More...
 
bool operator() (const IntType value) 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 is non-empty. More...
 
const_iterator at (const IntType 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...
 

Protected Member Functions

IntType rend_value () const noexcept
 The value 1 before the start of the range. More...
 
IntType end_value () const noexcept
 The value 1 beyond the end of the 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 63 of file IntRange.H.

Member Typedef Documentation

◆ value_type

typedef IntType value_type

Type of values the range contains.

Definition at line 94 of file IntRange.H.

◆ size_type

typedef IntType size_type

The type that can represent the size of the range.

Definition at line 97 of file IntRange.H.

Constructor & Destructor Documentation

◆ IntRange() [1/3]

constexpr IntRange ( )
inlineconstexprnoexcept

Default construct an empty range (0,0)

Definition at line 31 of file IntRangeI.H.

◆ IntRange() [2/3]

constexpr IntRange ( const IntType  len)
inlineexplicitconstexprnoexcept

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

Definition at line 40 of file IntRangeI.H.

◆ IntRange() [3/3]

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

Construct a range from start/length, no checks.

Definition at line 51 of file IntRangeI.H.

Member Function Documentation

◆ rend_value()

IntType rend_value ( ) const
inlineprotectednoexcept

The value 1 before the start of the range.

Corresponds to the value of the rend() iterator

Definition at line 457 of file IntRangeI.H.

Referenced by labelRange::before().

Here is the caller graph for this function:

◆ end_value()

IntType end_value ( ) const
inlineprotectednoexcept

The value 1 beyond the end of the range.

Corresponds to the value of the end() iterator

Definition at line 464 of file IntRangeI.H.

Referenced by labelRange::after().

Here is the caller graph for this function:

◆ start() [1/2]

IntType start ( ) const
inlinenoexcept

The (inclusive) lower value of the range.

Definition at line 408 of file IntRangeI.H.

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

Here is the caller graph for this function:

◆ size() [1/2]

IntType size ( ) const
inlinenoexcept

The size of the range.

Definition at line 415 of file IntRangeI.H.

Referenced by Foam::operator<(), and Foam::operator==().

Here is the caller graph for this function:

◆ start() [2/2]

IntType & start ( )
inlinenoexcept

Non-const access to start of the range.

Definition at line 422 of file IntRangeI.H.

◆ size() [2/2]

IntType & size ( )
inlinenoexcept

Non-const access to size of the range.

Definition at line 429 of file IntRangeI.H.

◆ empty()

bool empty ( ) const
inlinenoexcept

True if range is empty (zero-sized)

Definition at line 436 of file IntRangeI.H.

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

Here is the caller graph for this function:

◆ first()

IntType first ( ) const
inlinenoexcept

The (inclusive) lower value of the range. Same as start()

Definition at line 443 of file IntRangeI.H.

Referenced by Foam::operator<(), Foam::operator==(), labelRanges::remove(), Foam::BitOps::set(), bitSet::set(), and bitSet::unset().

Here is the caller graph for this function:

◆ last()

IntType last ( ) const
inlinenoexcept

The (inclusive) upper value of the range.

Definition at line 450 of file IntRangeI.H.

Referenced by labelRanges::remove(), and Foam::BitOps::set().

Here is the caller graph for this function:

◆ clear()

void clear ( )
inlinenoexcept

Reset to zero start and zero size.

Definition at line 471 of file IntRangeI.H.

Referenced by labelRanges::add().

Here is the caller graph for this function:

◆ reset()

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

Reset start and length, no checks.

Definition at line 479 of file IntRangeI.H.

◆ setStart()

void setStart ( const IntType  i)
inlinenoexcept

Set the start position, no checks.

Definition at line 490 of file IntRangeI.H.

◆ setSize()

void setSize ( const IntType  n)
inlinenoexcept

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

Definition at line 497 of file IntRangeI.H.

◆ resize()

void resize ( const IntType  n)
inlinenoexcept

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

Definition at line 504 of file IntRangeI.H.

◆ clampSize()

void clampSize ( )
inlinenoexcept

Enforce non-negative size.

Definition at line 511 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:

◆ found()

bool found ( const IntType  value) const
inlinenoexcept

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

Definition at line 518 of file IntRangeI.H.

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

Here is the caller graph for this function:

◆ operator[]()

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

Offset dereference, without bounds checking.

Definition at line 531 of file IntRangeI.H.

◆ operator()()

bool operator() ( const IntType  value) const
inlinenoexcept

True if the global value is located within the range.

Behaviour identical to found() - usable as a predicate

Definition at line 539 of file IntRangeI.H.

◆ operator++() [1/2]

IntType operator++ ( )
inlinenoexcept

Increase the size by 1.

Definition at line 547 of file IntRangeI.H.

◆ operator++() [2/2]

IntType operator++ ( int  )
inlinenoexcept

Definition at line 555 of file IntRangeI.H.

◆ operator+=()

IntType operator+= ( const IntType  n)
inlinenoexcept

Increase the size by n.

Definition at line 584 of file IntRangeI.H.

◆ operator--() [1/2]

IntType operator-- ( )
inlinenoexcept

Decrease the size by 1, but never below 0.

Definition at line 563 of file IntRangeI.H.

◆ operator--() [2/2]

IntType operator-- ( int  )
inlinenoexcept

Definition at line 573 of file IntRangeI.H.

◆ operator-=()

IntType operator-= ( const IntType  n)
inlinenoexcept

Decrease the size by n, but never below 0.

Definition at line 593 of file IntRangeI.H.

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

True if range is non-empty.

Definition at line 202 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 335 of file IntRangeI.H.

◆ begin()

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

A const_iterator set to the beginning of the range.

Definition at line 343 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 351 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 367 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 359 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 375 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 383 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 391 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 399 of file IntRangeI.H.


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