Back to home page

EIC code displayed by LXR

 
 

    


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

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 container_adaptor/list_adaptor.hpp
0010 /// \brief Container adaptor to easily build a std::list signature compatible container.
0011 
0012 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_ADAPTOR_HPP
0013 #define BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_ADAPTOR_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 #include <boost/bimap/container_adaptor/sequence_container_adaptor.hpp>
0022 #include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
0023 #include <boost/mpl/aux_/na.hpp>
0024 #include <boost/mpl/vector.hpp>
0025 #include <boost/call_traits.hpp>
0026 #include <functional>
0027 
0028 namespace boost {
0029 namespace bimaps {
0030 namespace container_adaptor {
0031 
0032 /// \brief Container adaptor to easily build a std::list signature compatible container.
0033 
0034 template
0035 <
0036     class Base,
0037 
0038     class Iterator,
0039     class ConstIterator,
0040     class ReverseIterator,
0041     class ConstReverseIterator,
0042 
0043     class IteratorToBaseConverter          = ::boost::mpl::na,
0044     class IteratorFromBaseConverter        = ::boost::mpl::na,
0045     class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
0046     class ValueToBaseConverter             = ::boost::mpl::na,
0047     class ValueFromBaseConverter           = ::boost::mpl::na,
0048 
0049     class FunctorsFromDerivedClasses = mpl::vector<>
0050 >
0051 class list_adaptor :
0052 
0053     public ::boost::bimaps::container_adaptor::sequence_container_adaptor
0054     <
0055         Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0056         IteratorToBaseConverter, IteratorFromBaseConverter,
0057         ReverseIteratorFromBaseConverter,
0058         ValueToBaseConverter, ValueFromBaseConverter,
0059         FunctorsFromDerivedClasses
0060     >
0061 {
0062     typedef ::boost::bimaps::container_adaptor::sequence_container_adaptor
0063     <
0064         Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0065         IteratorToBaseConverter, IteratorFromBaseConverter,
0066         ReverseIteratorFromBaseConverter,
0067         ValueToBaseConverter, ValueFromBaseConverter,
0068         FunctorsFromDerivedClasses
0069 
0070     > base_;
0071 
0072     // Access -----------------------------------------------------------------
0073 
0074     public:
0075 
0076     explicit list_adaptor(Base & c) :
0077         base_(c) {}
0078 
0079     protected:
0080 
0081     typedef list_adaptor list_adaptor_;
0082 
0083     // Interface -------------------------------------------------------------
0084 
0085     public:
0086 
0087     void splice(Iterator position, list_adaptor & x)
0088     {
0089         this->base().splice(
0090             this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()
0091                 (position),
0092             x.base()
0093         );
0094     }
0095 
0096     void splice(Iterator position, list_adaptor & x, Iterator i)
0097     {
0098         this->base().splice(
0099             this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()
0100                 (position),
0101             x.base(),
0102             this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
0103         );
0104     }
0105 
0106     void splice(Iterator position, list_adaptor & x, 
0107                 Iterator first, Iterator last)
0108     {
0109         this->base().splice(
0110             this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()
0111                 (position),
0112             x.base(),
0113             this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
0114             this->template functor<BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
0115         );
0116     }
0117 
0118     void remove(
0119         BOOST_DEDUCED_TYPENAME ::boost::call_traits<
0120             BOOST_DEDUCED_TYPENAME base_::value_type
0121         >::param_type value
0122     )
0123     {
0124         this->base().remove(
0125             this->template functor<BOOST_DEDUCED_TYPENAME base_::value_to_base>()(value)
0126         );
0127     }
0128 
0129     template< class Predicate >
0130     void remove_if(Predicate pred)
0131     {
0132         this->base().remove_if(
0133             ::boost::bimaps::container_adaptor::detail::unary_check_adaptor
0134             <
0135                 Predicate,
0136                 BOOST_DEDUCED_TYPENAME Base::value_type,
0137                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0138 
0139             >( pred, this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
0140         );
0141     }
0142 
0143     void unique()
0144     {
0145         this->base().unique(
0146             ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0147             <
0148                 std::equal_to<BOOST_DEDUCED_TYPENAME base_::value_type>,
0149                 BOOST_DEDUCED_TYPENAME Base::value_type,
0150                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0151 
0152             >(
0153                 std::equal_to<BOOST_DEDUCED_TYPENAME base_::value_type>(),
0154                 this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>()
0155             )
0156         );
0157     }
0158 
0159     template< class BinaryPredicate >
0160     void unique(BinaryPredicate binary_pred)
0161     {
0162         this->base().unique(
0163             ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0164             <
0165                 BinaryPredicate,
0166                 BOOST_DEDUCED_TYPENAME Base::value_type,
0167                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0168 
0169             >( binary_pred,
0170                this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
0171         );
0172     }
0173 
0174     void merge(list_adaptor & x)
0175     {
0176         this->base().merge(x.base(),
0177             ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0178             <
0179                 std::less<BOOST_DEDUCED_TYPENAME base_::value_type>,
0180                 BOOST_DEDUCED_TYPENAME Base::value_type,
0181                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0182 
0183             >(
0184                 std::less<BOOST_DEDUCED_TYPENAME base_::value_type>(),
0185                 this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>()
0186             )
0187         );
0188     }
0189 
0190     template< class Compare >
0191     void merge(list_adaptor & x, Compare comp)
0192     {
0193         this->base().merge(x.base(),
0194             ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0195             <
0196                 Compare,
0197                 BOOST_DEDUCED_TYPENAME Base::value_type,
0198                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0199 
0200             >( comp, this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
0201         );
0202     }
0203 
0204     void sort()
0205     {
0206         this->base().sort(
0207             ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0208             <
0209                 std::less<BOOST_DEDUCED_TYPENAME base_::value_type>,
0210                 BOOST_DEDUCED_TYPENAME Base::value_type,
0211                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0212 
0213             >(
0214                 std::less<BOOST_DEDUCED_TYPENAME base_::value_type>(),
0215                 this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>()
0216             )
0217         );
0218     }
0219 
0220     template< class Compare >
0221     void sort(Compare comp)
0222     {
0223         this->base().sort(
0224             ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0225             <
0226                 Compare,
0227                 BOOST_DEDUCED_TYPENAME Base::value_type,
0228                 BOOST_DEDUCED_TYPENAME base_::value_from_base
0229 
0230             >( comp, this->template functor<BOOST_DEDUCED_TYPENAME base_::value_from_base>() )
0231         );
0232     }
0233 
0234     void reverse()
0235     {
0236         this->base().reverse();
0237     }
0238 
0239 };
0240 
0241 
0242 } // namespace container_adaptor
0243 } // namespace bimaps
0244 } // namespace boost
0245 
0246 
0247 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_SET_ADAPTOR_HPP
0248 
0249