Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-12-16 08:32:04


Author: danieljames
Date: 2007-12-16 08:32:04 EST (Sun, 16 Dec 2007)
New Revision: 42103
URL: http://svn.boost.org/trac/boost/changeset/42103

Log:
Support for cbegin(n), cend(n).
Text files modified:
   sandbox/unordered/boost/unordered_map.hpp | 4 -
   sandbox/unordered/boost/unordered_set.hpp | 4 -
   sandbox/unordered/libs/unordered/doc/rationale.qbk | 6 ++
   sandbox/unordered/libs/unordered/doc/ref.xml | 96 ++++++++++++++++++++++++++++++++++++++++
   sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp | 2
   sandbox/unordered/libs/unordered/test/unordered/compile_tests.cpp | 5 ++
   6 files changed, 109 insertions(+), 8 deletions(-)

Modified: sandbox/unordered/boost/unordered_map.hpp
==============================================================================
--- sandbox/unordered/boost/unordered_map.hpp (original)
+++ sandbox/unordered/boost/unordered_map.hpp 2007-12-16 08:32:04 EST (Sun, 16 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: sandbox/unordered/boost/unordered_set.hpp
==============================================================================
--- sandbox/unordered/boost/unordered_set.hpp (original)
+++ sandbox/unordered/boost/unordered_set.hpp 2007-12-16 08:32:04 EST (Sun, 16 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: sandbox/unordered/libs/unordered/doc/rationale.qbk
==============================================================================
--- sandbox/unordered/libs/unordered/doc/rationale.qbk (original)
+++ sandbox/unordered/libs/unordered/doc/rationale.qbk 2007-12-16 08:32:04 EST (Sun, 16 Dec 2007)
@@ -182,6 +182,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: sandbox/unordered/libs/unordered/doc/ref.xml
==============================================================================
--- sandbox/unordered/libs/unordered/doc/ref.xml (original)
+++ sandbox/unordered/libs/unordered/doc/ref.xml 2007-12-16 08:32:04 EST (Sun, 16 Dec 2007)
@@ -530,6 +530,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">
@@ -1117,6 +1141,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">
@@ -1755,6 +1803,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">
@@ -2352,6 +2424,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: sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/bucket_tests.cpp 2007-12-16 08:32:04 EST (Sun, 16 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: sandbox/unordered/libs/unordered/test/unordered/compile_tests.cpp
==============================================================================
--- sandbox/unordered/libs/unordered/test/unordered/compile_tests.cpp (original)
+++ sandbox/unordered/libs/unordered/test/unordered/compile_tests.cpp 2007-12-16 08:32:04 EST (Sun, 16 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