pqueue

package
v0.1.1-0...-bd21e6c Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PriorityQueue

type PriorityQueue[T any] struct {
	// contains filtered or unexported fields
}
Example
package main

import (
	"fmt"

	"github.com/nobishino/gotipcode/pqueue"
)

func main() {
	pq := pqueue.New(func(x, y int) bool {
		return x < y
	})

	pq.Enqueue(2)
	pq.Enqueue(3)
	pq.Enqueue(1)
	pq.Enqueue(5)
	pq.Enqueue(4)

	for i := 0; i < 5; i++ {
		v := pq.Dequeue()
		fmt.Println(v)
	}
}
Output:

1
2
3
4
5

func New

func New[T any](less func(x, y T) bool) PriorityQueue[T]

func (*PriorityQueue[T]) Dequeue

func (pq *PriorityQueue[T]) Dequeue() T

func (*PriorityQueue[T]) Enqueue

func (pq *PriorityQueue[T]) Enqueue(item T)

Jump to

Keyboard shortcuts

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