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 00033 bool Contains(const double value) const; 00034 00036 const std::list<QInterval>& GetIntervals() const {return fIntervals;} 00037 00039 QMatrix GetMatrix(); 00040 00042 double GetMax() const 00043 {return !fIntervals.empty() ? fIntervals.back().GetMax() : 0;} 00044 00046 double GetMin() const 00047 {return !fIntervals.empty() ? fIntervals.front().GetMin() : 0;} 00048 00050 void Insert(const double min, const double max) 00051 {QInterval interval(min, max); Insert(interval);} 00052 00054 void Insert(QInterval interval); 00055 00057 double Length() const; 00058 00060 void RemoveIntervalsShorterThan(const double minimumLength); 00061 00063 void SetLowerBound(const double lowerBound); 00064 00066 void SetUpperBound(const double upperBound); 00067 00069 size_t Size() const {return fIntervals.size();} 00070 00071 protected: 00073 std::list<QInterval> fIntervals; 00074 00076 bool fIsLowerBoundSet; 00077 00079 bool fIsUpperBoundSet; 00080 00082 double fLowerBound; 00083 00085 double fUpperBound; 00086 }; 00087 00088 Q_END_NAMESPACE 00089 00090 #endif