queue

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 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 implements a FIFO queue backed by an array.Array for efficient block-based allocations.

func (*Queue[T]) Empty

func (q *Queue[T]) Empty() bool

Empty reports whether if the queue contains no entries.

func (*Queue[T]) Get

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

Get obtains the value of an entry at a specific offset. Like a Go slice this results in a panic if the value is outside the array bounds.

func (*Queue[T]) Len

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

Len gets the number of values in the queue.

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() (v T, ok bool)

Pop removes the oldest value from the queue in FIFO order if any are available.

func (*Queue[T]) PopWithPool

func (q *Queue[T]) PopWithPool(pool *array.Pool[T]) (v T, ok bool)

PopWithPool removes the oldest value from the queue in FIFO order if any are available. If the removed value was the only item remaining in the block of the backing array.Array, that block will be returned to the pool.

func (*Queue[T]) Ptr

func (q *Queue[T]) Ptr(i int) *T

Ptr obtains the pointer to a value for an entry at a specific offset. The returned pointer is guaranteed not to change until the index is popped from the array. Like a Go slice this results in a panic if the value is outside the array bounds.

func (*Queue[T]) Push

func (q *Queue[T]) Push(v T)

Push adds a new value to the end of the queue.

func (*Queue[T]) PushWithPool

func (q *Queue[T]) PushWithPool(v T, pool *array.Pool[T])

PushWithPool adds a new value to the end of the queue. If a new block is required by the backing array.Array, it will be allocated from the pool.

Jump to

Keyboard shortcuts

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