Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LessFunction ¶
type LessFunction[T comparable] func(T, T) bool
Generic comparator function that is passed as a parameter when creating a new PQ.
type PQ ¶
type PQ[T comparable] struct { Items []*T // contains filtered or unexported fields }
Internally maintains a slice of pointers to items of type T.
func CreatePQ ¶
func CreatePQ[T comparable](less LessFunction[T]) *PQ[T]
Creates a new instance of a priority queue with the given comparator function.
func (*PQ[T]) Get ¶
func (pq *PQ[T]) Get() T
Removes and returns the top item from the priority queue.
func (*PQ[T]) Peek ¶
func (pq *PQ[T]) Peek() T
Returns the top item from the priority queue without removing it.
Click to show internal directories.
Click to hide internal directories.