Circular Buffer

Tobias Pankrath tobias at pankrath.net
Thu Feb 13 12:50:25 PST 2014


On Thursday, 13 February 2014 at 20:40:21 UTC, Tobias Pankrath 
wrote:
> On Monday, 10 February 2014 at 03:14:31 UTC, Jonathan Dunlap 
> wrote:
>> (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?
>
> I don't think it is currently possible, but it shouldn't be 
> hard to make retro work with cycle

Yep, I've missed three pages of this discussion.

@monarch_dodra
I'd say a bidirectional cycle should be a consistent to the 
random access version, so popBack becomes essentially a index-- 
and back == front initially.


More information about the Digitalmars-d-learn mailing list