11 : fIsLowerBoundSet(false), fIsUpperBoundSet(false)
16 : fIsLowerBoundSet(false), fIsUpperBoundSet(false)
34 list<QInterval>::iterator currentInterval =
fIntervals.begin();
35 list<QInterval>::iterator nextInterval = currentInterval;
39 = nextInterval->GetMin() - currentInterval->GetMax();
40 if (gap <= smallestAllowedGap) {
42 currentInterval->SetMax(nextInterval->GetMax());
48 nextInterval = currentInterval;
55 if (gap <= smallestAllowedGap) {
62 if (gap <= smallestAllowedGap) {
71 bool foundOverlappedIntervals =
false;
73 list<QInterval>::iterator currentInterval =
fIntervals.begin();
74 while (foundOverlappedIntervals ==
false
76 list<QInterval>::iterator nextInterval = currentInterval;
79 if (currentInterval->GetMax() >= nextInterval->GetMin()) {
80 foundOverlappedIntervals =
true;
81 currentInterval->SetMax(
82 std::max(currentInterval->GetMax(), nextInterval->GetMax())
91 if (foundOverlappedIntervals) {
95 return foundOverlappedIntervals;
100 bool contains =
false;
102 list<QInterval>::const_iterator currentInterval =
fIntervals.begin();
104 && value >= currentInterval->GetMin()) {
105 contains = currentInterval->Contains(value);
116 std::list<QInterval>::const_iterator interval;
120 matrix(row, 0) = interval->GetMin();
121 matrix(row, 1) = interval->GetMax();
151 list<QInterval>::iterator insertionPoint
157 bool intersectsPreceeding
159 if (intersectsPreceeding) {
169 else if (insertionPoint ==
fIntervals.begin()) {
170 bool intersectsFollowing
172 if (intersectsFollowing) {
187 list<QInterval>::iterator preceedingInterval = insertionPoint;
188 --preceedingInterval;
189 bool intersectsPreceeding
190 = interval.
GetMin() <= preceedingInterval->GetMax();
191 bool intersectsFollowing
192 = interval.
GetMax() >= insertionPoint->GetMin();
193 if (!intersectsPreceeding && !intersectsFollowing) {
198 else if (intersectsPreceeding && !intersectsFollowing) {
200 preceedingInterval->SetMax(
203 preceedingInterval->GetMax()
207 else if (intersectsFollowing && !intersectsPreceeding) {
209 insertionPoint->SetMin(
212 insertionPoint->GetMin()
215 insertionPoint->SetMax(
218 insertionPoint->GetMax()
222 else if (intersectsPreceeding && intersectsFollowing) {
224 preceedingInterval->SetMax(
227 insertionPoint->GetMax()
241 for (list<QInterval>::const_iterator interval =
fIntervals.begin();
244 length += interval->Length();
251 list<QInterval>::iterator currentInterval =
fIntervals.begin();
253 if (currentInterval->Length() <= minimumLength) {
254 currentInterval =
fIntervals.erase(currentInterval);
298 std::list<QInterval>::const_iterator it;
300 o <<
"\t" << it->GetMin() <<
" - " << it->GetMax() << std::endl;
#define Q_BEGIN_NAMESPACE
QObjectImp(Diana::QIntervalSet)
double min(const Diana::QVector &v)
void RemoveIntervalsShorterThan(const double minimumLength)
Remove intervals shorter than minimumLength.
std::list< QInterval > fIntervals
Intervals in the set.
double Length() const
Get total length of all intervals in the set.
void CloseGapsSmallerThan(const double smallestAllowedGap)
Close gaps smaller than smallestAllowedGap.
void Dump(std::ostream &o) const
Dump the intervals to a stream.
void SetLowerBound(const double lowerBound)
Set lower bound on the contents of the set.
QIntervalSet()
Default constructor.
QMatrix GetMatrix()
Get matrix containing the intervals.
double fUpperBound
Upper bound on the contents of the set.
double GetMax() const
Get maximum of all intervals in the set.
size_t Size() const
Get number of intervals in the set.
void Insert(const double min, const double max)
Add interval to the set.
bool Contains(const double value) const
Return whether the interval set contains a value.
double GetMin() const
Get minimum of all intervals in the set.
void SetUpperBound(const double upperBound)
Set upper bound on the contents of the set.
bool Consolidate()
Consolidate overlapped intervals.
bool fIsLowerBoundSet
Whether or not a lower bound is set.
bool fIsUpperBoundSet
Whether or not an upper bound is set.
double fLowerBound
Lower bound on the contents of the set.
Interval of real numbers.
void SetMin(const double min)
Set minimum of the interval.
void SetMax(const double max)
Set maximum of the interval.
double GetMax() const
Get maximum of interval.
double GetMin() const
Get minimum of interval.
Interface for matrices in Diana analysis.