Jump to page: 1 24  
Page
Thread overview
Circular Buffer
Dec 20, 2013
Frustrated
Dec 20, 2013
Orvid King
Dec 20, 2013
Frustrated
Dec 20, 2013
Orvid King
Dec 20, 2013
bearophile
Dec 20, 2013
Timon Gehr
Dec 20, 2013
lomereiter
Feb 10, 2014
Jonathan Dunlap
Feb 10, 2014
Chris Cain
Feb 10, 2014
Gary Willoughby
Feb 10, 2014
Russel Winder
Feb 10, 2014
bearophile
Feb 12, 2014
Russel Winder
Feb 13, 2014
Frustrated
Feb 13, 2014
Artem Tarasov
Feb 11, 2014
Jonathan Dunlap
Feb 11, 2014
Martijn Pot
Feb 11, 2014
Andrea Fontana
Feb 11, 2014
Andrea Fontana
Feb 11, 2014
Rene Zwanenburg
Feb 11, 2014
Rene Zwanenburg
Feb 11, 2014
Andrea Fontana
Feb 12, 2014
Jonathan Dunlap
Feb 12, 2014
Russel Winder
Feb 13, 2014
bearophile
Feb 13, 2014
Russel Winder
Feb 13, 2014
Russel Winder
Feb 13, 2014
monarch_dodra
Feb 13, 2014
Tobias Pankrath
Feb 13, 2014
Tobias Pankrath
Dec 21, 2013
ponce
Dec 21, 2013
simendsjo
December 20, 2013
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 ;)

December 20, 2013
There's actually already a circular buffer implemented in vibe.d, and if I remember right it's not dependent on anything from vibe.

On 12/20/13, Frustrated <c1514843@drdrb.com> 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 ;)
>
>
December 20, 2013
But does it rely on the GC?
December 20, 2013
Frustrated:

> I'm in need of a circular buffer/array. I am using std.container.array to avoid the GC.

Why do you need to avoid the GC?

Bye,
bearophile
December 20, 2013
On 12/20/2013 04:45 PM, 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?  ...

What prevents you from implementing your buffer using an std.container.Array as the backing store?

December 20, 2013
On 12/20/13, Frustrated <c1514843@drdrb.com> wrote:
> But does it rely on the GC?
>

Nope, the template you wanted is vibe.utils.array:FixedRingBuffer.
December 20, 2013
Use std.range.cycle with std.container.Array (slice the array to get a range).

http://dlang.org/phobos/std_range.html#.cycle
December 21, 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 ;)

http://p0nce.github.io/gfm/gfm.core.queue.html#RingBuffer < and use malloc instead of .length
December 21, 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
February 10, 2014
(disclaimer: I'm new around here)
Is it possible to cycle backwards? If not, what's the best approach?

Example of some ideal "takeBack" function:
data = cycle([1,2,3][])
take(data, 4) is [1,2,3,1][]
takeBack(data, 4) would be [1,3,2,1][]

Thoughts?
« First   ‹ Prev
1 2 3 4