Constructor.
Appends a new piece of data to the end of the buffer. The item is also added to the slices list.
Empties the buffer.
foreach iterator over the items which have been added to the buffer and their indices.
foreach iterator over the items which have been added to the buffer.
Gets an indexed item in the items list.
Get the stored slices.
Removes an indexed item in the items list, maintaining the order of the list.
element type of buffer
This template is useful for situations where you need to build up a list of arrays of type T[], and be able to repeatedly fill and empty the list without recurring memory allocation. Note that once an item is added to the buffer, it is *not* possible to modify its length, as each item is only stored as a slice (though it is possible to modify the contents of a slice). (For situations where you want to be able to modify the lengths of the individual arrays after adding them to the collection, a Pool of structs containing arrays would be a suitable solution -- see ocean.core.ObjectPool.)
Usage example:
import ocean.util.container.ConcatBuffer; // Create a slice buffer auto buff = new SliceBuffer!(char); // Repeatedly... while ( application_running ) { // Empty the buffer buff.clear(); // Add stuff to the buffer buff.add("hello"); buff.add("world"); // Iterate over the items in the buffer foreach ( index, item; buff ) { } }
Slice buffer class template. Extends ConcatBuffer, encapsulating a buffer with a list of slices to the concatenated items.