Relacs Core Library  0.9.8
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
RangeLoop Class Reference

#include <rangeloop.h>

Public Types

enum  Sequence {
  Up =0, Down =1, Alternate =2, AlternateIn =Alternate,
  AlternateInUp =Alternate, AlternateDown =3, AlternateInDown =AlternateDown, AlternateOut =4,
  AlternateOutUp =AlternateOut, AlternateOutDown =5, Random =6, PseudoRandom =7
}
 
enum  AddMode { Add, Skip, RemoveAll, AddRemove }
 

Public Member Functions

 RangeLoop (void)
 
 RangeLoop (double first, double last, double step, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
 RangeLoop (double first, double last, int n, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
 RangeLoop (double value, int size=1, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
 RangeLoop (const string &range)
 
 ~RangeLoop (void)
 
int size (void) const
 
bool empty (void) const
 
void resize (int newsize, double dflt=0.0)
 
void clear (void)
 
int capacity (void) const
 
void reserve (int newsize)
 
void set (double first, double last, double step, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
void add (double first, double last, double step)
 
void setLog (double first, double last, double fac, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
void addLog (double first, double last, double fac)
 
void set (double first, double last, int n, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
void add (double first, double last, int n)
 
void setLog (double first, double last, int n, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
void addLog (double first, double last, int n)
 
void set (double value, int size=1, int repeat=1, int blockrepeat=1, int singlerepeat=1, int increment=1)
 
bool add (double value)
 
void set (const string &range, double scale=1.0)
 
const RangeLoopoperator= (const string &range)
 
AddMode addMode (void) const
 
void setAddMode (AddMode addmode)
 
int repeat (void) const
 
void setRepeat (int repeat)
 
int currentRepetition (void) const
 
int blockRepeat (void) const
 
void setBlockRepeat (int repeat)
 
int currentBlockRepetition (void) const
 
bool finishedBlock (void) const
 
int singleRepeat (void) const
 
void setSingleRepeat (int repeat)
 
int currentSingleRepetition (void) const
 
bool finishedSingle (void) const
 
bool lastSingle (void) const
 
void setIncrement (int increment=1)
 
void setLargeIncrement (void)
 
int currentIncrement (void) const
 
double currentIncrementValue (void) const
 
int totalCount (void) const
 
int maxCount (void) const
 
int maxBlockCount (void) const
 
int remainingCount (void) const
 
int remainingBlockCount (void) const
 
void setSequence (Sequence seq)
 
void up (void)
 
void down (void)
 
void alternateInUp (void)
 
void alternateInDown (void)
 
void alternateOutUp (void)
 
void alternateOutDown (void)
 
void random (void)
 
void pseudoRandom (void)
 
int sequenceSize (void) const
 
void reset (int pos=-1, bool clearskip=true)
 
void purge (void)
 
const RangeLoopoperator= (int pos)
 
const RangeLoopoperator++ (void)
 
bool operator! (void) const
 
void update (int pos=-2)
 
int loop (void) const
 
double value (void) const
 
double operator* (void) const
 
int pos (void) const
 
int index (void) const
 
int count (void) const
 
void noCount (void)
 
void setSkip (bool skip=true)
 
double value (int pos) const
 
double operator[] (int pos) const
 
double & operator[] (int pos)
 
double front (void) const
 
double & front (void)
 
double back (void) const
 
double & back (void)
 
double minValue (void) const
 
double maxValue (void) const
 
double step (void) const
 
int count (int pos) const
 
int skip (int pos) const
 
void setSkip (int pos, bool skip=true)
 
void setSkipBelow (int pos, bool skip=true)
 
void setSkipAbove (int pos, bool skip=true)
 
void setSkipBetween (int pos1, int pos2, bool skip=true)
 
void setSkipNocount (bool skip=true)
 
void setSkipNumber (int num)
 
int next (int pos) const
 
int previous (int pos) const
 
int pos (int index) const
 
int pos (double value) const
 
int index (int pos) const
 
bool active (int p) const
 
bool near (int pos, double value) const
 

Static Public Member Functions

static const string & sequenceStrings (void)
 

Friends

ostream & operator<< (ostream &str, const RangeLoop &rl)
 

Detailed Description

A flexible and sophisticated way to loop trough a range of values.

Author
Jan Benda
Todo:
set( string ): introduce control characters for controlling the addMode

RangeLoop is a one-dimensional array of doubles. The array can be filled by the constructors or by the set() and add() functions. All the standard vector functions for accessing and manipulating the data values are provided: operator[], back(), front(), size(), empty(), resize(), clear(), capacity(), reserve().

Now, RangeLoop provides a couple of features for looping through this array. The basic usage is like this:

RangeLoop range( 1.0, 4.0, 0.5 );
for ( range.reset(); ! range; ++range )
cout << *range << '\n';

This will print the sequence 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0 on the screen.

You can specify in which order the array is traversed by setSequence() or by calling one of the functions up(), down(), alternateInUp(), alternateInDown(), alternateOutUp(), alternateOutDown(), random(), pseudoRandom(). They will produce the following sequences:

How often a single data value is immediately repeated can be specified by setSingleRepeat(), the number of repetitions of the whole sequence is controlled by setRepeat(). The latter can be zero, indicating that the whole sequence should be repeated indefinitely.

By specifying an increment by setIncrement(), you can create sub-sequences of reduced resolutions that are traversed first. The number of repetitions of each of the sub-sequences are set by setBlockRepeat(). After a sub-sequence is finished, the increment is halfed, and a new sub-sequence is created. This is continued until all data-values have been traversed.

Data values can be excluded form being further traversed by setSkip(), setSkipAbove(), setSkipBelow(), and setSkipBetween(). How often a data value was traversed can be retrieved by count(). You can remove data elements that have their skip flag set by calling purge().

pos() is the index of an data element from the whole data array. index() is the current index into the current (sub-)sequence.

Member Enumeration Documentation

enum Sequence

Different sequences for looping through the data.

Enumerator
Up 

Traverse trough the data values in the order they are stored.

Down 

Traverse reversed trough the data values in the order they are stored.

Alternate 

Traverse upwards trough the data values alternating from the up and down sequence starting with the outermost values.

AlternateIn 

Same as Alternate

AlternateInUp 

Same as Alternate

AlternateDown 

Traverse downwards trough the data values alternating from the up and down sequence starting with the outermost values.

AlternateInDown 

Same as AlternateDown

AlternateOut 

Traverse upwards trough the data values alternating from the up and down sequence starting with the innermost values.

AlternateOutUp 

Same as AlternateOut

AlternateOutDown 

Traverse downwards trough the data values alternating from the up and down sequence starting with the innermost values.

Random 

Traverse randomly through the data values with the random seed set to the current time.

PseudoRandom 

Traverse randomly through the data values with always the same random seed.

enum AddMode

Different ways how addition of already existing values is handled.

Enumerator
Add 

Simply add the value, no matter whether it is already contained in the range or not.

Skip 

Don't add the value if it is already contained in the list.

RemoveAll 

Don't add the value if it is already contained in the list and remove the existing entries as well.

AddRemove 

Add the value and remove any already existing entries.

Constructor & Destructor Documentation

RangeLoop ( void  )

Construct an empty RangeLoop. Use the set() and add() functions to fil lthe range.

RangeLoop ( double  first,
double  last,
double  step,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Construct a linear range. See set( double, double, double, int, int, int, int ) for details.

References RangeLoop::set().

RangeLoop ( double  first,
double  last,
int  n,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Construct a linear range. See set( double, double, int, int, int, int, int ) for details.

References RangeLoop::set().

RangeLoop ( double  value,
int  size = 1,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Construct a range with a single value value. See set( double, int, int, int, int, int ) for details.

References RangeLoop::set().

RangeLoop ( const string &  range)

Construct a range from range. See set( const string& ) for details.

References RangeLoop::set().

~RangeLoop ( void  )

Destruct thre RangeLoop.

Member Function Documentation

int size ( void  ) const

The number of elements.

Referenced by RangeLoop::next(), and RangeLoop::step().

bool empty ( void  ) const

True if the range is empty.

void resize ( int  newsize,
double  dflt = 0.0 
)

Resize the number of elements in the buffer and indices to newsize and initialize new elements with dflt. .

Referenced by RangeLoop::clear().

void clear ( void  )

References RangeLoop::resize().

int capacity ( void  ) const

The maximum number of elements for which memory is allocated.

void reserve ( int  newsize)

Allocate memory for newsize elements and indices.

void set ( double  first,
double  last,
double  step,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Initialize the range with first value first, last value last, and increment value step. The whole sequence is repeated repeat times. If repeat is set to zero, the whole sequence is repeated indefinitely. Each subsets of data elements for a given increment is repeated blockrepeat times. Each data element is repeated singlerepeat times. The initial increment is set according to increment via setIncrement().

References RangeLoop::Add, RangeLoop::add(), RangeLoop::repeat(), RangeLoop::setIncrement(), and RangeLoop::Up.

Referenced by RangeLoop::operator=(), and RangeLoop::RangeLoop().

void add ( double  first,
double  last,
double  step 
)

Add the range with first value first, last value last, and increment value step to the range.

See Also
addMode()

References relacs::floor(), and RangeLoop::step().

Referenced by RangeLoop::add(), RangeLoop::addLog(), and RangeLoop::set().

void setLog ( double  first,
double  last,
double  fac,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Initialize the range with first value first, last value last, and increment factor fac. The whole sequence is repeated repeat times. If repeat is set to zero, the whole sequence is repeated indefinitely. Each subsets of data elements for a given increment is repeated blockrepeat times. Each data element is repeated singlerepeat times. The initial increment is set according to increment via setIncrement().

References RangeLoop::Add, RangeLoop::addLog(), RangeLoop::repeat(), RangeLoop::setIncrement(), and RangeLoop::Up.

void addLog ( double  first,
double  last,
double  fac 
)

Add the range with first value first, last value last, increment factor fac to the range.

See Also
addMode()

References RangeLoop::add(), and relacs::log().

Referenced by RangeLoop::set(), and RangeLoop::setLog().

void set ( double  first,
double  last,
int  n,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Initialize the range with n evenly spaced values starting with the first value first and ending with the last value last. The sequence is repeated repeat times. If repeat is set to zero, the whole sequence is repeated indefinitely. Each subsets of data elements for a given increment is repeated blockrepeat times. Each data element is repeated singlerepeat times. The initial increment is set according to increment via setIncrement().

References RangeLoop::Add, RangeLoop::add(), RangeLoop::repeat(), RangeLoop::setIncrement(), and RangeLoop::Up.

void add ( double  first,
double  last,
int  n 
)

Add a range with n evenly spaced values starting with the first value first and ending with the last value last to the range.

See Also
addMode()

References RangeLoop::add(), and RangeLoop::step().

void setLog ( double  first,
double  last,
int  n,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Initialize the range with n logarithmically spaced values starting with the first value first and ending with the last value last. The sequence is repeated repeat times. If repeat is set to zero, the whole sequence is repeated indefinitely. Each subsets of data elements for a given increment is repeated blockrepeat times. Each data element is repeated singlerepeat times. The initial increment is set according to increment via setIncrement().

References RangeLoop::Add, RangeLoop::addLog(), RangeLoop::repeat(), RangeLoop::setIncrement(), and RangeLoop::Up.

void addLog ( double  first,
double  last,
int  n 
)

Add a range with n logarithmically spaced values starting with the first value first and ending with the last value last to the range.

See Also
addMode()

References RangeLoop::add(), relacs::exp(), and relacs::log().

void set ( double  value,
int  size = 1,
int  repeat = 1,
int  blockrepeat = 1,
int  singlerepeat = 1,
int  increment = 1 
)

Initialize the range with a single value value and allocate memory for size elements. The sequence is repeated repeat times. If repeat is set to zero, the whole sequence is repeated indefinitely. Each subsets of data elements for a given increment is repeated blockrepeat times. Each data element is repeated singlerepeat times. The initial increment is set according to increment via setIncrement().

References RangeLoop::Add, RangeLoop::repeat(), RangeLoop::setIncrement(), and RangeLoop::Up.

bool add ( double  value)

Add the single value value to the range. If the value already exist, then value is removed from the range. Returns true if value was added to the range, and false if it was not added.

See Also
addMode()

References RangeLoop::Add, RangeLoop::AddRemove, and RangeLoop::RemoveAll.

void set ( const string &  range,
double  scale = 1.0 
)

Initialize the range as defined by range. range is a comma separated list of numbers, ranges, and specifiers. Numbers and ranges are added to the range in the order they appear in range. Linear ranges are defined by a minimum and a maximum value, and an optional step size, separated by "..". For example, "-1,10..16..2" defines the following range of values: -1, 10, 12, 14, 16. Logarithmic ranges are defined by a minimum and a maximum value separated by "..", and an optional increment factor, separated by "*". For example, "2..16..2" defines the following range of values: 2, 4, 8, 16. The order is specified by a separate string ('up' (default), 'down', 'random', 'alternateinup', etc) and the initial increment by 'i:xx', where xx is an integer. For example 4..12..2,down,i:2 generates 12, 8, 4, 10, 6. All the values of the range are rescaled with scale.

References StrQueue::add(), RangeLoop::Add, RangeLoop::add(), RangeLoop::addLog(), Str::FirstNumber, RangeLoop::index(), relacs::log(), RangeLoop::setIncrement(), StrQueue::size(), RangeLoop::step(), and RangeLoop::Up.

const RangeLoop & operator= ( const string &  range)

Initialize the range as defined by range.

See Also
set(const string &range )

References RangeLoop::set().

RangeLoop::AddMode addMode ( void  ) const

Returns the current method that is used for adding already existing data vales to the range.

See Also
setAddMode()
void setAddMode ( AddMode  addmode)

Set the method that is used for adding already existing data vales to the range to addmode.

See Also
addMode()
int repeat ( void  ) const
void setRepeat ( int  repeat)

Set the number of repetitions for the whole sequence to repeat. If repeat is set to zero, the whole sequence is repeated indefinitely.

See Also
repeat(), setBlockRepeat(), setSingleRepeat()

References RangeLoop::repeat().

int currentRepetition ( void  ) const

Return the number of executed repetitions for the whole sequence to repeat.

See Also
repeat(), currentBlockRepetition(), currentSingleRepetition()
int blockRepeat ( void  ) const

The number of repetitons for a block of data elements of a single increment.

See Also
setBlockRepeat(), currentBlockRepetition(), finishedBlock(), repeat(), singleRepeat()
void setBlockRepeat ( int  repeat)

Set the number of repetitons for a block of data elements of a single increment to repeat.

See Also
blockRepeat(), setRepeat(), setSingleRepeat()

References RangeLoop::repeat().

int currentBlockRepetition ( void  ) const

Return the number of executed repetitions for a block of data elements of a single increment.

See Also
blockRepeat(), finishedBlock(), currentRepetition(), currentSingleRepetition()
bool finishedBlock ( void  ) const

Returns true if the current block repetitions are completed.

See Also
blockRepeat(), currentBlockRepetition(), finishedSingle()
int singleRepeat ( void  ) const

The number of repetitons for a single data element.

See Also
setSingleRepeat(), currentSingleRepetition(), finishedSingle(), lastSingle(), repeat(), blockRepeat()
void setSingleRepeat ( int  repeat)

Set the number of repetitons for a single data element to repeat.

See Also
singleRepeat(), setRepeat(), setBlockRepeat()

References RangeLoop::repeat().

int currentSingleRepetition ( void  ) const

Return the number of executed repetitions for a single data element.

See Also
singleRpeat(), finishedSingle(), lastSingle(), currentRepetition(), currentBlockRepetition()
bool finishedSingle ( void  ) const

Returns true if the current single repetitions are completed, i.e. the next data element is to be started.

See Also
singleRpeat(), currentSignelRepetition(), lastSingle(), finishedBlock()
bool lastSingle ( void  ) const

Returns true if this is the last single repetition.

See Also
singleRpeat(), currentSignelRepetition(), finishedSingle()
void setIncrement ( int  increment = 1)

Set the initial increment to increment indices. E.g. an increment of 2 selects every second data value. If increment equals 0, the the increment is set to setLargeIncrement(). If increment is negative, then the increment is set to setLargeIncrement() / 2^|increment|.

See Also
setLargeIncrement(), currentIncrement()

References relacs::abs(), and RangeLoop::setLargeIncrement().

Referenced by RangeLoop::set(), and RangeLoop::setLog().

void setLargeIncrement ( void  )

Set the initial increment to the largest power of two less or equal than half the number of the data elements.

See Also
setIncrement(), currentIncrement()

Referenced by RangeLoop::setIncrement().

int currentIncrement ( void  ) const

Return the current increment.

See Also
setIncrement()
double currentIncrementValue ( void  ) const

Return the value corresponding to the current increment. This is currentIncrement() times the difference of succesive values in case of a linear range, the factor between succesive increments to the power of currentIncrement() in case of logarithmic ranges, or zero otherwise.

See Also
currentIncrement()
int totalCount ( void  ) const

The sum of all counts of alle range elements.

See Also
count()
int maxCount ( void  ) const

The maximum possible number of repetitions of a single data element (repeat() * blockRepeat() * singleRepeat() ).

See Also
totalCount(), maxBlockCount(), remainingCount()
int maxBlockCount ( void  ) const

The maximum possible number of repetitions of a single data element for the current block sequence.

See Also
maxCount(), remainingCount()

Referenced by RangeLoop::operator++().

int remainingCount ( void  ) const

Returns the overall number of remaining counts summed over all data elements that do not have their skip flag set. If repeat() is set to zero, returns the remaining count for a single repeat.

See Also
remainingBlockCount(), maxCount()

References RangeLoop::Skip.

int remainingBlockCount ( void  ) const

Returns the overall number of remaining counts summed over all data elements that do not have their skip flag set for the current block of data.

References RangeLoop::Skip.

void setSequence ( Sequence  seq)
void up ( void  )

Loop upwards trough the data values.

See Also
setSequence()

References RangeLoop::setSequence(), and RangeLoop::Up.

void down ( void  )

Loop downwards trough the data values.

See Also
setSequence()

References RangeLoop::Down, and RangeLoop::setSequence().

void alternateInUp ( void  )

Loop alternating trough the data values starting with the highest value.

See Also
setSequence()

References RangeLoop::AlternateInUp, and RangeLoop::setSequence().

void alternateInDown ( void  )

Loop alternating trough the data values starting with the lowest value.

See Also
setSequence()

References RangeLoop::AlternateInDown, and RangeLoop::setSequence().

void alternateOutUp ( void  )

Loop alternating trough the data values starting in the middle upwards.

See Also
setSequence()

References RangeLoop::AlternateOutUp, and RangeLoop::setSequence().

void alternateOutDown ( void  )

Loop alternating trough the data values starting in the middle downwards.

See Also
setSequence()

References RangeLoop::AlternateOutDown, and RangeLoop::setSequence().

void random ( void  )

Loop randomly trough the data values, i.e. always draw a new sequence of random number.

See Also
setSequence()

References RangeLoop::setSequence().

void pseudoRandom ( void  )

Loop pseudo-randomly trough the data values, i.e. repeat always the same random sequence.

See Also
setSequence()

References RangeLoop::PseudoRandom, and RangeLoop::setSequence().

const string & sequenceStrings ( void  )
static

Returns a string with the names of possible sequence types according to Sequence separated by '|'.

int sequenceSize ( void  ) const

Number of elements in the current sequence.

void reset ( int  pos = -1,
bool  clearskip = true 
)

Reset the range. Set index and repeat counters to zero, reset current increment, set the counts of the data elements to zero. If clearskip is set to true (default) then the skip flags are also cleared. A new sequence of indices is generated starting with the one nearest to pos. If pos is negative (default) it is set to an appropriate value.

See Also
purge()

Referenced by RangeLoop::operator=().

void purge ( void  )

Remove all data elements, that have their skip flag set and generate a new sequence.

See Also
reset()
const RangeLoop & operator= ( int  pos)

Reset the sequence and use pos as the first data element.

See Also
reset()

References RangeLoop::reset().

const RangeLoop & operator++ ( void  )

Increment the current index of the sequence by one.

References RangeLoop::maxBlockCount(), RangeLoop::pos(), and RangeLoop::Skip.

Referenced by RangeLoop::update().

bool operator! ( void  ) const

True if the RangeLoop is currently pointing to an existing data element.

void update ( int  pos = -2)

Call this function either if you set some skip flags to regenerate the sequence or if you want a different start position for the sequence. pos = -2: keep using the previously set start position. pos = -1: use the default start position. >= 0: use pos as the start position.

Note
the new sequence might be empty!

References RangeLoop::operator++(), and RangeLoop::pos().

int loop ( void  ) const

Number of increments since last call of reset().

double value ( void  ) const

Return the value of the current data element.

References RangeLoop::pos().

double operator* ( void  ) const

Return the value of the current data element.

References RangeLoop::pos().

int pos ( void  ) const
int index ( void  ) const

Return the current index of the sequence.

Referenced by RangeLoop::pos(), and RangeLoop::set().

int count ( void  ) const

Return the count of the current data element.

See Also
totalCount()

References RangeLoop::pos().

Referenced by RangeLoop::next(), and RangeLoop::previous().

void noCount ( void  )

Decrement the count of the current data element. Use it before calling operator++() if you do not want the count of the current data element to be incremented.

References RangeLoop::pos().

void setSkip ( bool  skip = true)

Set the skipping behavior of the current data element to skip. If skip is true (default) this data element will be skipped in future sequences.

References RangeLoop::pos(), and RangeLoop::skip().

double value ( int  pos) const

Return the value of the data element at position pos.

References RangeLoop::pos().

double operator[] ( int  pos) const

Return the value of the data element at position pos.

References RangeLoop::pos().

double & operator[] ( int  pos)

Return a reference to the value of the data element at position pos.

References RangeLoop::pos().

double front ( void  ) const

Return the value of the first data element.

double & front ( void  )

Return a reference to the value of the first data element.

double back ( void  ) const

Return the value of the last data element.

double & back ( void  )

Return a reference to the value of the last data element.

double minValue ( void  ) const

Return the minimum value of the range.

References relacs::min().

Referenced by RangeLoop::step().

double maxValue ( void  ) const

Return the maximum value of the range.

References relacs::max().

Referenced by RangeLoop::step().

double step ( void  ) const

Return the step size which is computed as (maxValue()-minValue())/(size()-1)

References RangeLoop::maxValue(), RangeLoop::minValue(), and RangeLoop::size().

Referenced by RangeLoop::add(), and RangeLoop::set().

int count ( int  pos) const

Return the count of the data element at position pos.

References RangeLoop::pos().

int skip ( int  pos) const

Return true if the data element at position pos is to be skipped.

See Also
setSkip()

References RangeLoop::pos().

Referenced by RangeLoop::setSkip(), and RangeLoop::setSkipNocount().

void setSkip ( int  pos,
bool  skip = true 
)

Set the skipping behavior of the data element a position pos to skip. If skip is true (default) this data element will be skipped in future sequences.

See Also
skip(), setSkipBelow(), setSkipAbove(), setSkipBetween(), setSkipNocount()

References RangeLoop::pos(), and RangeLoop::skip().

void setSkipBelow ( int  pos,
bool  skip = true 
)

Set the skipping behavior of all data elements below position pos inclusively to skip. If skip is true (default) these data elements will be skipped in future sequences.

See Also
setSkipAbove(), setSkipBetween(), setSkip(), setSkipNocount()

References RangeLoop::pos(), and RangeLoop::Skip.

void setSkipAbove ( int  pos,
bool  skip = true 
)

Set the skipping behavior of all data elements above position pos inclusively to skip. If skip is true (default) these data elements will be skipped in future sequences.

See Also
setSkipBelow(), setSkipBetween(), setSkip(), setSkipNocount()

References RangeLoop::Skip.

void setSkipBetween ( int  pos1,
int  pos2,
bool  skip = true 
)

Set the skipping behavior of all data elements above position pos1 inclusively and below position pos2 inclusively to skip. If skip is true (default) these data elements will be skipped in future sequences.

See Also
setSkip(), setSkipBelow(), setSkipAbove(), setSkipNocount()

References RangeLoop::Skip.

void setSkipNocount ( bool  skip = true)

Set the skipping behavior of all data elements that have not been used yet, i.e. with zero count(), to skip. If skip is true (default) these data elements will be skipped in future sequences.

See Also
setSkip(), setSkipBelow(), setSkipAbove(), setSkipBetween()

References RangeLoop::skip().

void setSkipNumber ( int  num)

Within the range o non-skipped data elements leave at minimum num data elements non-skipped. Keep the ones that have a count greater than zero, and respect the current increment when selecting the not to be skipped elements.

References RangeLoop::Skip.

int next ( int  pos) const

Returns the position of the data element next or equal to position pos with count larger than zero. If there isn't any such element, size() is returned.

See Also
previous()

References RangeLoop::count(), RangeLoop::pos(), and RangeLoop::size().

int previous ( int  pos) const

Returns the position of the data element previous or equal to position pos with count larger than zero. If there isn't any such element, -1 is returned.

See Also
next()

References RangeLoop::count(), and RangeLoop::pos().

int pos ( int  index) const

Return the position of the data element at index index.

References RangeLoop::index().

int pos ( double  value) const

Return the position of the data element whose value is closest to value.

int index ( int  pos) const

Return the index of the data element at position pos. If there is no index for that data element, -1 is retunred.

bool active ( int  p) const

Returns true if the data element at position p is the active one.

References RangeLoop::pos().

bool near ( int  pos,
double  value 
) const

Returns true if value is closest to the value of the data element with position pos.

Friends And Related Function Documentation

ostream& operator<< ( ostream &  str,
const RangeLoop rl 
)
friend

Write the content of the range to str.


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