Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xuoe/go-ring
Generic Ring Buffer
https://github.com/xuoe/go-ring
circular-buffer ring-buffer
Last synced: about 10 hours ago
JSON representation
Generic Ring Buffer
- Host: GitHub
- URL: https://github.com/xuoe/go-ring
- Owner: xuoe
- License: isc
- Created: 2022-07-23T11:25:39.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-10T13:17:08.000Z (about 2 years ago)
- Last Synced: 2024-06-20T03:46:44.872Z (6 months ago)
- Topics: circular-buffer, ring-buffer
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
[![Go Reference](https://pkg.go.dev/badge/github.com/xuoe/go-ring.svg)](https://pkg.go.dev/github.com/xuoe/go-ring)
This library provides a generic [ring buffer](https://en.wikipedia.org/wiki/Circular_buffer) implementation.
### API
```go
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](https://pkg.go.dev/github.com/xuoe/go-ring) for more.