Boost logo

Boost-Commit :

From: nesotto_at_[hidden]
Date: 2008-06-03 18:15:14


Author: nesotto
Date: 2008-06-03 18:15:13 EDT (Tue, 03 Jun 2008)
New Revision: 46097
URL: http://svn.boost.org/trac/boost/changeset/46097

Log:
update for unordered containers
Added:
   trunk/boost/ptr_container/detail/meta_functions.hpp (contents, props changed)
Text files modified:
   trunk/boost/ptr_container/detail/associative_ptr_container.hpp | 114 ++++++++++++++++++++++++++-------------
   trunk/boost/ptr_container/detail/map_iterator.hpp | 36 ++++++++++++
   2 files changed, 111 insertions(+), 39 deletions(-)

Modified: trunk/boost/ptr_container/detail/associative_ptr_container.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/associative_ptr_container.hpp (original)
+++ trunk/boost/ptr_container/detail/associative_ptr_container.hpp 2008-06-03 18:15:13 EDT (Tue, 03 Jun 2008)
@@ -38,6 +38,8 @@
         typedef BOOST_DEDUCED_TYPENAME base_type::scoped_deleter
                                 scoped_deleter;
 
+ typedef BOOST_DEDUCED_TYPENAME Config::container_type
+ container_type;
     public: // typedefs
         typedef BOOST_DEDUCED_TYPENAME Config::key_type
                                 key_type;
@@ -45,6 +47,10 @@
                                 key_compare;
         typedef BOOST_DEDUCED_TYPENAME Config::value_compare
                                 value_compare;
+ typedef BOOST_DEDUCED_TYPENAME Config::hasher
+ hasher;
+ typedef BOOST_DEDUCED_TYPENAME Config::key_equal
+ key_equal;
         typedef BOOST_DEDUCED_TYPENAME Config::iterator
                                 iterator;
         typedef BOOST_DEDUCED_TYPENAME Config::const_iterator
@@ -53,57 +59,77 @@
                                 size_type;
 
     public: // foundation
+ associative_ptr_container()
+ { }
 
- template< class Compare, class Allocator >
- associative_ptr_container( const Compare& comp,
- const Allocator& a )
+ template< class SizeType >
+ associative_ptr_container( SizeType n, unordered_associative_container_tag tag )
+ : base_type( n, tag )
+ { }
+
+ template< class Compare, class Allocator >
+ associative_ptr_container( const Compare& comp,
+ const Allocator& a )
          : base_type( comp, a )
- { }
-
- template< class InputIterator, class Compare, class Allocator >
- associative_ptr_container( InputIterator first, InputIterator last,
- const Compare& comp,
- const Allocator& a )
+ { }
+
+ template< class Hash, class Pred, class Allocator >
+ associative_ptr_container( const Hash& hash,
+ const Pred& pred,
+ const Allocator& a )
+ : base_type( hash, pred, a )
+ { }
+
+ template< class InputIterator, class Compare, class Allocator >
+ associative_ptr_container( InputIterator first, InputIterator last,
+ const Compare& comp,
+ const Allocator& a )
          : base_type( first, last, comp, a )
- { }
-
- template< class PtrContainer >
- explicit associative_ptr_container( std::auto_ptr<PtrContainer> r )
- : base_type( r, key_compare() )
- { }
-
- explicit associative_ptr_container( const associative_ptr_container& r )
- : base_type( r.begin(), r.end(), key_compare(),
- BOOST_DEDUCED_TYPENAME Config::allocator_type() )
- { }
-
- template< class C, class V >
- explicit associative_ptr_container( const associative_ptr_container<C,V>& r )
- : base_type( r.begin(), r.end(), key_compare(),
- BOOST_DEDUCED_TYPENAME Config::allocator_type() )
- { }
-
- template< class PtrContainer >
- associative_ptr_container& operator=( std::auto_ptr<PtrContainer> r ) // nothrow
- {
+ { }
+
+ template< class InputIterator, class Hash, class Pred, class Allocator >
+ associative_ptr_container( InputIterator first, InputIterator last,
+ const Hash& hash,
+ const Pred& pred,
+ const Allocator& a )
+ : base_type( first, last, hash, pred, a )
+ { }
+
+ template< class PtrContainer >
+ explicit associative_ptr_container( std::auto_ptr<PtrContainer> r )
+ : base_type( r )
+ { }
+
+ explicit associative_ptr_container( const associative_ptr_container& r )
+ : base_type( r.begin(), r.end(), container_type() )
+ { }
+
+ template< class C, class V >
+ explicit associative_ptr_container( const associative_ptr_container<C,V>& r )
+ : base_type( r.begin(), r.end(), container_type() )
+ { }
+
+ template< class PtrContainer >
+ associative_ptr_container& operator=( std::auto_ptr<PtrContainer> r ) // nothrow
+ {
            base_type::operator=( r );
            return *this;
- }
-
- template< class C, class V >
- associative_ptr_container& operator=( const associative_ptr_container<C,V>& r ) // strong
- {
+ }
+
+ template< class C, class V >
+ associative_ptr_container& operator=( const associative_ptr_container<C,V>& r ) // strong
+ {
            associative_ptr_container clone( r );
            this->swap( clone );
            return *this;
- }
+ }
         
- associative_ptr_container& operator=( const associative_ptr_container& r ) // strong
- {
+ associative_ptr_container& operator=( const associative_ptr_container& r ) // strong
+ {
            associative_ptr_container clone( r );
            this->swap( clone );
            return *this;
- }
+ }
 
     public: // associative container interface
         key_compare key_comp() const
@@ -116,6 +142,16 @@
             return this->base().value_comp();
         }
 
+ hasher hash_function() const
+ {
+ return this->base().hash_function();
+ }
+
+ key_equal key_eq() const
+ {
+ return this->base().key_eq();
+ }
+
         iterator erase( iterator before ) // nothrow
         {
             BOOST_ASSERT( !this->empty() );

Modified: trunk/boost/ptr_container/detail/map_iterator.hpp
==============================================================================
--- trunk/boost/ptr_container/detail/map_iterator.hpp (original)
+++ trunk/boost/ptr_container/detail/map_iterator.hpp 2008-06-03 18:15:13 EDT (Tue, 03 Jun 2008)
@@ -18,6 +18,7 @@
 
 #include <boost/config.hpp>
 #include <boost/iterator/iterator_adaptor.hpp>
+#include <boost/utility/compare_pointees.hpp>
 #include <utility>
 
 namespace boost
@@ -47,6 +48,41 @@
             {
                 return this;
             }
+
+ friend inline bool operator==( ref_pair l, ref_pair r )
+ {
+ return l.first == r.first &&
+ boost::equal_pointees( l.second, r.second );
+ }
+
+ friend inline bool operator!=( ref_pair l, ref_pair r )
+ {
+ return !( l == r );
+ }
+
+ friend inline bool operator<( ref_pair l, ref_pair r )
+ {
+ if( l.first == r.first )
+ return boost::less_pointees( l.second, r.second );
+ else
+ return l.first < r.first;
+ }
+
+ friend inline bool operator>( ref_pair l, ref_pair r )
+ {
+ return r < l;
+ }
+
+ friend inline bool operator<=( ref_pair l, ref_pair r )
+ {
+ return !(r < l);
+ }
+
+ friend inline bool operator>=( ref_pair l, ref_pair r )
+ {
+ return !(l < r);
+ }
+
         };
     }
     

Added: trunk/boost/ptr_container/detail/meta_functions.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/ptr_container/detail/meta_functions.hpp 2008-06-03 18:15:13 EDT (Tue, 03 Jun 2008)
@@ -0,0 +1,48 @@
+//
+// Boost.Pointer Container
+//
+// Copyright Thorsten Ottosen 2008. Use, modification and
+// distribution is subject to the Boost Software License, Version
+// 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// For more information, see http://www.boost.org/libs/ptr_container/
+//
+
+#ifndef BOOST_PTR_CONTAINER_DETAIL_META_FUNCTIONS
+#define BOOST_PTR_CONTAINER_DETAIL_META_FUNCTIONS
+
+#include <boost/mpl/identity.hpp>
+#include <boost/mpl/eval_if.hpp>
+
+namespace boost
+{
+namespace ptr_container_detail
+{
+ template< class T >
+ struct select_value_compare
+ {
+ typedef typename T::value_compare type;
+ };
+
+ template< class T >
+ struct select_key_compare
+ {
+ typedef typename T::key_compare type;
+ };
+
+ template< class T >
+ struct select_hasher
+ {
+ typedef typename T::hasher type;
+ };
+
+ template< class T >
+ struct select_key_equal
+ {
+ typedef typename T::key_equal type;
+ };
+}
+}
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk