queue

package
v0.0.0-...-b3af538 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: Apache-2.0 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[V any] struct {
	// contains filtered or unexported fields
}

Queue represents a single instance of the queue data structure.

func New

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

New constructs and returns a new Queue.

func (*Queue[V]) Add

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

Add puts an element on the end of the queue.

func (*Queue[V]) Get

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

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[V]) Length

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

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

func (*Queue[V]) Peek

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

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

func (*Queue[V]) Remove

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

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

Jump to

Keyboard shortcuts

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