Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RingBuffer ¶ added in v0.15.7
type RingBuffer struct {
// contains filtered or unexported fields
}
RingBuffer is a generic ring buffer implementation that contains sequential data (i.e. such as time ordered data). RingBuffer is implemented using slices. From testing, this should be fast than linked-list implementations, and also allows for efficient indexing of ordered data.
func NewRingBuffer ¶ added in v0.15.7
func NewRingBuffer(bufferSize int) *RingBuffer
NewRingBuffer constructs a new ring buffer for a given buffer size.
func (*RingBuffer) Add ¶ added in v0.15.7
func (eb *RingBuffer) Add(e interface{})
Add adds an element to the buffer.
func (*RingBuffer) Compact ¶ added in v0.15.7
func (eb *RingBuffer) Compact(isValid func(interface{}) bool)
Compact clears out invalidated elements in the buffer. This may require copying the entire buffer. It is assumed that if buffer[i] is invalid then every entry [0...i-1] is also not valid.
func (*RingBuffer) Iterate ¶ added in v0.15.7
func (eb *RingBuffer) Iterate(callback func(interface{}))
Iterate is a convenience function over IterateValid that iterates all elements in the buffer.
func (*RingBuffer) IterateValid ¶ added in v0.15.7
func (eb *RingBuffer) IterateValid(isValid func(interface{}) bool, callback func(interface{}))
IterateValid calls the callback on each element of the buffer, starting with the first element in the buffer that satisfies "isValid".
func (*RingBuffer) Size ¶ added in v0.15.7
func (eb *RingBuffer) Size() int
Size returns the size of the buffer.