Documentation ¶
Overview ¶
Package circular provides 'circular' data structures,
Index ¶
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 }
Buffer provides a circular buffer that grows as needed.
func (*Buffer[T]) Append ¶
func (b *Buffer[T]) Append(v []T)
Append appends the specified values to the buffer, growing the buffer as needed.
func (*Buffer[T]) Compact ¶
func (b *Buffer[T]) Compact()
Compact reduces the storage used by the buffer to the minimum necessary to store its current contents. This also has the effect of freeing any pointers that are no longer accessible via the buffer and hence may be GC'd.
func (*Buffer[T]) Head ¶
Head returns the first n elements of the buffer, removing them from the buffer. If n is greater than the number of elements in the buffer then all elements are returned. The values returned are not zeroed out and hence if pointers will not be GC'd until the buffer itself is released or Compact is called.