[Bf-blender-cvs] [d575b72c16d] master: BLI: add Set.is_empty method
Jacques Lucke
noreply at git.blender.org
Tue Apr 28 16:35:56 CEST 2020
Commit: d575b72c16d217353795594032196a5857907de2
Author: Jacques Lucke
Date: Tue Apr 28 16:35:49 2020 +0200
Branches: master
https://developer.blender.org/rBd575b72c16d217353795594032196a5857907de2
BLI: add Set.is_empty method
===================================================================
M source/blender/blenlib/BLI_set.hh
M tests/gtests/blenlib/BLI_set_test.cc
===================================================================
diff --git a/source/blender/blenlib/BLI_set.hh b/source/blender/blenlib/BLI_set.hh
index b09dd910007..f9d4bbfaed4 100644
--- a/source/blender/blenlib/BLI_set.hh
+++ b/source/blender/blenlib/BLI_set.hh
@@ -276,6 +276,14 @@ class Set {
return m_array.slots_set();
}
+ /**
+ * Return true if this set contains no elements.
+ */
+ bool is_empty() const
+ {
+ return this->size() == 0;
+ }
+
/**
* Returns true when there is at least one element that is in both sets.
* Otherwise false.
diff --git a/tests/gtests/blenlib/BLI_set_test.cc b/tests/gtests/blenlib/BLI_set_test.cc
index dc163e752d8..ae46c2bf52e 100644
--- a/tests/gtests/blenlib/BLI_set_test.cc
+++ b/tests/gtests/blenlib/BLI_set_test.cc
@@ -10,6 +10,7 @@ TEST(set, Defaultconstructor)
{
IntSet set;
EXPECT_EQ(set.size(), 0);
+ EXPECT_TRUE(set.is_empty());
}
TEST(set, ContainsNotExistant)
@@ -22,8 +23,10 @@ TEST(set, ContainsExistant)
{
IntSet set;
EXPECT_FALSE(set.contains(5));
+ EXPECT_TRUE(set.is_empty());
set.add(5);
EXPECT_TRUE(set.contains(5));
+ EXPECT_FALSE(set.is_empty());
}
TEST(set, AddMany)
More information about the Bf-blender-cvs
mailing list