heap

package
v0.3.0-devel Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

heap.Interface implementation inspired by https://github.com/kubernetes/kubernetes/blob/master/pkg/scheduler/internal/heap/heap.go

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
}

Heap is a producer/consumer queue that implements a heap data structure. It can be used to implement priority queues and similar data structures.

func New

func New(keyFn keyFunc, lessFn lessFunc) Heap

New returns a Heap which can be used to queue up items to process.

func (*Heap) Delete

func (h *Heap) Delete(key string)

Delete removes an item.

func (*Heap) Get

func (h *Heap) Get(obj interface{}) (item interface{})

Get returns the requested item, exists, error.

func (*Heap) GetByKey

func (h *Heap) GetByKey(key string) interface{}

GetByKey returns the requested item, or sets exists=false.

func (*Heap) Len

func (h *Heap) Len() int

Len returns the number of items in the heap.

func (*Heap) List

func (h *Heap) List() []interface{}

List returns a list of all the items.

func (*Heap) Pop

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

Pop returns the head of the heap and removes it.

func (*Heap) PushIfNotPresent

func (h *Heap) PushIfNotPresent(obj interface{}) (added bool)

PushIfNotPresent inserts an item to the queue. If an item with the key is present in the map, no changes is made to the item.

func (*Heap) PushOrUpdate

func (h *Heap) PushOrUpdate(obj interface{})

PushOrUpdate inserts an item to the queue. The item will be updated if it already exists.

Jump to

Keyboard shortcuts

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