The class modelling intervals of floating point values. More...
Public Types | |
typedef QLinkedList< SimpleInterval >::const_iterator | const_iterator |
The const iterator on simple intervals. More... | |
Public Member Functions | |
Intervals () | |
Constructor. More... | |
Intervals (const SimpleInterval &interval) | |
Constructor. More... | |
template<class List_t > | |
Intervals (const List_t &list) | |
Constructor. More... | |
Intervals (const Intervals &other) | |
Copy Constructor. More... | |
~Intervals () | |
Destructor. More... | |
const_iterator | begin () const |
Returns a const iterator to the beginning of the list of simple intervals. More... | |
void | clear () |
Sets this to an empty interval. More... | |
const_iterator | constBegin () const |
Returns a const iterator to the beginning of the list of simple intervals. More... | |
const_iterator | constEnd () const |
Returns a const iterator to the end of the list of simple intervals. More... | |
bool | empty () const |
Returns true if the list of intervals is empty. More... | |
const_iterator | end () const |
Returns a const iterator to the end of the list of simple intervals. More... | |
const QLinkedList< SimpleInterval > & | getSimpleIntervalList () const |
Returns a const reference to the list of simple intervals. More... | |
Intervals & | intersect (const Intervals &other) |
Intersects intervals in this with other. More... | |
Intervals & | intersect (const SimpleInterval &i) |
Intersects intervals in this with the given simple interval. More... | |
bool | isEmpty () const |
Returns true if the list of intervals is empty. More... | |
real | length () const |
Returns the size of the intervals. More... | |
operator QString () const | |
Returns the string representation of the intervals. More... | |
bool | operator!= (const Intervals &other) const |
Returns true if this and other are different. More... | |
Intervals | operator& (const Intervals &other) const |
Returns the intersection of this and other. More... | |
Intervals | operator& (const SimpleInterval &i) const |
Returns the intersection of this and the given simple interval. More... | |
Intervals & | operator&= (const Intervals &other) |
Intersects intervals in this with other. More... | |
Intervals & | operator&= (const SimpleInterval &value) |
Intersects a simple interval with intervals in this one. More... | |
Intervals | operator+ (const Intervals &other) const |
Returns the union of this and other. More... | |
Intervals | operator+ (const SimpleInterval &i) const |
Returns the union of this and the given simple interval. More... | |
Intervals & | operator+= (const Intervals &other) |
Unites intervals in this with other. More... | |
Intervals & | operator+= (const SimpleInterval &value) |
Unites a simple interval with intervals in this one. More... | |
Intervals | operator- (const Intervals &other) const |
Returns the subtraction of this and other. More... | |
Intervals | operator- (const SimpleInterval &i) const |
Returns the subtraction of this and the given simple interval. More... | |
Intervals & | operator-= (const Intervals &other) |
Subtracts intervals in this with other. More... | |
Intervals & | operator-= (const SimpleInterval &value) |
Subtracts a simple interval with intervals in this one. More... | |
Intervals & | operator<< (const SimpleInterval &value) |
Unites a simple interval with intervals in this one. More... | |
Intervals & | operator= (const Intervals &other) |
Copy operator. More... | |
bool | operator== (const Intervals &other) const |
Returns true if this and other are the same. More... | |
Intervals | operator| (const Intervals &other) const |
Returns the union of this and other. More... | |
Intervals | operator| (const SimpleInterval &i) const |
Returns the union of this and the given simple interval. More... | |
Intervals & | operator|= (const Intervals &other) |
Unites intervals in this with other. More... | |
Intervals & | operator|= (const SimpleInterval &value) |
Unites a simple interval with intervals in this one. More... | |
Intervals & | subtract (const Intervals &other) |
Subtracts intervals from other to these ones. More... | |
Intervals & | subtract (const SimpleInterval &i) |
Subtracts intervals in this with the given simple interval. More... | |
QString | toString () const |
Returns the string representation of the interval. More... | |
Intervals & | unite (const Intervals &other) |
Unites intervals in this with other. More... | |
Intervals & | unite (const SimpleInterval &i) |
Unites intervals in this with the given simple interval. More... | |
bool | valueIn (real v) const |
Returns true if the given value belongs to these intervals. More... | |
Protected Member Functions | |
template<class OtherIterator_t > | |
void | intersect (OtherIterator_t otherBegin, OtherIterator_t otherEnd) |
Performs the intersection of the intervals in this object and the intervals in the list delimited by the start and end iterators. More... | |
void | recomputeLength () |
Recomputes the length of the interval. More... | |
template<class OtherIterator_t > | |
void | subtract (OtherIterator_t otherBegin, OtherIterator_t otherEnd) |
Performs the subtraction of the intervals in this object and the intervals in the list delimited by the start and end iterators. More... | |
template<class OtherIterator_t > | |
void | unite (OtherIterator_t otherBegin, OtherIterator_t otherEnd) |
Performs the union of the intervals in this object and the intervals in the list delimited by the start and end iterators. More... | |
Protected Attributes | |
QLinkedList< SimpleInterval > | m_intervals |
The list of simple intervals. More... | |
real | m_length |
The total length of intervals. More... | |
Detailed Description
The class modelling intervals of floating point values.
This class models intervals of floating point values. It is made up of multiple SimpleInterval instances. The composing intervals are always ordered by ascending starting value, are never overlapping and never empty (i.e. for no simple interval start is equal to end. This means that single points cannot belong to an interval). Functions accepting a SimpleInterval take intervals with start > end as modelling the intervals [-inf, end] + [start, inf]. They are internally split in two, no interval is ever returned with start > end. To access the simple intervals you have to use const_iterators or get the const linked list of SimpleInterval
Definition at line 218 of file intervals.h.
Member Typedef Documentation
typedef QLinkedList<SimpleInterval>::const_iterator const_iterator |
The const iterator on simple intervals.
Definition at line 224 of file intervals.h.
Constructor & Destructor Documentation
|
inline |
Intervals | ( | const SimpleInterval & | interval | ) |
Constructor.
Builds an interval made up of a single SimpleInterval
- Parameters
-
interval the simple interval making this up
Definition at line 119 of file intervals.cpp.
References SimpleInterval::end, Intervals::m_intervals, Intervals::recomputeLength(), and SimpleInterval::start.
|
inline |
Constructor.
Builds an interval from a list of Intervals or SimpleIntervals
- Parameters
-
list the list of Intervals or SimpleIntervals making this up
Definition at line 253 of file intervals.h.
|
inline |
Destructor.
Definition at line 284 of file intervals.h.
Member Function Documentation
|
inline |
Returns a const iterator to the beginning of the list of simple intervals.
This iterator is the same as QLinkedList::const_iterator
- Returns
- a const iterator to the beginning of the list of simple intervals
Definition at line 324 of file intervals.h.
Referenced by Intervals::operator==(), Intervals::recomputeLength(), and Intervals::valueIn().
void clear | ( | ) |
Sets this to an empty interval.
Definition at line 169 of file intervals.cpp.
References Intervals::m_intervals, and Intervals::m_length.
|
inline |
Returns a const iterator to the beginning of the list of simple intervals.
This iterator is the same as QLinkedList::const_iterator
- Returns
- a const iterator to the beginning of the list of simple intervals
Definition at line 337 of file intervals.h.
Referenced by Intervals::intersect(), Intervals::subtract(), and Intervals::unite().
|
inline |
Returns a const iterator to the end of the list of simple intervals.
This iterator is the same as QLinkedList::const_iterator
- Returns
- a const iterator to the end of the list of simple intervals
Definition at line 361 of file intervals.h.
Referenced by Intervals::intersect(), Intervals::subtract(), and Intervals::unite().
|
inline |
Returns true if the list of intervals is empty.
- Returns
- true if the list of intervals is empty
Definition at line 391 of file intervals.h.
|
inline |
Returns a const iterator to the end of the list of simple intervals.
This iterator is the same as QLinkedList::const_iterator
- Returns
- a const iterator to the end of the list of simple intervals
Definition at line 349 of file intervals.h.
Referenced by Intervals::operator==(), Intervals::recomputeLength(), and Intervals::valueIn().
|
inline |
Returns a const reference to the list of simple intervals.
- Returns
- a const reference to the list of simple intervals
Definition at line 371 of file intervals.h.
Intersects intervals in this with other.
- Parameters
-
other the intervals to intersect to these ones
- Returns
- a reference to this
Definition at line 407 of file intervals.h.
References Intervals::constBegin(), and Intervals::constEnd().
Referenced by Intervals::operator&().
|
inline |
Intersects intervals in this with the given simple interval.
- Parameters
-
i the simple interval to intersect to these ones
- Returns
- a reference to this
Definition at line 419 of file intervals.h.
|
protected |
Performs the intersection of the intervals in this object and the intervals in the list delimited by the start and end iterators.
- Parameters
-
otherBegin the start iterator to the the other intervals otherEnd the end iterator to the other intervals
Definition at line 218 of file intervals.cpp.
References Intervals::m_intervals, and Intervals::recomputeLength().
|
inline |
Returns true if the list of intervals is empty.
- Returns
- true if the list of intervals is empty
Definition at line 381 of file intervals.h.
|
inline |
Returns the size of the intervals.
The size is the sum of the length of composing single intervals
- Returns
- the size of the intervals
Definition at line 311 of file intervals.h.
operator QString | ( | ) | const |
Returns the string representation of the intervals.
- Returns
- the string representation of the intervals
Definition at line 151 of file intervals.cpp.
|
inline |
Returns true if this and other are different.
Two Intervals are different if at least one SimpleInterval differs
- Parameters
-
other the intervals to compare with this one
- Returns
- true is this and other are different
Definition at line 675 of file intervals.h.
Returns the intersection of this and other.
- Parameters
-
other the intervals to intersect to these ones
- Returns
- a new object resulting from the intersection
Definition at line 431 of file intervals.h.
References Intervals::intersect().
|
inline |
Returns the intersection of this and the given simple interval.
- Parameters
-
i the simple interval to intersect to these ones
- Returns
- a new object resulting from the intersection
Definition at line 443 of file intervals.h.
References Intervals::intersect().
Intersects intervals in this with other.
- Parameters
-
other the intervals to intersect to these ones
- Returns
- a reference to this
Definition at line 455 of file intervals.h.
|
inline |
Intersects a simple interval with intervals in this one.
- Parameters
-
value the interval to intersect to these ones
- Returns
- a reference to this
Definition at line 466 of file intervals.h.
Returns the union of this and other.
- Parameters
-
other the intervals to unite to these ones
- Returns
- a new object resulting from the union
Definition at line 501 of file intervals.h.
References Intervals::unite().
|
inline |
Returns the union of this and the given simple interval.
- Parameters
-
i the simple interval to unite to these ones
- Returns
- a new object resulting from the union
Definition at line 513 of file intervals.h.
References Intervals::unite().
Unites intervals in this with other.
- Parameters
-
other the intervals to unite to these ones
- Returns
- a reference to this
Definition at line 525 of file intervals.h.
|
inline |
Unites a simple interval with intervals in this one.
- Parameters
-
value the interval to unite to these ones
- Returns
- a reference to this
Definition at line 536 of file intervals.h.
Returns the subtraction of this and other.
- Parameters
-
other the intervals to subtract from these ones
- Returns
- a new object resulting from the subtraction
Definition at line 628 of file intervals.h.
References Intervals::subtract().
|
inline |
Returns the subtraction of this and the given simple interval.
- Parameters
-
i the simple interval to subtract from these ones
- Returns
- a new object resulting from the subtraction
Definition at line 640 of file intervals.h.
References Intervals::subtract().
Subtracts intervals in this with other.
- Parameters
-
other the intervals to subtract from these ones
- Returns
- a reference to this
Definition at line 652 of file intervals.h.
|
inline |
Subtracts a simple interval with intervals in this one.
- Parameters
-
value the interval to subtract from these ones
- Returns
- a reference to this
Definition at line 663 of file intervals.h.
|
inline |
Unites a simple interval with intervals in this one.
- Parameters
-
value the interval to unite to these ones
- Returns
- a reference to this
Definition at line 593 of file intervals.h.
Copy operator.
- Parameters
-
other the intervals to copy
- Returns
- a reference to this
Definition at line 139 of file intervals.cpp.
References Intervals::m_intervals, and Intervals::m_length.
bool operator== | ( | const Intervals & | other | ) | const |
Returns true if this and other are the same.
Two Intervals are equal if all SimpleIntervals are the same
- Parameters
-
other the intervals to compare with this one
- Returns
- true is this and other are equal
Definition at line 175 of file intervals.cpp.
References Intervals::begin(), and Intervals::end().
Returns the union of this and other.
- Parameters
-
other the intervals to unite to these ones
- Returns
- a new object resulting from the union
Definition at line 547 of file intervals.h.
References Intervals::unite().
|
inline |
Returns the union of this and the given simple interval.
- Parameters
-
i the simple interval to unite to these ones
- Returns
- a new object resulting from the union
Definition at line 559 of file intervals.h.
References Intervals::unite().
Unites intervals in this with other.
- Parameters
-
other the intervals to unite to these ones
- Returns
- a reference to this
Definition at line 571 of file intervals.h.
|
inline |
Unites a simple interval with intervals in this one.
- Parameters
-
value the interval to unite to these ones
- Returns
- a reference to this
Definition at line 582 of file intervals.h.
|
protected |
Recomputes the length of the interval.
Definition at line 209 of file intervals.cpp.
References Intervals::begin(), Intervals::end(), and Intervals::m_length.
Referenced by Intervals::intersect(), Intervals::Intervals(), Intervals::subtract(), and Intervals::unite().
Subtracts intervals from other to these ones.
- Parameters
-
other the intervals to subtract from these ones
- Returns
- a reference to this
Definition at line 604 of file intervals.h.
References Intervals::constBegin(), and Intervals::constEnd().
Referenced by Intervals::operator-().
|
inline |
Subtracts intervals in this with the given simple interval.
- Parameters
-
i the simple interval to subtract from these ones
- Returns
- a reference to this
Definition at line 616 of file intervals.h.
|
protected |
Performs the subtraction of the intervals in this object and the intervals in the list delimited by the start and end iterators.
- Parameters
-
otherBegin the start iterator to the the other intervals otherEnd the end iterator to the other intervals
Definition at line 374 of file intervals.cpp.
References Intervals::m_intervals, and Intervals::recomputeLength().
|
inline |
Returns the string representation of the interval.
- Returns
- the string representation of the interval
Definition at line 300 of file intervals.h.
Unites intervals in this with other.
- Parameters
-
other the intervals to unite to these ones
- Returns
- a reference to this
Definition at line 477 of file intervals.h.
References Intervals::constBegin(), and Intervals::constEnd().
Referenced by Intervals::operator+(), and Intervals::operator|().
|
inline |
Unites intervals in this with the given simple interval.
- Parameters
-
i the simple interval to unite to these ones
- Returns
- a reference to this
Definition at line 489 of file intervals.h.
|
protected |
Performs the union of the intervals in this object and the intervals in the list delimited by the start and end iterators.
- Parameters
-
otherBegin the start iterator to the the other intervals otherEnd the end iterator to the other intervals
Definition at line 304 of file intervals.cpp.
References Intervals::m_intervals, farsa::max(), farsa::min(), and Intervals::recomputeLength().
bool valueIn | ( | real | v | ) | const |
Returns true if the given value belongs to these intervals.
- Parameters
-
v the value to check
- Returns
- true if the value belongs to these intervals
Definition at line 198 of file intervals.cpp.
References Intervals::begin(), and Intervals::end().
Member Data Documentation
|
protected |
The list of simple intervals.
This list is always sorted by ascending start of the simple intervals. Moreover no two intervals ever intersect
Definition at line 746 of file intervals.h.
Referenced by Intervals::clear(), Intervals::intersect(), Intervals::Intervals(), Intervals::operator=(), Intervals::subtract(), and Intervals::unite().
|
protected |
The total length of intervals.
Definition at line 738 of file intervals.h.
Referenced by Intervals::clear(), Intervals::operator=(), and Intervals::recomputeLength().
The documentation for this class was generated from the following files:
- utilities/include/intervals.h
- utilities/src/intervals.cpp