diff --git a/doc/changes.qbk b/doc/changes.qbk index f776fa01..608f0d52 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -117,4 +117,15 @@ First official release. 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] diff --git a/doc/ref.xml b/doc/ref.xml index 3abf9d45..92aaffa7 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -464,8 +464,8 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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 - erase_return_void which will be faster. + The method quick_erase is faster, but has yet + to be standardized. @@ -503,6 +503,30 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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. + + + const_iterator + + void + + Erase the element pointed to by position. + + + Only throws an exception if it is thrown by hasher or key_equal. + 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. + + + + This method is faster than erase as + it doesn't have to find the next element in the container - + a potentially costly operation. + + + As it hasn't been standardized, it's likely that this may + change in the future. + + + const_iterator @@ -517,10 +541,10 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - This is a temporary workaround for the inefficient - erase method. Hopefully, in a future - version the signature of erase will - be changed and this will be deprecated. + This method is now deprecated, use + quick_return instead. Although be + warned that as that isn't standardized yet, it could also + change. @@ -1327,8 +1351,8 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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 - erase_return_void which will be faster. + The method quick_erase is faster, but has yet + to be standardized. @@ -1366,6 +1390,30 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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. + + + const_iterator + + void + + Erase the element pointed to by position. + + + Only throws an exception if it is thrown by hasher or key_equal. + 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. + + + + This method is faster than erase as + it doesn't have to find the next element in the container - + a potentially costly operation. + + + As it hasn't been standardized, it's likely that this may + change in the future. + + + const_iterator @@ -1380,10 +1428,10 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - This is a temporary workaround for the inefficient - erase method. Hopefully, in a future - version the signature of erase will - be changed and this will be deprecated. + This method is now deprecated, use + quick_return instead. Although be + warned that as that isn't standardized yet, it could also + change. @@ -2204,8 +2252,8 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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 - erase_return_void which will be faster. + The method quick_erase is faster, but has yet + to be standardized. @@ -2243,6 +2291,30 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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. + + + const_iterator + + void + + Erase the element pointed to by position. + + + Only throws an exception if it is thrown by hasher or key_equal. + 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. + + + + This method is faster than erase as + it doesn't have to find the next element in the container - + a potentially costly operation. + + + As it hasn't been standardized, it's likely that this may + change in the future. + + + const_iterator @@ -2257,10 +2329,10 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - This is a temporary workaround for the inefficient - erase method. Hopefully, in a future - version the signature of erase will - be changed and this will be deprecated. + This method is now deprecated, use + quick_return instead. Although be + warned that as that isn't standardized yet, it could also + change. @@ -3116,8 +3188,8 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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 - erase_return_void which will be faster. + The method quick_erase is faster, but has yet + to be standardized. @@ -3155,6 +3227,30 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 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. + + + const_iterator + + void + + Erase the element pointed to by position. + + + Only throws an exception if it is thrown by hasher or key_equal. + 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. + + + + This method is faster than erase as + it doesn't have to find the next element in the container - + a potentially costly operation. + + + As it hasn't been standardized, it's likely that this may + change in the future. + + + const_iterator @@ -3169,10 +3265,10 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - This is a temporary workaround for the inefficient - erase method. Hopefully, in a future - version the signature of erase will - be changed and this will be deprecated. + This method is now deprecated, use + quick_return instead. Although be + warned that as that isn't standardized yet, it could also + change. diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 4c399b8a..5bad0ebd 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -369,6 +369,11 @@ namespace boost 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 @@ namespace boost 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)); diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 2c291f46..ec48b8c8 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -361,6 +361,11 @@ namespace boost 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 @@ namespace boost 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)); diff --git a/test/unordered/erase_tests.cpp b/test/unordered/erase_tests.cpp index ca54bf03..4a3fe2c9 100644 --- a/test/unordered/erase_tests.cpp +++ b/test/unordered/erase_tests.cpp @@ -116,7 +116,7 @@ void erase_tests1(Container*, 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 v(1000, generator); Container x(v.begin(), v.end()); @@ -126,7 +126,7 @@ void erase_tests1(Container*, BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*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 @@ void erase_tests1(Container*, BOOST_TEST(x.empty()); } - std::cerr<<"erase_return_void(random position).\n"; + std::cerr<<"quick_erase(random position).\n"; { test::random_values v(1000, generator); Container x(v.begin(), v.end()); @@ -155,7 +155,7 @@ void erase_tests1(Container*, BOOST_DEDUCED_TYPENAME Container::key_type key = test::get_key(*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() :