Documentation ¶
Overview ¶
A circular buffer data type for floating point values.
A circular buffer data type for generic values.
Index ¶
- type Buffer
- func (b *Buffer) Clear()
- func (b *Buffer) Each(cb func(int, float64))
- func (b *Buffer) GetFromEnd(index int) float64
- func (b *Buffer) GoPushChannel(values <-chan float64, sampleRate int)
- func (b *Buffer) IsFinished() bool
- func (b *Buffer) IsFull() bool
- func (b *Buffer) Push(value float64) float64
- func (b *Buffer) Size() int
- type TypedBuffer
- func (b *TypedBuffer) Clear()
- func (b *TypedBuffer) Each(cb func(int, interface{}))
- func (b *TypedBuffer) GetFromEnd(index int) interface{}
- func (b *TypedBuffer) GoPushChannel(values <-chan interface{}, sampleRate int)
- func (b *TypedBuffer) IsFinished() bool
- func (b *TypedBuffer) IsFull() bool
- func (b *TypedBuffer) Push(value interface{}) interface{}
- func (b *TypedBuffer) Size() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer holds the values within the buffer plus a collection of metadata.
func (*Buffer) Each ¶
Each applies a given function to all the values in the buffer, from least recent first, ending at the most recent.
func (*Buffer) GetFromEnd ¶
GetFromEnd returns the most recent buffer values. 0 returns the most recently pushed, the least recent being b.size - 1
func (*Buffer) GoPushChannel ¶
GoPushChannel constantly pushes values from a channel, in a separate thread, optionally only sampling 1 every sampleRate values.
func (*Buffer) IsFinished ¶
IsFinished returns whether there is nothing more to be added to the buffer
func (*Buffer) IsFull ¶
IsFull returns whether the buffer is full, in that adding more entries will delete older ones.
type TypedBuffer ¶
type TypedBuffer struct {
// contains filtered or unexported fields
}
Buffer holds the values within the buffer plus a collection of metadata.
func NewTypedBuffer ¶
func NewTypedBuffer(capacity int) *TypedBuffer
NewTypedBuffer creates a new circular buffer of a given maximum size.
func (*TypedBuffer) Each ¶
func (b *TypedBuffer) Each(cb func(int, interface{}))
Each applies a given function to all the values in the buffer, from least recent first, ending at the most recent.
func (*TypedBuffer) GetFromEnd ¶
func (b *TypedBuffer) GetFromEnd(index int) interface{}
GetFromEnd returns the most recent buffer values. 0 returns the most recently pushed, the least recent being b.size - 1
func (*TypedBuffer) GoPushChannel ¶
func (b *TypedBuffer) GoPushChannel(values <-chan interface{}, sampleRate int)
GoPushChannel constantly pushes values from a channel, in a separate thread, optionally only sampling 1 every sampleRate values.
func (*TypedBuffer) IsFinished ¶
func (b *TypedBuffer) IsFinished() bool
IsFinished returns whether there is nothing more to be added to the buffer
func (*TypedBuffer) IsFull ¶
func (b *TypedBuffer) IsFull() bool
IsFull returns whether the buffer is full, in that adding more entries will delete older ones.
func (*TypedBuffer) Push ¶
func (b *TypedBuffer) Push(value interface{}) interface{}
Push adds a new value at the end of the buffer.
func (*TypedBuffer) Size ¶
func (b *TypedBuffer) Size() int
Size returns the number of values in the buffer.