bpp-core3  3.0.0
bpp::Range< T > Class Template Reference

The Range class, defining an interval. More...

#include <Bpp/Numeric/Range.h>

+ Inheritance diagram for bpp::Range< T >:
+ Collaboration diagram for bpp::Range< T >:

Public Member Functions

 Range (const T &a=0, const T &b=0)
 Creates a new interval. More...
 
 Range (const Range< T > &range)
 
Range< T > & operator= (const Range< T > &range)
 
Range< T > * clone () const
 Create a copy of this object and send a pointer to it. More...
 
virtual ~Range ()
 
bool operator== (const Range< T > &r) const
 
bool operator!= (const Range< T > &r) const
 
bool operator< (const Range< T > &r) const
 
virtual Rangeoperator+= (const T &val)
 
virtual Range operator+ (const T &val)
 
virtual Rangeoperator-= (const T &val)
 
virtual Range operator- (const T &val)
 
begin () const
 
end () const
 
length () const
 
bool overlap (const Range &r) const
 
bool isContiguous (const Range &r) const
 
bool contains (const Range &r) const
 
void expandWith (const Range &r)
 Expand the current interval with the given one. More...
 
void sliceWith (const Range &r)
 Restrict the current interval to the intersection with the given one. More...
 
bool isEmpty () const
 
std::string toString () const
 

Private Attributes

begin_
 
end_
 

Detailed Description

template<class T>
class bpp::Range< T >

The Range class, defining an interval.

Methods are provided for extending the range, get union and intersection.

Definition at line 26 of file Range.h.

Constructor & Destructor Documentation

◆ Range() [1/2]

template<class T>
bpp::Range< T >::Range ( const T &  a = 0,
const T &  b = 0 
)
inline

Creates a new interval.

If a > b, then the positions are swapped. If a == b, the interval is considered empty. Coordinates are 0-based and of type [a, b[, so that the length of the interval is computed as b - a.

Parameters
aFirst position
bSecond position

Definition at line 46 of file Range.h.

◆ Range() [2/2]

template<class T>
bpp::Range< T >::Range ( const Range< T > &  range)
inline

Definition at line 51 of file Range.h.

◆ ~Range()

template<class T>
virtual bpp::Range< T >::~Range ( )
inlinevirtual

Definition at line 62 of file Range.h.

Member Function Documentation

◆ begin()

template<class T>
T bpp::Range< T >::begin ( ) const
inline

Definition at line 98 of file Range.h.

References bpp::Range< T >::begin_.

◆ clone()

template<class T>
Range<T>* bpp::Range< T >::clone ( ) const
inlinevirtual

Create a copy of this object and send a pointer to it.

Returns
A pointer toward the copy object.

Implements bpp::Clonable.

Definition at line 60 of file Range.h.

Referenced by bpp::RangeSet< T >::addRange(), and bpp::MultiRange< T >::addRange().

◆ contains()

template<class T>
bool bpp::Range< T >::contains ( const Range< T > &  r) const
inline
Parameters
rRange to compare with.
Returns
True if the given interval is included in the instanciated one.

Definition at line 127 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

Referenced by bpp::RangeSet< T >::filterWithin(), and bpp::MultiRange< T >::filterWithin().

◆ end()

template<class T>
T bpp::Range< T >::end ( ) const
inline

Definition at line 100 of file Range.h.

References bpp::Range< T >::end_.

◆ expandWith()

template<class T>
void bpp::Range< T >::expandWith ( const Range< T > &  r)
inline

Expand the current interval with the given one.

If the two intervals do not overlap, then the interval is not modified.

Parameters
rinput interval.

Definition at line 138 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

◆ isContiguous()

template<class T>
bool bpp::Range< T >::isContiguous ( const Range< T > &  r) const
inline
Parameters
rRange to compare with.
Returns
True if the two intervals are contiguous (i.e. the two intervals are adjacent and share one bound).

Definition at line 118 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

◆ isEmpty()

template<class T>
bool bpp::Range< T >::isEmpty ( ) const
inline
Returns
True if then begining position equals the ending one.

Definition at line 171 of file Range.h.

References bpp::Range< T >::end_.

Referenced by bpp::RangeSet< T >::addRange(), and bpp::RangeCollection< T >::~RangeCollection().

◆ length()

template<class T>
T bpp::Range< T >::length ( ) const
inline

Definition at line 102 of file Range.h.

References bpp::Range< T >::begin_.

◆ operator!=()

template<class T>
bool bpp::Range< T >::operator!= ( const Range< T > &  r) const
inline

Definition at line 69 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

◆ operator+()

template<class T>
virtual Range bpp::Range< T >::operator+ ( const T &  val)
inlinevirtual

Definition at line 83 of file Range.h.

◆ operator+=()

template<class T>
virtual Range& bpp::Range< T >::operator+= ( const T &  val)
inlinevirtual

Definition at line 77 of file Range.h.

◆ operator-()

template<class T>
virtual Range bpp::Range< T >::operator- ( const T &  val)
inlinevirtual

Definition at line 93 of file Range.h.

◆ operator-=()

template<class T>
virtual Range& bpp::Range< T >::operator-= ( const T &  val)
inlinevirtual

Definition at line 87 of file Range.h.

◆ operator<()

template<class T>
bool bpp::Range< T >::operator< ( const Range< T > &  r) const
inline

Definition at line 73 of file Range.h.

◆ operator=()

template<class T>
Range<T>& bpp::Range< T >::operator= ( const Range< T > &  range)
inline

Definition at line 53 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

◆ operator==()

template<class T>
bool bpp::Range< T >::operator== ( const Range< T > &  r) const
inline

Definition at line 65 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

◆ overlap()

template<class T>
bool bpp::Range< T >::overlap ( const Range< T > &  r) const
inline
Parameters
rRange to compare with.
Returns
True if the two intervals overlap.

Definition at line 108 of file Range.h.

References bpp::Range< T >::begin_, and bpp::Range< T >::end_.

Referenced by bpp::MultiRange< T >::addRange(), and bpp::Range< T >::sliceWith().

◆ sliceWith()

template<class T>
void bpp::Range< T >::sliceWith ( const Range< T > &  r)
inline

Restrict the current interval to the intersection with the given one.

If the two intervals do not overlap, then the interval is set to empty.

Parameters
rinput interval.

Definition at line 152 of file Range.h.

References bpp::Range< T >::begin_, bpp::Range< T >::end_, and bpp::Range< T >::overlap().

◆ toString()

template<class T>
std::string bpp::Range< T >::toString ( ) const
inline
Returns
A string describing the range.

Definition at line 176 of file Range.h.

References bpp::TextTools::toString().

Referenced by bpp::RangeCollection< T >::~RangeCollection().

Member Data Documentation

◆ begin_

◆ end_


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