empty the buffer
assignment
range interface
push to buffer
retrieve item from buffer (lifo)
push to buffer
retrieve item from buffer (fifo)
example
RingBuffer!(int, 5) buff; buff.push(69); buff ~= 420; // equivalent to the push syntax assert(buff.shift == 69); assert(buff.shift == 420); import std.array : staticArray; import std.range : iota; immutable int[5] temp = staticArray!(iota(5)); buff.push(temp); // multiple items may be pushed in a single call assert(buff.length == 5); assert(buff.capacity == 0); assert(buff.pop == 4); assert(buff.length == 4); assert(buff.capacity == 1); buff.clear(); assert(buff.length == 0); assert(buff.capacity == 5);
Date: 2022-02-03 Licence: AGPL-3.0 or later
Susan, 2022 special thanks to my good friend flussence, whose advice while making this module was invaluable. <3
a simple template ringbuffer, compatible with @safe, @nogc, pure and nothrow code.