Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comparator ¶
Comparator is a function that returns a value indicating whether the first argument is less than, greater than, or equal to the second argument. If the returned value is less than zero, the first argument is less than the second If the returned value is greater than zero, the first argument is greater than the second If the returned value is zero, the first argument is equal to the second
type PriorityQueue ¶
type PriorityQueue[E any] struct { // contains filtered or unexported fields }
PriorityQueue is an ordered collection of elements. Elements can be pushed and popped from a PriorityQueue; when popping, elements come out in an order determined by the provided comparator. Elements that compare as "less" than others come out first
func MakePriorityQueue ¶
func MakePriorityQueue[E any](c Comparator[E], initialElements ...E) *PriorityQueue[E]
func (PriorityQueue[E]) Len ¶
func (pq PriorityQueue[E]) Len() int
func (*PriorityQueue[E]) Pop ¶
func (pq *PriorityQueue[E]) Pop() E
func (*PriorityQueue[E]) Push ¶
func (pq *PriorityQueue[E]) Push(e E)
type Set ¶
type Set[E comparable] struct { // contains filtered or unexported fields }
Set represents a unique set of elements. It has constant-time insert and contains operations
func MakeSet ¶
func MakeSet[E comparable](initialElements ...E) *Set[E]
MakeSet returns a Set containing the given initial elements
func (*Set[E]) Insert ¶
Insert inserts the given element into the set. It returns true if the element was not previously in the set, false otherwise