lu.container

Containers and thereto related functionality.

Members

Structs

Buffer
struct Buffer(T, Flag!"dynamic" dynamic = No.dynamic, size_t originalSize = 128)

Simple buffer/queue for storing and fetching items of any type T. Does not use manual memory allcation.

Examples

{
    Buffer!string buffer;

    buffer.put("abc");
    buffer.put("def");
    assert(!buffer.empty);
    assert(buffer.front == "abc");
    buffer.popFront();
    assert(buffer.front == "def");
    buffer.popFront();
    assert(buffer.empty);
}
{
    Buffer!(char, Yes.dynamic, 3) buffer;

    assert(!buffer.buf.length);
    buffer ~= 'a';
    assert(buffer.buf.length == 3);
    buffer ~= 'b';
    buffer ~= 'c';
    assert(buffer.length == 3);
    buffer ~= 'd';
    assert(buffer.buf.length > 3);
    assert(buffer[0..5] == "abcd");
    buffer.clear();
    assert(buffer.empty);
}

Meta