Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Queue ¶
type Queue[T comparable] struct { // contains filtered or unexported fields }
Queue represents a priority queue data structure. Elements are ordered according to their natural ordering (for Ordered types) or a custom comparator provided during initialization.
func New ¶
New creates a new priority queue with the given Ordered type. The queue orders elements according to their natural ordering (ascending).
func NewWith ¶
func NewWith[T comparable](comparator utils.Comparator[T]) *Queue[T]
NewWith creates a new priority queue with the given comparator. The queue orders elements according to the comparator provided.
func (*Queue[T]) Dequeue ¶
Dequeue removes and returns the element with the highest priority (minimum value). Returns ok=false if the queue is empty.
func (*Queue[T]) Enqueue ¶
func (queue *Queue[T]) Enqueue(value T)
Enqueue adds an element to the priority queue.
Click to show internal directories.
Click to hide internal directories.