Circular Buffer

simendsjo simendsjo at gmail.com
Sat Dec 21 03:35:50 PST 2013


On Friday, 20 December 2013 at 15:45:04 UTC, Frustrated wrote:
> I'm in need of a circular buffer/array. I am using 
> std.container.array to avoid the GC. I suppose I could copy and 
> modify the code but is there any easier way? It looks like it 
> is defined as templates so could I somehow hijack the code and 
> modify only what is needed rather than duplicate a lot of 
> stuff? (or maybe someone could just add it to the library... 
> circular arrays are useful ya know ;)

Writing your own should be quite simple. I see others have 
already added some implementations, so I'll add mine too. 
Modifying it to use a static array shouldn't be too difficult, 
but you're probably better off using some of the others code as 
this is dynamic and haven't been used in production.

https://gist.github.com/simendsjo/3b8a9c60bd92e16691d7


More information about the Digitalmars-d-learn mailing list