elembuf 1.1.5

Simple to use circular buffer/array for efficient IO

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:



An efficient and simple to use buffer/array for data manipulation.

wiki LICENSE bench ci cov


A circular buffer can be thought of as an array that can eliminate program side copying, making data reads from sockets or other IO more efficient. The simple idea is that if elements/array items are popped/removed from the front, the free slots can be used to fill the back of the array without moving the existing data. A simple way to understand the concept is that a circular buffer is a faster concatenator (concat/cat/~) as all free data reserves are more easily taken advantage of, however, circular buffers are limited to a maximum size.

Elembuf is an implementation of a circular buffer. It is however different from a regular circular buffer in that it is as compact as an array, infact it is indistinquishable from a regular dynamic array and it can even be directly cast to it. Allocated memory of an Elembuf is internally memory mapped to work like a mirror of itself and it achieves higher speeds by being allocated to a custom memory position. The mirroring properties of the implementation give additional benefits to encryption and compression algorithms. You may however use Elembuf for any purpose which a regular array is used for, such as when parsing data, reading files or assembling data. Elembuf has a page sized or larger maximum array byte length and works directly with the OS, thus it does not use the garbage collector.

Because construction speed is slightly slower than with a regular array, reusage is key to the function of an Elembuf. You should construct the buffer at the start of the program, or at server boot, and change the source where data is received instead of deconstructing the array/buffer. This way you can take advantage of the filling speed.

Elembuf currently works for Windows, Linux, Mac and other Posix compatible systems.

Getting Started

For examples on how to use the library, the documentation is a good place to start:


You can download the repo and open the solution file in the repository called "Elembuf.sln" (VS17 & VS19) with visuald in visual studio. The source files should automatically link and you may easily edit the source code and add your own code into the solution.


Manual linking must be done using the instructions of your own compiler.

You may use the source files as is, regardless of what os, editor or IDE you use, as long as you know how to link them through your compiler.


#!/usr/bin/env dub
/+ dub.sdl:
name "app"
dependency "elembuf" version="~>1.1.5"

module app;

import buffer;
import std.stdio;

void main() {
    Buffer!char bufchar = Buffer!()(); // char[]
    assert(bufchar == "");
    bufchar << "Hello world!";

$ dub app.d

Hello world!


Feel free to contribute by sending a pull request or sending in bug reports through issues. If you wish to help, you can assist in making the buffer callable from the C language. Remember to include tests in your pull requests!


  • Cyroxin
1.2.3 2020-Jun-23
1.2.2 2020-Jun-23
1.2.1 2020-Jun-23
1.2.0 2020-Jun-23
1.1.5 2020-Jun-16
Show all 12 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 44 downloads total

Short URL: