Improve Stack Implementation by making it Array based & adding missing methods with proper Tests#7
Conversation
|
Hi I have a couple of questions:
|
|
Hi @Ducasse , Thnx for pointing out & You're correct I made these changes because I thought that Stack should be of fixed size & was worried that Stephane I also noticed the original implementation used If they are O(n) , should I use |
Yes, I also think that the stack should increase without limit. So we need to hand that case. We can do the same as in OrderedCollection. We allocate a new array the double size and we copy the elements. There is the method
For So, it will be better to prepare some examples using this new implementation vs the previous one to measure the speed gains. Could you first handle the case that the stack gets full and then you reallocate the double array etc... And then we measue the performance of the two implementations |
Summary
Improved
CTStackreplacing inefficient OrderedCollection based approach with high-performance Array based approach along with adding missing methods & TestsChanges
CTStackTestclass