Added boost header
This commit is contained in:
45
test/external/boost/icl/concept/comparable.hpp
vendored
Normal file
45
test/external/boost/icl/concept/comparable.hpp
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_COMPARABLE_HPP_JOFA_100921
|
||||
#define BOOST_ICL_CONCEPT_COMPARABLE_HPP_JOFA_100921
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/icl/type_traits/is_icl_container.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Equivalences and Orderings<Comparable>
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_icl_container<Type>, bool>::type
|
||||
operator != (const Type& left, const Type& right)
|
||||
{ return !(left == right); }
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_icl_container<Type>, bool>::type
|
||||
operator > (const Type& left, const Type& right)
|
||||
{ return right < left; }
|
||||
|
||||
/** Partial ordering which is induced by Compare */
|
||||
template<class Type>
|
||||
inline typename enable_if<is_icl_container<Type>, bool>::type
|
||||
operator <= (const Type& left, const Type& right)
|
||||
{ return !(left > right); }
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_icl_container<Type>, bool>::type
|
||||
operator >= (const Type& left, const Type& right)
|
||||
{ return !(left < right); }
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
87
test/external/boost/icl/concept/container.hpp
vendored
Normal file
87
test/external/boost/icl/concept/container.hpp
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_CONTAINER_HPP_JOFA_100923
|
||||
#define BOOST_ICL_CONCEPT_CONTAINER_HPP_JOFA_100923
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/icl/type_traits/is_container.hpp>
|
||||
#include <boost/icl/type_traits/is_icl_container.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Emptieness
|
||||
//==============================================================================
|
||||
|
||||
/** Tests if the container is empty.
|
||||
Complexity: constant. */
|
||||
template<class Type>
|
||||
typename enable_if<is_container<Type>, bool>::type
|
||||
is_empty(const Type& object)
|
||||
{
|
||||
return object.begin()==object.end();
|
||||
}
|
||||
|
||||
|
||||
/** All content of the container is dropped.
|
||||
Complexity: linear. */
|
||||
template<class Type>
|
||||
typename enable_if<is_container<Type>, void>::type
|
||||
clear(Type& object)
|
||||
{
|
||||
object.erase(object.begin(), object.end());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Size
|
||||
//==============================================================================
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<mpl::and_< is_container<Type>
|
||||
, mpl::not_<is_icl_container<Type> > >
|
||||
, std::size_t>::type
|
||||
iterative_size(const Type& object)
|
||||
{
|
||||
return object.size();
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Swap
|
||||
//==============================================================================
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_container<Type>, void>::type
|
||||
swap(Type& left, Type& right)
|
||||
{
|
||||
left.swap(right);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Iteration
|
||||
//==============================================================================
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_container<Type>, typename Type::iterator>::type
|
||||
cyclic_prior(Type& object, typename Type::iterator it_)
|
||||
{ return it_ == object.begin() ? object.end() : --it_; }
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_container<Type>, typename Type::const_iterator>::type
|
||||
cyclic_prior(const Type& object, typename Type::const_iterator it_)
|
||||
{ return it_ == object.begin() ? object.end() : --it_; }
|
||||
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
506
test/external/boost/icl/concept/element_associator.hpp
vendored
Normal file
506
test/external/boost/icl/concept/element_associator.hpp
vendored
Normal file
@@ -0,0 +1,506 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_ELEMENT_ASSOCIATOR_HPP_JOFA_100921
|
||||
#define BOOST_ICL_CONCEPT_ELEMENT_ASSOCIATOR_HPP_JOFA_100921
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/icl/type_traits/is_associative_element_container.hpp>
|
||||
#include <boost/icl/type_traits/is_key_container_of.hpp>
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
#include <boost/icl/detail/subset_comparer.hpp>
|
||||
#include <boost/icl/concept/element_set.hpp>
|
||||
#include <boost/icl/concept/element_map.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Size
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<is_element_container<Type>, std::size_t>::type
|
||||
iterative_size(const Type& object)
|
||||
{
|
||||
return object.size();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
|
||||
size(const Type& object)
|
||||
{
|
||||
return icl::iterative_size(object);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
|
||||
cardinality(const Type& object)
|
||||
{
|
||||
return icl::iterative_size(object);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Containedness<ElementSet|ElementMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool within(c P&, c T&) T:{s}|{m} P:{e}|{i} fragment_types|key_types
|
||||
//------------------------------------------------------------------------------
|
||||
/** Checks if a key is in the associative container */
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, bool>::type
|
||||
within(const typename Type::key_type& key, const Type& super)
|
||||
{
|
||||
return !(super.find(key) == super.end());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool within(c P&, c T&) T:{s}|{m} P:{s'} fragment_types|key_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class SubT, class SuperT>
|
||||
typename enable_if<mpl::and_< is_associative_element_container<SuperT>
|
||||
, is_key_container_of<SubT, SuperT> >,
|
||||
bool>::type
|
||||
within(const SubT& sub, const SuperT& super)
|
||||
{
|
||||
if(icl::is_empty(sub)) return true;
|
||||
if(icl::is_empty(super)) return false;
|
||||
if(icl::size(super) < icl::size(sub)) return false;
|
||||
|
||||
typename SubT::const_iterator common_lwb_;
|
||||
typename SubT::const_iterator common_upb_;
|
||||
if(!Set::common_range(common_lwb_, common_upb_, sub, super))
|
||||
return false;
|
||||
|
||||
typename SubT::const_iterator sub_ = sub.begin();
|
||||
typename SuperT::const_iterator super_;
|
||||
while(sub_ != sub.end())
|
||||
{
|
||||
super_ = super.find(key_value<SubT>(sub_));
|
||||
if(super_ == super.end())
|
||||
return false;
|
||||
else if(!co_equal(sub_, super_, &sub, &super))
|
||||
return false;
|
||||
|
||||
++sub_;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{s}|{m} P:{e}|{i} fragment_types|key_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, bool>::type
|
||||
contains(const Type& super, const typename Type::key_type& key)
|
||||
{
|
||||
return icl::within(key, super);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{s}|{m} P:{s'} fragment_types|key_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class SubT, class SuperT>
|
||||
typename enable_if<mpl::and_< is_associative_element_container<SuperT>
|
||||
, is_key_container_of<SubT, SuperT> >,
|
||||
bool>::type
|
||||
contains(const SuperT& super, const SubT& sub)
|
||||
{
|
||||
return icl::within(sub, super);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Equivalences and Orderings
|
||||
//==============================================================================
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996) //'std::equal': Function call with parameters that may be unsafe - this call relies on the caller to check that the passed values are correct. To disable this warning, use -D_SCL_SECURE_NO_WARNINGS. See documentation on how to use Visual C++ 'Checked Iterators'
|
||||
#endif // I do guarantee here that I am using the parameters correctly :)
|
||||
|
||||
/** Standard equality, which is lexicographical equality of the sets
|
||||
as sequences, that are given by their Compare order. */
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, bool>::type
|
||||
operator == (const Type& left, const Type& right)
|
||||
{
|
||||
return left.size() == right.size()
|
||||
&& std::equal(left.begin(), left.end(), right.begin());
|
||||
}
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, bool>::type
|
||||
is_element_equal(const Type& left, const Type& right)
|
||||
{ return left == right; }
|
||||
|
||||
|
||||
/* Strict weak less ordering which is given by the Compare order */
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, bool>::type
|
||||
operator < (const Type& left, const Type& right)
|
||||
{
|
||||
return std::lexicographical_compare(
|
||||
left.begin(), left.end(), right.begin(), right.end(),
|
||||
typename Type::element_compare()
|
||||
);
|
||||
}
|
||||
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_concept_equivalent<is_element_container,LeftT, RightT>,
|
||||
int>::type
|
||||
inclusion_compare(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return Set::subset_compare(left, right,
|
||||
left.begin(), left.end(),
|
||||
right.begin(), right.end());
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Addition
|
||||
//==============================================================================
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator += (Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
return icl::add(object, operand);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator + (Type object, const typename Type::value_type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator + (const typename Type::value_type& operand, Type object)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator += (Type& object, const Type& operand)
|
||||
{
|
||||
if(&object == &operand)
|
||||
return object;
|
||||
|
||||
typename Type::iterator prior_ = object.end();
|
||||
ICL_const_FORALL(typename Type, it_, operand)
|
||||
prior_ = icl::add(object, prior_, *it_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator + (Type object, const Type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator |= (Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
return icl::add(object, operand);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator | (Type object, const typename Type::value_type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator | (const typename Type::value_type& operand, Type object)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator |= (Type& object, const Type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator | (Type object, const Type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Insertion
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- V insert(T&, c P&) T:{s}|{m} P:{e}|{b} fragment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>,
|
||||
std::pair<typename Type::iterator,bool> >::type
|
||||
insert(Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
return object.insert(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>,
|
||||
typename Type::iterator>::type
|
||||
insert(Type& object, typename Type::iterator prior,
|
||||
const typename Type::value_type& operand)
|
||||
{
|
||||
return object.insert(prior, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T insert(T&, c T&) T:{s m} map fragment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
insert(Type& object, const Type& addend)
|
||||
{
|
||||
typedef typename Type::iterator iterator;
|
||||
|
||||
iterator prior_ = object.end();
|
||||
ICL_const_FORALL(typename Type, elem_, addend)
|
||||
icl::insert(object, prior_, *elem_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Erasure
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, typename Type::size_type>::type
|
||||
erase(Type& object, const typename Type::key_type& key_value)
|
||||
{
|
||||
typedef typename Type::size_type size_type;
|
||||
typename Type::iterator it_ = object.find(key_value);
|
||||
if(it_ != object.end())
|
||||
{
|
||||
object.erase(it_);
|
||||
return unit_element<size_type>::value();
|
||||
}
|
||||
return identity_element<size_type>::value();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
erase(Type& object, const Type& erasure)
|
||||
{
|
||||
ICL_const_FORALL(typename Type, elem_, erasure)
|
||||
icl::erase(object, *elem_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Subtraction<ElementSet|ElementMap>
|
||||
//==============================================================================
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator -= (Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
return icl::subtract(object, operand);
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator - (Type object, const typename Type::value_type& operand)
|
||||
{
|
||||
return object -= operand;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator -= (Type& object, const Type& subtrahend)
|
||||
{
|
||||
ICL_const_FORALL(typename Type, it_, subtrahend)
|
||||
icl::subtract(object, *it_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator - (Type object, const Type& subtrahend)
|
||||
{
|
||||
return object -= subtrahend;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- void add_intersection(T&, c T&, c P&) T:{s}{m} P:{e}{e} key_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::key_type& operand)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator it_ = object.find(operand);
|
||||
if(it_ != object.end())
|
||||
icl::add(section, *it_);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- void add_intersection(T&, c T&, c P&) T:{s}{m} P:{s}{s} set key_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename key_container_type_of<Type>::type& operand)
|
||||
{
|
||||
typedef typename key_container_type_of<Type>::type key_container_type;
|
||||
typedef typename key_container_type::const_iterator const_iterator;
|
||||
const_iterator common_lwb_, common_upb_;
|
||||
if(!Set::common_range(common_lwb_, common_upb_, operand, object))
|
||||
return;
|
||||
|
||||
const_iterator sec_ = common_lwb_;
|
||||
while(sec_ != common_upb_)
|
||||
add_intersection(section, object, *sec_++);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- Intersection<ElementMap|ElementSet>
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator &= (Type& object, const typename Type::key_type& operand)
|
||||
{
|
||||
Type section;
|
||||
add_intersection(section, object, operand);
|
||||
object.swap(section);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator & (Type object, const typename Type::key_type& operand)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator & (const typename Type::key_type& operand, Type object)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
operator &= (Type& object, const typename key_container_type_of<Type>::type& operand)
|
||||
{
|
||||
Type section;
|
||||
add_intersection(section, object, operand);
|
||||
object.swap(section);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator & (Type object, const Type& operand)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class Type, class CoType>
|
||||
inline typename enable_if<is_associative_element_container<Type>, bool>::type
|
||||
disjoint(const Type& left, const Type& right)
|
||||
{
|
||||
return !intersects(left, right);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Symmetric difference<ElementSet|ElementMap>
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator ^ (Type object, const typename Type::value_type& operand)
|
||||
{
|
||||
return icl::flip(object, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator ^ (const typename Type::value_type& operand, Type object)
|
||||
{
|
||||
return icl::flip(object, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type
|
||||
operator ^ (Type object, const Type& operand)
|
||||
{
|
||||
return object ^= operand;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Manipulation by predicates
|
||||
//==============================================================================
|
||||
template<class Type, class Predicate>
|
||||
typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
erase_if(const Predicate& pred, Type& object)
|
||||
{
|
||||
typename Type::iterator it_ = object.begin();
|
||||
while(it_ != object.end())
|
||||
if(pred(*it_))
|
||||
icl::erase(object, it_++);
|
||||
else ++it_;
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type, class Predicate>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
add_if(const Predicate& pred, Type& object, const Type& src)
|
||||
{
|
||||
typename Type::const_iterator it_ = src.begin();
|
||||
while(it_ != src.end())
|
||||
if(pred(*it_))
|
||||
icl::add(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type, class Predicate>
|
||||
inline typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
assign_if(const Predicate& pred, Type& object, const Type& src)
|
||||
{
|
||||
icl::clear(object);
|
||||
return add_if(object, src, pred);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
480
test/external/boost/icl/concept/element_map.hpp
vendored
Normal file
480
test/external/boost/icl/concept/element_map.hpp
vendored
Normal file
@@ -0,0 +1,480 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_ELEMENT_MAP_HPP_JOFA_100921
|
||||
#define BOOST_ICL_CONCEPT_ELEMENT_MAP_HPP_JOFA_100921
|
||||
|
||||
#include <boost/mpl/and.hpp>
|
||||
#include <boost/mpl/not.hpp>
|
||||
#include <boost/icl/detail/on_absorbtion.hpp>
|
||||
#include <boost/icl/type_traits/is_total.hpp>
|
||||
#include <boost/icl/type_traits/absorbs_identities.hpp>
|
||||
#include <boost/icl/type_traits/is_associative_element_container.hpp>
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
|
||||
#include <boost/icl/concept/map_value.hpp>
|
||||
#include <boost/icl/detail/map_algo.hpp>
|
||||
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//NOTE: Some forward declarations are needed by some compilers.
|
||||
template<class Type, class Predicate>
|
||||
typename enable_if<is_associative_element_container<Type>, Type>::type&
|
||||
erase_if(const Predicate& pred, Type& object);
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Containedness<ElementMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool within(c P&, c T&) T:{m} P:{b} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
/** Checks if a key-value pair is in the map */
|
||||
template<class Type>
|
||||
typename enable_if<is_element_map<Type>, bool>::type
|
||||
within(const typename Type::element_type& value_pair, const Type& super)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator found_ = super.find(value_pair.first);
|
||||
return found_ != super.end() && (*found_).second == value_pair.second;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{m} P:{b} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_element_map<Type>, bool>::type
|
||||
contains(const Type& super, const typename Type::element_type& value_pair)
|
||||
{
|
||||
return icl::within(value_pair, super);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Equivalences and Orderings<ElementMap>
|
||||
//==============================================================================
|
||||
|
||||
/** Protonic equality is equality on all elements that do not carry an identity element as content. */
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, bool>::type
|
||||
is_distinct_equal(const Type& lhs, const Type& rhs)
|
||||
{
|
||||
return Map::lexicographical_distinct_equal(lhs, rhs);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Addition<ElementMap>
|
||||
//==============================================================================
|
||||
/** \c add inserts \c value_pair into the map if it's key does
|
||||
not exist in the map.
|
||||
If \c value_pairs's key value exists in the map, it's data
|
||||
value is added to the data value already found in the map. */
|
||||
template <class Type>
|
||||
typename enable_if<is_element_map<Type>, Type>::type&
|
||||
add(Type& object, const typename Type::value_type& value_pair)
|
||||
{
|
||||
return object.add(value_pair);
|
||||
}
|
||||
|
||||
/** \c add add \c value_pair into the map using \c prior as a hint to
|
||||
insert \c value_pair after the position \c prior is pointing to. */
|
||||
template <class Type>
|
||||
typename enable_if<is_element_map<Type>, typename Type::iterator>::type
|
||||
add(Type& object, typename Type::iterator prior,
|
||||
const typename Type::value_type& value_pair)
|
||||
{
|
||||
return object.add(prior, value_pair);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Erasure
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& erase(T&, c P&) T:{m} P:{b} fragment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template <class Type>
|
||||
typename enable_if<is_element_map<Type>, typename Type::size_type>::type
|
||||
erase(Type& object, const typename Type::element_type& value_pair)
|
||||
{
|
||||
typedef typename Type::size_type size_type;
|
||||
typedef typename Type::iterator iterator;
|
||||
typedef typename Type::on_identity_absorbtion on_identity_absorbtion;
|
||||
|
||||
if(on_identity_absorbtion::is_absorbable(value_pair.second))
|
||||
return identity_element<size_type>::value();
|
||||
|
||||
iterator it_ = object.find(value_pair.first);
|
||||
if(it_ != object.end() && value_pair.second == (*it_).second)
|
||||
{
|
||||
object.erase(it_);
|
||||
return unit_element<size_type>::value();
|
||||
}
|
||||
|
||||
return identity_element<size_type>::value();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_element_map<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::set_type& erasure)
|
||||
{
|
||||
typedef typename Type::set_type set_type;
|
||||
ICL_const_FORALL(typename set_type, elem_, erasure)
|
||||
icl::erase(object, *elem_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Subtraction
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{m} P:{b} fragment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template <class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return object.subtract(operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{m} P:{e} key_type
|
||||
//------------------------------------------------------------------------------
|
||||
template <class Type>
|
||||
typename enable_if<is_element_map<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::domain_type& key_value)
|
||||
{
|
||||
return icl::erase(object, key_value);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{m} P:{s} set key_type
|
||||
//------------------------------------------------------------------------------
|
||||
template <class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type&
|
||||
operator -= (Type& object, const typename Type::set_type& operand)
|
||||
{
|
||||
typedef typename Type::set_type set_type;
|
||||
typedef typename set_type::const_iterator co_iterator;
|
||||
typedef typename Type::iterator iterator;
|
||||
|
||||
co_iterator common_lwb_, common_upb_;
|
||||
if(!Set::common_range(common_lwb_, common_upb_, operand, object))
|
||||
return object;
|
||||
|
||||
co_iterator it_ = common_lwb_;
|
||||
iterator common_;
|
||||
|
||||
while(it_ != common_upb_)
|
||||
object.erase(*it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type
|
||||
operator - (Type object, const typename Type::set_type& subtrahend)
|
||||
{
|
||||
return object -= subtrahend;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Selective Update<ElementMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& set_at(T&, c P&) T:{m} P:{b}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type&
|
||||
set_at(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
typedef typename Type::iterator iterator;
|
||||
typedef typename Type::codomain_combine codomain_combine;
|
||||
typedef on_absorbtion<Type,codomain_combine,absorbs_identities<Type>::value>
|
||||
on_identity_absorbtion;
|
||||
|
||||
if(!on_identity_absorbtion::is_absorbable(operand.second))
|
||||
{
|
||||
std::pair<iterator,bool> insertion = object.insert(operand);
|
||||
if(!insertion.second)
|
||||
insertion->second = operand.second;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::element_type& operand)
|
||||
{
|
||||
object.add_intersection(section, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object, const Type& operand)
|
||||
{
|
||||
ICL_const_FORALL(typename Type, it_, operand)
|
||||
icl::add_intersection(section, object, *it_);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op &=(T&, c P&) T:{m} P:{b m} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<mpl::and_<is_element_map<Type>, is_total<Type> >, Type>::type&
|
||||
operator &=(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
object.add(operand);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<mpl::and_<is_element_map<Type>, mpl::not_<is_total<Type> > >, Type>::type&
|
||||
operator &=(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
Type section;
|
||||
icl::add_intersection(section, object, operand);
|
||||
object.swap(section);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type
|
||||
operator & (Type object, const typename Type::element_type& operand)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type
|
||||
operator & (const typename Type::element_type& operand, Type object)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<mpl::and_<is_element_map<Type>, is_total<Type> >, Type>::type&
|
||||
operator &=(Type& object, const Type& operand)
|
||||
{
|
||||
object += operand;
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<mpl::and_<is_element_map<Type>, mpl::not_<is_total<Type> > >, Type>::type&
|
||||
operator &=(Type& object, const Type& operand)
|
||||
{
|
||||
Type section;
|
||||
icl::add_intersection(section, object, operand);
|
||||
object.swap(section);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type
|
||||
operator & (Type object, const typename Type::key_object_type& operand)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type
|
||||
operator & (const typename Type::key_object_type& operand, Type object)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection<ElementMap> bool intersects(x,y)
|
||||
//==============================================================================
|
||||
template<class Type, class CoType>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, is_total<Type> >
|
||||
, bool>::type
|
||||
intersects(const Type&, const CoType&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
intersects(const Type& object, const typename Type::domain_type& operand)
|
||||
{
|
||||
return icl::contains(object, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
intersects(const Type& object, const typename Type::set_type& operand)
|
||||
{
|
||||
if(object.iterative_size() < operand.iterative_size())
|
||||
return Map::intersects(object, operand);
|
||||
else
|
||||
return Map::intersects(operand, object);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
intersects(const Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
Type intersection;
|
||||
icl::add_intersection(intersection, object, operand);
|
||||
return !intersection.empty();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
intersects(const Type& object, const Type& operand)
|
||||
{
|
||||
if(object.iterative_size() < operand.iterative_size())
|
||||
return Map::intersects(object, operand);
|
||||
else
|
||||
return Map::intersects(operand, object);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Symmetric difference
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>, Type>::type&
|
||||
flip(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return object.flip(operand);
|
||||
}
|
||||
|
||||
template<class Type, class CoType>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, is_total<Type>
|
||||
, absorbs_identities<Type> >
|
||||
, Type>::type&
|
||||
operator ^= (Type& object, const CoType&)
|
||||
{
|
||||
icl::clear(object);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, is_total<Type>
|
||||
, mpl::not_<absorbs_identities<Type> > >
|
||||
, Type>::type&
|
||||
operator ^= (Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return object.flip(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, is_total<Type>
|
||||
, mpl::not_<absorbs_identities<Type> > >
|
||||
, Type>::type&
|
||||
operator ^= (Type& object, const Type& operand)
|
||||
{
|
||||
ICL_const_FORALL(typename Type, it_, operand)
|
||||
icl::flip(object, *it_);
|
||||
|
||||
ICL_FORALL(typename Type, it2_, object)
|
||||
(*it2_).second = identity_element<typename Type::codomain_type>::value();
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, Type>::type&
|
||||
operator ^= (Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::flip(object, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if< mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, Type>::type&
|
||||
operator ^= (Type& object, const Type& operand)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator it_ = operand.begin();
|
||||
while(it_ != operand.end())
|
||||
icl::flip(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Set selection
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_map<Type>,
|
||||
typename Type::set_type>::type&
|
||||
domain(typename Type::set_type& domain_set, const Type& object)
|
||||
{
|
||||
typename Type::set_type::iterator prior_ = domain_set.end();
|
||||
typename Type::const_iterator it_ = object.begin();
|
||||
while(it_ != object.end())
|
||||
prior_ = domain_set.insert(prior_, (*it_++).first);
|
||||
|
||||
return domain_set;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Neutron absorbtion
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<mpl::and_< is_element_map<Type>
|
||||
, absorbs_identities<Type> >, Type>::type&
|
||||
absorb_identities(Type& object)
|
||||
{
|
||||
typedef typename Type::element_type element_type;
|
||||
return icl::erase_if(content_is_identity_element<element_type>(), object);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<mpl::and_< is_element_map<Type>
|
||||
, mpl::not_<absorbs_identities<Type> > >
|
||||
, Type>::type&
|
||||
absorb_identities(Type&){}
|
||||
|
||||
//==============================================================================
|
||||
//= Streaming<ElementMap>
|
||||
//==============================================================================
|
||||
template<class CharType, class CharTraits, class Type>
|
||||
inline typename enable_if<is_element_map<Type>, std::basic_ostream<CharType, CharTraits> >::type&
|
||||
operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
|
||||
{
|
||||
stream << "{";
|
||||
ICL_const_FORALL(typename Type, it, object)
|
||||
stream << "(" << it->first << "->" << it->second << ")";
|
||||
|
||||
return stream << "}";
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
134
test/external/boost/icl/concept/element_set.hpp
vendored
Normal file
134
test/external/boost/icl/concept/element_set.hpp
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_ELEMENT_SET_HPP_JOFA_100921
|
||||
#define BOOST_ICL_CONCEPT_ELEMENT_SET_HPP_JOFA_100921
|
||||
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
#include <boost/icl/concept/set_value.hpp>
|
||||
#include <boost/icl/detail/std_set.hpp>
|
||||
#include <boost/icl/detail/set_algo.hpp>
|
||||
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Addition<ElementSet>
|
||||
//==============================================================================
|
||||
/** \c add inserts \c operand into the map if it's key does
|
||||
not exist in the map.
|
||||
If \c operands's key value exists in the map, it's data
|
||||
value is added to the data value already found in the map. */
|
||||
template <class Type>
|
||||
typename enable_if<is_element_set<Type>, Type>::type&
|
||||
add(Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
object.insert(operand);
|
||||
return object;
|
||||
}
|
||||
|
||||
/** \c add add \c operand into the map using \c prior as a hint to
|
||||
insert \c operand after the position \c prior is pointing to. */
|
||||
template <class Type>
|
||||
typename enable_if<is_element_set<Type>, typename Type::iterator>::type
|
||||
add(Type& object, typename Type::iterator prior,
|
||||
const typename Type::value_type& operand)
|
||||
{
|
||||
return object.insert(prior, operand);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Subtraction
|
||||
//==============================================================================
|
||||
/** If the \c operand's key value is in the map, it's data value is
|
||||
subtraced from the data value stored in the map. */
|
||||
template<class Type>
|
||||
typename enable_if<is_element_set<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
object.erase(operand);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_set<Type>, bool>::type
|
||||
intersects(const Type& object, const typename Type::key_type& operand)
|
||||
{
|
||||
return !(object.find(operand) == object.end());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_set<Type>, bool>::type
|
||||
intersects(const Type& object, const Type& operand)
|
||||
{
|
||||
if(iterative_size(object) < iterative_size(operand))
|
||||
return Set::intersects(object, operand);
|
||||
else
|
||||
return Set::intersects(operand, object);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Symmetric difference
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_set<Type>, Type>::type&
|
||||
flip(Type& object, const typename Type::value_type& operand)
|
||||
{
|
||||
typedef typename Type::iterator iterator;
|
||||
std::pair<iterator,bool> insertion = object.insert(operand);
|
||||
if(!insertion.second)
|
||||
object.erase(insertion.first);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_set<Type>, Type>::type&
|
||||
operator ^= (Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::flip(object, operand);
|
||||
}
|
||||
|
||||
/** Symmetric subtract map \c x2 and \c *this.
|
||||
So \c *this becomes the symmetric difference of \c *this and \c x2 */
|
||||
template<class Type>
|
||||
inline typename enable_if<is_element_set<Type>, Type>::type&
|
||||
operator ^= (Type& object, const Type& operand)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator it_ = operand.begin();
|
||||
while(it_ != operand.end())
|
||||
icl::flip(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Streaming<ElementSet>
|
||||
//==============================================================================
|
||||
template<class CharType, class CharTraits, class Type>
|
||||
inline typename enable_if<is_element_set<Type>, std::basic_ostream<CharType, CharTraits> >::type&
|
||||
operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
|
||||
{
|
||||
stream << "{";
|
||||
ICL_const_FORALL(typename Type, it, object)
|
||||
stream << (*it) << " ";
|
||||
|
||||
return stream << "}";
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
31
test/external/boost/icl/concept/element_set_value.hpp
vendored
Normal file
31
test/external/boost/icl/concept/element_set_value.hpp
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_ELEMENT_SET_VALUE_HPP_JOFA_100924
|
||||
#define BOOST_ICL_CONCEPT_ELEMENT_SET_VALUE_HPP_JOFA_100924
|
||||
|
||||
#include <boost/icl/type_traits/is_element_container.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= AlgoUnifiers<Set>
|
||||
//==============================================================================
|
||||
template<class Type, class Iterator>
|
||||
inline typename enable_if<is_element_set<Type>, const typename Type::key_type>::type&
|
||||
co_value(Iterator it_)
|
||||
{
|
||||
return *it_;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
1473
test/external/boost/icl/concept/interval.hpp
vendored
Normal file
1473
test/external/boost/icl/concept/interval.hpp
vendored
Normal file
File diff suppressed because it is too large
Load Diff
898
test/external/boost/icl/concept/interval_associator.hpp
vendored
Normal file
898
test/external/boost/icl/concept/interval_associator.hpp
vendored
Normal file
@@ -0,0 +1,898 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_INTERVAL_ASSOCIATOR_HPP_JOFA_100920
|
||||
#define BOOST_ICL_CONCEPT_INTERVAL_ASSOCIATOR_HPP_JOFA_100920
|
||||
|
||||
#include <boost/icl/type_traits/domain_type_of.hpp>
|
||||
#include <boost/icl/type_traits/interval_type_of.hpp>
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
#include <boost/icl/detail/set_algo.hpp>
|
||||
#include <boost/icl/detail/map_algo.hpp>
|
||||
#include <boost/icl/detail/interval_set_algo.hpp>
|
||||
#include <boost/icl/detail/interval_map_algo.hpp>
|
||||
#include <boost/icl/concept/interval.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Containedness<IntervalSet|IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool within(c T&, c P&) T={Set,Map} P={e i b p S M}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class SubT, class SuperT>
|
||||
typename enable_if<is_interval_container<SuperT>, bool>::type
|
||||
within(const SubT& sub, const SuperT& super)
|
||||
{
|
||||
return icl::contains(super, sub);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Equivalences and Orderings<IntervalSet|IntervalMap>
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_container<Type>, bool>::type
|
||||
operator == (const Type& left, const Type& right)
|
||||
{
|
||||
return Set::lexicographical_equal(left, right);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_container<Type>, bool>::type
|
||||
operator < (const Type& left, const Type& right)
|
||||
{
|
||||
typedef typename Type::segment_compare segment_compare;
|
||||
return std::lexicographical_compare(
|
||||
left.begin(), left.end(), right.begin(), right.end(),
|
||||
segment_compare()
|
||||
);
|
||||
}
|
||||
|
||||
/** Returns true, if \c left and \c right contain the same elements.
|
||||
Complexity: linear. */
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
|
||||
is_element_equal(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return Interval_Set::is_element_equal(left, right);
|
||||
}
|
||||
|
||||
/** Returns true, if \c left is lexicographically less than \c right.
|
||||
Intervals are interpreted as sequence of elements.
|
||||
Complexity: linear. */
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
|
||||
is_element_less(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return Interval_Set::is_element_less(left, right);
|
||||
}
|
||||
|
||||
/** Returns true, if \c left is lexicographically greater than \c right.
|
||||
Intervals are interpreted as sequence of elements.
|
||||
Complexity: linear. */
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_intra_combinable<LeftT, RightT>, bool>::type
|
||||
is_element_greater(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return Interval_Set::is_element_greater(left, right);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_inter_combinable<LeftT, RightT>, int>::type
|
||||
inclusion_compare(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return Interval_Set::subset_compare(left, right,
|
||||
left.begin(), left.end(),
|
||||
right.begin(), right.end());
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if< is_concept_compatible<is_interval_map, LeftT, RightT>,
|
||||
bool >::type
|
||||
is_distinct_equal(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return Map::lexicographical_distinct_equal(left, right);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Size<IntervalSet|IntervalMap>
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, std::size_t>::type
|
||||
iterative_size(const Type& object)
|
||||
{
|
||||
return object.iterative_size();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
< mpl::and_< is_interval_container<Type>
|
||||
, is_discrete<typename Type::domain_type> >
|
||||
, typename Type::size_type
|
||||
>::type
|
||||
cardinality(const Type& object)
|
||||
{
|
||||
typedef typename Type::size_type size_type;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
|
||||
size_type size = identity_element<size_type>::value();
|
||||
ICL_const_FORALL(typename Type, it, object)
|
||||
size += icl::cardinality(key_value<Type>(it));
|
||||
return size;
|
||||
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
< mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_discrete<typename Type::domain_type> > >
|
||||
, typename Type::size_type
|
||||
>::type
|
||||
cardinality(const Type& object)
|
||||
{
|
||||
typedef typename Type::size_type size_type;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
|
||||
size_type size = identity_element<size_type>::value();
|
||||
size_type interval_size;
|
||||
ICL_const_FORALL(typename Type, it, object)
|
||||
{
|
||||
interval_size = icl::cardinality(key_value<Type>(it));
|
||||
if(interval_size == icl::infinity<size_type>::value())
|
||||
return interval_size;
|
||||
else
|
||||
size += interval_size;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_container<Type>, typename Type::size_type>::type
|
||||
size(const Type& object)
|
||||
{
|
||||
return icl::cardinality(object);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, typename Type::difference_type>::type
|
||||
length(const Type& object)
|
||||
{
|
||||
typedef typename Type::difference_type difference_type;
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
difference_type length = identity_element<difference_type>::value();
|
||||
const_iterator it_ = object.begin();
|
||||
|
||||
while(it_ != object.end())
|
||||
length += icl::length(key_value<Type>(it_++));
|
||||
return length;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, std::size_t>::type
|
||||
interval_count(const Type& object)
|
||||
{
|
||||
return icl::iterative_size(object);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename enable_if< is_interval_container<Type>
|
||||
, typename Type::difference_type >::type
|
||||
distance(const Type& object)
|
||||
{
|
||||
typedef typename Type::difference_type DiffT;
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator it_ = object.begin(), pred_;
|
||||
DiffT dist = identity_element<DiffT>::value();
|
||||
|
||||
if(it_ != object.end())
|
||||
pred_ = it_++;
|
||||
|
||||
while(it_ != object.end())
|
||||
dist += icl::distance(key_value<Type>(pred_++), key_value<Type>(it_++));
|
||||
|
||||
return dist;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Range<IntervalSet|IntervalMap>
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>,
|
||||
typename Type::interval_type>::type
|
||||
hull(const Type& object)
|
||||
{
|
||||
return
|
||||
icl::is_empty(object)
|
||||
? identity_element<typename Type::interval_type>::value()
|
||||
: icl::hull( key_value<Type>(object.begin()),
|
||||
key_value<Type>(object.rbegin()) );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>,
|
||||
typename domain_type_of<Type>::type>::type
|
||||
lower(const Type& object)
|
||||
{
|
||||
typedef typename domain_type_of<Type>::type DomainT;
|
||||
return
|
||||
icl::is_empty(object)
|
||||
? unit_element<DomainT>::value()
|
||||
: icl::lower( key_value<Type>(object.begin()) );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>,
|
||||
typename domain_type_of<Type>::type>::type
|
||||
upper(const Type& object)
|
||||
{
|
||||
typedef typename domain_type_of<Type>::type DomainT;
|
||||
return
|
||||
icl::is_empty(object)
|
||||
? identity_element<DomainT>::value()
|
||||
: icl::upper( key_value<Type>(object.rbegin()) );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
< mpl::and_< is_interval_container<Type>
|
||||
, is_discrete<typename domain_type_of<Type>::type> >
|
||||
, typename domain_type_of<Type>::type>::type
|
||||
first(const Type& object)
|
||||
{
|
||||
typedef typename domain_type_of<Type>::type DomainT;
|
||||
return
|
||||
icl::is_empty(object)
|
||||
? unit_element<DomainT>::value()
|
||||
: icl::first( key_value<Type>(object.begin()) );
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
< mpl::and_< is_interval_container<Type>
|
||||
, is_discrete<typename domain_type_of<Type>::type> >
|
||||
, typename domain_type_of<Type>::type>::type
|
||||
last(const Type& object)
|
||||
{
|
||||
typedef typename domain_type_of<Type>::type DomainT;
|
||||
return
|
||||
icl::is_empty(object)
|
||||
? identity_element<DomainT>::value()
|
||||
: icl::last( key_value<Type>(object.rbegin()) );
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Addition<IntervalSet|IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op +=(T&, c P&) T:{S}|{M} P:{e i}|{b p}
|
||||
//------------------------------------------------------------------------------
|
||||
/* \par \b Requires: \c OperandT is an addable derivative type of \c Type.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Returns: A reference to \c object.
|
||||
\b Complexity:
|
||||
\code
|
||||
\ OperandT:
|
||||
\ element segment
|
||||
Type:
|
||||
interval container O(log n) O(n)
|
||||
|
||||
interval_set amortized
|
||||
spearate_interval_set O(log n)
|
||||
|
||||
n = object.interval_count()
|
||||
\endcode
|
||||
|
||||
For the addition of \b elements or \b segments
|
||||
complexity is \b logarithmic or \b linear respectively.
|
||||
For \c interval_sets and \c separate_interval_sets addition of segments
|
||||
is \b amortized \b logarithmic.
|
||||
*/
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
|
||||
operator += (Type& object, const OperandT& operand)
|
||||
{
|
||||
return icl::add(object, operand);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op +=(T&, c P&) T:{S}|{M} P:{S'}|{M'}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c OperandT is an interval container addable to \c Type.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Returns: A reference to \c object.
|
||||
\b Complexity: loglinear */
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
|
||||
operator += (Type& object, const OperandT& operand)
|
||||
{
|
||||
typename Type::iterator prior_ = object.end();
|
||||
ICL_const_FORALL(typename OperandT, elem_, operand)
|
||||
prior_ = icl::add(object, prior_, *elem_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op + (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c object and \c operand are addable.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Efficieny: There is one additional copy of
|
||||
\c Type \c object compared to inplace \c operator \c += */
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
|
||||
operator + (Type object, const OperandT& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op + (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c object and \c operand are addable.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Efficieny: There is one additional copy of
|
||||
\c Type \c object compared to inplace \c operator \c += */
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
|
||||
operator + (const OperandT& operand, Type object)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op + (T, c P&) T:{S}|{M} P:{S}|{M}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c object and \c operand are addable.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Efficieny: There is one additional copy of
|
||||
\c Type \c object compared to inplace \c operator \c += */
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, Type>::type
|
||||
operator + (Type object, const Type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- Addition |=, |
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op |=(c P&) T:{S}|{M} P:{e i}|{b p}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: Types \c Type and \c OperandT are addable.
|
||||
\par \b Effects: \c operand is added to \c object.
|
||||
\par \b Returns: A reference to \c object.
|
||||
\b Complexity:
|
||||
\code
|
||||
\ OperandT: interval
|
||||
\ element segment container
|
||||
Type:
|
||||
interval container O(log n) O(n) O(m log(n+m))
|
||||
|
||||
interval_set amortized
|
||||
spearate_interval_set O(log n)
|
||||
|
||||
n = object.interval_count()
|
||||
m = operand.interval_count()
|
||||
\endcode
|
||||
|
||||
For the addition of \b elements, \b segments and \b interval \b containers
|
||||
complexity is \b logarithmic, \b linear and \b loglinear respectively.
|
||||
For \c interval_sets and \c separate_interval_sets addition of segments
|
||||
is \b amortized \b logarithmic.
|
||||
*/
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_right_intra_combinable<Type, OperandT>, Type>::type&
|
||||
operator |= (Type& object, const OperandT& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op | (T, c P&) T:{S}|{M} P:{e i S}|{b p M}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c object and \c operand are addable.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Efficieny: There is one additional copy of
|
||||
\c Type \c object compared to inplace \c operator \c |= */
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
|
||||
operator | (Type object, const OperandT& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c object and \c operand are addable.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Efficieny: There is one additional copy of
|
||||
\c Type \c object compared to inplace \c operator \c |= */
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
|
||||
operator | (const OperandT& operand, Type object)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op | (T, c P&) T:{S}|{M} P:{S}|{M}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: \c object and \c operand are addable.
|
||||
\b Effects: \c operand is added to \c object.
|
||||
\par \b Efficieny: There is one additional copy of
|
||||
\c Type \c object compared to inplace \c operator \c |= */
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, Type>::type
|
||||
operator | (Type object, const Type& operand)
|
||||
{
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Insertion<IntervalSet|IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& insert(T&, c P&) T:{S}|{M} P:{S'}|{M'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
|
||||
insert(Type& object, const OperandT& operand)
|
||||
{
|
||||
typename Type::iterator prior_ = object.end();
|
||||
ICL_const_FORALL(typename OperandT, elem_, operand)
|
||||
insert(object, *elem_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Erasure<IntervalSet|IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& erase(T&, c P&) T:{S}|{M} P:{S'}|{S' M'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<combines_right_to_interval_container<Type, OperandT>,
|
||||
Type>::type&
|
||||
erase(Type& object, const OperandT& operand)
|
||||
{
|
||||
typedef typename OperandT::const_iterator const_iterator;
|
||||
|
||||
if(icl::is_empty(operand))
|
||||
return object;
|
||||
|
||||
const_iterator common_lwb, common_upb;
|
||||
if(!Set::common_range(common_lwb, common_upb, operand, object))
|
||||
return object;
|
||||
|
||||
const_iterator it_ = common_lwb;
|
||||
while(it_ != common_upb)
|
||||
icl::erase(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Subtraction<IntervalSet|IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op -= (c P&) T:{M} P:{M'}
|
||||
//------------------------------------------------------------------------------
|
||||
/** \par \b Requires: Types \c Type and \c OperandT are subtractable.
|
||||
\par \b Effects: \c operand is subtracted from \c object.
|
||||
\par \b Returns: A reference to \c object.
|
||||
\b Complexity:
|
||||
\code
|
||||
\ OperandT: interval
|
||||
\ element segment container
|
||||
Type:
|
||||
interval container O(log n) O(n) O(m log(n+m))
|
||||
|
||||
amortized
|
||||
interval_sets O(log n)
|
||||
|
||||
n = object.interval_count()
|
||||
m = operand.interval_count()
|
||||
\endcode
|
||||
|
||||
For the subtraction of \em elements, \b segments and \b interval \b containers
|
||||
complexity is \b logarithmic, \b linear and \b loglinear respectively.
|
||||
For interval sets subtraction of segments
|
||||
is \b amortized \b logarithmic.
|
||||
*/
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_concept_compatible<is_interval_map, Type, OperandT>,
|
||||
Type>::type&
|
||||
operator -=(Type& object, const OperandT& operand)
|
||||
{
|
||||
ICL_const_FORALL(typename OperandT, elem_, operand)
|
||||
icl::subtract(object, *elem_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op -= (c P&) T:{S}|{M} P:{e i}|{b p}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
|
||||
operator -= (Type& object, const OperandT& operand)
|
||||
{
|
||||
return icl::subtract(object, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op -= (c P&) T:{M} P:{e i}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_cross_derivative<Type, OperandT>, Type>::type&
|
||||
operator -= (Type& object, const OperandT& operand)
|
||||
{
|
||||
return icl::erase(object, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op -= (c P&) T:{S M} P:{S'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class IntervalSetT>
|
||||
typename enable_if<combines_right_to_interval_set<Type, IntervalSetT>,
|
||||
Type>::type&
|
||||
operator -= (Type& object, const IntervalSetT& operand)
|
||||
{
|
||||
return erase(object, operand);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op - (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type
|
||||
operator - (Type object, const OperandT& operand)
|
||||
{
|
||||
return object -= operand;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection<IntervalSet|IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- void add_intersection(T&, c T&, c P&) T:{S M} P:{S'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<mpl::and_<is_interval_set<Type>,
|
||||
combines_right_to_interval_set<Type, OperandT> >,
|
||||
void>::type
|
||||
add_intersection(Type& section, const Type& object, const OperandT& operand)
|
||||
{
|
||||
typedef typename OperandT::const_iterator const_iterator;
|
||||
|
||||
if(operand.empty())
|
||||
return;
|
||||
|
||||
const_iterator common_lwb, common_upb;
|
||||
if(!Set::common_range(common_lwb, common_upb, operand, object))
|
||||
return;
|
||||
|
||||
const_iterator it_ = common_lwb;
|
||||
while(it_ != common_upb)
|
||||
icl::add_intersection(section, object, key_value<OperandT>(it_++));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op &=(T&, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_right_inter_combinable<Type, OperandT>, Type>::type&
|
||||
operator &= (Type& object, const OperandT& operand)
|
||||
{
|
||||
Type intersection;
|
||||
add_intersection(intersection, object, operand);
|
||||
object.swap(intersection);
|
||||
return object;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op & (T, c P&) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
|
||||
operator & (Type object, const OperandT& operand)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op & (c P&, T) T:{S}|{M} P:{e i S'}|{e i b p S' M'} S<S' M<M' <:coarser
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_inter_combinable<Type, OperandT>, Type>::type
|
||||
operator & (const OperandT& operand, Type object)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op & (T, c T&) T:{S M}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, Type>::type
|
||||
operator & (Type object, const Type& operand)
|
||||
{
|
||||
return object &= operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- intersects<IntervalSet|IntervalMap>
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool intersects(c T&, c P&) T:{S}|{M} P:{e i}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class CoType>
|
||||
typename enable_if<mpl::and_< is_interval_container<Type>
|
||||
, boost::is_same<CoType, typename domain_type_of<Type>::type> >,
|
||||
bool>::type
|
||||
intersects(const Type& left, const CoType& right)
|
||||
{
|
||||
return icl::contains(left, right);
|
||||
}
|
||||
|
||||
template<class Type, class CoType>
|
||||
typename enable_if<mpl::and_< is_interval_container<Type>
|
||||
, boost::is_same<CoType, typename interval_type_of<Type>::type> >,
|
||||
bool>::type
|
||||
intersects(const Type& left, const CoType& right)
|
||||
{
|
||||
return icl::find(left, right) != left.end();
|
||||
}
|
||||
|
||||
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if< mpl::and_< is_intra_combinable<LeftT, RightT>
|
||||
, mpl::or_<is_total<LeftT>, is_total<RightT> > >
|
||||
, bool>::type
|
||||
intersects(const LeftT&, const RightT&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if< mpl::and_< is_intra_combinable<LeftT, RightT>
|
||||
, mpl::not_<mpl::or_< is_total<LeftT>
|
||||
, is_total<RightT> > > >
|
||||
, bool>::type
|
||||
intersects(const LeftT& left, const RightT& right)
|
||||
{
|
||||
typedef typename RightT::const_iterator const_iterator;
|
||||
LeftT intersection;
|
||||
|
||||
const_iterator right_common_lower_, right_common_upper_;
|
||||
if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
|
||||
return false;
|
||||
|
||||
const_iterator it_ = right_common_lower_;
|
||||
while(it_ != right_common_upper_)
|
||||
{
|
||||
icl::add_intersection(intersection, left, *it_++);
|
||||
if(!icl::is_empty(intersection))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_cross_combinable<LeftT, RightT>, bool>::type
|
||||
intersects(const LeftT& left, const RightT& right)
|
||||
{
|
||||
typedef typename RightT::const_iterator const_iterator;
|
||||
LeftT intersection;
|
||||
|
||||
if(icl::is_empty(left) || icl::is_empty(right))
|
||||
return false;
|
||||
|
||||
const_iterator right_common_lower_, right_common_upper_;
|
||||
if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
|
||||
return false;
|
||||
|
||||
typename RightT::const_iterator it_ = right_common_lower_;
|
||||
while(it_ != right_common_upper_)
|
||||
{
|
||||
icl::add_intersection(intersection, left, key_value<RightT>(it_++));
|
||||
if(!icl::is_empty(intersection))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** \b Returns true, if \c left and \c right have no common elements.
|
||||
Intervals are interpreted as sequence of elements.
|
||||
\b Complexity: loglinear, if \c left and \c right are interval containers. */
|
||||
template<class LeftT, class RightT>
|
||||
typename enable_if<is_inter_combinable<LeftT, RightT>, bool>::type
|
||||
disjoint(const LeftT& left, const RightT& right)
|
||||
{
|
||||
return !intersects(left, right);
|
||||
}
|
||||
|
||||
/** \b Returns true, if \c left and \c right have no common elements.
|
||||
Intervals are interpreted as sequence of elements.
|
||||
\b Complexity: logarithmic, if \c AssociateT is an element type \c Type::element_type.
|
||||
linear, if \c AssociateT is a segment type \c Type::segment_type. */
|
||||
template<class Type, class AssociateT>
|
||||
typename enable_if<is_inter_derivative<Type, AssociateT>, bool>::type
|
||||
disjoint(const Type& left, const AssociateT& right)
|
||||
{
|
||||
return !intersects(left,right);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Symmetric difference<IntervalSet|IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- Symmetric difference ^=, ^
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op ^=(T&, c P&) T:{S}|{M} P:{S'}|{M'}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_intra_combinable<Type, OperandT>, Type>::type&
|
||||
operator ^= (Type& object, const OperandT& operand)
|
||||
{
|
||||
return icl::flip(object, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& op ^=(T&, c P&) T:{S}|{M} P:{e i}|{b p}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_intra_derivative<Type, OperandT>, Type>::type&
|
||||
operator ^= (Type& object, const OperandT& operand)
|
||||
{
|
||||
return icl::flip(object, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op ^ (T, c P&) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
|
||||
operator ^ (Type object, const OperandT& operand)
|
||||
{
|
||||
return object ^= operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op ^ (c P&, T) T:{S}|{M} P:{e i S'}|{b p M'} S<S' M<M' <:coarser
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_binary_intra_combinable<Type, OperandT>, Type>::type
|
||||
operator ^ (const OperandT& operand, Type object)
|
||||
{
|
||||
return object ^= operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T op ^ (T, c T&) T:{S M}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, Type>::type
|
||||
operator ^ (typename Type::overloadable_type object, const Type& operand)
|
||||
{
|
||||
return object ^= operand;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//= Element Iteration <IntervalSet|IntervalMap>
|
||||
//==========================================================================
|
||||
//--------------------------------------------------------------------------
|
||||
//- Forward
|
||||
//--------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_iterator>::type
|
||||
elements_begin(Type& object)
|
||||
{
|
||||
return typename Type::element_iterator(object.begin());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_iterator>::type
|
||||
elements_end(Type& object)
|
||||
{
|
||||
return typename Type::element_iterator(object.end());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_const_iterator>::type
|
||||
elements_begin(const Type& object)
|
||||
{
|
||||
return typename Type::element_const_iterator(object.begin());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_const_iterator>::type
|
||||
elements_end(const Type& object)
|
||||
{
|
||||
return typename Type::element_const_iterator(object.end());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
//- Reverse
|
||||
//--------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_reverse_iterator>::type
|
||||
elements_rbegin(Type& object)
|
||||
{
|
||||
return typename Type::element_reverse_iterator(object.rbegin());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_reverse_iterator>::type
|
||||
elements_rend(Type& object)
|
||||
{
|
||||
return typename Type::element_reverse_iterator(object.rend());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_const_reverse_iterator>::type
|
||||
elements_rbegin(const Type& object)
|
||||
{
|
||||
return typename Type::element_const_reverse_iterator(object.rbegin());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if
|
||||
<mpl::and_< is_interval_container<Type>
|
||||
, mpl::not_<is_continuous_interval<typename Type::interval_type> > >,
|
||||
typename Type::element_const_reverse_iterator>::type
|
||||
elements_rend(const Type& object)
|
||||
{
|
||||
return typename Type::element_const_reverse_iterator(object.rend());
|
||||
}
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
149
test/external/boost/icl/concept/interval_associator_base.hpp
vendored
Normal file
149
test/external/boost/icl/concept/interval_associator_base.hpp
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2011-2011: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_INTERVAL_ASSOCIATOR_BASE_HPP_JOFA_110301
|
||||
#define BOOST_ICL_CONCEPT_INTERVAL_ASSOCIATOR_BASE_HPP_JOFA_110301
|
||||
|
||||
#include <boost/icl/type_traits/domain_type_of.hpp>
|
||||
#include <boost/icl/type_traits/interval_type_of.hpp>
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
#include <boost/icl/concept/set_value.hpp>
|
||||
#include <boost/icl/concept/map_value.hpp>
|
||||
#include <boost/icl/concept/interval.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Selection<IntervalSet|IntervalMap>
|
||||
//==============================================================================
|
||||
template<class Type> inline
|
||||
typename enable_if<mpl::and_< is_interval_container<Type>
|
||||
, is_discrete<typename domain_type_of<Type>::type>
|
||||
>
|
||||
, typename Type::const_iterator>::type
|
||||
find(const Type& object, const typename domain_type_of<Type>::type& key_val)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
return object.find(icl::detail::unit_trail<interval_type>(key_val));
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
typename enable_if<mpl::and_< is_interval_container<Type>
|
||||
, is_continuous<typename domain_type_of<Type>::type>
|
||||
, has_dynamic_bounds<typename interval_type_of<Type>::type>
|
||||
>
|
||||
, typename Type::const_iterator>::type
|
||||
find(const Type& object, const typename domain_type_of<Type>::type& key_val)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
return object.find(icl::singleton<interval_type>(key_val));
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
typename enable_if<mpl::and_< is_interval_container<Type>
|
||||
, is_continuous<typename domain_type_of<Type>::type>
|
||||
, is_static_right_open<typename interval_type_of<Type>::type>
|
||||
, boost::detail::is_incrementable<typename domain_type_of<Type>::type>
|
||||
>
|
||||
, typename Type::const_iterator>::type
|
||||
find(const Type& object, const typename domain_type_of<Type>::type& key_val)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
const_iterator first_collision = object.lower_bound(icl::detail::unit_trail<interval_type>(key_val));
|
||||
// A part of the unit_trail(key_value)-interval may be found in the container, that
|
||||
// does not contain key_value. Therefore we have to check for its existence:
|
||||
return ( first_collision == object.end()
|
||||
|| icl::contains(key_value<Type>(first_collision), key_val) )
|
||||
? first_collision
|
||||
: object.end();
|
||||
}
|
||||
|
||||
template<class Type> inline
|
||||
typename enable_if<mpl::and_< is_interval_container<Type>
|
||||
, is_continuous<typename domain_type_of<Type>::type>
|
||||
, is_static_left_open<typename interval_type_of<Type>::type>
|
||||
, boost::detail::is_incrementable<typename domain_type_of<Type>::type>
|
||||
>
|
||||
, typename Type::const_iterator>::type
|
||||
find(const Type& object, const typename domain_type_of<Type>::type& key_val)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
const_iterator last_collision = object.upper_bound(icl::detail::unit_trail<interval_type>(key_val));
|
||||
if(last_collision != object.begin())
|
||||
--last_collision;
|
||||
// A part of the unit_trail(key_value)-interval may be found in the container, that
|
||||
// does not contain key_value. Therefore we have to check for its existence:
|
||||
return ( last_collision == object.end()
|
||||
|| icl::contains(key_value<Type>(last_collision), key_val) )
|
||||
? last_collision
|
||||
: object.end();
|
||||
}
|
||||
|
||||
// NOTE: find(object, key) won't compile if key is of continuous type that does
|
||||
// not implement in(de)crementation (e.g. std::string).
|
||||
|
||||
template<class Type> inline
|
||||
typename enable_if< is_interval_container<Type>
|
||||
, typename Type::const_iterator>::type
|
||||
find(const Type& object, const typename interval_type_of<Type>::type& inter_val)
|
||||
{
|
||||
return object.find(inter_val);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Morphisms
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_container<Type>, Type>::type&
|
||||
join(Type& object)
|
||||
{
|
||||
typedef typename Type::interval_type interval_type;
|
||||
typedef typename Type::iterator iterator;
|
||||
|
||||
iterator it_ = object.begin();
|
||||
if(it_ == object.end())
|
||||
return object;
|
||||
|
||||
iterator next_ = it_; next_++;
|
||||
|
||||
while(next_ != object.end())
|
||||
{
|
||||
if( segmental::is_joinable<Type>(it_, next_) )
|
||||
{
|
||||
iterator fst_mem = it_; // hold the first member
|
||||
|
||||
// Go on while touching members are found
|
||||
it_++; next_++;
|
||||
while( next_ != object.end()
|
||||
&& segmental::is_joinable<Type>(it_, next_) )
|
||||
{ it_++; next_++; }
|
||||
|
||||
// finally we arrive at the end of a sequence of joinable intervals
|
||||
// and it points to the last member of that sequence
|
||||
const_cast<interval_type&>(key_value<Type>(it_))
|
||||
= hull(key_value<Type>(it_), key_value<Type>(fst_mem));
|
||||
object.erase(fst_mem, it_);
|
||||
|
||||
it_++; next_=it_;
|
||||
if(next_!=object.end())
|
||||
next_++;
|
||||
}
|
||||
else { it_++; next_++; }
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
157
test/external/boost/icl/concept/interval_bounds.hpp
vendored
Normal file
157
test/external/boost/icl/concept/interval_bounds.hpp
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_INTERVAL_BOUNDS_HPP_JOFA_100927
|
||||
#define BOOST_ICL_CONCEPT_INTERVAL_BOUNDS_HPP_JOFA_100927
|
||||
|
||||
#include <boost/icl/interval_bounds.hpp>
|
||||
#include <boost/icl/type_traits/is_discrete.hpp>
|
||||
#include <boost/icl/type_traits/is_numeric.hpp>
|
||||
|
||||
namespace boost{namespace icl
|
||||
{
|
||||
|
||||
inline interval_bounds left(interval_bounds x1)
|
||||
{ return interval_bounds(x1._bits & interval_bounds::_left); }
|
||||
|
||||
inline interval_bounds right(interval_bounds x1)
|
||||
{ return interval_bounds(x1._bits & interval_bounds::_right); }
|
||||
|
||||
inline interval_bounds all(interval_bounds x1)
|
||||
{ return interval_bounds(x1._bits & interval_bounds::_all); }
|
||||
|
||||
inline bool operator == (const interval_bounds x1, const interval_bounds x2)
|
||||
{ return x1._bits == x2._bits; }
|
||||
|
||||
inline bool operator != (const interval_bounds x1, const interval_bounds x2)
|
||||
{ return x1._bits != x2._bits; }
|
||||
|
||||
inline interval_bounds operator & (interval_bounds x1, interval_bounds x2)
|
||||
{ return interval_bounds(x1._bits & x2._bits); }
|
||||
|
||||
inline interval_bounds operator | (interval_bounds x1, interval_bounds x2)
|
||||
{ return interval_bounds(x1._bits | x2._bits); }
|
||||
|
||||
// left shift (multiplies by 2^shift)
|
||||
inline interval_bounds operator << (interval_bounds bounds, unsigned int shift)
|
||||
{ return interval_bounds(bounds._bits << shift); }
|
||||
|
||||
// right shift (divides by 2^shift)
|
||||
inline interval_bounds operator >> (interval_bounds bounds, unsigned int shift)
|
||||
{ return interval_bounds(bounds._bits >> shift); }
|
||||
|
||||
inline interval_bounds operator ~ (interval_bounds x1)
|
||||
{ return all(interval_bounds(~(x1._bits))); }
|
||||
|
||||
inline interval_bounds outer_bounds(interval_bounds x1, interval_bounds x2)
|
||||
{ return left(x1) | right(x2); }
|
||||
|
||||
inline interval_bounds inner_bounds(interval_bounds x1, interval_bounds x2)
|
||||
{ return interval_bounds(x1.reverse_right() | x2.reverse_left()); }
|
||||
|
||||
inline interval_bounds left_bounds(interval_bounds x1, interval_bounds x2)
|
||||
{ return left(x1) | (left(x2) >> 1); }
|
||||
|
||||
inline interval_bounds right_bounds(interval_bounds x1, interval_bounds x2)
|
||||
{ return (right(x1) <<1 ) | right(x2); }
|
||||
|
||||
inline interval_bounds left_subtract_bounds(interval_bounds x1, interval_bounds x2)
|
||||
{ return right(x1) | ~(right(x2) << 1); }
|
||||
|
||||
inline interval_bounds right_subtract_bounds(interval_bounds x1, interval_bounds x2)
|
||||
{ return left(x1) | ~(left(x2) >> 1); }
|
||||
|
||||
inline bool is_complementary(interval_bounds x1)
|
||||
{ return x1 == interval_bounds::right_open() || x1 == interval_bounds::left_open(); }
|
||||
|
||||
inline bool is_left_closed(interval_bounds bounds)
|
||||
{ return bounds.left().bits()==2; }
|
||||
|
||||
inline bool is_right_closed(interval_bounds bounds)
|
||||
{ return bounds.right().bits()==1; }
|
||||
|
||||
inline std::string left_bracket(interval_bounds bounds)
|
||||
{ return is_left_closed(bounds) ? "[" : "("; }
|
||||
|
||||
inline std::string right_bracket(interval_bounds bounds)
|
||||
{ return is_right_closed(bounds) ? "]" : ")"; }
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_discrete<Type>, Type>::type
|
||||
shift_lower(interval_bounds decl, interval_bounds repr, const Type& low)
|
||||
{
|
||||
if(is_left_closed(decl) && !is_left_closed(repr))
|
||||
return icl::pred(low);
|
||||
else if(!is_left_closed(decl) && is_left_closed(repr))
|
||||
return icl::succ(low);
|
||||
else
|
||||
return low;
|
||||
}
|
||||
|
||||
template <class Type>
|
||||
inline typename enable_if<is_discrete<Type>, Type>::type
|
||||
shift_upper(interval_bounds decl, interval_bounds repr, const Type& up)
|
||||
{
|
||||
if(!is_right_closed(decl) && is_right_closed(repr))
|
||||
return icl::pred(up);
|
||||
else if(is_right_closed(decl) && !is_right_closed(repr))
|
||||
return icl::succ(up);
|
||||
else
|
||||
return up;
|
||||
}
|
||||
|
||||
template<class CharType, class CharTraits>
|
||||
std::basic_ostream<CharType, CharTraits>& operator <<
|
||||
(std::basic_ostream<CharType, CharTraits> &stream,
|
||||
interval_bounds const& object)
|
||||
{
|
||||
return stream << left_bracket(object) << right_bracket(object);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class IntervalT>
|
||||
inline typename
|
||||
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
|
||||
outer_bounds(const IntervalT& x1, const IntervalT& x2)
|
||||
{ return outer_bounds(x1.bounds(), x2.bounds()); }
|
||||
|
||||
template<class IntervalT>
|
||||
inline typename
|
||||
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
|
||||
inner_bounds(const IntervalT& x1, const IntervalT& x2)
|
||||
{ return inner_bounds(x1.bounds(), x2.bounds()); }
|
||||
|
||||
template<class IntervalT>
|
||||
inline typename
|
||||
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
|
||||
left_bounds(const IntervalT& x1, const IntervalT& x2)
|
||||
{ return left_bounds(x1.bounds(), x2.bounds()); }
|
||||
|
||||
template<class IntervalT>
|
||||
inline typename
|
||||
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
|
||||
right_bounds(const IntervalT& x1, const IntervalT& x2)
|
||||
{ return right_bounds(x1.bounds(), x2.bounds()); }
|
||||
|
||||
template<class IntervalT>
|
||||
inline typename
|
||||
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
|
||||
left_subtract_bounds(const IntervalT& x1, const IntervalT& x2)
|
||||
{ return left_subtract_bounds(x1.bounds(), x2.bounds()); }
|
||||
|
||||
template<class IntervalT>
|
||||
inline typename
|
||||
boost::enable_if<has_dynamic_bounds<IntervalT>, interval_bounds>::type
|
||||
right_subtract_bounds(const IntervalT& x1, const IntervalT& x2)
|
||||
{ return right_subtract_bounds(x1.bounds(), x2.bounds()); }
|
||||
|
||||
|
||||
}} // namespace icl boost
|
||||
|
||||
#endif
|
||||
|
||||
677
test/external/boost/icl/concept/interval_map.hpp
vendored
Normal file
677
test/external/boost/icl/concept/interval_map.hpp
vendored
Normal file
@@ -0,0 +1,677 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_INTERVAL_MAP_HPP_JOFA_100920
|
||||
#define BOOST_ICL_CONCEPT_INTERVAL_MAP_HPP_JOFA_100920
|
||||
|
||||
#include <boost/icl/type_traits/element_type_of.hpp>
|
||||
#include <boost/icl/type_traits/segment_type_of.hpp>
|
||||
#include <boost/icl/type_traits/absorbs_identities.hpp>
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
#include <boost/icl/type_traits/is_interval_splitter.hpp>
|
||||
|
||||
#include <boost/icl/detail/set_algo.hpp>
|
||||
#include <boost/icl/detail/interval_map_algo.hpp>
|
||||
#include <boost/icl/concept/interval.hpp>
|
||||
#include <boost/icl/concept/joinable.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_map<Type>, typename Type::segment_type>::type
|
||||
make_segment(const typename Type::element_type& element)
|
||||
{
|
||||
typedef typename Type::interval_type interval_type;
|
||||
typedef typename Type::segment_type segment_type;
|
||||
return segment_type(icl::singleton<interval_type>(element.key), element.data);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Containedness<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{M} P:{b p M} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, bool>::type
|
||||
contains(const Type& super, const typename Type::element_type& key_value_pair)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator it_ = icl::find(super, key_value_pair.key);
|
||||
return it_ != super.end() && (*it_).second == key_value_pair.data;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, bool>::type
|
||||
contains(const Type& super, const typename Type::segment_type& sub_segment)
|
||||
{
|
||||
typedef typename Type::interval_type interval_type;
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
|
||||
interval_type sub_interval = sub_segment.first;
|
||||
if(icl::is_empty(sub_interval))
|
||||
return true;
|
||||
|
||||
std::pair<const_iterator, const_iterator> exterior = super.equal_range(sub_interval);
|
||||
if(exterior.first == exterior.second)
|
||||
return false;
|
||||
|
||||
const_iterator last_overlap = prior(exterior.second);
|
||||
|
||||
if(!(sub_segment.second == exterior.first->second) )
|
||||
return false;
|
||||
|
||||
return
|
||||
icl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
|
||||
&& Interval_Map::is_joinable(super, exterior.first, last_overlap);
|
||||
}
|
||||
|
||||
template<class Type, class CoType>
|
||||
typename enable_if<is_concept_compatible<is_interval_map, Type, CoType>, bool>::type
|
||||
contains(const Type& super, const CoType& sub)
|
||||
{
|
||||
return Interval_Set::within(sub, super);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{M} P:{e i S} key_types : total
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class CoType>
|
||||
typename enable_if< mpl::and_< is_interval_map<Type>
|
||||
, is_total<Type>
|
||||
, is_cross_derivative<Type, CoType> >
|
||||
, bool>::type
|
||||
contains(const Type&, const CoType&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{M} P:{e i S} key_types : partial
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if< mpl::and_< is_interval_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
contains(const Type& super, const typename Type::domain_type& key)
|
||||
{
|
||||
return icl::find(super, key) != super.end();
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if< mpl::and_< is_interval_map<Type>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
contains(const Type& super, const typename Type::interval_type& sub_interval)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
|
||||
if(icl::is_empty(sub_interval))
|
||||
return true;
|
||||
|
||||
std::pair<const_iterator, const_iterator> exterior = super.equal_range(sub_interval);
|
||||
if(exterior.first == exterior.second)
|
||||
return false;
|
||||
|
||||
const_iterator last_overlap = prior(exterior.second);
|
||||
|
||||
return
|
||||
icl::contains(hull(exterior.first->first, last_overlap->first), sub_interval)
|
||||
&& Interval_Set::is_joinable(super, exterior.first, last_overlap);
|
||||
}
|
||||
|
||||
template<class Type, class KeyT>
|
||||
typename enable_if< mpl::and_< is_concept_combinable<is_interval_map, is_interval_set, Type, KeyT>
|
||||
, mpl::not_<is_total<Type> > >
|
||||
, bool>::type
|
||||
contains(const Type& super, const KeyT& sub)
|
||||
{
|
||||
return Interval_Set::within(sub, super);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Addition<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& add(T&, c P&) T:{M} P:{b p} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
add(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.add(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
add(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::add(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& add(T&, J, c P&) T:{M} P:{p} segment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, typename Type::iterator >::type
|
||||
add(Type& object, typename Type::iterator prior_,
|
||||
const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.add(prior_, operand);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Insertion<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& insert(T&, c P&) T:{M} P:{b p} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
insert(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.insert(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
insert(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::insert(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& insert(T&, J, c P&) T:{M} P:{p} with hint
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, typename Type::iterator>::type
|
||||
insert(Type& object, typename Type::iterator prior,
|
||||
const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.insert(prior, operand);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Erasure<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& erase(T&, c P&) T:{M} P:{e i} key_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::interval_type& operand)
|
||||
{
|
||||
return object.erase(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::domain_type& operand)
|
||||
{
|
||||
typedef typename Type::interval_type interval_type;
|
||||
return icl::erase(object, icl::singleton<interval_type>(operand));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& erase(T&, c P&) T:{M} P:{b p} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.erase(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::erase(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Subtraction<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{M} P:{b p} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.subtract(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::subtract(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{M} P:{e i} key_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::domain_type& operand)
|
||||
{
|
||||
return object.erase(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::interval_type& operand)
|
||||
{
|
||||
return object.erase(operand);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Selective Update<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& set_at(T&, c P&) T:{M} P:{e i}
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
set_at(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
icl::erase(object, operand.first);
|
||||
return icl::insert(object, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
set_at(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::set_at(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{M} P:{b p} fragment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::element_type& operand)
|
||||
{
|
||||
typedef typename Type::segment_type segment_type;
|
||||
object.add_intersection(section, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::segment_type& operand)
|
||||
{
|
||||
object.add_intersection(section, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{M} P:{M'} map fragment_type total
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class MapT>
|
||||
typename enable_if
|
||||
<
|
||||
mpl::and_< is_total<Type>
|
||||
, is_concept_compatible<is_interval_map, Type, MapT> >
|
||||
, void
|
||||
>::type
|
||||
add_intersection(Type& section, const Type& object, const MapT& operand)
|
||||
{
|
||||
section += object;
|
||||
section += operand;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{M} P:{M'} map fragment_type partial
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class MapT>
|
||||
typename enable_if
|
||||
<
|
||||
mpl::and_< mpl::not_<is_total<Type> >
|
||||
, is_concept_compatible<is_interval_map, Type, MapT> >
|
||||
, void
|
||||
>::type
|
||||
add_intersection(Type& section, const Type& object, const MapT& operand)
|
||||
{
|
||||
typedef typename Type::segment_type segment_type;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
typedef typename MapT::const_iterator const_iterator;
|
||||
|
||||
if(operand.empty())
|
||||
return;
|
||||
const_iterator common_lwb, common_upb;
|
||||
if(!Set::common_range(common_lwb, common_upb, operand, object))
|
||||
return;
|
||||
const_iterator it_ = common_lwb;
|
||||
while(it_ != common_upb)
|
||||
add_intersection(section, object, *it_++);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{M} P:{e i S} key_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::domain_type& key_value)
|
||||
{
|
||||
typedef typename Type::interval_type interval_type;
|
||||
typedef typename Type::segment_type segment_type;
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
|
||||
const_iterator it_ = icl::find(object, key_value);
|
||||
if(it_ != object.end())
|
||||
add(section, segment_type(interval_type(key_value),(*it_).second));
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::interval_type& inter_val)
|
||||
{
|
||||
typedef typename Type::interval_type interval_type;
|
||||
typedef typename Type::value_type value_type;
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::iterator iterator;
|
||||
|
||||
if(icl::is_empty(inter_val))
|
||||
return;
|
||||
|
||||
std::pair<const_iterator, const_iterator> exterior
|
||||
= object.equal_range(inter_val);
|
||||
if(exterior.first == exterior.second)
|
||||
return;
|
||||
|
||||
iterator prior_ = section.end();
|
||||
for(const_iterator it_=exterior.first; it_ != exterior.second; it_++)
|
||||
{
|
||||
interval_type common_interval = (*it_).first & inter_val;
|
||||
if(!icl::is_empty(common_interval))
|
||||
prior_ = add(section, prior_,
|
||||
value_type(common_interval, (*it_).second) );
|
||||
}
|
||||
}
|
||||
|
||||
template<class Type, class KeySetT>
|
||||
typename enable_if<is_concept_combinable<is_interval_map, is_interval_set, Type, KeySetT>, void>::type
|
||||
add_intersection(Type& section, const Type& object, const KeySetT& key_set)
|
||||
{
|
||||
typedef typename KeySetT::const_iterator const_iterator;
|
||||
|
||||
if(icl::is_empty(key_set))
|
||||
return;
|
||||
|
||||
const_iterator common_lwb, common_upb;
|
||||
if(!Set::common_range(common_lwb, common_upb, key_set, object))
|
||||
return;
|
||||
|
||||
const_iterator it_ = common_lwb;
|
||||
while(it_ != common_upb)
|
||||
add_intersection(section, object, *it_++);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- intersects<IntervalMaps> fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<mpl::and_< is_interval_map<Type>
|
||||
, is_total<Type>
|
||||
, boost::is_same< OperandT
|
||||
, typename segment_type_of<Type>::type> >,
|
||||
bool>::type
|
||||
intersects(const Type&, const OperandT&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<mpl::and_< is_interval_map<Type>
|
||||
, mpl::not_<is_total<Type> >
|
||||
, boost::is_same<OperandT, typename segment_type_of<Type>::type> >,
|
||||
bool>::type
|
||||
intersects(const Type& object, const OperandT& operand)
|
||||
{
|
||||
Type intersection;
|
||||
icl::add_intersection(intersection, object, operand);
|
||||
return !icl::is_empty(intersection);
|
||||
}
|
||||
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<mpl::and_< is_interval_map<Type>
|
||||
, boost::is_same<OperandT, typename element_type_of<Type>::type> >,
|
||||
bool>::type
|
||||
intersects(const Type& object, const OperandT& operand)
|
||||
{
|
||||
return icl::intersects(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Symmetric difference<IntervalMap>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& flip(T&, c P&) T:{M} P:{b p} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
flip(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.flip(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_map<Type>, Type>::type&
|
||||
flip(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::flip(object, make_segment<Type>(operand));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& flip(T&, c P&) T:{M} P:{M'} total absorber
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if< mpl::and_< is_total<Type>
|
||||
, absorbs_identities<Type>
|
||||
, is_concept_compatible<is_interval_map,
|
||||
Type, OperandT >
|
||||
>
|
||||
, Type>::type&
|
||||
flip(Type& object, const OperandT&)
|
||||
{
|
||||
object.clear();
|
||||
return object;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& flip(T&, c P&) T:{M} P:{M'} total enricher
|
||||
//------------------------------------------------------------------------------
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4127) // conditional expression is constant
|
||||
#endif
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if< mpl::and_< is_total<Type>
|
||||
, mpl::not_<absorbs_identities<Type> >
|
||||
, is_concept_compatible<is_interval_map,
|
||||
Type, OperandT >
|
||||
>
|
||||
, Type>::type&
|
||||
flip(Type& object, const OperandT& operand)
|
||||
{
|
||||
typedef typename Type::codomain_type codomain_type;
|
||||
|
||||
object += operand;
|
||||
ICL_FORALL(typename Type, it_, object)
|
||||
(*it_).second = identity_element<codomain_type>::value();
|
||||
|
||||
if(mpl::not_<is_interval_splitter<Type> >::value)
|
||||
icl::join(object);
|
||||
|
||||
return object;
|
||||
}
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& flip(T&, c P&) T:{M} P:{M'} partial
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if< mpl::and_< mpl::not_<is_total<Type> >
|
||||
, is_concept_compatible<is_interval_map,
|
||||
Type, OperandT >
|
||||
>
|
||||
, Type>::type&
|
||||
flip(Type& object, const OperandT& operand)
|
||||
{
|
||||
typedef typename OperandT::const_iterator const_iterator;
|
||||
typedef typename Type::codomain_type codomain_type;
|
||||
|
||||
const_iterator common_lwb, common_upb;
|
||||
|
||||
if(!Set::common_range(common_lwb, common_upb, operand, object))
|
||||
return object += operand;
|
||||
|
||||
const_iterator it_ = operand.begin();
|
||||
|
||||
// All elements of operand left of the common range are added
|
||||
while(it_ != common_lwb)
|
||||
icl::add(object, *it_++);
|
||||
// All elements of operand in the common range are symmetrically subtracted
|
||||
while(it_ != common_upb)
|
||||
icl::flip(object, *it_++);
|
||||
// All elements of operand right of the common range are added
|
||||
while(it_ != operand.end())
|
||||
icl::add(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Set selection
|
||||
//==============================================================================
|
||||
template<class Type, class SetT>
|
||||
typename enable_if<is_concept_combinable<is_interval_set, is_interval_map,
|
||||
SetT, Type>, SetT>::type&
|
||||
domain(SetT& result, const Type& object)
|
||||
{
|
||||
typedef typename SetT::iterator set_iterator;
|
||||
result.clear();
|
||||
set_iterator prior_ = result.end();
|
||||
ICL_const_FORALL(typename Type, it_, object)
|
||||
prior_ = icl::insert(result, prior_, (*it_).first);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
template<class Type, class SetT>
|
||||
typename enable_if<is_concept_combinable<is_interval_set, is_interval_map,
|
||||
SetT, Type>, SetT>::type&
|
||||
between(SetT& in_between, const Type& object)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename SetT::iterator set_iterator;
|
||||
in_between.clear();
|
||||
const_iterator it_ = object.begin(), pred_;
|
||||
set_iterator prior_ = in_between.end();
|
||||
|
||||
if(it_ != object.end())
|
||||
pred_ = it_++;
|
||||
|
||||
while(it_ != object.end())
|
||||
prior_ = icl::insert(in_between, prior_,
|
||||
between((*pred_++).first, (*it_++).first));
|
||||
|
||||
return in_between;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Manipulation by predicates
|
||||
//==============================================================================
|
||||
template<class MapT, class Predicate>
|
||||
typename enable_if<is_interval_map<MapT>, MapT>::type&
|
||||
erase_if(const Predicate& pred, MapT& object)
|
||||
{
|
||||
typename MapT::iterator it_ = object.begin();
|
||||
while(it_ != object.end())
|
||||
if(pred(*it_))
|
||||
object.erase(it_++);
|
||||
else ++it_;
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class MapT, class Predicate>
|
||||
inline typename enable_if<is_interval_map<MapT>, MapT>::type&
|
||||
add_if(const Predicate& pred, MapT& object, const MapT& src)
|
||||
{
|
||||
typename MapT::const_iterator it_ = src.begin();
|
||||
while(it_ != src.end())
|
||||
if(pred(*it_))
|
||||
icl::add(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class MapT, class Predicate>
|
||||
inline typename enable_if<is_interval_map<MapT>, MapT>::type&
|
||||
assign_if(const Predicate& pred, MapT& object, const MapT& src)
|
||||
{
|
||||
icl::clear(object);
|
||||
return add_if(object, src, pred);
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Morphisms
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<mpl::and_< is_interval_map<Type>
|
||||
, absorbs_identities<Type> >, Type>::type&
|
||||
absorb_identities(Type& object)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<mpl::and_< is_interval_map<Type>
|
||||
, mpl::not_<absorbs_identities<Type> > >, Type>::type&
|
||||
absorb_identities(Type& object)
|
||||
{
|
||||
typedef typename Type::segment_type segment_type;
|
||||
return icl::erase_if(content_is_identity_element<segment_type>(), object);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Streaming
|
||||
//==============================================================================
|
||||
template<class CharType, class CharTraits, class Type>
|
||||
typename enable_if<is_interval_map<Type>,
|
||||
std::basic_ostream<CharType, CharTraits> >::type&
|
||||
operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
|
||||
{
|
||||
stream << "{";
|
||||
ICL_const_FORALL(typename Type, it_, object)
|
||||
stream << "(" << (*it_).first << "->" << (*it_).second << ")";
|
||||
|
||||
return stream << "}";
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
354
test/external/boost/icl/concept/interval_set.hpp
vendored
Normal file
354
test/external/boost/icl/concept/interval_set.hpp
vendored
Normal file
@@ -0,0 +1,354 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_INTERVAL_SET_HPP_JOFA_100920
|
||||
#define BOOST_ICL_CONCEPT_INTERVAL_SET_HPP_JOFA_100920
|
||||
|
||||
#include <boost/icl/type_traits/is_combinable.hpp>
|
||||
#include <boost/icl/type_traits/interval_type_of.hpp>
|
||||
#include <boost/icl/detail/set_algo.hpp>
|
||||
#include <boost/icl/detail/interval_set_algo.hpp>
|
||||
#include <boost/icl/concept/interval.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= Containedness<IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- bool contains(c T&, c P&) T:{S} P:{e i S} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, bool>::type
|
||||
contains(const Type& super, const typename Type::element_type& element)
|
||||
{
|
||||
return !(icl::find(super, element) == super.end());
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, bool>::type
|
||||
contains(const Type& super, const typename Type::segment_type& inter_val)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
if(icl::is_empty(inter_val))
|
||||
return true;
|
||||
|
||||
std::pair<const_iterator, const_iterator> exterior
|
||||
= super.equal_range(inter_val);
|
||||
if(exterior.first == exterior.second)
|
||||
return false;
|
||||
|
||||
const_iterator last_overlap = cyclic_prior(super, exterior.second);
|
||||
|
||||
return
|
||||
icl::contains(hull(*(exterior.first), *last_overlap), inter_val)
|
||||
&& Interval_Set::is_joinable(super, exterior.first, last_overlap);
|
||||
}
|
||||
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<has_same_concept<is_interval_set, Type, OperandT>,
|
||||
bool>::type
|
||||
contains(const Type& super, const OperandT& sub)
|
||||
{
|
||||
return Interval_Set::contains(super, sub);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Addition<IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& add(T&, c P&) T:{S} P:{e i} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
add(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.add(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
add(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
typedef typename Type::segment_type segment_type;
|
||||
return icl::add(object, icl::singleton<segment_type>(operand));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& add(T&, J, c P&) T:{S} P:{i} interval_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_set<Type>, typename Type::iterator>::type
|
||||
add(Type& object, typename Type::iterator prior,
|
||||
const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.add(prior, operand);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Insertion<IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& insert(T&, c P&) T:{S} P:{e i} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
insert(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return icl::add(object, operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
insert(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
return icl::add(object, operand);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& insert(T&, J, c P&) T:{S} P:{i} with hint
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_set<Type>, typename Type::iterator>::type
|
||||
insert(Type& object, typename Type::iterator prior,
|
||||
const typename Type::segment_type& operand)
|
||||
{
|
||||
return icl::add(object, prior, operand);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Subtraction<IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& subtract(T&, c P&) T:{S} P:{e i} fragment_type
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::segment_type& operand)
|
||||
{
|
||||
return object.subtract(operand);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
subtract(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
typedef typename Type::segment_type segment_type;
|
||||
return icl::subtract(object, icl::singleton<segment_type>(operand));
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Erasure<IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& erase(T&, c P&) T:{S} P:{e i} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::segment_type& minuend)
|
||||
{
|
||||
return icl::subtract(object, minuend);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
erase(Type& object, const typename Type::element_type& minuend)
|
||||
{
|
||||
return icl::subtract(object, minuend);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Intersection
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- void add_intersection(T&, c T&, c P&) T:{S} P:{e i} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::element_type& operand)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
const_iterator found = icl::find(object, operand);
|
||||
if(found != object.end())
|
||||
icl::add(section, operand);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, void>::type
|
||||
add_intersection(Type& section, const Type& object,
|
||||
const typename Type::segment_type& segment)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::iterator iterator;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
|
||||
if(icl::is_empty(segment))
|
||||
return;
|
||||
|
||||
std::pair<const_iterator, const_iterator> exterior
|
||||
= object.equal_range(segment);
|
||||
if(exterior.first == exterior.second)
|
||||
return;
|
||||
|
||||
iterator prior_ = section.end();
|
||||
for(const_iterator it_=exterior.first; it_ != exterior.second; it_++)
|
||||
{
|
||||
interval_type common_interval = key_value<Type>(it_) & segment;
|
||||
if(!icl::is_empty(common_interval))
|
||||
prior_ = section.insert(prior_, common_interval);
|
||||
}
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Symmetric difference<IntervalSet>
|
||||
//==============================================================================
|
||||
//------------------------------------------------------------------------------
|
||||
//- T& flip(T&, c P&) T:{S} P:{e i S'} fragment_types
|
||||
//------------------------------------------------------------------------------
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
flip(Type& object, const typename Type::element_type& operand)
|
||||
{
|
||||
if(icl::contains(object, operand))
|
||||
return object -= operand;
|
||||
else
|
||||
return object += operand;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
flip(Type& object, const typename Type::segment_type& segment)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::interval_type interval_type;
|
||||
// That which is common shall be subtracted
|
||||
// That which is not shall be added
|
||||
// So x has to be 'complementary added' or flipped
|
||||
interval_type span = segment;
|
||||
std::pair<const_iterator, const_iterator> exterior
|
||||
= object.equal_range(span);
|
||||
|
||||
const_iterator fst_ = exterior.first;
|
||||
const_iterator end_ = exterior.second;
|
||||
|
||||
interval_type covered, left_over;
|
||||
const_iterator it_ = fst_;
|
||||
while(it_ != end_)
|
||||
{
|
||||
covered = *it_++;
|
||||
//[a ... : span
|
||||
// [b ... : covered
|
||||
//[a b) : left_over
|
||||
left_over = right_subtract(span, covered);
|
||||
icl::subtract(object, span & covered); //That which is common shall be subtracted
|
||||
icl::add(object, left_over); //That which is not shall be added
|
||||
|
||||
//... d) : span
|
||||
//... c) : covered
|
||||
// [c d) : span'
|
||||
span = left_subtract(span, covered);
|
||||
}
|
||||
|
||||
//If span is not empty here, it_ is not in the set so it_ shall be added
|
||||
icl::add(object, span);
|
||||
return object;
|
||||
}
|
||||
|
||||
|
||||
template<class Type, class OperandT>
|
||||
typename enable_if<is_concept_compatible<is_interval_set, Type, OperandT>, Type>::type&
|
||||
flip(Type& object, const OperandT& operand)
|
||||
{
|
||||
typedef typename OperandT::const_iterator const_iterator;
|
||||
|
||||
if(operand.empty())
|
||||
return object;
|
||||
|
||||
const_iterator common_lwb, common_upb;
|
||||
|
||||
if(!Set::common_range(common_lwb, common_upb, operand, object))
|
||||
return object += operand;
|
||||
|
||||
const_iterator it_ = operand.begin();
|
||||
|
||||
// All elements of operand left of the common range are added
|
||||
while(it_ != common_lwb)
|
||||
icl::add(object, *it_++);
|
||||
// All elements of operand in the common range are symmertrically subtracted
|
||||
while(it_ != common_upb)
|
||||
icl::flip(object, *it_++);
|
||||
// All elements of operand right of the common range are added
|
||||
while(it_ != operand.end())
|
||||
icl::add(object, *it_++);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
//= Set selection
|
||||
//==============================================================================
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
domain(Type& dom, const Type& object)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::iterator iterator;
|
||||
dom.clear();
|
||||
const_iterator it_ = object.begin();
|
||||
iterator prior_ = dom.end();
|
||||
|
||||
while(it_ != object.end())
|
||||
prior_ = icl::insert(dom, prior_, *it_++);
|
||||
|
||||
return dom;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, Type>::type&
|
||||
between(Type& in_between, const Type& object)
|
||||
{
|
||||
typedef typename Type::const_iterator const_iterator;
|
||||
typedef typename Type::iterator iterator;
|
||||
in_between.clear();
|
||||
const_iterator it_ = object.begin(), pred_;
|
||||
iterator prior_ = in_between.end();
|
||||
|
||||
if(it_ != object.end())
|
||||
pred_ = it_++;
|
||||
|
||||
while(it_ != object.end())
|
||||
prior_ = icl::insert(in_between, prior_,
|
||||
icl::between(*pred_++, *it_++));
|
||||
|
||||
return in_between;
|
||||
}
|
||||
|
||||
|
||||
//==============================================================================
|
||||
//= Streaming
|
||||
//==============================================================================
|
||||
template<class CharType, class CharTraits, class Type>
|
||||
typename enable_if<is_interval_set<Type>,
|
||||
std::basic_ostream<CharType, CharTraits> >::type&
|
||||
operator << (std::basic_ostream<CharType, CharTraits>& stream, const Type& object)
|
||||
{
|
||||
stream << "{";
|
||||
ICL_const_FORALL(typename Type, it_, object)
|
||||
stream << (*it_);
|
||||
|
||||
return stream << "}";
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
33
test/external/boost/icl/concept/interval_set_value.hpp
vendored
Normal file
33
test/external/boost/icl/concept/interval_set_value.hpp
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_INTERVAL_SET_VALUE_HPP_JOFA_100924
|
||||
#define BOOST_ICL_CONCEPT_INTERVAL_SET_VALUE_HPP_JOFA_100924
|
||||
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/icl/type_traits/is_interval_container.hpp>
|
||||
#include <boost/icl/concept/interval.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= AlgoUnifiers<Set>
|
||||
//==============================================================================
|
||||
template<class Type, class Iterator>
|
||||
inline typename enable_if<is_interval_set<Type>, typename Type::codomain_type>::type
|
||||
co_value(Iterator value_)
|
||||
{
|
||||
typedef typename Type::codomain_type codomain_type;
|
||||
return icl::is_empty(*value_)? codomain_type() : (*value_).lower();
|
||||
}
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
41
test/external/boost/icl/concept/joinable.hpp
vendored
Normal file
41
test/external/boost/icl/concept/joinable.hpp
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_JOINABLE_HPP_JOFA_100920
|
||||
#define BOOST_ICL_CONCEPT_JOINABLE_HPP_JOFA_100920
|
||||
|
||||
#include <boost/icl/type_traits/is_interval_container.hpp>
|
||||
#include <boost/icl/concept/interval.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
namespace segmental
|
||||
{
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_set<Type>, bool>::type
|
||||
is_joinable(typename Type::iterator it_, typename Type::iterator next_, Type* = 0)
|
||||
{
|
||||
return touches(*it_, *next_);
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
typename enable_if<is_interval_map<Type>, bool>::type
|
||||
is_joinable(typename Type::iterator it_, typename Type::iterator next_, Type* = 0)
|
||||
{
|
||||
return touches((*it_).first, (*next_).first)
|
||||
&& (*it_).second == (*next_).second ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
61
test/external/boost/icl/concept/map_value.hpp
vendored
Normal file
61
test/external/boost/icl/concept/map_value.hpp
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_MAP_VALUE_HPP_JOFA_100924
|
||||
#define BOOST_ICL_CONCEPT_MAP_VALUE_HPP_JOFA_100924
|
||||
|
||||
#include <boost/icl/type_traits/predicate.hpp>
|
||||
#include <boost/icl/type_traits/identity_element.hpp>
|
||||
#include <boost/icl/type_traits/is_map.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= AlgoUnifiers<Map>
|
||||
//==============================================================================
|
||||
template<class Type, class Iterator>
|
||||
inline typename enable_if<is_map<Type>, const typename Type::key_type>::type&
|
||||
key_value(Iterator it_)
|
||||
{
|
||||
return (*it_).first;
|
||||
}
|
||||
|
||||
template<class Type, class Iterator>
|
||||
inline typename enable_if<is_map<Type>, const typename Type::codomain_type>::type&
|
||||
co_value(Iterator it_)
|
||||
{
|
||||
return (*it_).second;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_map<Type>, typename Type::value_type>::type
|
||||
make_value(const typename Type:: key_type& key_val,
|
||||
const typename Type::codomain_type& co_val)
|
||||
{
|
||||
return typename Type::value_type(key_val, co_val);
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
class content_is_identity_element: public property<Type>
|
||||
{
|
||||
public:
|
||||
bool operator() (const Type& value_pair)const
|
||||
{
|
||||
return value_pair.second
|
||||
== identity_element<typename Type::second_type>::value();
|
||||
}
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
40
test/external/boost/icl/concept/set_value.hpp
vendored
Normal file
40
test/external/boost/icl/concept/set_value.hpp
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/*-----------------------------------------------------------------------------+
|
||||
Copyright (c) 2010-2010: Joachim Faulhaber
|
||||
+------------------------------------------------------------------------------+
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENCE.txt or copy at
|
||||
http://www.boost.org/LICENSE_1_0.txt)
|
||||
+-----------------------------------------------------------------------------*/
|
||||
#ifndef BOOST_ICL_CONCEPT_SET_VALUE_HPP_JOFA_100924
|
||||
#define BOOST_ICL_CONCEPT_SET_VALUE_HPP_JOFA_100924
|
||||
|
||||
#include <boost/icl/type_traits/is_set.hpp>
|
||||
#include <boost/icl/type_traits/codomain_type_of.hpp>
|
||||
|
||||
namespace boost{ namespace icl
|
||||
{
|
||||
|
||||
//==============================================================================
|
||||
//= AlgoUnifiers<Set>
|
||||
//==============================================================================
|
||||
template<class Type, class Iterator>
|
||||
inline typename enable_if<is_set<Type>, const typename Type::key_type>::type&
|
||||
key_value(Iterator it_)
|
||||
{
|
||||
return *it_;
|
||||
}
|
||||
|
||||
template<class Type>
|
||||
inline typename enable_if<is_set<Type>, typename Type::value_type>::type
|
||||
make_value(const typename Type::key_type& key_val,
|
||||
const typename codomain_type_of<Type>::type& )
|
||||
{
|
||||
return typename Type::value_type(key_val);
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost icl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user