Dynamic Arrays as Stack and/or Queue
    Ali Çehreli 
    acehreli at yahoo.com
       
    Mon Oct  7 21:05:04 UTC 2019
    
    
  
On 10/07/2019 10:11 AM, Just Dave wrote:
> I need a stack and a queue
There is a DoubleEndedQueue example under "Indexing Operators" here:
 
http://ddili.org/ders/d.en/operator_overloading.html#ix_operator_overloading.opIndexOpAssign
It does not have the pop varieties but it should be trivial to add those 
because it internally uses two slices and the "head" of the whole 
container is the actual "end" of one of those slices. (The elementAt() 
member function takes care of reversed indexing for half of the elements.)
I stole the idea of that example from Chuck Allison after one of his 
DConf presentations.
Ali
    
    
More information about the Digitalmars-d-learn
mailing list