From 44ca984dc7b150e5fd6ad88b999d0dbdc7cb9218 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 17 Jan 2022 15:10:52 -0600 Subject: BLI: Add index_range method to VectorSet This can simplify iterating through all of the indices in the vector, which is fairly common, since one of the benefits of the data structure is that all values are contiguous. --- source/blender/blenlib/BLI_vector_set.hh | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'source/blender/blenlib') diff --git a/source/blender/blenlib/BLI_vector_set.hh b/source/blender/blenlib/BLI_vector_set.hh index cc9cb585a1c..0aac96f93bc 100644 --- a/source/blender/blenlib/BLI_vector_set.hh +++ b/source/blender/blenlib/BLI_vector_set.hh @@ -464,6 +464,14 @@ class VectorSet { return keys_ + this->size(); } + /** + * Get an index range containing all valid indices for this array. + */ + IndexRange index_range() const + { + return IndexRange(this->size()); + } + /** * Print common statistics like size and collision count. This is useful for debugging purposes. */ -- cgit v1.2.3