GCpp general purpose C++ library
version 1.0
|
#include <GInterval.hh>
Public Member Functions | |
template<class Q > | |
bool | IsInstanceOf () const |
template<class Q > | |
bool | IsInstanceOf () |
virtual GInterval * | Clone () const |
virtual const char * | ClassName () const |
GInterval () | |
GInterval (int i) | |
GInterval (int i1, int i2) | |
GInterval (const string &s) | |
GInterval (const GInterval &original) | |
virtual | ~GInterval () |
GInterval & | operator= (const GInterval &original) |
int | GetMin () const |
int | GetMax () const |
void | SetMin (int i) |
void | SetMax (int i) |
bool | IsEmpty () const |
string | GetString () const |
string | GetStringPar () const |
int | GetValNumber () const |
virtual bool | operator== (const GInterval &item) |
GInterval | Overlap (const GInterval &inter) const |
bool | IsInside (const GInterval &inter, const bool exclude=false) const |
bool | Contains (const GInterval &inter, const bool exclude=false) const |
bool | Touches (const GInterval &inter) const |
Static Public Member Functions | |
static const char * | StaticClassName () |
Protected Attributes | |
int | i_min |
Interval lower bound. | |
int | i_max |
Interval upper bound. | |
Static Private Attributes | |
static string | c_range = ":" |
Range character identification. | |
This class defines an interval between 2 integer values. The bounds belong to the interval. If the upper bound is smaller than the lower bound, the interval is considered empty.
|
inline |
|
inline |
GInterval::GInterval | ( | const string & | s | ) |
Constructor from a string definition. The definition should look like min:max, or (min:max).
s | interval definition string |
References c_range, GString::GetSubstring(), i_max, i_min, GString::NoEndSpace(), and GString::ReadInt().
|
inline |
|
inlinevirtual |
Destructor.
bool GInterval::Contains | ( | const GInterval & | inter, |
const bool | exclude = false |
||
) | const |
The function returns true if the interval contains the argument interval.
inter | interval in which inclusion is tested |
exclude | indicates that bounds must be excluded |
References IsInside().
|
inline |
Get the interval upper bound.
References i_max.
Referenced by GIntervalList::Add(), IsInside(), operator==(), Overlap(), GIntervalList::Remove(), and Touches().
|
inline |
Get the interval lower bound.
References i_min.
Referenced by GIntervalList::Add(), IsInside(), operator==(), Overlap(), GIntervalList::Remove(), and Touches().
string GInterval::GetString | ( | ) | const |
Return a string definition of the interval.
References c_range, GGetString(), i_max, i_min, and IsEmpty().
Referenced by GetStringPar().
|
inline |
Return a string with interval definition, enclosed in parenthesis.
References GetString().
Referenced by GIntervalList::Add(), and GIntervalList::Remove().
|
inline |
|
inline |
Return true if the interval does not contain any value (if the upper bound is smaller than the lower bound.
Referenced by GIntervalList::Add(), GetString(), GetValNumber(), IsInside(), operator==(), Overlap(), GIntervalList::Remove(), and Touches().
bool GInterval::IsInside | ( | const GInterval & | inter, |
const bool | exclude = false |
||
) | const |
The function returns true if the interval is included in the argument interval.
inter | interval in which inclusion is tested |
exclude | indicates that bounds must be excluded |
References GetMax(), GetMin(), and IsEmpty().
Referenced by Contains().
|
inline |
Macro from GCpp library that defines the following functions:
|
virtual |
|
inline |
Set the interval upper bound.
i | new bound value |
References i_max.
Referenced by GIntervalList::Add(), and Overlap().
|
inline |
Set the interval lower bound.
i | new bound value |
References i_min.
Referenced by GIntervalList::Add(), and Overlap().
bool GInterval::Touches | ( | const GInterval & | inter | ) | const |