queue

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 1 Imported by: 20 modules, 43 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

GitHub Test Status GoDoc License Go Report CodeFactor

A priority queue written in Go that signals using channels

Installation Go Version

go get -v -u github.com/caffix/queue@main

Licensing License

This program is free software: you can redistribute it and/or modify it under the terms of the Apache license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue interface {
	// Append adds the data to the Queue at priority level PriorityNormal.
	Append(data any)

	// AppendPriority adds the data to the Queue with respect to priority.
	AppendPriority(data any, priority QueuePriority)

	// Signal returns the Queue signal channel.
	Signal() <-chan struct{}

	// Next returns the data at the front of the Queue.
	Next() (any, bool)

	// Process will execute the callback parameter for each element on the Queue.
	Process(callback func(any))

	// Empty returns true if the Queue is empty.
	Empty() bool

	// Len returns the current length of the Queue.
	Len() int
}

Queue implements a FIFO data structure that can support a few priorities.

func NewQueue

func NewQueue() Queue

NewQueue returns an initialized Queue.

type QueuePriority added in v0.3.0

type QueuePriority int
const (
	PriorityLow      QueuePriority = 0
	PriorityNormal   QueuePriority = 1
	PriorityHigh     QueuePriority = 2
	PriorityCritical QueuePriority = 3
)

The priority levels for the priority Queue.

Jump to

Keyboard shortcuts

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