Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions include/boost/icl/concept/interval.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ typename enable_if
singleton(const typename interval_traits<Type>::domain_type& value)
{
//ASSERT: This always creates an interval with exactly one element
typedef typename interval_traits<Type>::domain_type domain_type;
typedef typename interval_traits<Type>::domain_compare domain_compare;
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(value) ));
boost::ignore_unused<domain_type, domain_compare>();

return interval_traits<Type>::construct(value, domain_next<Type>(value));
}

Expand Down Expand Up @@ -127,6 +133,8 @@ singleton(const typename interval_traits<Type>::domain_type& value)
typedef typename interval_traits<Type>::domain_compare domain_compare;
BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_less_than(value)));
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(value)));
boost::ignore_unused<domain_type, domain_compare>();

return interval_traits<Type>::construct( domain_prior<Type>(value)
Expand Down Expand Up @@ -168,6 +176,12 @@ typename enable_if
>::type
unit_trail(const typename interval_traits<Type>::domain_type& value)
{
typedef typename interval_traits<Type>::domain_type domain_type;
typedef typename interval_traits<Type>::domain_compare domain_compare;
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(value) ));
boost::ignore_unused<domain_type, domain_compare>();

return interval_traits<Type>::construct(value, domain_next<Type>(value));
}

Expand Down Expand Up @@ -202,6 +216,8 @@ unit_trail(const typename interval_traits<Type>::domain_type& value)
typedef typename interval_traits<Type>::domain_compare domain_compare;
BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_less_than(value)));
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(value)));
boost::ignore_unused<domain_type, domain_compare>();

return interval_traits<Type>::construct( domain_prior<Type>(value)
Expand Down Expand Up @@ -283,11 +299,21 @@ typename enable_if<is_static_right_open<Type>, Type>::type
hull(const typename interval_traits<Type>::domain_type& left,
const typename interval_traits<Type>::domain_type& right)
{
typedef typename interval_traits<Type>::domain_type domain_type;
typedef typename interval_traits<Type>::domain_compare domain_compare;
boost::ignore_unused<domain_type>();
if(domain_compare()(left,right))
{
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(right) ));
return construct<Type>(left, domain_next<Type>(right));
}
else
{
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(left) ));
return construct<Type>(right, domain_next<Type>(left));
}
}

template<class Type>
Expand Down Expand Up @@ -338,13 +364,17 @@ hull(const typename interval_traits<Type>::domain_type& left,
{
BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_less_than(left) ));
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(right) ));
return construct<Type>( domain_prior<Type>(left)
, domain_next<Type>(right));
}
else
{
BOOST_ASSERT((numeric_minimum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_less_than(right) ));
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(left) ));
return construct<Type>( domain_prior<Type>(right)
, domain_next<Type>(left));
}
Expand Down Expand Up @@ -400,6 +430,12 @@ enable_if< mpl::and_< mpl::or_<is_static_left_open<Type>, is_static_open<Type> >
, typename interval_traits<Type>::domain_type>::type
first(const Type& object)
{
typedef typename interval_traits<Type>::domain_type domain_type;
typedef typename interval_traits<Type>::domain_compare domain_compare;
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than(lower(object)) ));
boost::ignore_unused<domain_type, domain_compare>();

return domain_next<Type>(lower(object));
}

Expand All @@ -408,6 +444,12 @@ inline typename enable_if<is_discrete_interval<Type>,
typename interval_traits<Type>::domain_type>::type
first(const Type& object)
{
typedef typename interval_traits<Type>::domain_type domain_type;
typedef typename interval_traits<Type>::domain_compare domain_compare;
BOOST_ASSERT((numeric_maximum<domain_type, domain_compare, is_numeric<domain_type>::value>
::is_greater_than_or(lower(object), is_left_closed(object.bounds())) ));
boost::ignore_unused<domain_type, domain_compare>();

return is_left_closed(object.bounds()) ?
lower(object) :
domain_next<Type>(lower(object));
Expand Down
30 changes: 27 additions & 3 deletions include/boost/icl/detail/exclusive_less_than.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,35 @@ namespace boost{ namespace icl
template <class IntervalT>
struct exclusive_less_than
{
/** Operator <tt>operator()</tt> implements a strict weak ordering on intervals. */
/// Enables heterogeneous lookup on a domain point (C++14 std::set / Boost.Container).
typedef void is_transparent;

typedef typename interval_traits<IntervalT>::domain_type domain_type;


/** Strict partial ordering on intervals (unchanged). */
bool operator()(const IntervalT& left, const IntervalT& right)const
{
return icl::non_empty::exclusive_less(left, right);
{
return icl::non_empty::exclusive_less(left, right);
}


/** interval vs point: left lies exclusively to the left of point p. */
bool operator()(const IntervalT& left, const domain_type& p)const
{
return icl::domain_less<IntervalT>(icl::upper(left), p)
|| ( !icl::domain_less<IntervalT>(p, icl::upper(left)) // upper(left) == p
&& !icl::is_right_closed(icl::bounds(left)) ); // ... and right border open
}

/** point vs interval: point p lies exclusively to the left of right. */
bool operator()(const domain_type& p, const IntervalT& right)const
{
return icl::domain_less<IntervalT>(p, icl::lower(right))
|| ( !icl::domain_less<IntervalT>(icl::lower(right), p) // p == lower(right)
&& !icl::is_left_closed(icl::bounds(right)) ); // ... and left border open
}

};

}} // namespace boost icl
Expand Down
Loading
Loading