mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Add size_t MapVector::erase(KeyT) similar to the one in std::map.
llvm-svn: 219240
This commit is contained in:
parent
e284151ab7
commit
6c182edff1
@ -147,6 +147,17 @@ public:
|
||||
return Next;
|
||||
}
|
||||
|
||||
/// \brief Remove all elements with the key value Key.
|
||||
///
|
||||
/// Returns the number of elements removed.
|
||||
size_type erase(const KeyT &Key) {
|
||||
auto Iterator = find(Key);
|
||||
if (Iterator == end())
|
||||
return 0;
|
||||
erase(Iterator);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// \brief Remove the elements that match the predicate.
|
||||
///
|
||||
/// Erase all elements that match \c Pred in a single pass. Takes linear
|
||||
|
@ -67,6 +67,11 @@ TEST(MapVectorTest, erase) {
|
||||
ASSERT_EQ(MV.find(1), MV.end());
|
||||
ASSERT_EQ(MV[3], 4);
|
||||
ASSERT_EQ(MV[5], 6);
|
||||
|
||||
MV.erase(3);
|
||||
ASSERT_EQ(MV.size(), 1u);
|
||||
ASSERT_EQ(MV.find(3), MV.end());
|
||||
ASSERT_EQ(MV[5], 6);
|
||||
}
|
||||
|
||||
TEST(MapVectorTest, remove_if) {
|
||||
|
Loading…
Reference in New Issue
Block a user