rttr::array_range< T, Predicate > Class Template - 0.9.7 |RTTR
  • rttr::array_range< T, Predicate > Class Template
rttr::array_range< T, Predicate > Class Template Reference

The array_range class provides a view into an underlying data structure with lower and upper limits. More...

#include <array_range.h>

Public Types

using  bounds_type = T *
 
using  const_iterator = array_iterator< const T >
  A constant forward iterator. More...
 
using  const_reverse_iterator = array_reverse_iterator< const T >
  A constant forward iterator that reverses the direction. More...
 
using  iterator = array_iterator< T >
  A forward iterator. More...
 
using  reverse_iterator = array_reverse_iterator< T >
  A forward iterator that reverses the direction. More...
 
using  size_type = std::size_t
 
using  value_type = T
 

Public Member Functions

  Default constructor. More...
 
  array_range (const T *begin, size_type size, const Predicate &pred=Predicate())
  Constructs an array range starting from begin to end [begin, end). More...
 
  Returns an iterator to the first element of the range. More...
 
const_iterator  begin () const
  Returns a constant iterator to the first element of the range. More...
 
const_iterator  cbegin () const
  Returns a constant iterator to the first element of the range. More...
 
const_iterator  cend () const
  Returns a constant iterator to the element following the last element of the range. More...
 
  Returns a constant reverse iterator to the first element of the reversed range. More...
 
  Returns a constant reverse iterator to the element following the last element of the reversed range. More...
 
bool  empty () const
  Checks if the range has no elements, i.e. More...
 
  Returns an iterator to the element following the last element of the range. More...
 
const_iterator  end () const
  Returns a constant iterator to the element following the last element of the range. More...
 
  Returns a reverse iterator to the first element of the reversed range. More...
 
  Returns a constant reverse iterator to the first element of the reversed range. More...
 
  Returns a reverse iterator to the element following the last element of the reversed range. More...
 
  Returns a constant reverse iterator to the element following the last element of the reversed range. More...
 
size_t  size () const
  Returns the number of elements in the range. More...
 

Detailed Description

template<typename T, typename Predicate = detail::default_predicate<T>>
class rttr::array_range< T, Predicate >

The array_range class provides a view into an underlying data structure with lower and upper limits.

In order to iterate over the data structure use the returned forward iterators from begin() or rbegin(). To check whether the end of the range has reached use end() or rend(). Using the standard C++ range-based for loop will implicit do all this work.

Remarks
When the underlying data structure gets modified while holding a range, its iterators and the range itself will be invalidated.

Member Typedef Documentation

template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::bounds_type = T*
template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::const_iterator = array_iterator<const T>

A constant forward iterator.

template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::const_reverse_iterator = array_reverse_iterator<const T>

A constant forward iterator that reverses the direction.

template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::iterator = array_iterator<T>

A forward iterator.

template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::reverse_iterator = array_reverse_iterator<T>

A forward iterator that reverses the direction.

template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::size_type = std::size_t
template<typename T, typename Predicate = detail::default_predicate<T>>
using rttr::array_range< T, Predicate >::value_type = T

Constructor & Destructor Documentation

template<typename T, typename Predicate = detail::default_predicate<T>>
rttr::array_range< T, Predicate >::array_range ( )

Default constructor.

Constructs an empty array_range.

template<typename T, typename Predicate = detail::default_predicate<T>>
rttr::array_range< T, Predicate >::array_range ( const T *  begin,
size_type  size,
const Predicate &  pred = Predicate() 
)

Constructs an array range starting from begin to end [begin, end).

Parameters
begin Marks the start of the range. Is included of the range.
size The number of elements to include in the range.
pred Determines whether an element in the range fulfills the condition of the predicate.

Member Function Documentation

template<typename T, typename Predicate = detail::default_predicate<T>>
const_iterator rttr::array_range< T, Predicate >::begin ( )

Returns an iterator to the first element of the range.

Remarks
If the range is empty, the returned iterator will be equal to end().
Returns
Iterator to the first element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_iterator rttr::array_range< T, Predicate >::begin ( ) const

Returns a constant iterator to the first element of the range.

Remarks
If the range is empty, the returned iterator will be equal to end().
Returns
Constant iterator to the first element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_iterator rttr::array_range< T, Predicate >::cbegin ( ) const

Returns a constant iterator to the first element of the range.

Remarks
If the range is empty, the returned iterator will be equal to end().
Returns
Constant iterator to the first element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_iterator rttr::array_range< T, Predicate >::cend ( ) const

Returns a constant iterator to the element following the last element of the range.

Remarks
This element acts as placeholder, attempting to access it results in undefined behavior. If the range is empty, the returned iterator will be equal to begin().
Returns
Constant iterator to the element following the last element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_reverse_iterator rttr::array_range< T, Predicate >::crbegin ( ) const

Returns a constant reverse iterator to the first element of the reversed range.

It corresponds to the last element of the non-reversed range.

Remarks
If the range is empty, the returned iterator will be equal to rend().
Returns
Constant reverse iterator to the first element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_reverse_iterator rttr::array_range< T, Predicate >::crend ( ) const

Returns a constant reverse iterator to the element following the last element of the reversed range.

It corresponds to the element preceding the first element of the non-reversed range.

Remarks
If the range is empty, the returned iterator will be equal to rbegin().
Returns
Constant reverse iterator to the element following the last element.
template<typename T, typename Predicate = detail::default_predicate<T>>
bool rttr::array_range< T, Predicate >::empty ( ) const

Checks if the range has no elements, i.e.

whether begin() == end() .

Remarks
Every element will be checked against the condition of the used predicate. Only when every element doe not fulfill the condition of predicate, the range is declared empty. That means, in order to check for emptiness, the underlying algorithm needs to iterate through the whole range. So don't call it to often. It's better to cache the result in a temporary variable.
Returns
True if this range is empty, otherwise false.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_iterator rttr::array_range< T, Predicate >::end ( )

Returns an iterator to the element following the last element of the range.

Remarks
This element acts as placeholder, attempting to access it results in undefined behavior. If the range is empty, the returned iterator will be equal to begin().
Returns
Iterator to the element following the last element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_iterator rttr::array_range< T, Predicate >::end ( ) const

Returns a constant iterator to the element following the last element of the range.

Remarks
This element acts as placeholder, attempting to access it results in undefined behavior. If the range is empty, the returned iterator will be equal to begin().
Returns
Constant iterator to the element following the last element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_reverse_iterator rttr::array_range< T, Predicate >::rbegin ( )

Returns a reverse iterator to the first element of the reversed range.

It corresponds to the last element of the non-reversed range.

Remarks
If the range is empty, the returned iterator will be equal to rend().
Returns
Reverse iterator to the first element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_reverse_iterator rttr::array_range< T, Predicate >::rbegin ( ) const

Returns a constant reverse iterator to the first element of the reversed range.

It corresponds to the last element of the non-reversed range.

Remarks
If the range is empty, the returned iterator will be equal to rend().
Returns
Constant reverse iterator to the first element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_reverse_iterator rttr::array_range< T, Predicate >::rend ( )

Returns a reverse iterator to the element following the last element of the reversed range.

It corresponds to the element preceding the first element of the non-reversed range.

Remarks
If the range is empty, the returned iterator will be equal to rbegin().
Returns
Reverse iterator to the element following the last element.
template<typename T, typename Predicate = detail::default_predicate<T>>
const_reverse_iterator rttr::array_range< T, Predicate >::rend ( ) const

Returns a constant reverse iterator to the element following the last element of the reversed range.

It corresponds to the element preceding the first element of the non-reversed range.

Remarks
If the range is empty, the returned iterator will be equal to rbegin().
Returns
Constant reverse iterator to the element following the last element.
template<typename T, typename Predicate = detail::default_predicate<T>>
size_t rttr::array_range< T, Predicate >::size ( ) const

Returns the number of elements in the range.

Remarks
Every element will be checked against the condition of the used predicate. Only elements which fulfill the condition of predicate will be included in the counter. That means, in order to determine the size of the range, the underlying algorithm needs to iterate through the whole range. So don't call it to often. It's better to cache the result in a temporary variable.
Returns
The number of elements in the range.

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

AltStyle によって変換されたページ (->オリジナル) /