BaseContainer and range-based loop
Say I am using a
BaseContainerto hold a list of
Int32values, I know there exists a
BrowseContainerto loop over the content of the
But what if I would prefer to use a range-based for-loop for this, how would I go about this?
I know there are
HashMapwhich would be preferred in order to provide for a native range-based for-loop (as well as native iterator support).
But let's assume these types don't cut it, and that the
BaseContaineris the better approach for holding the data. How would one go about implementing range-based support (or iterator support in general) for this?
r_gigante last edited by
Hi @C4DS thanks for reaching out us.
Just to be sure we're on the same page: are you referring to this, right?
I already had a look into the technicals for a range-based for-loop, and it requires a begin() and end() method. Both of these would then be related to a pointer to the data.
Constructing an own custom type or storage-container, I could see myself making use of an allocated block of memory and storing the data in that, allowing to work with the pointer.
However, for a
BaseContainerI don't see any way to interact with its internals.
The only pointers that can be obtained are
GeData*to specific entries (via
const GeData* GetDataPointer(Int32 id) const), but that obviously doesn't provide the appropriate pointers to allow begin() and end() to work with.
I am also looking into extending the functionality of an
HashMap, and in both cases I would use the storage (
BaseContainer) as a data container, encapsulated in my custom " list" type.
So, in general I am looking for a way to have custom storage containers (e.g. Int32UniqueList, Int32Set, ...) using
Int32, Float, Bool, ...as type, but with other functionality than available with the
BaseArray, BaseList, HashMap, SortedArray, .... Still being able to iterate over these via index, iterator and range-base.
And, as such, as a start, I am looking into the possibilities with
As the documentation mentions that "base" in
BaseArrayisn't an indication that one should derive from it, I am looking for possibilities to:
- or encapsulate the storage-type into a custom list-type
- or indeed derive from it and provide additional functionality
I hope I haven't confused you more than I have provided answers.
m_magalhaes last edited by m_magalhaes
I've tried several possibilities but for all of them you need to know how much ID you have and what they are. (doesn't help that much)
During all those years since R17 I must have continuously overlooked the
Thanks for pointing these out to me!
I am embarrassed to admit having missed these while browsing and searching through the SDK documentation, over and over again.
m_magalhaes last edited by
Make sense, because it's available since R20 ^^
However, I had preferred it was me who had overlooked these all those years. As this means I will still need to find a different solution for pre-R20 compatibility.