heap

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapValues

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

Types

type Map

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

func NewMap

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

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

func (*Map[K, V]) Fix

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

func (*Map[K, V]) Get

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

func (*Map[K, V]) Len

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

func (*Map[K, V]) Peek

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

func (*Map[K, V]) Pop

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

func (*Map[K, V]) Push

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

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

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

func NewSet

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

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

func (Set[T]) Fix

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

func (Set[T]) Len

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

func (Set[T]) Peek

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

func (Set[T]) Pop

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

func (Set[T]) Push

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

Push returns if the entry was added

func (Set[T]) Remove

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