btrstruct

package
v0.0.0-...-19bd271 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

Queue provides a fast, ring-buffer queue based on the version suggested by Dariusz Górecki. Using this instead of other, simpler, queue implementations (slice+append or linked list) provides substantial memory and time benefits, and fewer GC pauses.

The queue implemented here is as fast as it is for an additional reason: it is *not* thread-safe.

Queue represents a single instance of the queue data structure.

func NewQueue

func NewQueue[T any]() *Queue[T]

NewQueue constructs and returns a new Queue.

func (*Queue[T]) Add

func (q *Queue[T]) Add(elem T)

Add puts an element on the end of the queue.

func (*Queue[T]) Get

func (q *Queue[T]) Get(i int) interface{}

Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.

func (*Queue[T]) Length

func (q *Queue[T]) Length() int

Length returns the number of elements currently stored in the queue.

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() T

Peek returns the element at the head of the queue. This call panics if the queue is empty.

func (*Queue[T]) Remove

func (q *Queue[T]) Remove() T

Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.

type Tree

type Tree[K comparable, V any] struct {
	// contains filtered or unexported fields
}

REWORK

func (*Tree[K, V]) Get

func (t *Tree[K, V]) Get(branch []K) (V, bool)

func (*Tree[K, V]) Has

func (t *Tree[K, V]) Has(branch []K) bool

func (*Tree[K, V]) Set

func (t *Tree[K, V]) Set(branch []K, value V)

Jump to

Keyboard shortcuts

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