A class modelling a range of real values. More...

Public Member Functions

 SimpleInterval ()
 Constructor. More...
 
 SimpleInterval (real s, real e)
 Builds and interval from start to end. More...
 
 SimpleInterval (const SimpleInterval &other)
 Copy constructor. More...
 
 ~SimpleInterval ()
 Destructor. More...
 
bool equals (const SimpleInterval &other) const
 Returns true if other is equal to this interval. More...
 
real length () const
 Returns the length of the interval. More...
 
 operator QString () const
 Returns the string representation of the interval. More...
 
bool operator< (const SimpleInterval &other) const
 Compares two intervals. More...
 
SimpleIntervaloperator= (const SimpleInterval &other)
 Copy operator. More...
 
QString toString () const
 Returns the string representation of the interval. More...
 

Static Public Member Functions

static SimpleInterval fromString (QString str, bool *ok=NULL)
 Converts the given string to a SimpleInterval. More...
 
static QVector< SimpleIntervalvectorOfSimpleIntervalsFromString (QString s, bool *ok=NULL)
 Converts the given string to a vector of simple intervals. More...
 
static QString vectorOfSimpleIntervalsToString (QVector< SimpleInterval > v)
 Converts a vector of simple intervals to string. More...
 

Public Attributes

real end
 The ending value of the interval. More...
 
real start
 The starting value of the interval. More...
 

Detailed Description

A class modelling a range of real values.

This class simply stores a range of values, with a minimum and maximum value Use the Intervals class and its subclasses, which can also handle multiple intervals and operations with intervals. Moreover this class doesn't perform any sanity check (e.g. you are allowed to have start > end)

Definition at line 44 of file intervals.h.

Constructor & Destructor Documentation

SimpleInterval ( )
inline

Constructor.

Builds an empy interval (in which start == end)

Definition at line 52 of file intervals.h.

Referenced by SimpleInterval::fromString().

SimpleInterval ( real  s,
real  e 
)
inline

Builds and interval from start to end.

Parameters
sthe start of the interval
ethe end of the interval

Definition at line 64 of file intervals.h.

SimpleInterval ( const SimpleInterval other)
inline

Copy constructor.

Parameters
otherthe interval to copy

Definition at line 75 of file intervals.h.

~SimpleInterval ( )
inline

Destructor.

Definition at line 102 of file intervals.h.

Member Function Documentation

bool equals ( const SimpleInterval other) const
inline

Returns true if other is equal to this interval.

Parameters
otherthe interval whith which we are compared
Returns
true if the two intervals are equal

Definition at line 136 of file intervals.h.

References SimpleInterval::end, and SimpleInterval::start.

SimpleInterval fromString ( QString  str,
bool *  ok = NULL 
)
static

Converts the given string to a SimpleInterval.

The string should be in the form "[start, end]" where start and end are the starting and ending values of the interval

Parameters
strthe string to convert
okif not NULL, it is set to false if conversion was successful, to false otherwise
Returns
the SimpleInterval represented by str. If conversion was not successful, returns an empty interval

Definition at line 25 of file intervals.cpp.

References SimpleInterval::end, SimpleInterval::SimpleInterval(), and SimpleInterval::start.

Referenced by SimpleInterval::vectorOfSimpleIntervalsFromString().

real length ( ) const
inline

Returns the length of the interval.

Returns
the length of the interval

Definition at line 125 of file intervals.h.

operator QString ( ) const
inline

Returns the string representation of the interval.

Returns
the string representation of the interval

Definition at line 146 of file intervals.h.

bool operator< ( const SimpleInterval other) const
inline

Compares two intervals.

This function only compares the start of the two intervals. Useful for sorting by starting value

Parameters
otherthe interval with which we are compared
Returns
true if the start of this interval is less than the start of the other interval

Definition at line 115 of file intervals.h.

References SimpleInterval::start.

SimpleInterval& operator= ( const SimpleInterval other)
inline

Copy operator.

Parameters
otherthe interval to copy
Returns
a reference to this

Definition at line 87 of file intervals.h.

References SimpleInterval::end, and SimpleInterval::start.

QString toString ( ) const
inline

Returns the string representation of the interval.

Returns
the string representation of the interval

Definition at line 156 of file intervals.h.

QVector< SimpleInterval > vectorOfSimpleIntervalsFromString ( QString  s,
bool *  ok = NULL 
)
static

Converts the given string to a vector of simple intervals.

The string should be a comma-separated list of simple intervals

Parameters
sthe string to convert
okif not NULL, it is set to false if conversion was successful, to false otherwise
Returns
a vector of SimpleIntervals. If the string is not valid, an empty vector is returned

Definition at line 73 of file intervals.cpp.

References SimpleInterval::fromString().

QString vectorOfSimpleIntervalsToString ( QVector< SimpleInterval v)
static

Converts a vector of simple intervals to string.

Parameters
vthe vector to convert
Returns
a string representing the vector of simple intervals

Definition at line 59 of file intervals.cpp.

Member Data Documentation

real end

The ending value of the interval.

Definition at line 202 of file intervals.h.

Referenced by SimpleInterval::equals(), SimpleInterval::fromString(), Intervals::Intervals(), and SimpleInterval::operator=().

real start

The starting value of the interval.

Definition at line 197 of file intervals.h.

Referenced by SimpleInterval::equals(), SimpleInterval::fromString(), Intervals::Intervals(), SimpleInterval::operator<(), and SimpleInterval::operator=().


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