ring

package
v0.0.0-...-13a6da0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer struct {
	// contains filtered or unexported fields
}

Buffer is a deque maintained over a ring buffer.

Note: it is backed by a slice (unlike container/ring which is backed by a linked list).

func (*Buffer) AddFirst

func (r *Buffer) AddFirst(element interface{})

AddFirst add element to the front of the Buffer and doubles it's underlying slice if necessary.

func (*Buffer) AddLast

func (r *Buffer) AddLast(element interface{})

AddLast adds element to the end of the Buffer and doubles it's underlying slice if necessary.

func (*Buffer) Cap

func (r *Buffer) Cap() int

Cap returns the capacity of the Buffer.

func (*Buffer) Get

func (r *Buffer) Get(pos int) interface{}

Get returns an element at position pos in the Buffer (zero-based).

func (*Buffer) GetFirst

func (r *Buffer) GetFirst() interface{}

GetFirst returns an element at the front of the Buffer.

func (*Buffer) GetLast

func (r *Buffer) GetLast() interface{}

GetLast returns an element at the front of the Buffer.

func (*Buffer) Len

func (r *Buffer) Len() int

Len returns the number of elements in the Buffer.

func (*Buffer) RemoveFirst

func (r *Buffer) RemoveFirst()

RemoveFirst removes a single element from the front of the Buffer.

func (*Buffer) RemoveLast

func (r *Buffer) RemoveLast()

RemoveLast removes a single element from the end of the Buffer.

func (*Buffer) Reserve

func (r *Buffer) Reserve(n int)

Reserve reserves the provided number of elemnets in the Buffer. It is an error to reserve a size less than the Buffer's current length.

func (*Buffer) Reset

func (r *Buffer) Reset()

Reset makes Buffer treat its underlying memory as if it were empty. This allows for reusing the same memory again without explicitly removing old elements.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL