queue

package
v0.0.0-...-034ee8e Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ASC        Order = 1             // asc sort.
	DESC       Order = -1            // desc sort.
	MaxCap     int   = (1 << 31) - 2 // position with index 0 is not used.
	DefaultCap int   = (1 << 6) + 1  // default cap is 64
)

Variables

This section is empty.

Functions

func NewPriorityQueue

func NewPriorityQueue(comparator Comparator, order Order) *priorityQueue

func NewPriorityQueueWithCap

func NewPriorityQueueWithCap(capacity int, comparator Comparator, order Order) *priorityQueue

func NewPriorityQueueWithElems

func NewPriorityQueueWithElems(elems []interface{}, comparator Comparator, order Order) *priorityQueue

Types

type Comparator

type Comparator func(interface{}, interface{}) int

type Order

type Order int

type Queue

type Queue interface {
	// remove and return the first element of queue.
	PollFirst() interface{}
	// remove and return the last element of queue.
	PollLast() interface{}
	// return the first element of queue.
	PeekFirst() interface{}
	// return the last element of queue;
	PeekLast() interface{}
	// insert element to the head of queue.
	OfferFirst(interface{}) bool
	// insert element to the tail of queue.
	OfferLast(interface{}) bool
	// the same as PollFirst.
	RemoveFirst() interface{}
	// the same as PollLast.
	RemoveLast() interface{}
}

Queue defines the actions of queuq.

Jump to

Keyboard shortcuts

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