Skip to content

xuoe/go-ring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference

This library provides a generic ring buffer implementation.

API

func New(int) *Buffer[T]
func FromSlice([]T) *Buffer[T]
func WrapSlice([]T) *Buffer[T]

func (*Buffer[T]) Push(T) (T, bool)
func (*Buffer[T]) Pop() (T, bool)
func (*Buffer[T]) Head() (T, bool)
func (*Buffer[T]) Tail() (T, bool)
func (*Buffer[T]) Get(int) T
func (*Buffer[T]) Cap() int
func (*Buffer[T]) Len() int
func (*Buffer[T]) Empty() bool
func (*Buffer[T]) Full() bool
func (*Buffer[T]) Offset() int
func (*Buffer[T]) SetOffset(int)
func (*Buffer[T]) ToSlice() []T

See the docs for more.