binaryheap

package
v0.0.0-...-118d4d9 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2016 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

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

func NewWith

func NewWith(comparator utils.Comparator) *Heap

Instantiates a new empty heap tree with the custom comparator.

func NewWithIntComparator

func NewWithIntComparator() *Heap

Instantiates a new empty heap with the IntComparator, i.e. elements are of type int.

func NewWithStringComparator

func NewWithStringComparator() *Heap

Instantiates a new empty heap with the StringComparator, i.e. elements are of type string.

func (*Heap) Clear

func (heap *Heap) Clear()

Removes all elements from the heap.

func (*Heap) Empty

func (heap *Heap) Empty() bool

Returns true if heap does not contain any elements.

func (*Heap) Peek

func (heap *Heap) Peek() (value interface{}, ok bool)

Returns top element on the heap without removing it, or nil if heap is empty. Second return parameter is true, unless the heap was empty and there was nothing to peek.

func (*Heap) Pop

func (heap *Heap) Pop() (value interface{}, ok bool)

Pops (removes) top element on heap and returns it, or nil if heap is empty. Second return parameter is true, unless the heap was empty and there was nothing to pop.

func (*Heap) Push

func (heap *Heap) Push(value interface{})

Pushes a value onto the heap and bubbles it up accordingly.

func (*Heap) Size

func (heap *Heap) Size() int

Returns number of elements within the heap.

func (*Heap) String

func (heap *Heap) String() string

func (*Heap) Values

func (heap *Heap) Values() []interface{}

Returns all elements in the heap.

Jump to

Keyboard shortcuts

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