Documentation
¶
Overview ¶
package ringbuffer implements a sequential compact FIFO and LILO. Also called a Queue. To Use:
type myThing ringbuffer.RingElement var whatever == myThing("whatever") // Assuming a conversion from string. rb := RingBuffer.New(40) rb.Write(myThing) // Et cetera aThing := rb.Read() for 0 < rb.Size() { doSomethingWith(rb.Read()) } THIS IS NOT CONCURRENT —— ONE GOROUTINE ONLY.
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
}
func New ¶
func New(n int) *RingBuffer
New() allocates and initializes a new ring buffer of specified size
func (*RingBuffer) Clear ¶
func (b *RingBuffer) Clear()
Obliterate, Purge, and Remove the contents of the ring buffer. Support your local Garbage Collector!
func (*RingBuffer) Dump ¶
func (b *RingBuffer) Dump()
Dump displays the internal variables and the ENTIRE contents of the ring buffer.
func (*RingBuffer) DumpExt ¶
func (b *RingBuffer) DumpExt() []RingElement
Dump ENTIRE contents of the ring buffer into slices without changing indexes
func (*RingBuffer) Leng ¶
func (b *RingBuffer) Leng() int
Number of slots currently in use. Total writes - Total reads.
func (*RingBuffer) Read ¶
func (b *RingBuffer) Read() RingElement
Read fetches the next element from the ring buffer.
func (*RingBuffer) Write ¶
func (b *RingBuffer) Write(datum RingElement) error
Write inserts an element into the ring buffer.
type RingBufferError ¶
type RingBufferError struct {
What string
}
func (*RingBufferError) Error ¶
func (e *RingBufferError) Error() string
"Convert" ringbuffer.RingBufferError into a string.
type RingElement ¶
type RingElement interface{}
A ring buffer is stored in an array of ringbuffer.RingElement, of the size requested.