home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 24 / PCPLUS115.iso / pcplus / tclite / include / range.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-28  |  1.3 KB  |  40 lines

  1. #ifndef    RANGE_H
  2. #define    RANGE_H
  3.  
  4. #include "object.h"
  5.  
  6. extern const Class class_Range;
  7.  
  8. class Range: public Object {
  9.     int first,len;
  10. public:
  11.     Range()            { first = 0; len = -1; }
  12.     Range(int f, int l)    { first = f; len = l; }
  13.     Range(const Range& r)    { first = r.first;  len = r.len; }
  14.     int length() const       { return len; }
  15.     int length(int l)    { return len = l; }
  16.     int firstIndex() const   { return first; }
  17.     int firstIndex(int f)    { return first = f; }
  18.     int lastIndex() const     { return (first + len - 1); }
  19.     int lastIndex(int i)    { len = i - first + 1;  return i; }
  20.     bool valid() const        { return (len >= 0); }
  21.     void operator=(const Range& r)  { first = r.first;  len = r.len; }
  22.     bool operator==(const Range& r) const
  23.          {
  24.          return ((first == r.first) && (len == r.len));
  25.          }
  26.     bool operator!=(const Range& r) const
  27.          {
  28.             return !(*this==r);
  29.          }
  30.     virtual Object* copy() const;         // return shallowCopy();
  31.     virtual void deepenShallowCopy();    // {}
  32.     virtual unsigned hash() const;
  33.     virtual const Class* isA() const;
  34.     virtual bool isEqual(const Object&) const;
  35.     virtual void printOn(ostream& strm) const;
  36.     virtual const Class* species() const;
  37. };
  38.  
  39. #endif
  40.