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...
 
Intervalsintersect (const Intervals &other)
 Intersects intervals in this with other. More...
 
Intervalsintersect (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...
 
Intervalsoperator&= (const Intervals &other)
 Intersects intervals in this with other. More...
 
Intervalsoperator&= (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...
 
Intervalsoperator+= (const Intervals &other)
 Unites intervals in this with other. More...
 
Intervalsoperator+= (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...
 
Intervalsoperator-= (const Intervals &other)
 Subtracts intervals in this with other. More...
 
Intervalsoperator-= (const SimpleInterval &value)
 Subtracts a simple interval with intervals in this one. More...
 
Intervalsoperator<< (const SimpleInterval &value)
 Unites a simple interval with intervals in this one. More...
 
Intervalsoperator= (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...
 
Intervalsoperator|= (const Intervals &other)
 Unites intervals in this with other. More...
 
Intervalsoperator|= (const SimpleInterval &value)
 Unites a simple interval with intervals in this one. More...
 
Intervalssubtract (const Intervals &other)
 Subtracts intervals from other to these ones. More...
 
Intervalssubtract (const SimpleInterval &i)
 Subtracts intervals in this with the given simple interval. More...
 
QString toString () const
 Returns the string representation of the interval. More...
 
Intervalsunite (const Intervals &other)
 Unites intervals in this with other. More...
 
Intervalsunite (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< SimpleIntervalm_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

The const iterator on simple intervals.

Definition at line 224 of file intervals.h.

Constructor & Destructor Documentation

Intervals ( )
inline

Constructor.

Builds an empty interval

Definition at line 232 of file intervals.h.

Intervals ( const SimpleInterval interval)

Constructor.

Builds an interval made up of a single SimpleInterval

Parameters
intervalthe simple interval making this up

Definition at line 119 of file intervals.cpp.

References SimpleInterval::end, Intervals::m_intervals, Intervals::recomputeLength(), and SimpleInterval::start.

Intervals ( const List_t &  list)
inline

Constructor.

Builds an interval from a list of Intervals or SimpleIntervals

Parameters
listthe list of Intervals or SimpleIntervals making this up

Definition at line 253 of file intervals.h.

Intervals ( const Intervals other)
inline

Copy Constructor.

Parameters
otherthe intervals to copy

Definition at line 267 of file intervals.h.

~Intervals ( )
inline

Destructor.

Definition at line 284 of file intervals.h.

Member Function Documentation

const_iterator begin ( ) const
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.

const_iterator constBegin ( ) const
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().

const_iterator constEnd ( ) const
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().

bool empty ( ) const
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.

const_iterator end ( ) const
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().

const QLinkedList<SimpleInterval>& getSimpleIntervalList ( ) const
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.

Intervals& intersect ( const Intervals other)
inline

Intersects intervals in this with other.

Parameters
otherthe 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&().

Intervals& intersect ( const SimpleInterval i)
inline

Intersects intervals in this with the given simple interval.

Parameters
ithe simple interval to intersect to these ones
Returns
a reference to this

Definition at line 419 of file intervals.h.

void intersect ( OtherIterator_t  otherBegin,
OtherIterator_t  otherEnd 
)
protected

Performs the intersection of the intervals in this object and the intervals in the list delimited by the start and end iterators.

Parameters
otherBeginthe start iterator to the the other intervals
otherEndthe end iterator to the other intervals

Definition at line 218 of file intervals.cpp.

References Intervals::m_intervals, and Intervals::recomputeLength().

bool isEmpty ( ) const
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.

real length ( ) const
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.

bool operator!= ( const Intervals other) const
inline

Returns true if this and other are different.

Two Intervals are different if at least one SimpleInterval differs

Parameters
otherthe intervals to compare with this one
Returns
true is this and other are different

Definition at line 675 of file intervals.h.

Intervals operator& ( const Intervals other) const
inline

Returns the intersection of this and other.

Parameters
otherthe 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().

Intervals operator& ( const SimpleInterval i) const
inline

Returns the intersection of this and the given simple interval.

Parameters
ithe 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().

Intervals& operator&= ( const Intervals other)
inline

Intersects intervals in this with other.

Parameters
otherthe intervals to intersect to these ones
Returns
a reference to this

Definition at line 455 of file intervals.h.

Intervals& operator&= ( const SimpleInterval value)
inline

Intersects a simple interval with intervals in this one.

Parameters
valuethe interval to intersect to these ones
Returns
a reference to this

Definition at line 466 of file intervals.h.

Intervals operator+ ( const Intervals other) const
inline

Returns the union of this and other.

Parameters
otherthe 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().

Intervals operator+ ( const SimpleInterval i) const
inline

Returns the union of this and the given simple interval.

Parameters
ithe 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().

Intervals& operator+= ( const Intervals other)
inline

Unites intervals in this with other.

Parameters
otherthe intervals to unite to these ones
Returns
a reference to this

Definition at line 525 of file intervals.h.

Intervals& operator+= ( const SimpleInterval value)
inline

Unites a simple interval with intervals in this one.

Parameters
valuethe interval to unite to these ones
Returns
a reference to this

Definition at line 536 of file intervals.h.

Intervals operator- ( const Intervals other) const
inline

Returns the subtraction of this and other.

Parameters
otherthe 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().

Intervals operator- ( const SimpleInterval i) const
inline

Returns the subtraction of this and the given simple interval.

Parameters
ithe 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().

Intervals& operator-= ( const Intervals other)
inline

Subtracts intervals in this with other.

Parameters
otherthe intervals to subtract from these ones
Returns
a reference to this

Definition at line 652 of file intervals.h.

Intervals& operator-= ( const SimpleInterval value)
inline

Subtracts a simple interval with intervals in this one.

Parameters
valuethe interval to subtract from these ones
Returns
a reference to this

Definition at line 663 of file intervals.h.

Intervals& operator<< ( const SimpleInterval value)
inline

Unites a simple interval with intervals in this one.

Parameters
valuethe interval to unite to these ones
Returns
a reference to this

Definition at line 593 of file intervals.h.

Intervals & operator= ( const Intervals other)

Copy operator.

Parameters
otherthe 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
otherthe 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().

Intervals operator| ( const Intervals other) const
inline

Returns the union of this and other.

Parameters
otherthe 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().

Intervals operator| ( const SimpleInterval i) const
inline

Returns the union of this and the given simple interval.

Parameters
ithe 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().

Intervals& operator|= ( const Intervals other)
inline

Unites intervals in this with other.

Parameters
otherthe intervals to unite to these ones
Returns
a reference to this

Definition at line 571 of file intervals.h.

Intervals& operator|= ( const SimpleInterval value)
inline

Unites a simple interval with intervals in this one.

Parameters
valuethe interval to unite to these ones
Returns
a reference to this

Definition at line 582 of file intervals.h.

void recomputeLength ( )
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().

Intervals& subtract ( const Intervals other)
inline

Subtracts intervals from other to these ones.

Parameters
otherthe 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-().

Intervals& subtract ( const SimpleInterval i)
inline

Subtracts intervals in this with the given simple interval.

Parameters
ithe simple interval to subtract from these ones
Returns
a reference to this

Definition at line 616 of file intervals.h.

void subtract ( OtherIterator_t  otherBegin,
OtherIterator_t  otherEnd 
)
protected

Performs the subtraction of the intervals in this object and the intervals in the list delimited by the start and end iterators.

Parameters
otherBeginthe start iterator to the the other intervals
otherEndthe end iterator to the other intervals

Definition at line 374 of file intervals.cpp.

References Intervals::m_intervals, and Intervals::recomputeLength().

QString toString ( ) const
inline

Returns the string representation of the interval.

Returns
the string representation of the interval

Definition at line 300 of file intervals.h.

Intervals& unite ( const Intervals other)
inline

Unites intervals in this with other.

Parameters
otherthe 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|().

Intervals& unite ( const SimpleInterval i)
inline

Unites intervals in this with the given simple interval.

Parameters
ithe simple interval to unite to these ones
Returns
a reference to this

Definition at line 489 of file intervals.h.

void unite ( OtherIterator_t  otherBegin,
OtherIterator_t  otherEnd 
)
protected

Performs the union of the intervals in this object and the intervals in the list delimited by the start and end iterators.

Parameters
otherBeginthe start iterator to the the other intervals
otherEndthe 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
vthe 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

QLinkedList<SimpleInterval> m_intervals
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().

real m_length
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: