00001 00009 #ifndef _Q_INTERVAL_SET_HH_ 00010 #define _Q_INTERVAL_SET_HH_ 00011 00012 #include <list> 00013 #include "QMatrix.hh" 00014 #include "QInterval.hh" 00015 00016 Q_BEGIN_NAMESPACE 00017 00018 class QIntervalSet { 00019 public: 00021 QIntervalSet(); 00022 00024 QIntervalSet(const double min, const double max); 00025 00027 virtual ~QIntervalSet() {}; 00028 00030 void CloseGapsSmallerThan(const double smallestAllowedGap); 00031 00034 bool Consolidate(); 00035 00037 bool Contains(const double value) const; 00038 00040 const std::list<QInterval>& GetIntervals() const {return fIntervals;} 00041 00043 QMatrix GetMatrix(); 00044 00046 double GetMax() const 00047 {return !fIntervals.empty() ? fIntervals.back().GetMax() : 0;} 00048 00050 double GetMin() const 00051 {return !fIntervals.empty() ? fIntervals.front().GetMin() : 0;} 00052 00054 void Insert(const double min, const double max) 00055 {QInterval interval(min, max); Insert(interval);} 00056 00058 void Insert(QInterval interval); 00059 00061 double Length() const; 00062 00064 void RemoveIntervalsShorterThan(const double minimumLength); 00065 00067 void SetLowerBound(const double lowerBound); 00068 00070 void SetUpperBound(const double upperBound); 00071 00073 size_t Size() const {return fIntervals.size();} 00074 00075 protected: 00077 std::list<QInterval> fIntervals; 00078 00080 bool fIsLowerBoundSet; 00081 00083 bool fIsUpperBoundSet; 00084 00086 double fLowerBound; 00087 00089 double fUpperBound; 00090 }; 00091 00092 Q_END_NAMESPACE 00093 00094 #endif