Documentation
¶
Index ¶
- type Buffer
- func (b *Buffer[T]) Len() int
- func (b *Buffer[T]) Peek() T
- func (b *Buffer[T]) Pop() T
- func (b *Buffer[T]) Push(v T)
- func (b *Buffer[T]) Read(p []T) (int, error)
- func (b *Buffer[T]) Size() int
- func (b *Buffer[T]) TryPeek() (T, bool)
- func (b *Buffer[T]) TryPop() (T, bool)
- func (b *Buffer[T]) TryPush(v T) bool
- func (b *Buffer[T]) Write(p []T) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer[T any] struct { // contains filtered or unexported fields }
func (*Buffer[T]) Peek ¶
func (b *Buffer[T]) Peek() T
Peek returns first buffered element without consuming it. Function returns zero value if the buffer is empty.
func (*Buffer[T]) Pop ¶
func (b *Buffer[T]) Pop() T
Pop returns the first element and consumes it. Function returns zero value if the buffer is empty.
func (*Buffer[T]) Push ¶
func (b *Buffer[T]) Push(v T)
Push adds an element into the end of the buffer. It discards the oldest element if the buffer is already full.
func (*Buffer[T]) Read ¶
Read a number of elements from the buffer. Function returns io.EOF if the buffer is empty.
func (*Buffer[T]) TryPeek ¶
TryPeek tries to access first buffered element without consuming it. Function returns false if the buffer is empty.
func (*Buffer[T]) TryPop ¶
TryPop returns the first element and consumes it. Function returns false if the buffer is empty.
Click to show internal directories.
Click to hide internal directories.