Feature/growth insertion index
Feature request
- Each element has a
growthInsertionIndex
that can be queried using a grid method with the same name. - This index is only valid between calling
grow()
andpostGrow()
and only for elements that have been inserted using the gridsinsertElement
method. - It can be used to attach user data to an element inserted with the
insertElement
method, because we don't know at insertion time (before callinggrow()
) which index or id the element will have in the grid. - The concept is very similar to the
insertionIndex
of the factory with the difference that the validity of the index is only temporary.
I'm open to any suggestion how to make this better or also renaming of the interface function. Without this it's impossible to attach data to a newly created element at creation time, i.e. it's impossible to distinguish between new elments that were inserted together using insertElement().
This branch is based on !14 (merged)
Merge request reports
Activity
Do we really need this complexity? If the current grid has elements with indices 0 ... n-1, then if I grow an additional element will have index n, right? And if I grow a second element it gets n+1. Why do I need the new methods? "Conforming to existing practices" does not really convince me, as no other grid does growth anyway.
The problem is the following:
- We queue all elements to insert before actual insertion
- After I call
grow()
the id/index gets determined but it might not be the consecutive insertion order since- some elements might not have been inserted (not all elements are guaranteed to be inserted because we have some restrictions on possible elements)
- elements might have been removed in the same growth step
So the problem is the same as for the grid factory. It's currently not possible to attach user data to new elements on creation and I currently have a used case for that where I can't think of another possibility to create/attach my user data.
Edited by Timo Kochmentioned in commit a33c11bc