home *** CD-ROM | disk | FTP | other *** search
- #ifndef RANGE_HXX
- #define RANGE_HXX
-
-
- /* Range.h -- header file for class Range
-
- THIS SOFTWARE FITS THE DESCRIPTION IN THE U.S. COPYRIGHT ACT OF A
- "UNITED STATES GOVERNMENT WORK". IT WAS WRITTEN AS A PART OF THE
- AUTHOR'S OFFICIAL DUTIES AS A GOVERNMENT EMPLOYEE. THIS MEANS IT
- CANNOT BE COPYRIGHTED. THIS SOFTWARE IS FREELY AVAILABLE TO THE
- PUBLIC FOR USE WITHOUT A COPYRIGHT NOTICE, AND THERE ARE NO
- RESTRICTIONS ON ITS USE, NOW OR SUBSEQUENTLY.
-
- Author:
- C. J. Eppich
- Computer Systems Laboratory, DCRT
- National Institutes of Health
- Bethesda, MD 20892
-
- $Log: Range.h,v $
- * Revision 3.0 90/05/20 00:20:57 kgorlen
- * Release for 1st edition.
- *
- * @(#)Range.hxx 1.1
- *
- */
-
- class ostream;
-
- class Range {
- public: // constructors
- Range() : first(0), len(-1) {}
- Range(int f, int l) : first(f), len(l) {}
-
- public: // operators
- void operator=(const Range& r) { first = r.first; len = r.len; }
- int operator==(const Range& r) const { return ((first == r.first) && (len == r.len)); }
- int operator!=(const Range& r) const { return !(*this==r); }
-
- public: // functions
- int firstIndex() const { return first; }
- int firstIndex(int f) { return first = f; }
- int lastIndex() const { return (first + len - 1); }
- int lastIndex(int i) { len = i - first + 1; return i; }
- int length() const { return len; }
- int length(int l) { return len = l; }
- int valid() const { return (len >= 0); }
- void printOn(ostream& strm) const;
-
- private: // data
- int first,len;
- };
-
- extern ostream& operator<< (ostream& strm, const Range& r);
-
- #endif
-