queue

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 0 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue[T any] []T

Queue implements a FIFO queue.

func (*Queue[T]) Clear

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

Clear removes all elements from the queue.

func (*Queue[T]) Dequeue

func (q *Queue[T]) Dequeue() (T, bool)

Dequeue removes a single element from the front of the queue (if there is one) and returns it. Returns a zero value and false if there is no element to dequeue.

func (*Queue[T]) DequeueN

func (q *Queue[T]) DequeueN(N int) ([]T, bool)

DequeueN removes N elements from the front of the queue (if there are enough) and returns a slice of those elements. Returns a nil slice and false if there are insufficient elements to dequeue.

func (*Queue[T]) Enqueue

func (q *Queue[T]) Enqueue(t ...T)

Enqueue adds the elements to the back of the queue.

func (*Queue[T]) Len

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

Len returns the number of elements in the queue.

func (*Queue[T]) Peek

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

Peek returns the single element at the front of the queue (if there is one) without removing it. Returns a zero value and false if there is no element to peek at.

func (*Queue[T]) PeekN

func (q *Queue[T]) PeekN(N int) (T, bool)

PeekN returns the element in Nth position in the queue Returns a zero value and false if there are insufficient elements in the queue.

func (*Queue[T]) Prepend

func (q *Queue[T]) Prepend(t ...T)

Prepend inserts the elements at the front of the queue, preserving their order. A noop if t is empty.

Jump to

Keyboard shortcuts

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