Loading...
Searching...
No Matches
Range Utilities
Common » Utilities

Utilities for reduction like operations on ranges. More...

Collaboration diagram for Range Utilities:

## Classes

class | Dune::IntegralRange< T >
| dynamic integer range for use in range-based for loops More...
class | Dune::StaticIntegralRange< T, to, from >
| static integer range for use in range-based for loops More...
struct | Dune::ValueTransformationTag
| Tag to enable value based transformations in TransformedRangeView. More...
struct | Dune::IteratorTransformationTag
| Tag to enable iterator based transformations in TransformedRangeView. More...
class | Dune::TransformedRangeView< R, F, T >
| A range transforming the values of another range on-the-fly. More...

## Functions

template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>
T::value_type | Dune::max_value (const T &v)
| compute the maximum value over a range
template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>
T::value_type | Dune::min_value (const T &v)
| compute the minimum value over a range
template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>
bool | Dune::any_true (const T &v)
| similar to std::bitset<N>::any() return true, if any entries is true
template<std::size_t N>
bool | Dune::any_true (const std::bitset< N > &b)
template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>
bool | Dune::all_true (const T &v)
| similar to std::bitset<N>::all() return true, if any entries is true
template<std::size_t N>
bool | Dune::all_true (const std::bitset< N > &b)
template<class T, class U, std::enable_if_t< std::is_same< std::decay_t< T >, std::decay_t< U > >::value, int > = 0, std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>
static constexpr IntegralRange< std::decay_t< T > > | Dune::range (T &&from, U &&to) noexcept
| free standing function for setting up a range based for loop over an integer range for (auto i: range(0,10)) // 0,1,2,3,4,5,6,7,8,9 or for (auto i: range(-10,10)) // -10,-9,..,8,9 or for (auto i: range(10)) // 0,1,2,3,4,5,6,7,8,9
template<class T, std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>
static constexpr IntegralRange< std::decay_t< T > > | Dune::range (T &&to) noexcept
template<class T, T from, T to>
static constexpr StaticIntegralRange< T, to, from > | Dune::range (std::integral_constant< T, from >, std::integral_constant< T, to >) noexcept
template<class T, T to>
static constexpr StaticIntegralRange< T, to > | Dune::range (std::integral_constant< T, to >) noexcept
template<class R, class F>
auto | Dune::transformedRangeView (R &&range, F &&f)
| Create a TransformedRangeView.
template<class R, class F>
auto | Dune::iteratorTransformedRangeView (R &&range, F &&f)
| Create a TransformedRangeView using an iterator transformation.
template<class Range>
auto | Dune::sparseRange (Range &&range)
| Allow structured-binding for-loops for sparse iterators.

## Detailed Description

Utilities for reduction like operations on ranges.

All these reduction operations work for appropriate ranges and scalar values

## Function Documentation

## all_true() [1/2]

template<std::size_t N>

bool Dune::all_true | ( | const std::bitset< N > & | b | ) |

## all_true() [2/2]

template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>

bool Dune::all_true | ( | const T & | v | ) |

similar to std::bitset<N>::all() return true, if any entries is true

overloads for scalar values, ranges, and std::bitset<N> exist

## any_true() [1/2]

template<std::size_t N>

bool Dune::any_true | ( | const std::bitset< N > & | b | ) |

## any_true() [2/2]

template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>

bool Dune::any_true | ( | const T & | v | ) |

similar to std::bitset<N>::any() return true, if any entries is true

overloads for scalar values, ranges, and std::bitset<N> exist

## iteratorTransformedRangeView()

template<class R, class F>

auto Dune::iteratorTransformedRangeView | ( | R && | range,
|  | F && | f )

Create a TransformedRangeView using an iterator transformation.

Parameters

  range | The range to transform
  f | Unary function that should the applied to the entries of the range.

This behaves like a range providing begin() and end(). The iterators over this range internally iterate over the wrapped range. When dereferencing the iterator, the given transformation function is applied to the wrapped iterator on-the-fly and the result is returned. I.e, if

it

is the wrapped iterator and

f

is the transformation function, then the result of

f(it)

is returned.

The transformation may either return temporary values or l-value references. In the former case the range behaves like a proxy-container. In the latter case it forwards these references allowing, e.g., to sort a subset of some container by applying a transformation to an index-range for those values.

The iterators of the TransformedRangeView have the same iterator_category as the ones of the wrapped container.

If range is an r-value, then the TransformedRangeView stores it by value, if range is an l-value, then the TransformedRangeView stores it by reference.

## max_value()

template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>

T::value_type Dune::max_value | ( | const T & | v | ) |

compute the maximum value over a range

overloads for scalar values, and ranges exist

## min_value()

template<typename T, typename std::enable_if< IsIterable< T >::value, int >::type = 0>

T::value_type Dune::min_value | ( | const T & | v | ) |

compute the minimum value over a range

overloads for scalar values, and ranges exist

## range() [1/4]

template<class T, T from, T to>

constexpr StaticIntegralRange< T, to, from > Dune::range | ( | std::integral_constant< T, from > | ,
|  | std::integral_constant< T, to > | )

static constexpr noexcept

## range() [2/4]

template<class T, T to>

constexpr StaticIntegralRange< T, to > Dune::range | ( | std::integral_constant< T, to > |  | ) |

static constexpr noexcept

## range() [3/4]

template<class T, class U, std::enable_if_t< std::is_same< std::decay_t< T >, std::decay_t< U > >::value, int > = 0, std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>

constexpr IntegralRange< std::decay_t< T > > Dune::range | ( | T && | from,
|  | U && | to )

static constexpr noexcept

free standing function for setting up a range based for loop over an integer range for (auto i: range(0,10)) // 0,1,2,3,4,5,6,7,8,9 or for (auto i: range(-10,10)) // -10,-9,..,8,9 or for (auto i: range(10)) // 0,1,2,3,4,5,6,7,8,9

## range() [4/4]

template<class T, std::enable_if_t< std::is_integral< std::decay_t< T > >::value, int > = 0>

constexpr IntegralRange< std::decay_t< T > > Dune::range | ( | T && | to | ) |

static constexpr noexcept

## sparseRange()

template<class Range>

auto Dune::sparseRange | ( | Range && | range | ) |

Allow structured-binding for-loops for sparse iterators.

Given a sparse range R whose iterators it provide (additionally to dereferencing) a method it->index() for accessing the index of the current entry in the sparse range, this allows to write code like

for(auto&& [A_i, i] : sparseRange(R))
doSomethingWithValueAndIndex(A_i, i);
Dune::sparseRange
auto sparseRange(Range &&range)
Allow structured-binding for-loops for sparse iterators.
Definition rangeutilities.hh:716

## transformedRangeView()

template<class R, class F>

auto Dune::transformedRangeView | ( | R && | range,
|  | F && | f )

Create a TransformedRangeView.

Parameters

  range | The range to transform
  f | Unary function that should the applied to the entries of the range.

This behaves like a range providing begin() and end(). The iterators over this range internally iterate over the wrapped range. When dereferencing the iterator, the wrapped iterator is dereferenced, the given transformation function is applied on-the-fly, and the result is returned. I.e, if

it

is the wrapped iterator and

f

is the transformation function, then the result of

f(*it)

is returned

The transformation may either return temporary values or l-value references. In the former case the range behaves like a proxy-container. In the latter case it forwards these references allowing, e.g., to sort a subset of some container by applying a transformation to an index-range for those values.

The iterators of the TransformedRangeView have the same iterator_category as the ones of the wrapped container.

If range is an r-value, then the TransformedRangeView stores it by value, if range is an l-value, then the TransformedRangeView stores it by reference.