My Project
Loading...
Searching...
No Matches
Opm::Action::Result::ValueRange< T > Class Template Reference

Random access range of values. More...

#include <ActionResult.hpp>

Public Types

using RandIt = typename std::vector< T >::const_iterator
 Random access iterator.
 

Public Member Functions

 ValueRange (RandIt first, RandIt last, bool isSorted=false)
 Constructor.
 
auto begin () const
 Beginning of value range's elements.
 
auto end () const
 End of value range's elements.
 
auto empty () const
 Predicate for an empty value range.
 
auto size () const
 Number of elements in the value range.
 
std::vector< T > asVector () const
 Convert value range to a std::vector.
 
bool hasElement (const T &elem) const
 Element existence predicate.
 

Detailed Description

template<typename T>
class Opm::Action::Result::ValueRange< T >

Random access range of values.

Poor-man's substitute for C++20's std::span<T>.

Template Parameters
TElement type of range. Typically std::string since the common use case of class ValueRange<> is to represent a sequence of well or group names.

Member Typedef Documentation

◆ RandIt

template<typename T >
using Opm::Action::Result::ValueRange< T >::RandIt = typename std::vector<T>::const_iterator

Random access iterator.

Class ValueRange<> assumes that the underlying sequence is a std::vector<T> of sufficient lifetime.

Constructor & Destructor Documentation

◆ ValueRange()

template<typename T >
Opm::Action::Result::ValueRange< T >::ValueRange ( RandIt  first,
RandIt  last,
bool  isSorted = false 
)
inlineexplicit

Constructor.

Forms a ValueRange object from an iterator range.

Parameters
[in]firstFirst element in value range.
[in]lastOne past the end of the elements in the value range.
[in]isSortedWether or not the value range is sorted by
std::less<>
. In that case, element existence can be established in O(log(n)) time. This is an optimisation hook.

Member Function Documentation

◆ asVector()

template<typename T >
std::vector< T > Opm::Action::Result::ValueRange< T >::asVector ( ) const
inline

Convert value range to a std::vector.

Copies elements.

◆ hasElement()

template<typename T >
bool Opm::Action::Result::ValueRange< T >::hasElement ( const T &  elem) const
inline

Element existence predicate.

Parameters
[in]elemElement for which to check existence.
Returns
Whether or not elem exists in the value range.

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