queue

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package queue

(C) Copyright Alex Gaetano Padula

Licensed under the Mozilla Public License, v. 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

https://www.mozilla.org/en-US/MPL/2.0/

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node represents a node in the queue

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue implements a concurrent non-blocking queue

func New

func New() *Queue

New creates a new concurrent queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() interface{}

Dequeue removes and returns a value from the queue Returns nil if the queue is empty

func (*Queue) Enqueue

func (q *Queue) Enqueue(value interface{})

Enqueue adds a value to the queue

func (*Queue) ForEach

func (q *Queue) ForEach(f func(item interface{}) bool)

ForEach iterates over the queue and applies the function f to each item

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty

func (*Queue) List

func (q *Queue) List() []interface{}

List returns a slice of all values in the queue

func (*Queue) Peek

func (q *Queue) Peek() interface{}

Peek returns the value at the front of the queue without removing it Returns nil if the queue is empty

Jump to

Keyboard shortcuts

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