queue

package
v0.0.0-...-33647ad Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

type PriorityQueue interface {
	// Add adds an item to the priority queue with the given value and TTL
	Add(key string, value interface{}, ttl time.Duration)

	// Delete deletes the item with the given key from the priority queue
	Delete(key string)

	// DeleteExpired deletes all items from the priority queue that have
	// expired based on their TTL
	DeleteExpired(t time.Time) int

	// Get returns the item for a given key and increases its TTL on
	// retrieval
	Get(key string, ttl time.Duration) interface{}

	// Len returns the length of the priority queue
	Len() int
}

PriorityQueue represents an interface to a priority queue for items with a Time-To-Live (TTL)

func NewPriorityQueue

func NewPriorityQueue() PriorityQueue

NewPriorityQueue returns a new PriorityQueue

type Queue

type Queue interface {
	// Len returns the length of the queue
	Len() int

	// Pop returns and removes the next item in the queue
	Pop() interface{}

	// Push pushes a new item onto the queue
	Push(value interface{})
}

Queue represents an interface to queue collection

func New

func New() Queue

New returns a new Queue

Jump to

Keyboard shortcuts

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