queue

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: MIT Imports: 0 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[E any] struct {
	// contains filtered or unexported fields
}

Queue is generic FIFO queue.

func New

func New[E any]() *Queue[E]

New creates a new queue backed by a slice.

func (*Queue[E]) Clear

func (q *Queue[E]) Clear()

Clear removes all elements from the queue.

func (*Queue[E]) Empty

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

Empty returns true if the queue is empty.

func (*Queue[E]) Len

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

Len returns the number of elements in the queue.

func (*Queue[E]) Peek

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

Peek returns the first element in the queue. Peek panics if the queue is empty.

func (*Queue[E]) Pop

func (q *Queue[E]) Pop() E

Pop removes and returns the first element from the queue. Pop panics if the queue is empty.

func (*Queue[E]) Push

func (q *Queue[E]) Push(e E)

Push adds an element to last position of the queue.

func (*Queue[E]) Slice

func (q *Queue[E]) Slice() []E

Slice returns the underlying slice. The queue retains the returned slice, so altering the slice may break the invariants and invalidate the queue.

Jump to

Keyboard shortcuts

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