Make size increasing of GrowableStack<T> modifiable

Developer
Dec 8, 2010 at 12:39 PM

At the moment the size of a starLiGHT.Physic.TwoD.GrowableStack<T> gets doubled each time the capacity is reached. I think it is nice and easy to modify it so that the user can configure the increasing-step.

What do you mean?

Greets
Nils

Coordinator
Dec 8, 2010 at 12:52 PM

I choosed to double the size when the limit is reached, because this is the default behaviour of most of this things in .NET and it is the behaviour that the original Growable stack of Box2D has.

On one hand, you are perfectly right with what you wrote. It is possible to easily change this. The question on the other hand is, if this is worth the effort. The GrowableStack is an internal class of the physic engine and is not supposed to be used by the end user.

I don't really know actually whats the difference between this GrowableStack and the original Stack of the .NET-Framework. If there are important differences (like with FastList<T> compared to List<T>) we should consider to integrate such a class into the starLiGHT.Core collections namespace.

 

Cheers,

Roland

 

Developer
Dec 8, 2010 at 1:03 PM
Edited Dec 8, 2010 at 1:04 PM

Hmm ok you are right. But then i don't unterstand why you have implemented this class? I think it the same as the System.Collections.Generic.Stack<T>.

Do you know why Box2D has a own stack-class? The C++-Stl-lib has also one, see http://www.cplusplus.com/reference/stl/stack/.

I'm not so familiar with the implementation of your Box2D port, but if it is the same as System.Collections.Generic.Stack<T>, why we can use this one and remove the GrowableStack? Is this because you want to be very similar to the Box2D sources? Then i think we have to document this in the GrowableStack sources.

Greets
Nils

Coordinator
Dec 8, 2010 at 1:09 PM
Edited Dec 8, 2010 at 1:09 PM

The original Box2D has it's own GrowableStack because it is using a Small Block Allocator to decrease the overhead for allocating memory and to get a better cache coherence. We don't need this in .NET.

Maybe you are able to check if the Stack<T> of .NET is really the same as the GrowableStack<T> of starLiGHT.Physic2D. If it is really the same, feel free to replace it :-)

 

Developer
Dec 8, 2010 at 1:18 PM

I opend a issue for me, i will work on it in the next days.
I also added a Component (starLiGHT.Physic2D).

Greets
Nils

Coordinator
Dec 8, 2010 at 1:20 PM

Great

 

Coordinator
May 10, 2011 at 11:04 AM

I closed issue #220 a few minutes ago. The GrowableStack<T> is basically the same as Stack<T>. GrowableStack is now completly replaced by Stack<T> in starLiGHT.Physic2D as of revision 9922.