cockroach: github.com/cockroachdb/cockroach/pkg/util/ring Index | Files

package ring

import "github.com/cockroachdb/cockroach/pkg/util/ring"

Index

Package Files

ring_buffer.go

type Buffer Uses

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 Uses

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 Uses

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 Uses

func (r *Buffer) Cap() int

Cap returns the capacity of the Buffer.

func (*Buffer) Get Uses

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

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

func (*Buffer) GetFirst Uses

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

GetFirst returns an element at the front of the Buffer.

func (*Buffer) GetLast Uses

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

GetLast returns an element at the front of the Buffer.

func (*Buffer) Len Uses

func (r *Buffer) Len() int

Len returns the number of elements in the Buffer.

func (*Buffer) RemoveFirst Uses

func (r *Buffer) RemoveFirst()

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

func (*Buffer) RemoveLast Uses

func (r *Buffer) RemoveLast()

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

func (*Buffer) Reserve Uses

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 Uses

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.

Package ring is imported by 5 packages. Updated 2019-10-11. Refresh now. Tools for package owners.