/*
interval.hh -- part of flowerlib
- (c) 1996--2006 Han-Wen Nienhuys
+ (c) 1996--2009 Han-Wen Nienhuys
*/
#ifndef INTERVAL_HH
#include <math.h>
-#include "std-string.hh"
-
#include "flower-proto.hh"
#include "drul-array.hh"
/* A T interval. This represents the closed interval [left,right].
No invariants. T must be a totally ordered ring (with division, anyway ..)
- At instantiation, the function infinity () has to be defined explicitely. */
+ At instantiation, the function infinity () has to be defined explicitly. */
template<class T>
struct Interval_t : public Drul_array<T>
{
void set_empty ();
void set_full ();
- /*
- TODO: strip hungarian suffix.
- */
bool is_empty () const
{
return at (LEFT) > at (RIGHT);
return *this;
}
- Real linear_combination (Real x) const
- {
- Drul_array<Real> da (at (LEFT), at (RIGHT));
- return ::linear_combination (da, x);
- }
+ Real linear_combination (Real x) const;
string to_string () const;
bool contains (T r) const;
at (RIGHT) = t;
}
- static int left_comparison (Interval_t<T> const &a, Interval_t<T> const &b)
+ static bool left_less (Interval_t<T> const &a, Interval_t<T> const &b)
{
- return sign (a[LEFT] - b[RIGHT]);
+ return a[LEFT] < b[LEFT];
}
};