Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-12-19 18:13:20


Author: danieljames
Date: 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
New Revision: 42188
URL: http://svn.boost.org/trac/boost/changeset/42188

Log:
Merge: Support for cbegin(n), cend(n).

Properties modified:
   branches/unordered/trunk/ (props changed)
Text files modified:
   branches/unordered/trunk/boost/unordered_map.hpp | 4 -
   branches/unordered/trunk/boost/unordered_set.hpp | 4 -
   branches/unordered/trunk/libs/unordered/doc/rationale.qbk | 6 ++
   branches/unordered/trunk/libs/unordered/doc/ref.xml | 96 ++++++++++++++++++++++++++++++++++++++++
   branches/unordered/trunk/libs/unordered/test/unordered/bucket_tests.cpp | 2
   branches/unordered/trunk/libs/unordered/test/unordered/compile_tests.cpp | 5 ++
   6 files changed, 109 insertions(+), 8 deletions(-)

Modified: branches/unordered/trunk/boost/unordered_map.hpp
==============================================================================
--- branches/unordered/trunk/boost/unordered_map.hpp (original)
+++ branches/unordered/trunk/boost/unordered_map.hpp 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
@@ -294,7 +294,6 @@
             return const_local_iterator(base.end(n));
         }
 
-#if defined(BOOST_UNORDERED_LOCAL_CBEGIN)
         const_local_iterator cbegin(size_type n) const
         {
             return const_local_iterator(base.begin(n));
@@ -304,7 +303,6 @@
         {
             return const_local_iterator(base.end(n));
         }
-#endif
 
         // hash policy
 
@@ -593,7 +591,6 @@
             return const_local_iterator(base.end(n));
         }
 
-#if defined(BOOST_UNORDERED_LOCAL_CBEGIN)
         const_local_iterator cbegin(size_type n) const
         {
             return const_local_iterator(base.begin(n));
@@ -603,7 +600,6 @@
         {
             return const_local_iterator(base.end(n));
         }
-#endif
 
         // hash policy
 

Modified: branches/unordered/trunk/boost/unordered_set.hpp
==============================================================================
--- branches/unordered/trunk/boost/unordered_set.hpp (original)
+++ branches/unordered/trunk/boost/unordered_set.hpp 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
@@ -264,7 +264,6 @@
             return const_local_iterator(base.end(n));
         }
 
-#if defined(BOOST_UNORDERED_LOCAL_CBEGIN)
         const_local_iterator cbegin(size_type n) const
         {
             return const_local_iterator(base.begin(n));
@@ -274,7 +273,6 @@
         {
             return const_local_iterator(base.end(n));
         }
-#endif
 
         // hash policy
 
@@ -548,7 +546,6 @@
             return const_local_iterator(base.end(n));
         }
 
-#if defined(BOOST_UNORDERED_LOCAL_CBEGIN)
         const_local_iterator cbegin(size_type n) const
         {
             return const_local_iterator(base.begin(n));
@@ -558,7 +555,6 @@
         {
             return const_local_iterator(base.end(n));
         }
-#endif
 
         // hash policy
 

Modified: branches/unordered/trunk/libs/unordered/doc/rationale.qbk
==============================================================================
--- branches/unordered/trunk/libs/unordered/doc/rationale.qbk (original)
+++ branches/unordered/trunk/libs/unordered/doc/rationale.qbk 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
@@ -137,6 +137,12 @@
 This is [@http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#518 issue 581].
 The current proposal is that insert, erase and rehash are stable - so they are here.
 
+[h3 const_local_iterator cbegin, cend missing from TR1]
+
+[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2482.html#691
+Issue 691] is that `cbegin` and `cend` are missing for local iterators.
+The current resolution is that they'll be added, so I've added them.
+
 [h2 Future Developments]
 
 [h3 Support for `emplace`]

Modified: branches/unordered/trunk/libs/unordered/doc/ref.xml
==============================================================================
--- branches/unordered/trunk/libs/unordered/doc/ref.xml (original)
+++ branches/unordered/trunk/libs/unordered/doc/ref.xml 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
@@ -526,6 +526,30 @@
                 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
               </returns>
             </overloaded-method>
+ <method name="cbegin" cv="const">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
+ <method name="cend">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
           </method-group>
           <method-group name="hash policy">
             <method name="load_factor" cv="const">
@@ -1105,6 +1129,30 @@
                 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
               </returns>
             </overloaded-method>
+ <method name="cbegin" cv="const">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
+ <method name="cend">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
           </method-group>
           <method-group name="hash policy">
             <method name="load_factor" cv="const">
@@ -1735,6 +1783,30 @@
                 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
               </returns>
             </overloaded-method>
+ <method name="cbegin" cv="const">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
+ <method name="cend">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
           </method-group>
           <method-group name="hash policy">
             <method name="load_factor" cv="const">
@@ -2324,6 +2396,30 @@
                 <para>A local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
               </returns>
             </overloaded-method>
+ <method name="cbegin" cv="const">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the first element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
+ <method name="cend">
+ <parameter name="n">
+ <paramtype>size_type</paramtype>
+ </parameter>
+ <type>const_local_iterator</type>
+ <requires>
+ <para><code>n</code> shall be in the range <code>[0, bucket_count())</code>.</para>
+ </requires>
+ <returns>
+ <para>A constant local iterator pointing the 'one past the end' element in the bucket with index <code>n</code>.</para>
+ </returns>
+ </method>
           </method-group>
           <method-group name="hash policy">
             <method name="load_factor" cv="const">

Modified: branches/unordered/trunk/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- branches/unordered/trunk/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ branches/unordered/trunk/libs/unordered/test/unordered/bucket_tests.cpp 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
@@ -41,8 +41,10 @@
 
     for(size_type i = 0; i < x.bucket_count(); ++i) {
         BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x.begin(i), x.end(i)));
+ BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x.cbegin(i), x.cend(i)));
         X const& x_ref = x;
         BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.begin(i), x_ref.end(i)));
+ BOOST_TEST(x.bucket_size(i) == (size_type) std::distance(x_ref.cbegin(i), x_ref.cend(i)));
     }
 }
 

Modified: branches/unordered/trunk/libs/unordered/test/unordered/compile_tests.cpp
==============================================================================
--- branches/unordered/trunk/libs/unordered/test/unordered/compile_tests.cpp (original)
+++ branches/unordered/trunk/libs/unordered/test/unordered/compile_tests.cpp 2007-12-19 18:13:20 EST (Wed, 19 Dec 2007)
@@ -190,6 +190,11 @@
     test::check_return_type<local_iterator>::equals(a.end(0));
     test::check_return_type<const_local_iterator>::equals(b.end(0));
 
+ test::check_return_type<const_local_iterator>::equals(a.cbegin(0));
+ test::check_return_type<const_local_iterator>::equals(b.cbegin(0));
+ test::check_return_type<const_local_iterator>::equals(a.cend(0));
+ test::check_return_type<const_local_iterator>::equals(b.cend(0));
+
     test::check_return_type<float>::equals(b.load_factor());
     test::check_return_type<float>::equals(b.max_load_factor());
     a.max_load_factor((float) 2.0);


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