Relacs Core Library
0.9.8
|
#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 RangeLoop & | operator= (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 RangeLoop & | operator= (int pos) |
const RangeLoop & | operator++ (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) |
A flexible and sophisticated way to loop trough a range of values.
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:
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.
enum Sequence |
Different sequences for looping through the data.
enum AddMode |
Different ways how addition of already existing values is handled.
RangeLoop | ( | void | ) |
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().
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.
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.
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.
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.
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.
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.
References RangeLoop::set().
RangeLoop::AddMode addMode | ( | void | ) | const |
Returns the current method that is used for adding already existing data vales to the range.
void setAddMode | ( | AddMode | addmode | ) |
Set the method that is used for adding already existing data vales to the range to addmode.
int repeat | ( | void | ) | const |
The number of repetitions for the whole sequence.
Referenced by RangeLoop::set(), RangeLoop::setBlockRepeat(), RangeLoop::setLog(), RangeLoop::setRepeat(), and RangeLoop::setSingleRepeat().
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.
References RangeLoop::repeat().
int currentRepetition | ( | void | ) | const |
Return the number of executed repetitions for the whole sequence to repeat.
int blockRepeat | ( | void | ) | const |
The number of repetitons for a block of data elements of a single increment.
void setBlockRepeat | ( | int | repeat | ) |
Set the number of repetitons for a block of data elements of a single increment to repeat.
References RangeLoop::repeat().
int currentBlockRepetition | ( | void | ) | const |
Return the number of executed repetitions for a block of data elements of a single increment.
bool finishedBlock | ( | void | ) | const |
Returns true if the current block repetitions are completed.
int singleRepeat | ( | void | ) | const |
The number of repetitons for a single data element.
void setSingleRepeat | ( | int | repeat | ) |
Set the number of repetitons for a single data element to repeat.
References RangeLoop::repeat().
int currentSingleRepetition | ( | void | ) | const |
Return the number of executed repetitions for a single data element.
bool finishedSingle | ( | void | ) | const |
Returns true if the current single repetitions are completed, i.e. the next data element is to be started.
bool lastSingle | ( | void | ) | const |
Returns true if this is the last single repetition.
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|.
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.
Referenced by RangeLoop::setIncrement().
int currentIncrement | ( | void | ) | const |
Return the current increment.
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.
int totalCount | ( | void | ) | const |
The sum of all counts of alle range elements.
int maxCount | ( | void | ) | const |
The maximum possible number of repetitions of a single data element (repeat() * blockRepeat() * singleRepeat() ).
int maxBlockCount | ( | void | ) | const |
The maximum possible number of repetitions of a single data element for the current block sequence.
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.
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 | ) |
Set the sequence for looping through the data values to seq.
Referenced by RangeLoop::alternateInDown(), RangeLoop::alternateInUp(), RangeLoop::alternateOutDown(), RangeLoop::alternateOutUp(), RangeLoop::down(), RangeLoop::pseudoRandom(), RangeLoop::random(), and RangeLoop::up().
void up | ( | void | ) |
Loop upwards trough the data values.
References RangeLoop::setSequence(), and RangeLoop::Up.
void down | ( | void | ) |
Loop downwards trough the data values.
References RangeLoop::Down, and RangeLoop::setSequence().
void alternateInUp | ( | void | ) |
Loop alternating trough the data values starting with the highest value.
References RangeLoop::AlternateInUp, and RangeLoop::setSequence().
void alternateInDown | ( | void | ) |
Loop alternating trough the data values starting with the lowest value.
References RangeLoop::AlternateInDown, and RangeLoop::setSequence().
void alternateOutUp | ( | void | ) |
Loop alternating trough the data values starting in the middle upwards.
References RangeLoop::AlternateOutUp, and RangeLoop::setSequence().
void alternateOutDown | ( | void | ) |
Loop alternating trough the data values starting in the middle downwards.
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.
References RangeLoop::setSequence().
void pseudoRandom | ( | void | ) |
Loop pseudo-randomly trough the data values, i.e. repeat always the same random sequence.
References RangeLoop::PseudoRandom, and RangeLoop::setSequence().
|
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.
Referenced by RangeLoop::operator=().
void purge | ( | void | ) |
Remove all data elements, that have their skip flag set and generate a new sequence.
const RangeLoop & operator= | ( | int | pos | ) |
Reset the sequence and use pos as the first data element.
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.
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 |
Return the position of the current data element.
Referenced by RangeLoop::active(), RangeLoop::count(), RangeLoop::next(), RangeLoop::noCount(), RangeLoop::operator*(), RangeLoop::operator++(), RangeLoop::operator[](), RangeLoop::previous(), RangeLoop::setSkip(), RangeLoop::setSkipBelow(), RangeLoop::skip(), RangeLoop::update(), and RangeLoop::value().
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.
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 |
double maxValue | ( | void | ) | const |
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.
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.
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.
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.
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.
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.
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.
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.
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.
|
friend |
Write the content of the range to str.