Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:38

0001 // Boost.Bimap
0002 //
0003 // Copyright (c) 2006-2007 Matias Capeletto
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 /// \file detail/map_view_iterator.hpp
0010 /// \brief Iterator adaptors from multi-index to bimap.
0011 
0012 #ifndef BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP
0013 #define BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 // Boost
0022 
0023 #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
0024   #include <boost/core/serialization.hpp>
0025 #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
0026 
0027 #include <boost/iterator/detail/enable_if.hpp>
0028 #include <boost/iterator/iterator_adaptor.hpp>
0029 #include <boost/bimap/relation/support/pair_by.hpp>
0030 
0031 // check
0032 #include <boost/bimap/relation/detail/metadata_access_builder.hpp>
0033 #include <boost/bimap/relation/detail/static_access_builder.hpp>
0034 
0035 namespace boost {
0036 namespace bimaps {
0037 namespace detail {
0038 
0039 /** \brief Map View Iterator adaptors from multi index to bimap.
0040 
0041 These classes are based on transform iterators from Boost.Iterator.
0042                                                                          **/
0043 
0044 template< class Tag, class BimapCore > struct       map_view_iterator ;
0045 template< class Tag, class BimapCore > struct const_map_view_iterator ;
0046 
0047 template< class Tag, class BimapCore > struct       reverse_map_view_iterator ;
0048 template< class Tag, class BimapCore > struct const_reverse_map_view_iterator ;
0049 
0050 template< class Tag, class BimapCore > struct       local_map_view_iterator ;
0051 template< class Tag, class BimapCore > struct const_local_map_view_iterator ;
0052 
0053 
0054 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0055 
0056 #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
0057 /*===========================================================================*/
0058 #define BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT                   \
0059                                                                               \
0060     template< class Archive >                                                 \
0061     void serialize(Archive & ar, const unsigned int v)                        \
0062     {                                                                         \
0063         ::boost::core::split_member( ar, *this, v );                          \
0064     }                                                                         \
0065                                                                               \
0066     friend class ::boost::serialization::access;                              \
0067                                                                               \
0068     template< class Archive >                                                 \
0069     void save(Archive & ar, const unsigned int) const                         \
0070     {                                                                         \
0071         ar << ::boost::serialization::make_nvp("mi_iterator",this->base());   \
0072     }                                                                         \
0073                                                                               \
0074     template< class Archive >                                                 \
0075     void load(Archive & ar, const unsigned int)                               \
0076     {                                                                         \
0077         BOOST_DEDUCED_TYPENAME base_::base_type iter;                         \
0078         ar >> ::boost::serialization::make_nvp("mi_iterator",iter);           \
0079         this->base_reference() = iter;                                        \
0080     }
0081 /*===========================================================================*/
0082 #else
0083 #define BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT // None
0084 #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
0085 
0086 /*===========================================================================*/
0087 #define BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( METANAME, ITERATOR )       \
0088 BOOST_BIMAP_SYMMETRIC_STATIC_ACCESS_BUILDER( METANAME, BimapCore,             \
0089     typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE\
0090         index<BOOST_DEDUCED_TYPENAME BimapCore::left_tag>                     \
0091             ::type::ITERATOR type,                                            \
0092     typedef BOOST_DEDUCED_TYPENAME BimapCore::core_type::BOOST_NESTED_TEMPLATE\
0093         index<BOOST_DEDUCED_TYPENAME BimapCore::right_tag>                    \
0094             ::type::ITERATOR type                                             \
0095 )
0096 /*===========================================================================*/
0097 
0098 
0099 BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( core_iterator_type_by
0100                                          , iterator )
0101 
0102 BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( reverse_core_iterator_type_by
0103                                          , reverse_iterator )
0104 
0105 BOOST_BIMAP_CORE_ITERATOR_TYPE_BY_BUILDER( local_core_iterator_type_by
0106                                          , local_iterator )
0107 
0108 
0109 // map_view_iterator
0110 
0111 template< class Tag, class BimapCore >
0112 struct map_view_iterator_adaptor {
0113     typedef iterator_adaptor<
0114         map_view_iterator<Tag,BimapCore>,
0115         BOOST_DEDUCED_TYPENAME core_iterator_type_by<Tag,BimapCore>::type,
0116         BOOST_DEDUCED_TYPENAME 
0117             ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
0118     > type;
0119 };
0120 template< class Tag, class BimapCore >
0121 struct map_view_iterator : 
0122     public map_view_iterator_adaptor<Tag,BimapCore>::type
0123 {
0124     typedef BOOST_DEDUCED_TYPENAME 
0125         map_view_iterator_adaptor<Tag,BimapCore>::type base_;
0126     public:
0127 
0128     map_view_iterator() {}
0129     map_view_iterator(BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
0130       : base_(iter) {}
0131 
0132     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0133     {
0134         return ::boost::bimaps::relation::support::pair_by<Tag>(
0135             *const_cast<BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
0136                 &(*this->base())
0137             )
0138         );
0139     }
0140     private:
0141     friend class boost::iterators::iterator_core_access;
0142     BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
0143 };
0144 
0145 
0146 template< class Tag, class BimapCore >
0147 struct const_map_view_iterator_adaptor {
0148     typedef iterator_adaptor<
0149         const_map_view_iterator<Tag,BimapCore>,
0150         BOOST_DEDUCED_TYPENAME core_iterator_type_by<Tag,BimapCore>::type,
0151         const BOOST_DEDUCED_TYPENAME 
0152             ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
0153     > type;
0154 };
0155 template< class Tag, class BimapCore >
0156 struct const_map_view_iterator : 
0157     public const_map_view_iterator_adaptor<Tag,BimapCore>::type
0158 {
0159     typedef BOOST_DEDUCED_TYPENAME 
0160         const_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
0161     public:
0162 
0163     const_map_view_iterator() {}
0164     const_map_view_iterator(
0165             BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
0166       : base_(iter) {}
0167     const_map_view_iterator(map_view_iterator<Tag,BimapCore> i)
0168       : base_(i.base()) {}
0169 
0170     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0171     {
0172         return ::boost::bimaps::relation::support::pair_by<Tag>(*this->base());
0173     }
0174     private:
0175     friend class boost::iterators::iterator_core_access;
0176     BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
0177 };
0178 
0179 
0180 // reverse_map_view_iterator
0181 
0182 template< class Tag, class BimapCore >
0183 struct reverse_map_view_iterator_adaptor {
0184     typedef iterator_adaptor<
0185         reverse_map_view_iterator<Tag,BimapCore>,
0186         BOOST_DEDUCED_TYPENAME 
0187             reverse_core_iterator_type_by<Tag,BimapCore>::type,
0188         BOOST_DEDUCED_TYPENAME 
0189             ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
0190     > type;
0191 };
0192 template< class Tag, class BimapCore >
0193 struct reverse_map_view_iterator :
0194     public reverse_map_view_iterator_adaptor<Tag,BimapCore>::type
0195 {
0196     typedef BOOST_DEDUCED_TYPENAME 
0197         reverse_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
0198     public:
0199 
0200     reverse_map_view_iterator() {}
0201     reverse_map_view_iterator(
0202             BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
0203       : base_(iter) {}
0204 
0205     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0206     {
0207         return ::boost::bimaps::relation::support::pair_by<Tag>(
0208             *const_cast<BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
0209                 &(*this->base())
0210             )
0211         );
0212     }
0213     private:
0214     friend class boost::iterators::iterator_core_access;
0215     BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
0216 };
0217 
0218 template< class Tag, class BimapCore >
0219 struct const_reverse_map_view_iterator_adaptor {
0220     typedef iterator_adaptor<
0221         const_reverse_map_view_iterator<Tag,BimapCore>,
0222         BOOST_DEDUCED_TYPENAME 
0223             reverse_core_iterator_type_by<Tag,BimapCore>::type,
0224         const BOOST_DEDUCED_TYPENAME 
0225             ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
0226     > type;
0227 };
0228 template< class Tag, class BimapCore >
0229 struct const_reverse_map_view_iterator :
0230     public const_reverse_map_view_iterator_adaptor<Tag,BimapCore>::type
0231 {
0232     typedef BOOST_DEDUCED_TYPENAME 
0233         const_reverse_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
0234     
0235     public:
0236 
0237     const_reverse_map_view_iterator() {}
0238     const_reverse_map_view_iterator(
0239             BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
0240       : base_(iter) {}
0241     const_reverse_map_view_iterator(reverse_map_view_iterator<Tag,BimapCore> i)
0242       : base_(i.base()) {}
0243 
0244     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0245     {
0246         return ::boost::bimaps::relation::support::pair_by<Tag>(*this->base());
0247     }
0248     private:
0249     friend class boost::iterators::iterator_core_access;
0250     BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
0251 };
0252 
0253 
0254 // local_map_view_iterator
0255 
0256 template< class Tag, class BimapCore >
0257 struct local_map_view_iterator_adaptor {
0258     typedef iterator_adaptor<
0259         local_map_view_iterator<Tag,BimapCore>,
0260         BOOST_DEDUCED_TYPENAME 
0261             local_core_iterator_type_by<Tag,BimapCore>::type,
0262         BOOST_DEDUCED_TYPENAME 
0263             ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
0264     > type;
0265 };
0266 template< class Tag, class BimapCore >
0267 struct local_map_view_iterator :
0268     public local_map_view_iterator_adaptor<Tag,BimapCore>::type
0269 {
0270     typedef BOOST_DEDUCED_TYPENAME 
0271         local_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
0272     public:
0273 
0274     local_map_view_iterator() {}
0275     local_map_view_iterator(
0276             BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
0277       : base_(iter) {}
0278 
0279     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0280     {
0281         return ::boost::bimaps::relation::support::pair_by<Tag>(
0282             *const_cast<BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
0283                 &(*this->base())
0284             )
0285         );
0286     }
0287     private:
0288     friend class boost::iterators::iterator_core_access;
0289     BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
0290 };
0291 
0292 template< class Tag, class BimapCore >
0293 struct const_local_map_view_iterator_adaptor {
0294     typedef iterator_adaptor<
0295         const_local_map_view_iterator<Tag,BimapCore>,
0296         BOOST_DEDUCED_TYPENAME 
0297             local_core_iterator_type_by<Tag,BimapCore>::type,
0298         const BOOST_DEDUCED_TYPENAME 
0299             ::boost::bimaps::support::value_type_by<Tag,BimapCore>::type
0300     > type;
0301 };
0302 template< class Tag, class BimapCore >
0303 struct const_local_map_view_iterator :
0304     public const_local_map_view_iterator_adaptor<Tag,BimapCore>::type
0305 {
0306     typedef BOOST_DEDUCED_TYPENAME 
0307         const_local_map_view_iterator_adaptor<Tag,BimapCore>::type base_;
0308     public:
0309 
0310     const_local_map_view_iterator() {}
0311     const_local_map_view_iterator(
0312             BOOST_DEDUCED_TYPENAME base_::base_type const& iter)
0313       : base_(iter) {}
0314     const_local_map_view_iterator(local_map_view_iterator<Tag,BimapCore> i)
0315       : base_(i.base()) {}
0316 
0317     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0318     {
0319         return ::boost::bimaps::relation::support::pair_by<Tag>(*this->base());
0320     }
0321     private:
0322     friend class boost::iterators::iterator_core_access;
0323     BOOST_BIMAP_MAP_VIEW_ITERATOR_SERIALIZATION_SUPPORT
0324 };
0325 
0326 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0327 
0328 } // namespace detail
0329 } // namespace bimaps
0330 } // namespace boost
0331 
0332 #endif // BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP
0333 
0334