heap

package
v0.0.0-...-917641f Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package heap implements a heap value type

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Key1, Key2 int64
	Rank       int
}

Entry is a heap entry

type Heap

type Heap struct {
	Items map[interface{}]Entry
}

Heap implements a heap of keys

func (Heap) Apply

func (h Heap) Apply(ctx changes.Context, c changes.Change) changes.Value

Apply implments Changes.Value

func (Heap) Delete

func (h Heap) Delete(key interface{}) Heap

Delete removes the Entry from the heap

func (Heap) DeleteChange

func (h Heap) DeleteChange(key interface{}) changes.Change

DeleteChange returns the change to apply for deleting an item from the heap

func (Heap) Iterate

func (h Heap) Iterate(fn func(key interface{}, rank int) bool)

Iterate calls the provided function for each Entry in the heap in descending order of Rank value.

func (Heap) Update

func (h Heap) Update(key interface{}, rank int) Heap

Update inserts a new Entry wite provided Rank or updates the Rank for an existng Entry

func (Heap) UpdateChange

func (h Heap) UpdateChange(key interface{}, rank int) changes.Change

UpdateChange returns the change to apply for either inserting an item into the heap or updating its Rank.

Jump to

Keyboard shortcuts

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