queue

package
v0.0.0-...-ec87a65 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Paackage queue implements a growable queue implemented using a circlar buffer

The naive way to implement a queue is very wastful and lets the underlying buffer grow without bound.

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
}

func NewQueue

func NewQueue[T any](initialCapacity uint) Queue[T]

func (*Queue[T]) Empty

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

func (*Queue[T]) Len

func (self *Queue[T]) Len() uint

func (*Queue[T]) Pop

func (self *Queue[T]) Pop() (T, bool)

Pops an element from the front of the queue and returns it

If the queue is empty, the second value will be `false`

func (*Queue[T]) Push

func (self *Queue[T]) Push(elem T)

Pushes an element to the back of the queue.

If the queue is full, we grow the underlying buffer first

Jump to

Keyboard shortcuts

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