NAME
OTC_Range -
Class to represent a range of integers.
SYNOPSIS
#include <OTC/collctn/range.hh>
class OTC_Range
{
public:
static os_typespec* get_os_typespec();
inline OTC_Range(u_int theLength=0);
inline OTC_Range(int theLower, u_int theLength);
inline OTC_Range(OTC_Range const& theRange);
inline OTC_Range& operator=(OTC_Range const& theRange);
inline OTC_Boolean operator==(OTC_Range const& theRange) const;
inline OTC_Boolean operator!=(OTC_Range const& theRange) const;
inline int lower() const;
inline int upper() const;
inline u_int length() const;
inline OTC_Boolean contains(int theValue) const;
inline OTC_Boolean isNullRange() const;
OTC_Boolean isSubRange(OTC_Range const& theRange) const;
OTC_Iterator<int> indices(
OTC_Direction theDirection=OTCLIB_FORWARD
) const;
};
CLASS TYPE
Concrete
DESCRIPTION
This class is for representing a range of integers. That set of
integers is any integer i such that the condition lower() <=
i < upper() is satisfied. If lower() is equal to upper()
then it is a null range. In defining the range, the lower bound
and a length is expected. The property which relates the bounds
and the length is upper() == lower() + length().
CONSTRUCTION
inline OTC_Range(u_int theLength=0);
Initialises the class to represent
a range with a length theLength and
lower bound of 0.
inline OTC_Range(int theLower, u_int theLength);
Initialises the class to represent a
range with a lower bound theLower and
length theLength.
inline OTC_Range(OTC_Range const& theRange);
Initialises the class to represent
the same range as theRange.
ASSIGNMENT
inline OTC_Range& operator=(OTC_Range const& theRange);
Changes this class to represent the
same range as theRange.
COMPARISON
inline OTC_Boolean operator==(OTC_Range const& theRange) const;
Returns OTCLIB_FALSE if this range
isn't equivalent to theRange.
inline OTC_Boolean operator!=(OTC_Range const& theRange) const;
Returns OTCLIB_FALSE if this range
is equivalent to theRange.
QUERY
inline int lower() const;
Returns the integer which is the lower
bound of the range. Note that this value
is regarded as being in the range.
inline int upper() const;
Returns the integer which is the upper
bound of the range. Note that this value
is not regarded as being in the range, but
is one more than the highest value in the
range.
inline u_int length() const;
Returns the length of this range, ie., the
number of integers in the range.
inline OTC_Boolean contains(int theValue) const;
Returns OTCLIB_FALSE if theValue is
not contained in this range.
inline OTC_Boolean isNullRange() const;
Returns OTCLIB_FALSE if this is not a
null range.
OTC_Boolean isSubRange(OTC_Range const& theRange) const;
Returns OTCLIB_FALSE if this range is not
contained within theRange. If this
range is a null range then OTCLIB_TRUE
will always be returned.
OTC_Iterator<int> indices(
OTC_Direction theDirection=OTCLIB_FORWARD
) const;
Returns an iterator for the indices in the
range. theDirection indicates the
direction of traversal, namely, if
theDirection is OTCLIB_FORWARD,
traversal will be in the direction of
lower to upper. For OTCLIB_BACKWARD it
will be the reverse.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED