leetcode

package
v0.0.0-...-89b8728 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

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

Item is an Item that can be inserted into a PriorityQueue

func NewItem

func NewItem(key int, priority int) *Item

NewItem returns a pointer a new Item

func (Item) Key

func (i Item) Key() int

Key returns the key of the item This is used to find the item when updating etc.

func (Item) Priority

func (i Item) Priority() int

Priority returns the priority of the item

type PriorityQueue

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

PriorityQueue implements heap.Interface

func NewPriorityQueue

func NewPriorityQueue() PriorityQueue

NewPriorityQueue returns a PriorityQueue

func (*PriorityQueue) Contains

func (pq *PriorityQueue) Contains(key int) bool

Contains returns bool representing the presences/lack thereof of the Item with the corresponding key in the heap

func (*PriorityQueue) GetItem

func (pq *PriorityQueue) GetItem(key int) (Item, error)

GetItem returns an item in the heap by key if it is on the heap.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

Len implements sort.Interface

func (PriorityQueue) Less

func (pq PriorityQueue) Less(i, j int) bool

Less implements sort.Interface

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

Pop implements heap.Interface

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

Push implements heap.Interface

func (PriorityQueue) Swap

func (pq PriorityQueue) Swap(i, j int)

Swap implements sort.Interface

func (*PriorityQueue) Update

func (pq *PriorityQueue) Update(key int, priority int) error

Update updates the priority of the item with the corresponding key. Returns an error if the Item is not in the PriorityQueue

type TreeNode

type TreeNode struct {
	Val   int
	Left  *TreeNode
	Right *TreeNode
}

type Vertex

type Vertex [2]int

Jump to

Keyboard shortcuts

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