libMesh
Classes | Public Types | Public Member Functions | Private Attributes | List of all members
libMesh::IntRange< T > Class Template Reference

The IntRange templated class is intended to make it easy to loop over integers which are indices of a container. More...

#include <int_range.h>

Classes

class  iterator
 

Public Types

typedef IntRange< T >::iterator const_iterator
 

Public Member Functions

template<typename U , typename V >
 IntRange (U begin, V end)
 
 IntRange (const IntRange &, const const_iterator &begin, const const_iterator &end)
 
iterator begin () const
 
iterator end () const
 
std::size_t size () const
 
std::size_t grainsize () const
 

Private Attributes

iterator _begin
 
iterator _end
 

Detailed Description

template<typename T>
class libMesh::IntRange< T >

The IntRange templated class is intended to make it easy to loop over integers which are indices of a container.

In cases where such a range is defined by the result of a virtual function call, this allows range-based for loops to be easily written which make only a single such call, rather than a new call for each iteration.

We perform a cast_int operation (no-op in opt mode, test+assert in debug) at construction time to make sure that the given range bounds are representable by the given range type.

Author
Roy H. Stogner

Definition at line 53 of file int_range.h.

Member Typedef Documentation

◆ const_iterator

template<typename T>
typedef IntRange<T>::iterator libMesh::IntRange< T >::const_iterator

Definition at line 109 of file int_range.h.

Constructor & Destructor Documentation

◆ IntRange() [1/2]

template<typename T>
template<typename U , typename V >
libMesh::IntRange< T >::IntRange ( begin,
end 
)
inline

Definition at line 112 of file int_range.h.

112  :
113  _begin(cast_int<T>(begin)),
114  _end(cast_int<T>(end))
115  {}
iterator _begin
Definition: int_range.h:136
iterator end() const
Definition: int_range.h:127
iterator begin() const
Definition: int_range.h:125

◆ IntRange() [2/2]

template<typename T>
libMesh::IntRange< T >::IntRange ( const IntRange< T > &  ,
const const_iterator begin,
const const_iterator end 
)
inline

Definition at line 118 of file int_range.h.

120  :
121  _begin(begin),
122  _end(end)
123  {}
iterator _begin
Definition: int_range.h:136
iterator end() const
Definition: int_range.h:127
iterator begin() const
Definition: int_range.h:125

Member Function Documentation

◆ begin()

template<typename T>
iterator libMesh::IntRange< T >::begin ( ) const
inline

Definition at line 125 of file int_range.h.

References libMesh::IntRange< T >::_begin.

125 { return _begin; }
iterator _begin
Definition: int_range.h:136

◆ end()

template<typename T>
iterator libMesh::IntRange< T >::end ( ) const
inline

Definition at line 127 of file int_range.h.

References libMesh::IntRange< T >::_end.

127 { return _end; }

◆ grainsize()

template<typename T>
std::size_t libMesh::IntRange< T >::grainsize ( ) const
inline

Definition at line 133 of file int_range.h.

References libMesh::default_grainsize().

133 { return libMesh::default_grainsize(); }
unsigned int default_grainsize()
Definition: libmesh_base.h:117

◆ size()

template<typename T>
std::size_t libMesh::IntRange< T >::size ( ) const
inline

Definition at line 129 of file int_range.h.

References libMesh::IntRange< T >::_begin, and libMesh::IntRange< T >::_end.

130  { return *_end - *_begin; }
iterator _begin
Definition: int_range.h:136

Member Data Documentation

◆ _begin

template<typename T>
iterator libMesh::IntRange< T >::_begin
private

Definition at line 136 of file int_range.h.

Referenced by libMesh::IntRange< T >::begin(), and libMesh::IntRange< T >::size().

◆ _end

template<typename T>
iterator libMesh::IntRange< T >::_end
private

Definition at line 136 of file int_range.h.

Referenced by libMesh::IntRange< T >::end(), and libMesh::IntRange< T >::size().


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