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...
 
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...
 
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 39 of file IntRangeI.H.

References Foam::noexcept.

◆ IntRange() [3/3]

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

Construct a range from start/length, no checks.

Definition at line 50 of file IntRangeI.H.

References Foam::noexcept.

Member Function Documentation

◆ rend_value()

IntType rend_value
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
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
inlinenoexcept

The (inclusive) lower value of the range.

Definition at line 408 of file IntRangeI.H.

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

Here is the caller graph for this function:

◆ size() [1/2]

IntType size
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
inlinenoexcept

True if range is empty (zero-sized)

Definition at line 436 of file IntRangeI.H.

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

Here is the caller graph for this function:

◆ first()

IntType first
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(), bitSet::set(), and bitSet::unset().

Here is the caller graph for this function:

◆ last()

IntType last
inlinenoexcept

The (inclusive) upper value of the range.

Definition at line 450 of file IntRangeI.H.

Referenced by labelRanges::remove().

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

References n.

◆ resize()

void resize ( const IntType  n)
inlinenoexcept

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

Definition at line 504 of file IntRangeI.H.

References n.

◆ clampSize()

void clampSize
inlinenoexcept

Enforce non-negative size.

Definition at line 511 of file IntRangeI.H.

Referenced by labelRange::join(), IntRange< IntType >::operator--(), IntRange< IntType >::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.

◆ operator[]()

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

Offset dereference, without bounds checking.

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

References found.

◆ operator++() [1/2]

IntType operator++
inlinenoexcept

Increase the size by 1.

Definition at line 546 of file IntRangeI.H.

◆ operator++() [2/2]

IntType operator++ ( int  )
inlinenoexcept

Definition at line 554 of file IntRangeI.H.

◆ operator+=()

IntType operator+= ( const IntType  n)
inlinenoexcept

Increase the size by n.

Definition at line 583 of file IntRangeI.H.

References n.

◆ operator--() [1/2]

IntType operator--
inlinenoexcept

Decrease the size by 1, but never below 0.

Definition at line 562 of file IntRangeI.H.

References IntRange< IntType >::clampSize().

Here is the call graph for this function:

◆ operator--() [2/2]

IntType operator-- ( int  )
inlinenoexcept

Definition at line 572 of file IntRangeI.H.

References IntRange< IntType >::clampSize().

Here is the call graph for this function:

◆ operator-=()

IntType operator-= ( const IntType  n)
inlinenoexcept

Decrease the size by n, but never below 0.

Definition at line 592 of file IntRangeI.H.

References IntRange< IntType >::clampSize(), and n.

Here is the call graph for this function:

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

True if range is non-empty.

Definition at line 245 of file IntRange.H.

References bool.

◆ 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
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
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
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
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
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
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
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
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: