Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrIsEmpty = errors.New("ringbuffer is empty")
Functions ¶
This section is empty.
Types ¶
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
https://zh.wikipedia.org/wiki/%E7%92%B0%E5%BD%A2%E7%B7%A9%E8%A1%9D%E5%8D%80#%E9%95%9C%E5%83%8F%E6%8C%87%E7%A4%BA%E4%BD%8D RingBuffer is a ring buffer for common types. It never is full and always grows if it will be full. It is not thread-safe(goroutine-safe) so you must use the lock-like synchronization primitive to use it in multiple writers and multiple readers.
func NewRingBuffer ¶
func NewRingBuffer(initialSize int) *RingBuffer
func (*RingBuffer) Capacity ¶
func (r *RingBuffer) Capacity() int
Capacity returns the size of the underlying buffer.
func (*RingBuffer) IsEmpty ¶
func (r *RingBuffer) IsEmpty() bool
func (*RingBuffer) IsFull ¶
func (r *RingBuffer) IsFull() bool
func (*RingBuffer) Len ¶
func (r *RingBuffer) Len() int
func (*RingBuffer) Peek ¶
func (r *RingBuffer) Peek() T
func (*RingBuffer) Pop ¶
func (r *RingBuffer) Pop() T
func (*RingBuffer) Read ¶
func (r *RingBuffer) Read() (T, error)
func (*RingBuffer) Reset ¶
func (r *RingBuffer) Reset()
func (*RingBuffer) Write ¶
func (r *RingBuffer) Write(v T)
Click to show internal directories.
Click to hide internal directories.