mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +01:00
[llvm] Add contains(KeyType) -> bool methods to SetVector
Matches C++20 API addition. Differential Revision: https://reviews.llvm.org/D83449
This commit is contained in:
parent
f4752de569
commit
3cfbc95ca8
@ -205,6 +205,11 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Check if the SetVector contains the given key.
|
||||
bool contains(const key_type &key) const {
|
||||
return set_.find(key) != set_.end();
|
||||
}
|
||||
|
||||
/// Count the number of elements of a given key in the SetVector.
|
||||
/// \returns 0 if the element is not in the SetVector, 1 if it is.
|
||||
size_type count(const key_type &key) const {
|
||||
|
@ -31,3 +31,20 @@ TEST(SetVector, EraseTest) {
|
||||
EXPECT_EQ(2, *std::next(S.begin()));
|
||||
}
|
||||
|
||||
TEST(SetVector, ContainsTest) {
|
||||
SetVector<int> S;
|
||||
S.insert(0);
|
||||
S.insert(1);
|
||||
S.insert(2);
|
||||
|
||||
EXPECT_TRUE(S.contains(0));
|
||||
EXPECT_TRUE(S.contains(1));
|
||||
EXPECT_TRUE(S.contains(2));
|
||||
EXPECT_FALSE(S.contains(-1));
|
||||
|
||||
S.insert(2);
|
||||
EXPECT_TRUE(S.contains(2));
|
||||
|
||||
S.remove(2);
|
||||
EXPECT_FALSE(S.contains(2));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user