Re: Does D have a Queue and Stack container?

2013-01-14 Thread bearophile
Sorry, I meant to say, a dynamic array of pointers to fixed-sized arrays. That's for a stack. For a queue a nice implementation is a power-of-2 growable circular queue of pointers to fixed-sized arrays (chunks); plus a ("intrusive", no more memory needed) linked list of some of the last free

Re: Does D have a Queue and Stack container?

2013-01-13 Thread Jacob Carlborg
On 2013-01-13 20:55, Damian wrote: As per title, it would be awesome if someone could link me to these. I'm quite suprised that D does not already contain these.. are there any plans for them joining Phobos? Tango has a stack, at least: https://github.com/SiegeLord/Tango-D2 http://www.dsource.

Re: Does D have a Queue and Stack container?

2013-01-13 Thread bearophile
Andrey: D's containers are disappointment. They will get better because I think D is slowly getting all the machinery to implement them well, finishing the implementation of const/immutable, shared and memory allocators. Bye, bearophile

Re: Does D have a Queue and Stack container?

2013-01-13 Thread bearophile
ponce: I wrote a Queue/RingBuffer here: https://github.com/p0nce/gfm/blob/master/common/queue.d You have code like: return _data[(_first + _count - 1) % _data.length]; Take a look here: http://rosettacode.org/wiki/Queue/Usage#Faster_Version It keeps another instance field: private uint pow

Re: Does D have a Queue and Stack container?

2013-01-13 Thread Andrey
D's containers are disappointment. I'm currently writing custom module of data structures to be as fast, economic and close to hardware as possible. I'm almost at the beginning stage, so no clear timeline. Thanks creators, D allows to work with low level stuff and mix it rather effectively wi

Re: Does D have a Queue and Stack container?

2013-01-13 Thread ponce
On Sunday, 13 January 2013 at 19:55:28 UTC, Damian wrote: As per title, it would be awesome if someone could link me to these. I'm quite suprised that D does not already contain these.. are there any plans for them joining Phobos? I wrote a Queue/RingBuffer here: https://github.com/p0nce/gfm/b

Re: Does D have a Queue and Stack container?

2013-01-13 Thread H. S. Teoh
On Sun, Jan 13, 2013 at 09:02:38PM +0100, Peter Alexander wrote: > On Sunday, 13 January 2013 at 19:55:28 UTC, Damian wrote: > >As per title, it would be awesome if someone could link me to > >these. I'm quite suprised that D does not already contain these.. > >are there any plans for them joining

Re: Does D have a Queue and Stack container?

2013-01-13 Thread bearophile
The standard container you refer to is deque, sometimes implemented as a dynamic array of fixed-sized arrays, Sorry, I meant to say, a dynamic array of pointers to fixed-sized arrays. Bye, bearophile

Re: Does D have a Queue and Stack container?

2013-01-13 Thread bearophile
Peter Alexander: Well, a stack is just an array. int[] stack; stack ~= 1; stack ~= 2; assert(stack.back == 2); stack.popBack(); assert(stack.back == 1); stack.popBack(); assert(stack.empty); If you want strict stack semantics (i.e. *only* allow access to the top/back) then you could trivially

Re: Does D have a Queue and Stack container?

2013-01-13 Thread Robik
On Sunday, 13 January 2013 at 19:55:28 UTC, Damian wrote: As per title, it would be awesome if someone could link me to these. I'm quite suprised that D does not already contain these.. are there any plans for them joining Phobos? Here's one I am using: https://gist.github.com/4525926 You can

Re: Does D have a Queue and Stack container?

2013-01-13 Thread bearophile
Damian: As per title, it would be awesome if someone could link me to these. I'm quite suprised that D does not already contain these.. are there any plans for them joining Phobos? Currently Phobos doesn't have deque, queue and stack data structures. I hope it will eventually have them. In t

Re: Does D have a Queue and Stack container?

2013-01-13 Thread Peter Alexander
On Sunday, 13 January 2013 at 19:55:28 UTC, Damian wrote: As per title, it would be awesome if someone could link me to these. I'm quite suprised that D does not already contain these.. are there any plans for them joining Phobos? Well, a stack is just an array. int[] stack; stack ~= 1; stack

Does D have a Queue and Stack container?

2013-01-13 Thread Damian
As per title, it would be awesome if someone could link me to these. I'm quite suprised that D does not already contain these.. are there any plans for them joining Phobos?