CyclicArray

@nogc array without memory management using a cyclic array internally Should be treated like a static array when no len is set (copies on assignment) The maximum capacity is static and by default so many elements that it fills at most 4KiB, but at least 8 elements (even if that is more than 4KiB). Set length to 0 to make it a std.container.Array based array Bugs: foreach with ref value requires @nogc body to make this @nogc compatible

struct CyclicArray (
T
size_t len = max(8, 4096 / T.sizeof)
) {}

Mixed In Members

From mixin CyclicRangePrimitives!(T, q{ static if (len == 0) auto copy = typeof(cast() this)(array.length); else typeof(cast() this) copy; })

Examples

CyclicArray!int array;
assert(array.length == 0);
array ~= 5;
assert(!array.empty);
assert(array.front == 5);
assert(array[0] == 5);
array ~= [4, 3];

assert(array == [5, 4, 3]);

// same efficiency as insertBack/put/concat
array.insertFront(5);

Meta