diff options
-rw-r--r-- | source/blender/blenlib/BLI_vector_set.h (renamed from source/blender/blenlib/BLI_set_vector.h) | 22 | ||||
-rw-r--r-- | source/blender/blenlib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/gtests/blenlib/BLI_vector_set_test.cc (renamed from tests/gtests/blenlib/BLI_set_vector_test.cc) | 54 | ||||
-rw-r--r-- | tests/gtests/blenlib/CMakeLists.txt | 2 |
4 files changed, 40 insertions, 40 deletions
diff --git a/source/blender/blenlib/BLI_set_vector.h b/source/blender/blenlib/BLI_vector_set.h index 3d5a31e1cce..820c7c63c6a 100644 --- a/source/blender/blenlib/BLI_set_vector.h +++ b/source/blender/blenlib/BLI_vector_set.h @@ -14,15 +14,15 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#ifndef __BLI_SET_VECTOR_H__ -#define __BLI_SET_VECTOR_H__ +#ifndef __BLI_VECTOR_SET_H__ +#define __BLI_VECTOR_SET_H__ /** \file * \ingroup bli * - * A SetVector is a combination of a set and a vector. The elements are stored in a continuous - * array, but every element exists at most once. The insertion order is maintained, as long as - * there are no deletes. The expected time to check if a value is in the SetVector is O(1). + * A VectorSet is a set built on top of a vector. The elements are stored in a continuous array, + * but every element exists at most once. The insertion order is maintained, as long as there are + * no deletes. The expected time to check if a value is in the VectorSet is O(1). */ #include "BLI_hash_cxx.h" @@ -49,7 +49,7 @@ namespace BLI { // clang-format on -template<typename T, typename Allocator = GuardedAllocator> class SetVector { +template<typename T, typename Allocator = GuardedAllocator> class VectorSet { private: static constexpr int32_t IS_EMPTY = -1; static constexpr int32_t IS_DUMMY = -2; @@ -115,19 +115,19 @@ template<typename T, typename Allocator = GuardedAllocator> class SetVector { Vector<T, 4, Allocator> m_elements; public: - SetVector() = default; + VectorSet() = default; - SetVector(ArrayRef<T> values) + VectorSet(ArrayRef<T> values) { this->add_multiple(values); } - SetVector(const std::initializer_list<T> &values) + VectorSet(const std::initializer_list<T> &values) { this->add_multiple(values); } - SetVector(const Vector<T> &values) + VectorSet(const Vector<T> &values) { this->add_multiple(values); } @@ -394,4 +394,4 @@ template<typename T, typename Allocator = GuardedAllocator> class SetVector { } // namespace BLI -#endif /* __BLI_SET_VECTOR_H__ */ +#endif /* __BLI_VECTOR_SET_H__ */ diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index a5950051f90..f3740b5d39f 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -221,7 +221,6 @@ set(SRC BLI_rect.h BLI_scanfill.h BLI_set.h - BLI_set_vector.h BLI_smallhash.h BLI_sort.h BLI_sort_utils.h @@ -248,6 +247,7 @@ set(SRC BLI_utildefines_variadic.h BLI_uvproject.h BLI_vector.h + BLI_vector_set.h BLI_vfontdata.h BLI_voronoi_2d.h BLI_voxel.h diff --git a/tests/gtests/blenlib/BLI_set_vector_test.cc b/tests/gtests/blenlib/BLI_vector_set_test.cc index b135e31914c..675e5a154d5 100644 --- a/tests/gtests/blenlib/BLI_set_vector_test.cc +++ b/tests/gtests/blenlib/BLI_vector_set_test.cc @@ -1,27 +1,27 @@ #include "testing/testing.h" -#include "BLI_set_vector.h" +#include "BLI_vector_set.h" -using BLI::SetVector; -using IntSetVector = SetVector<int>; +using BLI::VectorSet; +using IntVectorSet = VectorSet<int>; -TEST(set_vector, DefaultConstructor) +TEST(vector_set, DefaultConstructor) { - IntSetVector set; + IntVectorSet set; EXPECT_EQ(set.size(), 0); } -TEST(set_vector, InitializerListConstructor_WithoutDuplicates) +TEST(vector_set, InitializerListConstructor_WithoutDuplicates) { - IntSetVector set = {1, 4, 5}; + IntVectorSet set = {1, 4, 5}; EXPECT_EQ(set.size(), 3); EXPECT_EQ(set[0], 1); EXPECT_EQ(set[1], 4); EXPECT_EQ(set[2], 5); } -TEST(set_vector, InitializerListConstructor_WithDuplicates) +TEST(vector_set, InitializerListConstructor_WithDuplicates) { - IntSetVector set = {1, 3, 3, 2, 1, 5}; + IntVectorSet set = {1, 3, 3, 2, 1, 5}; EXPECT_EQ(set.size(), 4); EXPECT_EQ(set[0], 1); EXPECT_EQ(set[1], 3); @@ -29,35 +29,35 @@ TEST(set_vector, InitializerListConstructor_WithDuplicates) EXPECT_EQ(set[3], 5); } -TEST(set_vector, Copy) +TEST(vector_set, Copy) { - IntSetVector set1 = {1, 2, 3}; - IntSetVector set2 = set1; + IntVectorSet set1 = {1, 2, 3}; + IntVectorSet set2 = set1; EXPECT_EQ(set1.size(), 3); EXPECT_EQ(set2.size(), 3); EXPECT_EQ(set1.index(2), 1); EXPECT_EQ(set2.index(2), 1); } -TEST(set_vector, Move) +TEST(vector_set, Move) { - IntSetVector set1 = {1, 2, 3}; - IntSetVector set2 = std::move(set1); + IntVectorSet set1 = {1, 2, 3}; + IntVectorSet set2 = std::move(set1); EXPECT_EQ(set1.size(), 0); EXPECT_EQ(set2.size(), 3); } -TEST(set_vector, AddNewIncreasesSize) +TEST(vector_set, AddNewIncreasesSize) { - IntSetVector set; + IntVectorSet set; EXPECT_EQ(set.size(), 0); set.add(5); EXPECT_EQ(set.size(), 1); } -TEST(set_vector, AddExistingDoesNotIncreaseSize) +TEST(vector_set, AddExistingDoesNotIncreaseSize) { - IntSetVector set; + IntVectorSet set; EXPECT_EQ(set.size(), 0); set.add(5); EXPECT_EQ(set.size(), 1); @@ -65,26 +65,26 @@ TEST(set_vector, AddExistingDoesNotIncreaseSize) EXPECT_EQ(set.size(), 1); } -TEST(set_vector, Index) +TEST(vector_set, Index) { - IntSetVector set = {3, 6, 4}; + IntVectorSet set = {3, 6, 4}; EXPECT_EQ(set.index(6), 1); EXPECT_EQ(set.index(3), 0); EXPECT_EQ(set.index(4), 2); } -TEST(set_vector, IndexTry) +TEST(vector_set, IndexTry) { - IntSetVector set = {3, 6, 4}; + IntVectorSet set = {3, 6, 4}; EXPECT_EQ(set.index_try(5), -1); EXPECT_EQ(set.index_try(3), 0); EXPECT_EQ(set.index_try(6), 1); EXPECT_EQ(set.index_try(2), -1); } -TEST(set_vector, Remove) +TEST(vector_set, Remove) { - IntSetVector set = {4, 5, 6, 7}; + IntVectorSet set = {4, 5, 6, 7}; EXPECT_EQ(set.size(), 4); set.remove(5); EXPECT_EQ(set.size(), 3); @@ -102,9 +102,9 @@ TEST(set_vector, Remove) EXPECT_EQ(set.size(), 0); } -TEST(set_vector, UniquePtrValue) +TEST(vector_set, UniquePtrValue) { - SetVector<std::unique_ptr<int>> set; + VectorSet<std::unique_ptr<int>> set; set.add_new(std::unique_ptr<int>(new int())); set.add(std::unique_ptr<int>(new int())); set.index_try(std::unique_ptr<int>(new int())); diff --git a/tests/gtests/blenlib/CMakeLists.txt b/tests/gtests/blenlib/CMakeLists.txt index 1d4b0b18973..1f52886132f 100644 --- a/tests/gtests/blenlib/CMakeLists.txt +++ b/tests/gtests/blenlib/CMakeLists.txt @@ -61,7 +61,6 @@ BLENDER_TEST(BLI_memiter "bf_blenlib") BLENDER_TEST(BLI_path_util "${BLI_path_util_extra_libs}") BLENDER_TEST(BLI_polyfill_2d "bf_blenlib") BLENDER_TEST(BLI_set "bf_blenlib") -BLENDER_TEST(BLI_set_vector "bf_blenlib") BLENDER_TEST(BLI_stack "bf_blenlib") BLENDER_TEST(BLI_stack_cxx "bf_blenlib") BLENDER_TEST(BLI_string "bf_blenlib") @@ -70,6 +69,7 @@ BLENDER_TEST(BLI_string_ref "bf_blenlib") BLENDER_TEST(BLI_string_utf8 "bf_blenlib") BLENDER_TEST(BLI_task "bf_blenlib;bf_intern_numaapi") BLENDER_TEST(BLI_vector "bf_blenlib") +BLENDER_TEST(BLI_vector_set "bf_blenlib") BLENDER_TEST_PERFORMANCE(BLI_ghash_performance "bf_blenlib") BLENDER_TEST_PERFORMANCE(BLI_task_performance "bf_blenlib") |