From bb1f02510b69a70ab9bde68be1a4d51c47d72d57 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Thu, 4 Mar 2021 17:37:46 +0100 Subject: BLI: support mutable lookup from multi value map --- source/blender/blenlib/BLI_multi_value_map.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source/blender/blenlib/BLI_multi_value_map.hh') diff --git a/source/blender/blenlib/BLI_multi_value_map.hh b/source/blender/blenlib/BLI_multi_value_map.hh index 018f080e633..4113085a1e3 100644 --- a/source/blender/blenlib/BLI_multi_value_map.hh +++ b/source/blender/blenlib/BLI_multi_value_map.hh @@ -103,6 +103,22 @@ template class MultiValueMap { return {}; } + /** + * Get a mutable span to all the values that are stored for the given key. + */ + MutableSpan lookup(const Key &key) + { + return this->lookup_as(key); + } + template MutableSpan lookup_as(const ForwardKey &key) + { + Vector *vector = map_.lookup_ptr_as(key); + if (vector != nullptr) { + return vector->as_mutable_span(); + } + return {}; + } + /** * Note: This signature will change when the implementation changes. */ -- cgit v1.2.3