00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef __INTERVAL_H__
00036 #define __INTERVAL_H__
00037
00038
00039 #include "PackDef.h"
00040
00041
00042 #include <iostream.h>
00043
00044
00045 class Interval
00046 {
00047 public:
00048
00049
00050
00051
00052
00053
00054
00055
00056 Interval();
00057 Interval(double aLeftPoint,
00058 double aRightPoint,
00059 int aLeftStatus = 0,
00060 int aRightStatus = 0);
00061 Interval(const Interval & aInterval);
00062 ~Interval();
00063
00064
00065
00066
00067
00068
00069 Interval & operator=(const Interval & aInterval);
00070
00071
00072
00073
00074
00075
00076 Bool operator==(const Interval & aInterval) const;
00077 Bool operator!=(const Interval & aInterval) const;
00078
00079
00080
00081
00082
00083
00084 void Print() const;
00085
00086
00087
00088
00089
00090
00091 double GetLeftPoint() const { return mLeftPoint; }
00092 double GetRightPoint() const { return mRightPoint; }
00093 double GetLength() const { return (mRightPoint - mLeftPoint); }
00094 int GetLeftStatus() const { return mLeftStatus; }
00095 int GetRightStatus() const { return mRightStatus; }
00096
00097
00098
00099
00100
00101
00102 void SetLeftPoint(double aLeftPoint) { mLeftPoint = aLeftPoint; }
00103 void SetRightPoint(double aRightPoint) { mRightPoint = aRightPoint; }
00104 void SetLeftStatus(int aLeftStatus) { mLeftStatus = aLeftStatus; }
00105 void SetRightStatus(int aRightStatus) { mRightStatus = aRightStatus; }
00106
00107
00108
00109
00110
00111
00112 Bool IsEmpty() const
00113 { return ((*this).GetLength() == 0 ? TRUE : FALSE); }
00114
00115
00116
00117
00118
00119
00120
00121 friend Bool NextTo(const Interval& Lhs, const Interval& Rhs);
00122
00123
00124
00125
00126
00127
00128 friend Interval
00129 Union(const Interval& Lhs, const Interval& Rhs);
00130
00131
00132
00133
00134
00135
00136 friend Interval
00137 Intersect(const Interval & Lhs, const Interval & Rhs);
00138 friend int
00139 compare(const Interval & Lhs, const Interval & Rhs);
00140 friend ostream &
00141 operator<<(ostream & aOstream, const Interval & aInterval);
00142 friend istream &
00143 operator>>(istream & aIstream, Interval & aInterval);
00144
00145
00146 private:
00147
00148 double mLeftPoint;
00149 double mRightPoint;
00150 int mLeftStatus;
00151 int mRightStatus;
00152 };
00153
00154
00155 #endif