12 #ifndef __STOUT_INTERVAL_HPP__ 13 #define __STOUT_INTERVAL_HPP__ 18 #include <boost/icl/interval.hpp> 19 #include <boost/icl/interval_set.hpp> 63 Bound(
const Type _type,
const T& _value)
64 : type(_type), value(_value) {}
81 T
lower()
const {
return data.lower(); }
84 T
upper()
const {
return data.upper(); }
94 return data == that.data;
99 return !(*
this == that);
105 template <
typename X>
107 std::ostream& stream,
110 Interval(
const boost::icl::right_open_interval<T, std::less>& _data)
116 boost::icl::right_open_interval<T, std::less> data;
120 template <
typename T>
121 std::ostream& operator<<(std::ostream& stream, const Interval<T>& interval)
123 return stream << interval.data;
127 template <
typename T>
131 if (right.type == OPEN) {
133 return boost::icl::static_interval<
134 boost::icl::right_open_interval<T, std::less>,
135 boost::icl::is_discrete<T>::value,
136 boost::icl::interval_bounds::static_open,
137 boost::icl::interval_bounds::static_right_open
141 return boost::icl::static_interval<
142 boost::icl::right_open_interval<T, std::less>,
143 boost::icl::is_discrete<T>::value,
144 boost::icl::interval_bounds::static_left_open,
145 boost::icl::interval_bounds::static_right_open
149 if (right.type == OPEN) {
151 return boost::icl::static_interval<
152 boost::icl::right_open_interval<T, std::less>,
153 boost::icl::is_discrete<T>::value,
154 boost::icl::interval_bounds::static_right_open,
155 boost::icl::interval_bounds::static_right_open
159 return boost::icl::static_interval<
160 boost::icl::right_open_interval<T, std::less>,
161 boost::icl::is_discrete<T>::value,
162 boost::icl::interval_bounds::static_closed,
163 boost::icl::interval_bounds::static_right_open
172 template <
typename T>
173 class IntervalSet :
public boost::icl::interval_set<T, std::less, Interval<T>>
213 static_cast<const Base&>(*
this),
214 static_cast<const Base&>(
set));
220 return boost::icl::intersects(static_cast<const Base&>(*
this), interval);
226 return boost::icl::intersects(
227 static_cast<const Base&>(*
this),
228 static_cast<const Base&>(
set));
234 return boost::icl::interval_count(static_cast<const Base&>(*
this));
240 return static_cast<const Base&
>(*this) ==
static_cast<const Base&
>(that);
245 return !(*
this == that);
250 static_cast<Base&
>(*this) += value;
256 static_cast<Base&
>(*this) += interval;
262 static_cast<Base&
>(*this) +=
static_cast<const Base&
>(
set);
268 static_cast<Base&
>(*this) -= value;
274 static_cast<Base&
>(*this) -= interval;
280 static_cast<Base&
>(*this) -=
static_cast<const Base&
>(
set);
286 static_cast<Base&
>(*this) &= value;
292 static_cast<Base&
>(*this) &= interval;
298 static_cast<Base&
>(*this) &=
static_cast<const Base&
>(
set);
303 template <
typename X>
305 std::ostream& stream,
309 typedef boost::icl::interval_set<T, std::less, Interval<T>> Base;
313 template <
typename T>
314 std::ostream& operator<<(std::ostream& stream, const IntervalSet<T>&
set)
316 return stream << static_cast<const typename IntervalSet<T>::Base&>(
set);
320 template <
typename T>
327 template <
typename T>
330 return set.intersects(*
this);
334 template <
typename T,
typename X>
343 template <
typename T,
typename X>
357 template <
typename T>
371 return interval.
lower();
376 return interval.
upper();
381 template <
typename T>
383 :
public interval_bound_type<right_open_interval<T, std::less>>
385 typedef interval_bound_type
type;
391 #endif // __STOUT_INTERVAL_HPP__ Definition: interval.hpp:34
bool operator!=(const Interval< T > &that) const
Definition: interval.hpp:97
IntervalSet< T > & operator+=(const Interval< T > &interval)
Definition: interval.hpp:254
bool construct(JNIEnv *env, jboolean jbool)
bool operator!=(const IntervalSet< T > &that) const
Definition: interval.hpp:243
static T lower(const Interval< T > &interval)
Definition: interval.hpp:369
Definition: interval.hpp:354
Interval< T > operator,(const Bound< T > &right) const
Definition: interval.hpp:128
IntervalSet(const Interval< T > &interval)
Definition: interval.hpp:183
bool intersects(const IntervalSet< T > &set) const
Definition: interval.hpp:224
IntervalSet(const Bound< T > &lower, const Bound< T > &upper)
Definition: interval.hpp:188
Definition: interval.hpp:28
bool operator==(const IntervalSet< T > &that) const
Definition: interval.hpp:238
IntervalSet< T > & operator-=(const Interval< T > &interval)
Definition: interval.hpp:272
IntervalSet< T > & operator+=(const T &value)
Definition: interval.hpp:248
Future< Nothing > add(const T &metric)
Definition: metrics.hpp:95
bool intersects(const Interval< T > &interval) const
Definition: interval.hpp:321
IntervalSet()
Definition: interval.hpp:176
Definition: interval.hpp:24
static Interval< T > construct(const T &lower, const T &upper)
Definition: interval.hpp:364
static Bound< T > open(const T &value)
Definition: interval.hpp:38
IntervalSet< T > operator-(const IntervalSet< T > &set, const X &x)
Definition: interval.hpp:344
T lower() const
Definition: interval.hpp:81
Interval()
Definition: interval.hpp:78
size_t intervalCount() const
Definition: interval.hpp:232
bool operator==(const Interval< T > &that) const
Definition: interval.hpp:92
IntervalSet< T > & operator&=(const IntervalSet< T > &set)
Definition: interval.hpp:296
bool contains(const IntervalSet< T > &set) const
Definition: interval.hpp:210
T upper() const
Definition: interval.hpp:84
T domain_type
Definition: interval.hpp:361
IntervalSet< T > & operator&=(const Interval< T > &interval)
Definition: interval.hpp:290
std::string upper(const std::string &s)
Definition: strings.hpp:437
IntervalSet< T > operator+(const IntervalSet< T > &set, const X &x)
Definition: interval.hpp:335
bool contains(const Interval< T > &interval) const
Definition: interval.hpp:200
IntervalSet< T > & operator+=(const IntervalSet< T > &set)
Definition: interval.hpp:260
IntervalSet< T > & operator-=(const T &value)
Definition: interval.hpp:266
IntervalSet(const T &value)
Definition: interval.hpp:178
IntervalSet< T > & operator-=(const IntervalSet< T > &set)
Definition: interval.hpp:278
interval_bound_type type
Definition: interval.hpp:385
std::less< T > domain_compare
Definition: interval.hpp:362
IntervalSet< T > & operator&=(const T &value)
Definition: interval.hpp:284
static T upper(const Interval< T > &interval)
Definition: interval.hpp:374
bool contains(const T &value) const
Definition: interval.hpp:194
interval_traits type
Definition: interval.hpp:360
static Bound< T > closed(const T &value)
Definition: interval.hpp:44
std::string lower(const std::string &s)
Definition: strings.hpp:429
std::ostream & operator<<(std::ostream &stream, const Interval< T > &interval)
Definition: interval.hpp:121
bool contains(const Resource &left, const Resource &right)
bool intersects(const Interval< T > &interval) const
Definition: interval.hpp:218