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... | |
SimpleInterval & | operator= (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< SimpleInterval > | vectorOfSimpleIntervalsFromString (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
|
inline |
Constructor.
Builds an empy interval (in which start == end)
Definition at line 52 of file intervals.h.
Referenced by SimpleInterval::fromString().
|
inline |
Builds and interval from start to end.
- Parameters
-
s the start of the interval e the end of the interval
Definition at line 64 of file intervals.h.
|
inline |
|
inline |
Destructor.
Definition at line 102 of file intervals.h.
Member Function Documentation
|
inline |
Returns true if other is equal to this interval.
- Parameters
-
other the 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.
|
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
-
str the string to convert ok if 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().
|
inline |
Returns the length of the interval.
- Returns
- the length of the interval
Definition at line 125 of file intervals.h.
|
inline |
Returns the string representation of the interval.
- Returns
- the string representation of the interval
Definition at line 146 of file intervals.h.
|
inline |
Compares two intervals.
This function only compares the start of the two intervals. Useful for sorting by starting value
- Parameters
-
other the 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.
|
inline |
Copy operator.
- Parameters
-
other the interval to copy
- Returns
- a reference to this
Definition at line 87 of file intervals.h.
References SimpleInterval::end, and SimpleInterval::start.
|
inline |
Returns the string representation of the interval.
- Returns
- the string representation of the interval
Definition at line 156 of file intervals.h.
|
static |
Converts the given string to a vector of simple intervals.
The string should be a comma-separated list of simple intervals
- Parameters
-
s the string to convert ok if 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().
|
static |
Converts a vector of simple intervals to string.
- Parameters
-
v the 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:
- utilities/include/intervals.h
- utilities/src/intervals.cpp