container

package
v1.0.0-beta.13 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmpty = errors.New("queue is empty")

ErrEmpty is returned for queues with no items.

Functions

This section is empty.

Types

type HashSet

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

func NewHashSet

func NewHashSet(s ...string) HashSet

func (*HashSet) Contains

func (set *HashSet) Contains(s string) bool

func (*HashSet) Insert

func (set *HashSet) Insert(s ...string)

func (*HashSet) Length

func (set *HashSet) Length() int

func (*HashSet) ToList

func (set *HashSet) ToList() []string

type PriorityQueue

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

func NewPriorityQueue

func NewPriorityQueue[T any](comp func(this, that *T) bool) *PriorityQueue[T]

NewPriorityQueue initializes internal data structure and returns new PriorityQueue accepting a comparator function comp function decides ordering in queue, Sort `this` before `that` if True.

func (*PriorityQueue[T]) Len

func (pq *PriorityQueue[T]) Len() int

Len returns items in queue.

func (*PriorityQueue[T]) Pop

func (pq *PriorityQueue[T]) Pop() (*T, error)

Pop pops the highest priority item from queue The complexity is O(log n) where n = h.Len().

func (*PriorityQueue[T]) Push

func (pq *PriorityQueue[T]) Push(x *T)

Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Len().

Jump to

Keyboard shortcuts

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