FIFO stack

Jesse Phillips jessekphillips+D at gmail.com
Wed Oct 26 12:16:30 PDT 2011


Ary Manzana Wrote:

> On 10/26/11 1:28 PM, Jonathan M Davis wrote:
> > 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
> 
> I think that if you have to read an article that long, with all the 
> explanations of the different caveats a programmer can bump to when 
> using them, to understand how arrays and slices work.... something must 
> be wrong.
> 
> Things should be simpler.

The thing is, it is simple. You can use them as a stack. But if performance matters to you, then you should be aware of how it operates. Or use something already built for performance for that use-case. Now it would be good if Arrays could be used for this, but that would make things more complicated, not less.


More information about the Digitalmars-d-learn mailing list