/*
interval.hh -- part of flowerlib
- (c) 1996--2005 Han-Wen Nienhuys
+ (c) 1996--2006 Han-Wen Nienhuys
*/
#ifndef INTERVAL_HH
#define INTERVAL_HH
+#include <math.h>
+
#include "flower-proto.hh"
#include "drul-array.hh"
{
set_empty ();
}
+ Interval_t (Drul_array<T> const &src)
+ : Drul_array<T> (src)
+ {
+ }
+
Interval_t (T m, T M) : Drul_array<T> (m, M)
{
}
}
String to_string () const;
- bool contains (T r);
+ bool contains (T r) const;
void negate ()
{
T r = -elem (LEFT);
elem_ref (LEFT) = elem (RIGHT);
elem_ref (RIGHT) = t;
}
+
+ static int left_comparison (Interval_t<T> const &a, Interval_t<T> const &b)
+ {
+ return sign (a[LEFT] - b[RIGHT]);
+ }
};
/**
return (elem (LEFT) + elem (RIGHT)) / T (2);
}
-// again? see flower-proto.hh
typedef Interval_t<Real> Interval;
typedef Interval_t<int> Slice; // weird name