Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60754 - in trunk: boost/unordered libs/unordered/doc libs/unordered/test/unordered
From: daniel_james_at_[hidden]
Date: 2010-03-21 20:42:08


Author: danieljames
Date: 2010-03-21 20:42:07 EDT (Sun, 21 Mar 2010)
New Revision: 60754
URL: http://svn.boost.org/trac/boost/changeset/60754

Log:
Add quick_erase to the unordered containers. Refs #3966.
Text files modified:
   trunk/boost/unordered/unordered_map.hpp | 10 ++
   trunk/boost/unordered/unordered_set.hpp | 10 ++
   trunk/libs/unordered/doc/changes.qbk | 11 +++
   trunk/libs/unordered/doc/ref.xml | 144 +++++++++++++++++++++++++++++++++------
   trunk/libs/unordered/test/unordered/erase_tests.cpp | 8 +-
   5 files changed, 155 insertions(+), 28 deletions(-)

Modified: trunk/boost/unordered/unordered_map.hpp
==============================================================================
--- trunk/boost/unordered/unordered_map.hpp (original)
+++ trunk/boost/unordered/unordered_map.hpp 2010-03-21 20:42:07 EDT (Sun, 21 Mar 2010)
@@ -369,6 +369,11 @@
             return iterator(table_.erase_range(get(first), get(last)));
         }
 
+ void quick_erase(const_iterator position)
+ {
+ table_.erase(get(position));
+ }
+
         void erase_return_void(const_iterator position)
         {
             table_.erase(get(position));
@@ -907,6 +912,11 @@
             return iterator(table_.erase_range(get(first), get(last)));
         }
 
+ void quick_erase(const_iterator position)
+ {
+ table_.erase(get(position));
+ }
+
         void erase_return_void(const_iterator position)
         {
             table_.erase(get(position));

Modified: trunk/boost/unordered/unordered_set.hpp
==============================================================================
--- trunk/boost/unordered/unordered_set.hpp (original)
+++ trunk/boost/unordered/unordered_set.hpp 2010-03-21 20:42:07 EDT (Sun, 21 Mar 2010)
@@ -361,6 +361,11 @@
             return iterator(table_.erase_range(get(first), get(last)));
         }
 
+ void quick_erase(const_iterator position)
+ {
+ table_.erase(get(position));
+ }
+
         void erase_return_void(const_iterator position)
         {
             table_.erase(get(position));
@@ -849,6 +854,11 @@
             return iterator(table_.erase_range(get(first), get(last)));
         }
 
+ void quick_erase(const_iterator position)
+ {
+ table_.erase(get(position));
+ }
+
         void erase_return_void(const_iterator position)
         {
             table_.erase(get(position));

Modified: trunk/libs/unordered/doc/changes.qbk
==============================================================================
--- trunk/libs/unordered/doc/changes.qbk (original)
+++ trunk/libs/unordered/doc/changes.qbk 2010-03-21 20:42:07 EDT (Sun, 21 Mar 2010)
@@ -117,4 +117,15 @@
   Add missing `std` qualifier to `ptrdiff_t`.
 * Some code formatting changes to fit almost all lines into 80 characters.
 
+
+[h2 Boost 1.43.0]
+
+* [@http://svn.boost.org/trac/boost/ticket/3966 Ticket 3966]:
+ `erase_return_void` is now `quick_erase`, which is the
+ [@http://home.roadrunner.com/~hinnant/issue_review/lwg-active.html#579
+ current forerunner for resolving the slow erase by iterator], although
+ there's a strong possibility that this may change in the future. The old
+ method name remains for backwards compatibility but is considered deprecated
+ and will be removed in a future release.
+
 [endsect]

Modified: trunk/libs/unordered/doc/ref.xml
==============================================================================
--- trunk/libs/unordered/doc/ref.xml (original)
+++ trunk/libs/unordered/doc/ref.xml 2010-03-21 20:42:07 EDT (Sun, 21 Mar 2010)
@@ -464,8 +464,8 @@
                   When the number of elements is a lot smaller than the number of buckets
                   this function can be very inefficient as it has to search through empty
                   buckets for the next element, in order to return the iterator.
- As a temporary workaround, the container has the method
- <methodname>erase_return_void</methodname> which will be faster.
+ The method <methodname>quick_erase</methodname> is faster, but has yet
+ to be standardized.
                 </para>
               </notes>
             </method>
@@ -503,6 +503,30 @@
                 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
               </throws>
             </method>
+ <method name="quick_erase">
+ <parameter name="position">
+ <paramtype>const_iterator</paramtype>
+ </parameter>
+ <type>void</type>
+ <description>
+ <para>Erase the element pointed to by <code>position</code>.</para>
+ </description>
+ <throws>
+ <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para>
+ <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
+ </throws>
+ <notes>
+ <para>
+ This method is faster than <methodname>erase</methodname> as
+ it doesn't have to find the next element in the container -
+ a potentially costly operation.
+ </para>
+ <para>
+ As it hasn't been standardized, it's likely that this may
+ change in the future.
+ </para>
+ </notes>
+ </method>
             <method name="erase_return_void">
               <parameter name="position">
                 <paramtype>const_iterator</paramtype>
@@ -517,10 +541,10 @@
               </throws>
               <notes>
                 <para>
- This is a temporary workaround for the inefficient
- <methodname>erase</methodname> method. Hopefully, in a future
- version the signature of <methodname>erase</methodname> will
- be changed and this will be deprecated.
+ This method is now deprecated, use
+ <methodname>quick_return</methodname> instead. Although be
+ warned that as that isn't standardized yet, it could also
+ change.
                 </para>
               </notes>
             </method>
@@ -1327,8 +1351,8 @@
                   When the number of elements is a lot smaller than the number of buckets
                   this function can be very inefficient as it has to search through empty
                   buckets for the next element, in order to return the iterator.
- As a temporary workaround, the container has the method
- <methodname>erase_return_void</methodname> which will be faster.
+ The method <methodname>quick_erase</methodname> is faster, but has yet
+ to be standardized.
                 </para>
               </notes>
             </method>
@@ -1366,6 +1390,30 @@
                 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
               </throws>
             </method>
+ <method name="quick_erase">
+ <parameter name="position">
+ <paramtype>const_iterator</paramtype>
+ </parameter>
+ <type>void</type>
+ <description>
+ <para>Erase the element pointed to by <code>position</code>.</para>
+ </description>
+ <throws>
+ <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para>
+ <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
+ </throws>
+ <notes>
+ <para>
+ This method is faster than <methodname>erase</methodname> as
+ it doesn't have to find the next element in the container -
+ a potentially costly operation.
+ </para>
+ <para>
+ As it hasn't been standardized, it's likely that this may
+ change in the future.
+ </para>
+ </notes>
+ </method>
             <method name="erase_return_void">
               <parameter name="position">
                 <paramtype>const_iterator</paramtype>
@@ -1380,10 +1428,10 @@
               </throws>
               <notes>
                 <para>
- This is a temporary workaround for the inefficient
- <methodname>erase</methodname> method. Hopefully, in a future
- version the signature of <methodname>erase</methodname> will
- be changed and this will be deprecated.
+ This method is now deprecated, use
+ <methodname>quick_return</methodname> instead. Although be
+ warned that as that isn't standardized yet, it could also
+ change.
                 </para>
               </notes>
             </method>
@@ -2204,8 +2252,8 @@
                   When the number of elements is a lot smaller than the number of buckets
                   this function can be very inefficient as it has to search through empty
                   buckets for the next element, in order to return the iterator.
- As a temporary workaround, the container has the method
- <methodname>erase_return_void</methodname> which will be faster.
+ The method <methodname>quick_erase</methodname> is faster, but has yet
+ to be standardized.
                 </para>
               </notes>
             </method>
@@ -2243,6 +2291,30 @@
                 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
               </throws>
             </method>
+ <method name="quick_erase">
+ <parameter name="position">
+ <paramtype>const_iterator</paramtype>
+ </parameter>
+ <type>void</type>
+ <description>
+ <para>Erase the element pointed to by <code>position</code>.</para>
+ </description>
+ <throws>
+ <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para>
+ <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
+ </throws>
+ <notes>
+ <para>
+ This method is faster than <methodname>erase</methodname> as
+ it doesn't have to find the next element in the container -
+ a potentially costly operation.
+ </para>
+ <para>
+ As it hasn't been standardized, it's likely that this may
+ change in the future.
+ </para>
+ </notes>
+ </method>
             <method name="erase_return_void">
               <parameter name="position">
                 <paramtype>const_iterator</paramtype>
@@ -2257,10 +2329,10 @@
               </throws>
               <notes>
                 <para>
- This is a temporary workaround for the inefficient
- <methodname>erase</methodname> method. Hopefully, in a future
- version the signature of <methodname>erase</methodname> will
- be changed and this will be deprecated.
+ This method is now deprecated, use
+ <methodname>quick_return</methodname> instead. Although be
+ warned that as that isn't standardized yet, it could also
+ change.
                 </para>
               </notes>
             </method>
@@ -3116,8 +3188,8 @@
                   When the number of elements is a lot smaller than the number of buckets
                   this function can be very inefficient as it has to search through empty
                   buckets for the next element, in order to return the iterator.
- As a temporary workaround, the container has the method
- <methodname>erase_return_void</methodname> which will be faster.
+ The method <methodname>quick_erase</methodname> is faster, but has yet
+ to be standardized.
                 </para>
               </notes>
             </method>
@@ -3155,6 +3227,30 @@
                 <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
               </throws>
             </method>
+ <method name="quick_erase">
+ <parameter name="position">
+ <paramtype>const_iterator</paramtype>
+ </parameter>
+ <type>void</type>
+ <description>
+ <para>Erase the element pointed to by <code>position</code>.</para>
+ </description>
+ <throws>
+ <para>Only throws an exception if it is thrown by <code>hasher</code> or <code>key_equal</code>.</para>
+ <para>In this implementation, this overload doesn't call either function object's methods so it is no throw, but this might not be true in other implementations.</para>
+ </throws>
+ <notes>
+ <para>
+ This method is faster than <methodname>erase</methodname> as
+ it doesn't have to find the next element in the container -
+ a potentially costly operation.
+ </para>
+ <para>
+ As it hasn't been standardized, it's likely that this may
+ change in the future.
+ </para>
+ </notes>
+ </method>
             <method name="erase_return_void">
               <parameter name="position">
                 <paramtype>const_iterator</paramtype>
@@ -3169,10 +3265,10 @@
               </throws>
               <notes>
                 <para>
- This is a temporary workaround for the inefficient
- <methodname>erase</methodname> method. Hopefully, in a future
- version the signature of <methodname>erase</methodname> will
- be changed and this will be deprecated.
+ This method is now deprecated, use
+ <methodname>quick_return</methodname> instead. Although be
+ warned that as that isn't standardized yet, it could also
+ change.
                 </para>
               </notes>
             </method>

Modified: trunk/libs/unordered/test/unordered/erase_tests.cpp
==============================================================================
--- trunk/libs/unordered/test/unordered/erase_tests.cpp (original)
+++ trunk/libs/unordered/test/unordered/erase_tests.cpp 2010-03-21 20:42:07 EDT (Sun, 21 Mar 2010)
@@ -116,7 +116,7 @@
         BOOST_TEST(x.erase(x.begin(), x.end()) == x.begin());
     }
 
- std::cerr<<"erase_return_void(begin()).\n";
+ std::cerr<<"quick_erase(begin()).\n";
     {
         test::random_values<Container> v(1000, generator);
         Container x(v.begin(), v.end());
@@ -126,7 +126,7 @@
             BOOST_DEDUCED_TYPENAME Container::key_type
                 key = test::get_key<Container>(*x.begin());
             std::size_t count = x.count(key);
- x.erase_return_void(x.begin());
+ x.quick_erase(x.begin());
             --size;
             BOOST_TEST(x.count(key) == count - 1);
             BOOST_TEST(x.size() == size);
@@ -134,7 +134,7 @@
         BOOST_TEST(x.empty());
     }
 
- std::cerr<<"erase_return_void(random position).\n";
+ std::cerr<<"quick_erase(random position).\n";
     {
         test::random_values<Container> v(1000, generator);
         Container x(v.begin(), v.end());
@@ -155,7 +155,7 @@
             BOOST_DEDUCED_TYPENAME Container::key_type
                 key = test::get_key<Container>(*pos);
             std::size_t count = x.count(key);
- x.erase_return_void(pos);
+ x.quick_erase(pos);
             --size;
             if(size > 0)
                 BOOST_TEST(index == 0 ? next == x.begin() :


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