heap

package
v0.0.0-...-39cf1df Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2015 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Element

type Element struct {
	// The key stored the heap node key.
	Key int
	// The value stored with this element.
	Value interface{}
}

Element is an element of a Minheap.

type Minheap

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

Minheap is priority queue(min heap) struct.

func NewMinheap

func NewMinheap(max int) *Minheap

NewMinheap new a Minheap struct with specified size.

func (*Minheap) Add

func (h *Minheap) Add(e *Element)

Add add a element to minheap.

func (*Minheap) Max

func (h *Minheap) Max() int

Max get minheap max size

func (*Minheap) Min

func (h *Minheap) Min() *Element

Min get the top of Minheap.

func (*Minheap) Poll

func (h *Minheap) Poll() *Element

Poll remove top element in minheap.

func (*Minheap) Size

func (h *Minheap) Size() int

Size get minheap current size

Jump to

Keyboard shortcuts

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