mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-31 03:47:16 +02:00
Add reference docs for erase_if()
This commit is contained in:
@ -198,6 +198,10 @@ template<class Key, class T, class Hash, class Pred, class Alloc>
|
|||||||
void xref:#unordered_map_swap_2[swap](unordered_map<Key, T, Hash, Pred, Alloc>& x,
|
void xref:#unordered_map_swap_2[swap](unordered_map<Key, T, Hash, Pred, Alloc>& x,
|
||||||
unordered_map<Key, T, Hash, Pred, Alloc>& y)
|
unordered_map<Key, T, Hash, Pred, Alloc>& y)
|
||||||
noexcept(noexcept(x.swap(y)));
|
noexcept(noexcept(x.swap(y)));
|
||||||
|
|
||||||
|
template<class K, class T, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_map<K, T, H, P, A>::size_type
|
||||||
|
xref:#unordered_map_erase_if[erase_if](unordered_map<K, T, H, P, A>& c, Predicate pred);
|
||||||
-----
|
-----
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1424,4 +1428,31 @@ Effects:;; `x.swap(y)`
|
|||||||
Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
|
Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
|
||||||
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
=== erase_if
|
||||||
|
```c++
|
||||||
|
template<class K, class T, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_map<K, T, H, P, A>::size_type
|
||||||
|
erase_if(unordered_map<K, T, H, P, A>& c, Predicate pred);
|
||||||
|
```
|
||||||
|
|
||||||
|
Traverses the container `c` and removes all elements for which the supplied predicate returns `true`.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Returns:;; The number of erased elements.
|
||||||
|
Notes:;; Equivalent to: +
|
||||||
|
+
|
||||||
|
```c++
|
||||||
|
auto original_size = c.size();
|
||||||
|
for (auto i = c.begin(), last = c.end(); i != last; ) {
|
||||||
|
if (pred(*i)) {
|
||||||
|
i = c.erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return original_size - c.size();
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
@ -193,6 +193,11 @@ template<class Key, class T, class Hash, class Pred, class Alloc>
|
|||||||
void xref:#unordered_multimap_swap_2[swap](unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
|
void xref:#unordered_multimap_swap_2[swap](unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
|
||||||
unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
|
unordered_multimap<Key, T, Hash, Pred, Alloc>& y)
|
||||||
noexcept(noexcept(x.swap(y)));
|
noexcept(noexcept(x.swap(y)));
|
||||||
|
|
||||||
|
template<class K, class T, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_multimap<K, T, H, P, A>::size_type
|
||||||
|
xref:#unordered_multimap_erase_if[erase_if](unordered_multimap<K, T, H, P, A>& c, Predicate pred);
|
||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1368,4 +1373,31 @@ Effects:;; `x.swap(y)`
|
|||||||
Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
|
Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
|
||||||
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
=== erase_if
|
||||||
|
```c++
|
||||||
|
template<class K, class T, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_multimap<K, T, H, P, A>::size_type
|
||||||
|
erase_if(unordered_multimap<K, T, H, P, A>& c, Predicate pred);
|
||||||
|
```
|
||||||
|
|
||||||
|
Traverses the container `c` and removes all elements for which the supplied predicate returns `true`.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Returns:;; The number of erased elements.
|
||||||
|
Notes:;; Equivalent to: +
|
||||||
|
+
|
||||||
|
```c++
|
||||||
|
auto original_size = c.size();
|
||||||
|
for (auto i = c.begin(), last = c.end(); i != last; ) {
|
||||||
|
if (pred(*i)) {
|
||||||
|
i = c.erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return original_size - c.size();
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
@ -187,6 +187,10 @@ template<class Key, class Hash, class Pred, class Alloc>
|
|||||||
void xref:#unordered_multiset_swap_2[swap](unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
void xref:#unordered_multiset_swap_2[swap](unordered_multiset<Key, Hash, Pred, Alloc>& x,
|
||||||
unordered_multiset<Key, Hash, Pred, Alloc>& y)
|
unordered_multiset<Key, Hash, Pred, Alloc>& y)
|
||||||
noexcept(noexcept(x.swap(y)));
|
noexcept(noexcept(x.swap(y)));
|
||||||
|
|
||||||
|
template<class K, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_multiset<K, H, P, A>::size_type
|
||||||
|
xref:#unordered_multiset_erase_if[erase_if](unordered_multiset<K, H, P, A>& c, Predicate pred);
|
||||||
-----
|
-----
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1326,4 +1330,31 @@ Effects:;; `x.swap(y)`
|
|||||||
Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
|
Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor or copy assignment operator of `key_equal` or `hasher`.
|
||||||
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
=== erase_if
|
||||||
|
```c++
|
||||||
|
template<class K, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_multiset<K, H, P, A>::size_type
|
||||||
|
erase_if(unordered_multiset<K, H, P, A>& c, Predicate pred);
|
||||||
|
```
|
||||||
|
|
||||||
|
Traverses the container `c` and removes all elements for which the supplied predicate returns `true`.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Returns:;; The number of erased elements.
|
||||||
|
Notes:;; Equivalent to: +
|
||||||
|
+
|
||||||
|
```c++
|
||||||
|
auto original_size = c.size();
|
||||||
|
for (auto i = c.begin(), last = c.end(); i != last; ) {
|
||||||
|
if (pred(*i)) {
|
||||||
|
i = c.erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return original_size - c.size();
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
@ -188,6 +188,10 @@ template<class Key, class Hash, class Pred, class Alloc>
|
|||||||
void xref:#unordered_set_swap_2[swap](unordered_set<Key, Hash, Pred, Alloc>& x,
|
void xref:#unordered_set_swap_2[swap](unordered_set<Key, Hash, Pred, Alloc>& x,
|
||||||
unordered_set<Key, Hash, Pred, Alloc>& y)
|
unordered_set<Key, Hash, Pred, Alloc>& y)
|
||||||
noexcept(noexcept(x.swap(y)));
|
noexcept(noexcept(x.swap(y)));
|
||||||
|
|
||||||
|
template<class K, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_set<K, H, P, A>::size_type
|
||||||
|
xref:#unordered_set_erase_if[erase_if](unordered_set<K, H, P, A>& c, Predicate pred);
|
||||||
-----
|
-----
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -1349,3 +1353,30 @@ Throws:;; Doesn't throw an exception unless it is thrown by the copy constructor
|
|||||||
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
Notes:;; The exception specifications aren't quite the same as the C++11 standard, as the equality predicate and hash function are swapped using their copy constructors.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
=== erase_if
|
||||||
|
```c++
|
||||||
|
template<class K, class H, class P, class A, class Predicate>
|
||||||
|
typename unordered_set<K, H, P, A>::size_type
|
||||||
|
erase_if(unordered_set<K, H, P, A>& c, Predicate pred);
|
||||||
|
```
|
||||||
|
|
||||||
|
Traverses the container `c` and removes all elements for which the supplied predicate returns `true`.
|
||||||
|
|
||||||
|
[horizontal]
|
||||||
|
Returns:;; The number of erased elements.
|
||||||
|
Notes:;; Equivalent to: +
|
||||||
|
+
|
||||||
|
```c++
|
||||||
|
auto original_size = c.size();
|
||||||
|
for (auto i = c.begin(), last = c.end(); i != last; ) {
|
||||||
|
if (pred(*i)) {
|
||||||
|
i = c.erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return original_size - c.size();
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
Reference in New Issue
Block a user