SEVN
Loading...
Searching...
No Matches
utilities::ListGenerator Class Reference

Class to handle the generation of a list of values. More...

#include <utilities.h>

Public Member Functions

 ListGenerator ()
 
 ListGenerator (double _vstep, double _vstep_max=std::nan(""), double _vstep_min=std::nan(""))
 
 ListGenerator (const std::vector< double > &_tlist)
 
double get () const
 
double get_max () const
 
double get_min () const
 
bool empty () const
 
void next ()
 
double operator++ ()
 
double operator++ (int)
 
double forecast () const
 

Static Public Member Functions

static std::unique_ptr< ListGeneratormake_unique (double _vstep, double _vstep_max=std::nan(""), double _vstep_min=std::nan(""))
 
static std::unique_ptr< ListGeneratormake_unique (std::vector< double > _vlist)
 

Private Member Functions

void initialise_tlist_iterators ()
 

Private Attributes

double vcurrent
 
double vstep =std::nan("")
 
double vmin =0.
 
double vmax =2E30
 
std::vector< double > vlist
 
std::vector< double >::iterator begin
 
std::vector< double >::iterator end
 
std::vector< double >::iterator current
 
bool end_of_list =false
 

Detailed Description

Class to handle the generation of a list of values.

The class usage is based on the methods get(), next() and empty(). get() return the current value, next() upate the value and empty() return true if the generator reach the ends. If empty() is true calling next() or get() throws an out_of_range error.

Constructor & Destructor Documentation

◆ ListGenerator() [1/3]

utilities::ListGenerator::ListGenerator ( )
inline

◆ ListGenerator() [2/3]

utilities::ListGenerator::ListGenerator ( double  _vstep,
double  _vstep_max = std::nan(""),
double  _vstep_min = std::nan("") 
)
inlineexplicit

Constructor based on a step value. The values will be generated from _vstep_min to _vstep_max (can be not included) with step _vstep. If _vstep_max is not given the generation can last theoretically forever (_vstep_max default is 1E30).

Parameters
_vstepstep value to generate the values
_vstep_maxmaximum value.
_vstep_minStarting value.

◆ ListGenerator() [3/3]

utilities::ListGenerator::ListGenerator ( const std::vector< double > &  _tlist)
inlineexplicit

Constructor based on a vector of doubles. The class will slice all the values in the vector and will be marked as empty when the end of the vector is reached.

Parameters
_tlistVector of doubles

Member Function Documentation

◆ empty()

bool utilities::ListGenerator::empty ( ) const
inline

◆ forecast()

double utilities::ListGenerator::forecast ( ) const
inline

Similar to next, but just return the next value withotu uptading anything

Returns
The next value if not empty, otherwise std::nan

◆ get()

double utilities::ListGenerator::get ( ) const
inline

◆ get_max()

double utilities::ListGenerator::get_max ( ) const
inline

◆ get_min()

double utilities::ListGenerator::get_min ( ) const
inline

◆ initialise_tlist_iterators()

void utilities::ListGenerator::initialise_tlist_iterators ( )
inlineprivate

◆ make_unique() [1/2]

std::unique_ptr< utilities::ListGenerator > utilities::ListGenerator::make_unique ( double  _vstep,
double  _vstep_max = std::nan(""),
double  _vstep_min = std::nan("") 
)
static

◆ make_unique() [2/2]

std::unique_ptr< utilities::ListGenerator > utilities::ListGenerator::make_unique ( std::vector< double >  _vlist)
static

◆ next()

void utilities::ListGenerator::next ( )
inline

◆ operator++() [1/2]

double utilities::ListGenerator::operator++ ( )
inline

◆ operator++() [2/2]

double utilities::ListGenerator::operator++ ( int  )
inline

Member Data Documentation

◆ begin

std::vector<double>::iterator utilities::ListGenerator::begin
private

◆ current

std::vector<double>::iterator utilities::ListGenerator::current
private

◆ end

std::vector<double>::iterator utilities::ListGenerator::end
private

◆ end_of_list

bool utilities::ListGenerator::end_of_list =false
private

◆ vcurrent

double utilities::ListGenerator::vcurrent
private

◆ vlist

std::vector<double> utilities::ListGenerator::vlist
private

◆ vmax

double utilities::ListGenerator::vmax =2E30
private

◆ vmin

double utilities::ListGenerator::vmin =0.
private

◆ vstep

double utilities::ListGenerator::vstep =std::nan("")
private

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