On Monday, 7 October 2019 at 17:11:08 UTC, Just Dave wrote:
I need a stack and a queue and I noticed that the standard
library doesn't appear to have one. Which is ok. I just need
something that can logically behave as a stack and queue, which
I think the dynamic array should be able to do (if I understand
correctly this is effectively the equivalent of vector<T> in
C++ or List<T> in C#). However, I'm having a hard time figuring
out the best way to push, pop, enqueue and dequeue using D.
I'm not seeing here: https://dlang.org/spec/arrays.html, anyway
to remove from the array. What's the correct syntax/method call
for this? I see you can easily concatenate with '~', but I see
no corresponding delete.
Sorry for the newbie question, but I'm just unsure where to
look for this.
Built-in D arrays rely on garbage collector, and you don't need
an explicit delete. For nogc arrays, there are 3rd party libs and
std.container.array. take a look at
https://dlang.org/phobos/std_container_array.html