1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/boost/ptr_container/detail/associative_ptr_container.hpp Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -0,0 +1,209 @@
1.4 +//
1.5 +// Boost.Pointer Container
1.6 +//
1.7 +// Copyright Thorsten Ottosen 2003-2005. Use, modification and
1.8 +// distribution is subject to the Boost Software License, Version
1.9 +// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
1.10 +// http://www.boost.org/LICENSE_1_0.txt)
1.11 +//
1.12 +// For more information, see http://www.boost.org/libs/ptr_container/
1.13 +//
1.14 +
1.15 +
1.16 +#ifndef BOOST_PTR_CONTAINER_DETAIL_ASSOCIATIVE_PTR_CONTAINER_HPP
1.17 +#define BOOST_PTR_CONTAINER_DETAIL_ASSOCIATIVE_PTR_CONTAINER_HPP
1.18 +
1.19 +#if defined(_MSC_VER) && (_MSC_VER >= 1200)
1.20 +# pragma once
1.21 +#endif
1.22 +
1.23 +#include <boost/ptr_container/detail/reversible_ptr_container.hpp>
1.24 +
1.25 +namespace boost
1.26 +{
1.27 +
1.28 +namespace ptr_container_detail
1.29 +{
1.30 + template
1.31 + <
1.32 + class Config,
1.33 + class CloneAllocator
1.34 + >
1.35 + class associative_ptr_container :
1.36 + public reversible_ptr_container<Config,CloneAllocator>
1.37 + {
1.38 + typedef reversible_ptr_container<Config,CloneAllocator>
1.39 + base_type;
1.40 +
1.41 + typedef BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
1.42 + scoped_deleter;
1.43 +
1.44 + public: // typedefs
1.45 + typedef BOOST_DEDUCED_TYPENAME Config::key_type
1.46 + key_type;
1.47 + typedef BOOST_DEDUCED_TYPENAME Config::key_compare
1.48 + key_compare;
1.49 + typedef BOOST_DEDUCED_TYPENAME Config::value_compare
1.50 + value_compare;
1.51 + typedef BOOST_DEDUCED_TYPENAME Config::iterator
1.52 + iterator;
1.53 + typedef BOOST_DEDUCED_TYPENAME Config::const_iterator
1.54 + const_iterator;
1.55 + typedef BOOST_DEDUCED_TYPENAME base_type::size_type
1.56 + size_type;
1.57 +
1.58 + public: // foundation
1.59 +
1.60 + template< class Compare, class Allocator >
1.61 + associative_ptr_container( const Compare& comp,
1.62 + const Allocator& a )
1.63 + : base_type( comp, a )
1.64 + { }
1.65 +
1.66 + template< class InputIterator, class Compare, class Allocator >
1.67 + associative_ptr_container( InputIterator first, InputIterator last,
1.68 + const Compare& comp,
1.69 + const Allocator& a )
1.70 + : base_type( first, last, comp, a )
1.71 + { }
1.72 +
1.73 + template< class PtrContainer >
1.74 + associative_ptr_container( std::auto_ptr<PtrContainer> r )
1.75 + : base_type( r, key_compare() )
1.76 + { }
1.77 +
1.78 + template< class PtrContainer >
1.79 + void operator=( std::auto_ptr<PtrContainer> r )
1.80 + {
1.81 + base_type::operator=( r );
1.82 + }
1.83 +
1.84 + public: // associative container interface
1.85 + key_compare key_comp() const
1.86 + {
1.87 + return this->c_private().key_comp();
1.88 + }
1.89 +
1.90 + value_compare value_comp() const
1.91 + {
1.92 + return this->c_private().value_comp();
1.93 + }
1.94 +
1.95 + iterator erase( iterator before ) // nothrow
1.96 + {
1.97 + BOOST_ASSERT( !this->empty() );
1.98 + BOOST_ASSERT( before != this->end() );
1.99 +
1.100 + this->remove( before ); // nothrow
1.101 + iterator res( before ); // nothrow
1.102 + ++res; // nothrow
1.103 + this->c_private().erase( before.base() ); // nothrow
1.104 + return res; // nothrow
1.105 + }
1.106 +
1.107 + size_type erase( const key_type& x ) // nothrow
1.108 + {
1.109 + iterator i( this->c_private().find( x ) ); // nothrow
1.110 + if( i == this->end() ) // nothrow
1.111 + return 0u; // nothrow
1.112 + this->remove( i ); // nothrow
1.113 + return this->c_private().erase( x ); // nothrow
1.114 + }
1.115 +
1.116 + iterator erase( iterator first,
1.117 + iterator last ) // nothrow
1.118 + {
1.119 + iterator res( last ); // nothrow
1.120 + if( res != this->end() )
1.121 + ++res; // nothrow
1.122 +
1.123 + this->remove( first, last ); // nothrow
1.124 + this->c_private().erase( first.base(), last.base() );// nothrow
1.125 + return res; // nothrow
1.126 + }
1.127 +
1.128 + protected:
1.129 +
1.130 + template< class AssociatePtrCont >
1.131 + void multi_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator object,
1.132 + AssociatePtrCont& from ) // strong
1.133 + {
1.134 + BOOST_ASSERT( (void*)&from != (void*)this );
1.135 + BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
1.136 +
1.137 + this->c_private().insert( *object.base() ); // strong
1.138 + from.c_private().erase( object.base() ); // nothrow
1.139 + }
1.140 +
1.141 + template< class AssociatePtrCont >
1.142 + size_type multi_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator first,
1.143 + BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator last,
1.144 + AssociatePtrCont& from ) // basic
1.145 + {
1.146 + BOOST_ASSERT( (void*)&from != (void*)this );
1.147 + BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
1.148 +
1.149 + size_type res = 0;
1.150 + for( ; first != last; )
1.151 + {
1.152 + BOOST_ASSERT( first != from.end() );
1.153 + this->c_private().insert( *first.base() ); // strong
1.154 + BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator
1.155 + to_delete( first );
1.156 + ++first;
1.157 + from.c_private().erase( to_delete.base() ); // nothrow
1.158 + ++res;
1.159 + }
1.160 +
1.161 + return res;
1.162 + }
1.163 +
1.164 + template< class AssociatePtrCont >
1.165 + bool single_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator object,
1.166 + AssociatePtrCont& from ) // strong
1.167 + {
1.168 + BOOST_ASSERT( (void*)&from != (void*)this );
1.169 + BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
1.170 +
1.171 + std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> p =
1.172 + this->c_private().insert( *object.base() ); // strong
1.173 + if( p.second )
1.174 + from.c_private().erase( object.base() ); // nothrow
1.175 +
1.176 + return p.second;
1.177 + }
1.178 +
1.179 + template< class AssociatePtrCont >
1.180 + size_type single_transfer( BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator first,
1.181 + BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator last,
1.182 + AssociatePtrCont& from ) // basic
1.183 + {
1.184 + BOOST_ASSERT( (void*)&from != (void*)this );
1.185 + BOOST_ASSERT( !from.empty() && "Cannot transfer from empty container" );
1.186 +
1.187 + size_type res = 0;
1.188 + for( ; first != last; )
1.189 + {
1.190 + BOOST_ASSERT( first != from.end() );
1.191 + std::pair<BOOST_DEDUCED_TYPENAME base_type::ptr_iterator,bool> p =
1.192 + this->c_private().insert( *first.base() ); // strong
1.193 + BOOST_DEDUCED_TYPENAME AssociatePtrCont::iterator
1.194 + to_delete( first );
1.195 + ++first;
1.196 + if( p.second )
1.197 + {
1.198 + from.c_private().erase( to_delete.base() ); // nothrow
1.199 + ++res;
1.200 + }
1.201 + }
1.202 + return res;
1.203 + }
1.204 +
1.205 + }; // class 'associative_ptr_container'
1.206 +
1.207 +} // namespace 'ptr_container_detail'
1.208 +
1.209 +} // namespace 'boost'
1.210 +
1.211 +
1.212 +#endif