6.6 Range

The Range class is used to define a range of values given by a minimum and a maximum, and to check if a given value is contained in the range. The range can be open or close at each extermum. This means that the range can be defined with the minimum or maximum being part of the range or not.

Range is a templated class. Ranges of any kind of data can be created. The only restriction is that the data type must have operators ==, <, and > defined. Range uses these 3 operators to compare values against the defined range to answer the contained question.


Synopsis


  #include <lyric/Range.hpp>
  
  template <class RIT>
  class Range
  {
  public:
    ~Range ();
    Range ();
    Range (const RIT& min, const RIT& max,
           const Range::Extrem& emin = Extrem::Include,
           const Range::Extrem& emax = Extrem::Include);
    Range (const Range& range);
    Range& operator = (const Range& range);
    bool operator == (const Range& range) const;
    bool operator != (const Range& range) const;
    const RIT& min () const;
    const RIT& max () const;
    void min (const RIT& val);
    void max (const RIT& val);
    bool contains (const RIT& val) const;
  };


Description


˜Range ()
Destroys this range. Releases all allocated resources to the system.

Range (const RIT& min,
const RIT& max,
const Range::Extrem& emin,
const Range::Extrem& emax



)
Constructs this range with the given minimum, and maximum. The optional emin and emax arguments specify if the extremas (min or max) are part of this range or not. Both are defaulted to Range::Exterm::Include, which means they are part of this range, or in other words that this range is a closed range. See Section 6.6.1 for the Range::Extrem class documentation.

Range (const Range& range)
Constructs this range from the given range. All properties and data of range are cloned into this range.

Range& operator = (const Range& range)
Assigns range to this range. All properties and data of range are cloned into this range.

bool operator == (const Range& range) const
Returns true if this range and the rvalue range are identical (i.e: store the same mimimum, maximum, and extremum properties), false if not.

bool operator != (const Range& range) const
Returns true if this range and the rvalue range are different (i.e: store the different mimimum, maximum, or extremum properties), false if not.

const RIT& min () const
Returns the minimum stored in this range.

const RIT& max () const
Returns the maximum stored in this range.

void min (const RIT& val)
Stores an new minimum in this range.

void max (const RIT& val)
Stores an new maximum in this range.

bool contains (const RIT& val) const
Returns true if teh given value is contained in this range.


  6.6.1 Range::Extrem