BLI: add Set.clear method

This commit is contained in:
Jacques Lucke 2020-04-28 16:41:37 +02:00
parent d575b72c16
commit c05ef1459c
2 changed files with 14 additions and 0 deletions

View File

@ -284,6 +284,12 @@ class Set {
return this->size() == 0;
}
void clear()
{
this->~Set();
new (this) Set();
}
/**
* Returns true when there is at least one element that is in both sets.
* Otherwise false.

View File

@ -194,3 +194,11 @@ TEST(set, UniquePtrValues)
EXPECT_EQ(set.size(), 3);
}
TEST(set, Clear)
{
Set<int> set = {3, 4, 6, 7};
EXPECT_EQ(set.size(), 4);
set.clear();
EXPECT_EQ(set.size(), 0);
}