[Bf-blender-cvs] [7de02135889] functions: access element at index in listbase
Jacques Lucke
noreply at git.blender.org
Fri Jul 5 12:26:53 CEST 2019
Commit: 7de02135889bdec955e574e75a7390b96bdcfa67
Author: Jacques Lucke
Date: Fri Jul 5 11:15:31 2019 +0200
Branches: functions
https://developer.blender.org/rB7de02135889bdec955e574e75a7390b96bdcfa67
access element at index in listbase
===================================================================
M source/blender/blenlib/BLI_listbase_wrapper.hpp
===================================================================
diff --git a/source/blender/blenlib/BLI_listbase_wrapper.hpp b/source/blender/blenlib/BLI_listbase_wrapper.hpp
index 903d50bc45c..650cb4246ac 100644
--- a/source/blender/blenlib/BLI_listbase_wrapper.hpp
+++ b/source/blender/blenlib/BLI_listbase_wrapper.hpp
@@ -72,6 +72,19 @@ template<typename T, bool intrusive> class ListBaseWrapper {
{
return Iterator(m_listbase, nullptr);
}
+
+ T get(uint index) const
+ {
+ void *ptr = BLI_findlink(m_listbase, index);
+ BLI_assert(ptr);
+
+ if (intrusive) {
+ return (T)ptr;
+ }
+ else {
+ return (T)((LinkData *)ptr)->data;
+ }
+ }
};
} /* namespace BLI */
More information about the Bf-blender-cvs
mailing list