queues

package
v0.0.0-...-5ce2504 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 1 Imported by: 0

README

Description

Implement a Queue. A queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO)

Example:

Input: Enqueue "value1", Enqueue "value2", Enqueue "value3", Dequeue 
Output: ["value2", "value3"]

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 Queue structure

func New

func New[T any](values ...T) *Queue[T]

New factory to generate new Queues

func (*Queue[T]) Clear

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

Clear clears Queue

func (*Queue[T]) Dequeue

func (q *Queue[T]) Dequeue() (res T, err error)

Dequeue remove from the Queue

func (*Queue[T]) Enqueue

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

Enqueue add to the Queue

func (*Queue[T]) GetValues

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

GetValues returns values

func (*Queue[T]) IsEmpty

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

IsEmpty checks if the Queue is empty

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() (res T, err error)

Peek returns front of the Queue

func (*Queue[T]) Size

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

Size returns size of the Queue

Jump to

Keyboard shortcuts

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