heap_internal

package
v0.0.0-...-a119377 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

This example demonstrates a priority queue built using the heap interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlayHeap

func PlayHeap()

func PlayKthElement

func PlayKthElement()

Types

type IMinHeapSizeK

type IMinHeapSizeK interface {
	GetSize() int
	Insert(n int)
	GetSmallestElement() int
}

func NewMinHeapSizeK

func NewMinHeapSizeK(k int) IMinHeapSizeK

type IntHeap

type IntHeap []int

func (IntHeap) Len

func (h IntHeap) Len() int

func (IntHeap) Less

func (h IntHeap) Less(i, j int) bool

func (*IntHeap) Pop

func (h *IntHeap) Pop() interface{}

func (*IntHeap) Push

func (h *IntHeap) Push(x interface{})

func (IntHeap) Swap

func (h IntHeap) Swap(i, j int)

type Item

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

An Item is something we manage in a priority queue.

type MinHeapSizeK

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

func (*MinHeapSizeK) GetSize

func (m *MinHeapSizeK) GetSize() int

func (*MinHeapSizeK) GetSmallestElement

func (m *MinHeapSizeK) GetSmallestElement() int

func (*MinHeapSizeK) Insert

func (m *MinHeapSizeK) Insert(n int)

type PriorityQueue

type PriorityQueue []*Item

A PriorityQueue implements heap.Interface and holds Items.

func (PriorityQueue) Len

func (pq PriorityQueue) Len() int

func (PriorityQueue) Less

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

func (*PriorityQueue) Pop

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

func (*PriorityQueue) Push

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

func (PriorityQueue) Swap

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

Jump to

Keyboard shortcuts

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