queue

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 0 Imported by: 0

README

A generic type Queue package

Go Reference

Installation

go get github.com/sujancse/queue

Usage in GoDoc

See GoDoc for documentation and examples.

Examples

See GoDoc or example_test.go for examples.

Contributing

Contributions welcome! Please fork the repository and open a pull request with your changes.

License

This is free software, licensed under the MIT License.

Documentation

Index

Examples

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 (*Queue[T]) Add

func (q *Queue[T]) Add(data T)
Example
q := Queue[int]{}
q.Add(1)
q.Add(2)
q.Add(3)
Output:

func (*Queue[T]) IsEmpty

func (q *Queue[T]) IsEmpty() bool
Example
q := Queue[int]{}
q.Add(1)
q.Add(2)

fmt.Println(q.IsEmpty())
// Output: false

q.Remove()
q.Remove()

fmt.Println(q.IsEmpty())
Output:

true

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() T
Example
q := Queue[int]{}
q.Add(1)
q.Add(2)

fmt.Println(q.Peek())
Output:

1

func (*Queue[T]) Remove

func (q *Queue[T]) Remove() T
Example
q := Queue[int]{}
q.Add(1)
q.Add(2)

fmt.Println(q.Remove())
Output:

1

Jump to

Keyboard shortcuts

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