Documentation
¶
Overview ¶
Package ringbuffer is simple ring (circular) buffer implementation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer type represents ring buffer.
func NewRingBuffer ¶
func NewRingBuffer(size int) *RingBuffer
NewRingBuffer returns a new RingBuffer.
func (*RingBuffer) Clear ¶
func (rb *RingBuffer) Clear() ([]interface{}, error)
Clear removes all elements and returns those elements.
func (*RingBuffer) Fetch ¶
func (rb *RingBuffer) Fetch() ([]interface{}, error)
Fetch returns all elements
func (*RingBuffer) Push ¶
func (rb *RingBuffer) Push(val interface{}) error
Push pushes the element val to the tail of the ring buffer.
func (*RingBuffer) Shift ¶
func (rb *RingBuffer) Shift() (interface{}, error)
Shift removes an element from head of the ring buffer and returns it.