cbuf v0.7.1 Cbuf behaviour

This module describes the behavior of a circular buffer.

A circular buffer is useful if you care about newer data more than older data. Examples might include applications where you want to process the most recent events without having to process older ones, or where you wish to compute statistics over only the newest events in a stream.

This library provides three implementations of Cbuf: Cbuf.Queue, Cbuf.Map, and Cbuf.ETS. I recommend defaulting to Cbuf.Queue unless you specifically know that Cbuf.Map or Cbuf.ETS will better serve your use case.

This version of the structure operates on a First In, First Out basis, where the “first” value out of the structure is the oldest, and every value after that will be newer, with the last item in the buffer being the newest.

Link to this section Summary

Link to this section Types

Link to this opaque t() (opaque)
t()

Link to this section Callbacks

Link to this callback delete(t)
delete(t()) :: t()
Link to this callback empty?(t)
empty?(t()) :: boolean()
Link to this callback insert(t, term)
insert(t(), term()) :: t()
Link to this callback member?(t, term)
member?(t(), term()) :: boolean()
Link to this callback new(pos_integer)
new(pos_integer()) :: t()
Link to this callback peek(t)
peek(t()) :: term() | nil
Link to this callback pop(t)
pop(t()) :: {term() | nil, t()}
Link to this callback to_list(t)
to_list(t()) :: [term()] | []