Documentation ¶
Index ¶
- type Item
- type PriorityQueue
- func (pq *PriorityQueue[T, V]) Get() (T, V)
- func (pq *PriorityQueue[T, V]) IsEmpty() bool
- func (pq *PriorityQueue[T, V]) Len() int
- func (pq *PriorityQueue[T, V]) Less(i, j int) bool
- func (pq *PriorityQueue[T, V]) Peek() (T, V)
- func (pq *PriorityQueue[T, V]) Pop() any
- func (pq *PriorityQueue[T, V]) Push(x any)
- func (pq *PriorityQueue[T, V]) Put(value T, priority V)
- func (pq *PriorityQueue[T, V]) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Item ¶
type Item[T any, V cmp.Ordered] struct { // The value associated with the item Value T // The priority of the item Priority V }
Item represents an item from the priority queue.
type PriorityQueue ¶
type PriorityQueue[T any, V cmp.Ordered] struct { sync.Mutex // contains filtered or unexported fields }
PriorityQueue is a priority queue implementation based container/heap.
func New ¶
func New[T any, V cmp.Ordered]() *PriorityQueue[T, V]
New creates a new priority queue, containing items of type T with priority V.
func (*PriorityQueue[T, V]) Get ¶ added in v2.11.0
func (pq *PriorityQueue[T, V]) Get() (T, V)
Get returns the next item from the priority queue
func (*PriorityQueue[T, V]) IsEmpty ¶ added in v2.11.0
func (pq *PriorityQueue[T, V]) IsEmpty() bool
IsEmpty returns a boolean indicating whether the priority queue is empty or not.
func (*PriorityQueue[T, V]) Len ¶
func (pq *PriorityQueue[T, V]) Len() int
Len implements sort.Interface.
func (*PriorityQueue[T, V]) Less ¶ added in v2.11.0
func (pq *PriorityQueue[T, V]) Less(i, j int) bool
Less implements sort.Interface.
func (*PriorityQueue[T, V]) Peek ¶ added in v2.11.0
func (pq *PriorityQueue[T, V]) Peek() (T, V)
Peek returns the next time from the priority queue without dequeing it.
func (*PriorityQueue[T, V]) Pop ¶
func (pq *PriorityQueue[T, V]) Pop() any
Pop implements heap.Interface.
func (*PriorityQueue[T, V]) Push ¶
func (pq *PriorityQueue[T, V]) Push(x any)
Push implements heap.Interface.
func (*PriorityQueue[T, V]) Put ¶ added in v2.11.0
func (pq *PriorityQueue[T, V]) Put(value T, priority V)
Put adds a value with the given priority to the priority queue.
func (*PriorityQueue[T, V]) Swap ¶ added in v2.11.0
func (pq *PriorityQueue[T, V]) Swap(i, j int)
Swap implements sort.Interface.
Click to show internal directories.
Click to hide internal directories.