File indexing completed on 2025-01-18 09:38:20
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_ICL_MAPALGO_HPP_JOFA_080225
0009 #define BOOST_ICL_MAPALGO_HPP_JOFA_080225
0010
0011 #include <boost/mpl/and.hpp>
0012 #include <boost/mpl/or.hpp>
0013 #include <boost/mpl/not.hpp>
0014 #include <boost/icl/detail/notate.hpp>
0015 #include <boost/icl/detail/set_algo.hpp>
0016
0017 #ifdef BOOST_MSVC
0018 #pragma warning(push)
0019 #pragma warning(disable:4127)
0020 #endif
0021
0022 namespace boost{namespace icl
0023 {
0024 namespace Map
0025 {
0026
0027 template <class ObjectT, class CoObjectT>
0028 bool intersects(const ObjectT& left, const CoObjectT& right)
0029 {
0030 typedef typename CoObjectT::const_iterator co_iterator;
0031 co_iterator right_common_lower_, right_common_upper_;
0032 if(!Set::common_range(right_common_lower_, right_common_upper_, right, left))
0033 return false;
0034
0035 co_iterator right_ = right_common_lower_;
0036 while(right_ != right_common_upper_)
0037 if(!(left.find(key_value<CoObjectT>(right_++))==left.end()))
0038 return true;
0039
0040 return false;
0041 }
0042
0043
0044 template<class MapT>
0045 typename MapT::const_iterator next_proton(typename MapT::const_iterator& iter_, const MapT& object)
0046 {
0047 while( iter_ != object.end()
0048 && (*iter_).second == identity_element<typename MapT::codomain_type>::value())
0049 ++iter_;
0050
0051 return iter_;
0052 }
0053
0054
0055
0056 template<class MapT>
0057 bool lexicographical_distinct_equal(const MapT& left, const MapT& right)
0058 {
0059 if(&left == &right)
0060 return true;
0061
0062 typename MapT::const_iterator left_ = left.begin();
0063 typename MapT::const_iterator right_ = right.begin();
0064
0065 left_ = next_proton(left_, left);
0066 right_ = next_proton(right_, right);
0067
0068 while(left_ != left.end() && right_ != right.end())
0069 {
0070 if(!(left_->first == right_->first && left_->second == right_->second))
0071 return false;
0072
0073 ++left_;
0074 ++right_;
0075 left_ = next_proton(left_, left);
0076 right_ = next_proton(right_, right);
0077 }
0078
0079 return left_ == left.end() && right_ == right.end();
0080 }
0081
0082 }
0083 }}
0084
0085 #ifdef BOOST_MSVC
0086 #pragma warning(pop)
0087 #endif
0088
0089 #endif
0090