FIFO stack

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 26 09:28:28 PDT 2011


On Wednesday, October 26, 2011 09:00 Dominic Jones wrote:
> > Also an plain array is a good stack. :)
> 
> I'd rather not use a plain array because (I assume) that when I push
> or pop using arrays, a swap array is created to resize the original.
> If this is not the case, then an array will certainly do.
> -Dominic

Not exactly. If you want to know more about how arrays work, you should read 
this: http://www.dsource.org/projects/dcollections/wiki/ArrayArticle It's a 
great read. As for using an array as a stack, you can do it with a wrapper 
struct, but using it by itself would result in a lot more reallocations than 
you'd want, as discussed here: 
https://www.semitwist.com/articles/article/view/don-t-use-arrays-as-stacks

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list