Chris@16: // Chris@16: // Boost.Pointer Container Chris@16: // Chris@16: // Copyright Thorsten Ottosen 2008. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/ptr_container/ Chris@16: // Chris@16: Chris@16: #ifndef BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP Chris@16: #define BOOST_PTR_CONTAINER_PTR_UNORDERED_MAP_HPP Chris@16: Chris@16: #if defined(_MSC_VER) && (_MSC_VER >= 1200) Chris@16: # pragma once Chris@16: #endif Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: Chris@16: template Chris@16: < Chris@16: class Key, Chris@16: class T, Chris@16: class Hash = boost::hash, Chris@16: class Pred = std::equal_to, Chris@16: class CloneAllocator = heap_clone_allocator, Chris@16: class Allocator = std::allocator< std::pair > Chris@16: > Chris@16: class ptr_unordered_map : Chris@16: public ptr_map_adapter, Chris@16: CloneAllocator,false> Chris@16: { Chris@16: typedef ptr_map_adapter, Chris@16: CloneAllocator,false> Chris@16: base_type; Chris@16: Chris@16: typedef ptr_unordered_map this_type; Chris@16: Chris@16: public: Chris@16: typedef typename base_type::size_type size_type; Chris@16: Chris@16: private: Chris@16: using base_type::lower_bound; Chris@16: using base_type::upper_bound; Chris@16: using base_type::rbegin; Chris@16: using base_type::rend; Chris@16: using base_type::crbegin; Chris@16: using base_type::crend; Chris@16: using base_type::key_comp; Chris@16: using base_type::value_comp; Chris@16: using base_type::front; Chris@16: using base_type::back; Chris@16: Chris@16: public: Chris@16: using base_type::begin; Chris@16: using base_type::end; Chris@16: using base_type::cbegin; Chris@16: using base_type::cend; Chris@16: using base_type::bucket_count; Chris@16: using base_type::max_bucket_count; Chris@16: using base_type::bucket_size; Chris@16: using base_type::bucket; Chris@16: using base_type::load_factor; Chris@16: using base_type::max_load_factor; Chris@16: using base_type::rehash; Chris@16: using base_type::key_eq; Chris@16: using base_type::hash_function; Chris@16: Chris@16: public: Chris@16: ptr_unordered_map() Chris@16: { } Chris@16: Chris@16: explicit ptr_unordered_map( size_type n ) Chris@16: : base_type( n, ptr_container_detail::unordered_associative_container_tag() ) Chris@16: { } Chris@16: Chris@16: ptr_unordered_map( size_type n, Chris@16: const Hash& comp, Chris@16: const Pred& pred = Pred(), Chris@16: const Allocator& a = Allocator() ) Chris@16: : base_type( n, comp, pred, a ) Chris@16: { } Chris@16: Chris@16: template< typename InputIterator > Chris@16: ptr_unordered_map( InputIterator first, InputIterator last ) Chris@16: : base_type( first, last ) Chris@16: { } Chris@16: Chris@16: template< typename InputIterator > Chris@16: ptr_unordered_map( InputIterator first, InputIterator last, Chris@16: const Hash& comp, Chris@16: const Pred& pred = Pred(), Chris@16: const Allocator& a = Allocator() ) Chris@16: : base_type( first, last, comp, pred, a ) Chris@16: { } Chris@16: Chris@16: BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_map, Chris@16: base_type, Chris@16: this_type ) Chris@16: Chris@16: template< class U > Chris@16: ptr_unordered_map( const ptr_unordered_map& r ) : base_type( r ) Chris@16: { } Chris@16: Chris@16: ptr_unordered_map& operator=( ptr_unordered_map r ) Chris@16: { Chris@16: this->swap( r ); Chris@16: return *this; Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: template Chris@16: < Chris@16: class Key, Chris@16: class T, Chris@16: class Hash = boost::hash, Chris@16: class Pred = std::equal_to, Chris@16: class CloneAllocator = heap_clone_allocator, Chris@16: class Allocator = std::allocator< std::pair > Chris@16: > Chris@16: class ptr_unordered_multimap : Chris@16: public ptr_multimap_adapter, Chris@16: CloneAllocator,false> Chris@16: { Chris@16: typedef ptr_multimap_adapter, Chris@16: CloneAllocator,false> Chris@16: base_type; Chris@16: Chris@16: typedef ptr_unordered_multimap this_type; Chris@16: Chris@16: public: Chris@16: typedef typename base_type::size_type size_type; Chris@16: Chris@16: private: Chris@16: using base_type::lower_bound; Chris@16: using base_type::upper_bound; Chris@16: using base_type::rbegin; Chris@16: using base_type::rend; Chris@16: using base_type::crbegin; Chris@16: using base_type::crend; Chris@16: using base_type::key_comp; Chris@16: using base_type::value_comp; Chris@16: using base_type::front; Chris@16: using base_type::back; Chris@16: Chris@16: public: Chris@16: using base_type::begin; Chris@16: using base_type::end; Chris@16: using base_type::cbegin; Chris@16: using base_type::cend; Chris@16: using base_type::bucket_count; Chris@16: using base_type::max_bucket_count; Chris@16: using base_type::bucket_size; Chris@16: using base_type::bucket; Chris@16: using base_type::load_factor; Chris@16: using base_type::max_load_factor; Chris@16: using base_type::rehash; Chris@16: using base_type::key_eq; Chris@16: using base_type::hash_function; Chris@16: Chris@16: public: Chris@16: ptr_unordered_multimap() Chris@16: { } Chris@16: Chris@16: explicit ptr_unordered_multimap( size_type n ) Chris@16: : base_type( n, ptr_container_detail::unordered_associative_container_tag() ) Chris@16: { } Chris@16: Chris@16: ptr_unordered_multimap( size_type n, Chris@16: const Hash& comp, Chris@16: const Pred& pred = Pred(), Chris@16: const Allocator& a = Allocator() ) Chris@16: : base_type( n, comp, pred, a ) Chris@16: { } Chris@16: Chris@16: template< typename InputIterator > Chris@16: ptr_unordered_multimap( InputIterator first, InputIterator last ) Chris@16: : base_type( first, last ) Chris@16: { } Chris@16: Chris@16: template< typename InputIterator > Chris@16: ptr_unordered_multimap( InputIterator first, InputIterator last, Chris@16: const Hash& comp, Chris@16: const Pred& pred = Pred(), Chris@16: const Allocator& a = Allocator() ) Chris@16: : base_type( first, last, comp, pred, a ) Chris@16: { } Chris@16: Chris@16: BOOST_PTR_CONTAINER_DEFINE_RELEASE_AND_CLONE( ptr_unordered_multimap, Chris@16: base_type, Chris@16: this_type ) Chris@16: Chris@16: template< class U > Chris@16: ptr_unordered_multimap( const ptr_unordered_multimap& r ) : base_type( r ) Chris@16: { } Chris@16: Chris@16: ptr_unordered_multimap& operator=( ptr_unordered_multimap r ) Chris@16: { Chris@16: this->swap( r ); Chris@16: return *this; Chris@16: } Chris@16: }; Chris@16: Chris@16: ////////////////////////////////////////////////////////////////////////////// Chris@16: // clonability Chris@16: Chris@16: template< class K, class T, class H, class P, class CA, class A > Chris@16: inline ptr_unordered_map* Chris@16: new_clone( const ptr_unordered_map& r ) Chris@16: { Chris@16: return r.clone().release(); Chris@16: } Chris@16: Chris@16: template< class K, class T, class H, class P, class CA, class A > Chris@16: inline ptr_unordered_multimap* Chris@16: new_clone( const ptr_unordered_multimap& r ) Chris@16: { Chris@16: return r.clone().release(); Chris@16: } Chris@16: Chris@16: ///////////////////////////////////////////////////////////////////////// Chris@16: // swap Chris@16: Chris@16: template< class K, class T, class H, class P, class CA, class A > Chris@16: inline void swap( ptr_unordered_map& l, Chris@16: ptr_unordered_map& r ) Chris@16: { Chris@16: l.swap(r); Chris@16: } Chris@16: Chris@16: template< class K, class T, class H, class P, class CA, class A > Chris@16: inline void swap( ptr_unordered_multimap& l, Chris@16: ptr_unordered_multimap& r ) Chris@16: { Chris@16: l.swap(r); Chris@16: } Chris@16: Chris@16: Chris@16: } Chris@16: Chris@16: #endif