BufferedInputRange

Allows appending to front on a regular input range, if that range is an array. It appends to the array rather than creating an array of arrays; it's meant to make the illusion of one continuous front rather than simply adding capability to walk backward to an existing input range.

I think something like this should be standard; I find File.byChunk to be almost useless without this capability.

struct BufferedInputRange (
Range
) if (
isInputRange!(Range) &&
isArray!(ElementType!(Range))
) {
bool usingUnderlyingBuffer;
}

Constructors

this
this(Range r)

Creates a buffer for the given range. You probably shouldn't keep using the underlying range directly.

Members

Functions

appendToFront
void appendToFront()

Append the next item available on the underlying range to our buffer.

consumeFromFront
void consumeFromFront(int count)

Remove the first count items from the buffer

empty
bool empty()

Forwards to the underlying range's empty function

front
ElementType!(Range) front()

Returns the current buffer

popFront
void popFront()

Discard the current buffer and get the next item off the underlying range. Be sure to call at least once to prime the range (after checking if it is empty, of course)

Suggestion Box / Bug Report