heap

package
v1.11.5 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapValues added in v1.10.14

func MapValues[K comparable, V any](m Map[K, V]) []V

Types

type Map added in v1.10.14

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

func NewMap added in v1.10.14

func NewMap[K comparable, V any](less func(a, b V) bool) Map[K, V]

NewMap returns a heap without duplicates ordered by its values

func (*Map[K, V]) Contains added in v1.10.14

func (m *Map[K, V]) Contains(k K) bool

func (*Map[K, V]) Fix added in v1.10.14

func (m *Map[K, V]) Fix(k K)

func (*Map[K, V]) Get added in v1.10.14

func (m *Map[K, V]) Get(k K) (V, bool)

func (*Map[K, V]) Len added in v1.10.14

func (m *Map[K, V]) Len() int

func (*Map[K, V]) Peek added in v1.10.14

func (m *Map[K, V]) Peek() (K, V, bool)

func (*Map[K, V]) Pop added in v1.10.14

func (m *Map[K, V]) Pop() (K, V, bool)

func (*Map[K, V]) Push added in v1.10.14

func (m *Map[K, V]) Push(k K, v V) (V, bool)

Push returns the evicted previous value if present

func (*Map[K, V]) Remove added in v1.10.14

func (m *Map[K, V]) Remove(k K) (V, bool)

type Queue

type Queue[T any] struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue[T any](less func(a, b T) bool) Queue[T]

NewQueue returns an empty heap. See QueueOf for more.

func QueueOf

func QueueOf[T any](less func(a, b T) bool, entries ...T) Queue[T]

QueueOf returns a heap containing entries ordered by less.

func (*Queue[T]) Fix

func (q *Queue[T]) Fix(i int)

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

func (*Queue[T]) Peek

func (q *Queue[T]) Peek() (T, bool)

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() (T, bool)

func (*Queue[T]) Push

func (q *Queue[T]) Push(t T)

type Set added in v1.10.14

type Set[T comparable] struct {
	// contains filtered or unexported fields
}

func NewSet added in v1.10.14

func NewSet[T comparable](less func(a, b T) bool) Set[T]

NewSet returns a heap without duplicates ordered by its values

func (Set[T]) Contains added in v1.10.14

func (s Set[T]) Contains(t T) bool

func (Set[T]) Fix added in v1.10.14

func (s Set[T]) Fix(t T)

func (Set[T]) Len added in v1.10.14

func (s Set[T]) Len() int

func (Set[T]) Peek added in v1.10.14

func (s Set[T]) Peek() (T, bool)

func (Set[T]) Pop added in v1.10.14

func (s Set[T]) Pop() (T, bool)

func (Set[T]) Push added in v1.10.14

func (s Set[T]) Push(t T) bool

Push returns if the entry was added

func (Set[T]) Remove added in v1.10.14

func (s Set[T]) Remove(t T) bool

Jump to

Keyboard shortcuts

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