OffsetRange< IntType > Class Template Reference

A tuple of integers comprising start, size, total. More...

Inheritance diagram for OffsetRange< IntType >:

Public Types

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

Public Member Functions

 OffsetRange (const OffsetRange &) noexcept=default
 Copy construct. More...
 
 OffsetRange (OffsetRange &&) noexcept=default
 Move construct. More...
 
OffsetRangeoperator= (const OffsetRange &) noexcept=default
 Copy assignment. More...
 
OffsetRangeoperator= (OffsetRange &&) noexcept=default
 Move assignment. More...
 
constexpr OffsetRange () noexcept
 Default construct as (0,0,0) More...
 
constexpr OffsetRange (IntType len) noexcept
 Construct with start=0 and specified size, assigns total=size. More...
 
constexpr OffsetRange (IntType beg, IntType len, IntType tot) noexcept
 Construct from all components, no checks. More...
 
constexpr bool empty () const noexcept
 True if zero-sized. More...
 
constexpr IntType size () const noexcept
 The size. More...
 
constexpr IntType & size () noexcept
 Non-const access to the size. More...
 
constexpr IntType start () const noexcept
 The lower value of the range. More...
 
constexpr IntType & start () noexcept
 Non-const access to start of the range. More...
 
constexpr IntType total () const noexcept
 The total size. More...
 
constexpr IntType & total () noexcept
 Non-const access to the total size. More...
 
IntRange< IntType > range () const noexcept
 The (start,size) range. More...
 
void clear () noexcept
 Reset to zero. More...
 
void reset (IntType len) noexcept
 Reset to the specified size, with start=0 and total=size. More...
 
void reset (IntType beg, IntType len, IntType tot) noexcept
 Reset all components. More...
 
template<class T2 >
constexpr bool equals (const OffsetRange< T2 > &) const noexcept
 Test equality of start/size/total. More...
 
template<class T2 >
constexpr int compare (const OffsetRange< T2 > &) const noexcept
 Compare start/size/total in that order. More...
 
template<class T2 >
constexpr bool operator== (const OffsetRange< T2 > &other) const noexcept
 Test for equality of begin/size/total values. More...
 
template<class T2 >
constexpr bool operator< (const OffsetRange< T2 > &other) const noexcept
 Comparison function for sorting, compares the start. More...
 
template<class T2 >
constexpr bool operator!= (const OffsetRange< T2 > &other) const noexcept
 
template<class T2 >
constexpr bool operator<= (const OffsetRange< T2 > &other) const noexcept
 
template<class T2 >
constexpr bool operator> (const OffsetRange< T2 > &other) const noexcept
 
template<class T2 >
constexpr bool operator>= (const OffsetRange< T2 > &other) const noexcept
 
void operator= (IntType len) noexcept
 Assign to the specified size, with start=0 and total=size. More...
 
template<class IntT2 >
void operator= (const OffsetRange< IntT2 > &rhs) noexcept
 Assign from an OffsetRange with the same or lower representation. More...
 
const_iterator at (IntType i) const
 Return const_iterator to a position within the range, with bounds checking. More...
 
constexpr IntType operator[] (IntType i) const noexcept
 Offset dereference, without bounds checking. More...
 
constexpr bool operator() (IntType i) const noexcept
 True if the value is between the start and size range. More...
 
constexpr bool contains (IntType value) const noexcept
 True if the value is between the start and size range range. More...
 
constexpr IntType begin_value () const noexcept
 The value at the beginning of the start/size range - same as start() More...
 
constexpr IntType end_value () const noexcept
 The value 1 beyond the end of the start/size range. More...
 
constexpr IntType rbegin_value () const noexcept
 The max value of the start/size range. More...
 
constexpr IntType rend_value () const noexcept
 The value 1 before the begin of start/size 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...
 
template<class IntT2 >
constexpr bool equals (const OffsetRange< IntT2 > &b) const noexcept
 
template<class IntT2 >
constexpr int compare (const OffsetRange< IntT2 > &b) const noexcept
 

Detailed Description

template<class IntType>
class Foam::OffsetRange< IntType >

A tuple of integers comprising start, size, total.

This frequently corresponds what is termed a "hyperslab", a "slice" or a "selection" for MPI addressing. For this type of use, the OffsetRange would represent the local rank addressing. Apart from the total size, it would not have information about any other ranks (like Foam::globalIndex does).

Note
Since this range is low-level, the IO operators are defined in the separate OffsetRangeIO.H header.
See also
Foam::globalIndex Foam::GlobalOffset
Source files

Definition at line 59 of file OffsetRange.H.

Member Typedef Documentation

◆ value_type

typedef IntType value_type

Type of values contained.

Definition at line 119 of file OffsetRange.H.

◆ size_type

typedef IntType size_type

The type that can represent the size.

Definition at line 124 of file OffsetRange.H.

◆ const_iterator

using const_iterator = IndexIterator<IntType>

Input iterator with const access.

Definition at line 129 of file OffsetRange.H.

◆ const_reverse_iterator

Reverse input iterator with const access.

Definition at line 134 of file OffsetRange.H.

Constructor & Destructor Documentation

◆ OffsetRange() [1/5]

OffsetRange ( const OffsetRange< IntType > &  )
defaultnoexcept

Copy construct.

◆ OffsetRange() [2/5]

OffsetRange ( OffsetRange< IntType > &&  )
defaultnoexcept

Move construct.

◆ OffsetRange() [3/5]

constexpr OffsetRange ( )
inlinenoexcept

Default construct as (0,0,0)

Definition at line 24 of file OffsetRangeI.H.

◆ OffsetRange() [4/5]

constexpr OffsetRange ( IntType  len)
inlinenoexcept

Construct with start=0 and specified size, assigns total=size.

Definition at line 33 of file OffsetRangeI.H.

◆ OffsetRange() [5/5]

constexpr OffsetRange ( IntType  beg,
IntType  len,
IntType  tot 
)
inlinenoexcept

Construct from all components, no checks.

Definition at line 43 of file OffsetRangeI.H.

Member Function Documentation

◆ operator=() [1/4]

OffsetRange& operator= ( const OffsetRange< IntType > &  )
defaultnoexcept

Copy assignment.

◆ operator=() [2/4]

OffsetRange& operator= ( OffsetRange< IntType > &&  )
defaultnoexcept

Move assignment.

◆ empty()

constexpr bool empty ( ) const
inlinenoexcept

True if zero-sized.

Definition at line 193 of file OffsetRange.H.

◆ size() [1/2]

constexpr IntType size ( ) const
inlinenoexcept

The size.

Definition at line 198 of file OffsetRange.H.

Referenced by GlobalOffset< IntType >::localSize().

Here is the caller graph for this function:

◆ size() [2/2]

constexpr IntType& size ( )
inlinenoexcept

Non-const access to the size.

Definition at line 203 of file OffsetRange.H.

◆ start() [1/2]

constexpr IntType start ( ) const
inlinenoexcept

The lower value of the range.

Definition at line 208 of file OffsetRange.H.

Referenced by GlobalOffset< IntType >::localStart(), and GlobalOffset< IntType >::toGlobal().

Here is the caller graph for this function:

◆ start() [2/2]

constexpr IntType& start ( )
inlinenoexcept

Non-const access to start of the range.

Definition at line 213 of file OffsetRange.H.

◆ total() [1/2]

constexpr IntType total ( ) const
inlinenoexcept

◆ total() [2/2]

constexpr IntType& total ( )
inlinenoexcept

Non-const access to the total size.

Definition at line 223 of file OffsetRange.H.

◆ range()

IntRange<IntType> range ( ) const
inlinenoexcept

The (start,size) range.

Definition at line 228 of file OffsetRange.H.

◆ clear()

void clear ( )
inlinenoexcept

Reset to zero.

Definition at line 97 of file OffsetRangeI.H.

◆ reset() [1/2]

void reset ( IntType  len)
inlinenoexcept

Reset to the specified size, with start=0 and total=size.

Can also use operator= assignment

Definition at line 106 of file OffsetRangeI.H.

Referenced by OffsetRange< label >::operator=().

Here is the caller graph for this function:

◆ reset() [2/2]

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

Reset all components.

Definition at line 116 of file OffsetRangeI.H.

◆ equals() [1/2]

constexpr bool equals ( const OffsetRange< T2 > &  ) const
inlinenoexcept

Test equality of start/size/total.

Referenced by OffsetRange< label >::operator==().

Here is the caller graph for this function:

◆ compare() [1/2]

constexpr int compare ( const OffsetRange< T2 > &  ) const
inlinenoexcept

Compare start/size/total in that order.

Returns
-1,0,+1

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

Here is the caller graph for this function:

◆ operator==()

constexpr bool operator== ( const OffsetRange< T2 > &  other) const
inlinenoexcept

Test for equality of begin/size/total values.

Definition at line 274 of file OffsetRange.H.

◆ operator<()

constexpr bool operator< ( const OffsetRange< T2 > &  other) const
inlinenoexcept

Comparison function for sorting, compares the start.

If the start values are equal, also compares the size, etc

Definition at line 285 of file OffsetRange.H.

◆ operator!=()

constexpr bool operator!= ( const OffsetRange< T2 > &  other) const
inlinenoexcept

Definition at line 292 of file OffsetRange.H.

◆ operator<=()

constexpr bool operator<= ( const OffsetRange< T2 > &  other) const
inlinenoexcept

Definition at line 298 of file OffsetRange.H.

◆ operator>()

constexpr bool operator> ( const OffsetRange< T2 > &  other) const
inlinenoexcept

Definition at line 304 of file OffsetRange.H.

◆ operator>=()

constexpr bool operator>= ( const OffsetRange< T2 > &  other) const
inlinenoexcept

Definition at line 310 of file OffsetRange.H.

◆ operator=() [3/4]

void operator= ( IntType  len)
inlinenoexcept

Assign to the specified size, with start=0 and total=size.

Definition at line 321 of file OffsetRange.H.

◆ operator=() [4/4]

void operator= ( const OffsetRange< IntT2 > &  rhs)
inlinenoexcept

Assign from an OffsetRange with the same or lower representation.

Definition at line 335 of file OffsetRange.H.

◆ at()

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 348 of file OffsetRange.H.

◆ operator[]()

constexpr IntType operator[] ( IntType  i) const
inlinenoexcept

Offset dereference, without bounds checking.

Definition at line 177 of file OffsetRangeI.H.

◆ operator()()

constexpr bool operator() ( IntType  i) const
inlinenoexcept

True if the value is between the start and size range.

Behaviour identical to contains() - usable as a predicate

Definition at line 360 of file OffsetRange.H.

◆ contains()

constexpr bool contains ( IntType  value) const
inlinenoexcept

True if the value is between the start and size range range.

Definition at line 130 of file OffsetRangeI.H.

Referenced by GlobalOffset< IntType >::isLocal(), and OffsetRange< label >::operator()().

Here is the caller graph for this function:

◆ begin_value()

constexpr IntType begin_value ( ) const
inlinenoexcept

The value at the beginning of the start/size range - same as start()

Definition at line 66 of file OffsetRangeI.H.

Referenced by OffsetRange< label >::begin(), and OffsetRange< label >::cbegin().

Here is the caller graph for this function:

◆ end_value()

constexpr IntType end_value ( ) const
inlinenoexcept

The value 1 beyond the end of the start/size range.

Definition at line 74 of file OffsetRangeI.H.

Referenced by OffsetRange< label >::cend(), and OffsetRange< label >::end().

Here is the caller graph for this function:

◆ rbegin_value()

constexpr IntType rbegin_value ( ) const
inlinenoexcept

The max value of the start/size range.

Definition at line 82 of file OffsetRangeI.H.

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

Here is the caller graph for this function:

◆ rend_value()

constexpr IntType rend_value ( ) const
inlinenoexcept

The value 1 before the begin of start/size range.

Definition at line 90 of file OffsetRangeI.H.

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

Here is the caller graph for this function:

◆ begin()

const_iterator begin ( ) const
inlinenoexcept

A const_iterator set to the beginning of the range.

Definition at line 402 of file OffsetRange.H.

◆ cbegin()

const_iterator cbegin ( ) const
inlinenoexcept

A const_iterator set to the beginning of the range.

Definition at line 407 of file OffsetRange.H.

◆ cend()

const_iterator cend ( ) const
inlinenoexcept

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

Definition at line 412 of file OffsetRange.H.

◆ end()

const_iterator end ( ) const
inlinenoexcept

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

Definition at line 417 of file OffsetRange.H.

◆ rbegin()

const_reverse_iterator rbegin ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the end of range.

Definition at line 426 of file OffsetRange.H.

◆ crbegin()

const_reverse_iterator crbegin ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the end of range.

Definition at line 432 of file OffsetRange.H.

◆ rend()

const_reverse_iterator rend ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the begin of range.

Definition at line 437 of file OffsetRange.H.

◆ crend()

const_reverse_iterator crend ( ) const
inlinenoexcept

A const_reverse_iterator set to 1 before the begin of range.

Definition at line 442 of file OffsetRange.H.

◆ equals() [2/2]

constexpr bool equals ( const OffsetRange< IntT2 > &  b) const
inlinenoexcept

Definition at line 140 of file OffsetRangeI.H.

◆ compare() [2/2]

constexpr int compare ( const OffsetRange< IntT2 > &  b) const
inlinenoexcept

Definition at line 156 of file OffsetRangeI.H.


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