diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-22 16:48:08 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-22 16:50:31 +0300 |
commit | 6223385043ddc93beaa8f092dfd31a2208b8e961 (patch) | |
tree | a4e208569308d293dc02101e09d3f84bff65af93 /source/blender/functions/FN_generic_vector_array.hh | |
parent | 7117ed96917a2b2dedf663a97f10bde5d285470f (diff) |
Functions: Various improvements to the spans and generic data structures
Most of this code is covered by unit tests.
Diffstat (limited to 'source/blender/functions/FN_generic_vector_array.hh')
-rw-r--r-- | source/blender/functions/FN_generic_vector_array.hh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/functions/FN_generic_vector_array.hh b/source/blender/functions/FN_generic_vector_array.hh index 90c0fbad136..1c8f74f2abe 100644 --- a/source/blender/functions/FN_generic_vector_array.hh +++ b/source/blender/functions/FN_generic_vector_array.hh @@ -119,6 +119,23 @@ class GVectorArray : NonCopyable, NonMovable { m_lengths[index]++; } + void extend(uint index, GVSpan span) + { + BLI_assert(m_type == span.type()); + for (uint i = 0; i < span.size(); i++) { + this->append(index, span[i]); + } + } + + void extend(IndexMask mask, GVArraySpan array_span) + { + BLI_assert(m_type == array_span.type()); + BLI_assert(mask.min_array_size() <= array_span.size()); + for (uint i : mask) { + this->extend(i, array_span[i]); + } + } + GMutableSpan operator[](uint index) { BLI_assert(index < m_starts.size()); @@ -158,6 +175,16 @@ template<typename T> class GVectorArrayRef { m_vector_array->append(index, &value); } + void extend(uint index, Span<T> values) + { + m_vector_array->extend(index, values); + } + + void extend(uint index, VSpan<T> values) + { + m_vector_array->extend(index, GVSpan(values)); + } + MutableSpan<T> operator[](uint index) { BLI_assert(index < m_vector_array->m_starts.size()); |