Documentation
¶
Index ¶
- func Help1() int
- func ReadFile() [][]string
- type HeapKind
- type Item
- type PriorityQueue
- func (pq *PriorityQueue[T, V]) Get() *Item[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]) 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)
- func (pq *PriorityQueue[T, V]) Update(value T, priority V)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Item ¶
type Item[T comparable, V int64 | float64] struct { // The value associated with the item Value T // The priority of the item Priority V // contains filtered or unexported fields }
Item represents an item from the priority queue.
type PriorityQueue ¶
type PriorityQueue[T comparable, V int64 | float64] struct { sync.Mutex // contains filtered or unexported fields }
PriorityQueue is a priority queue implementation based container/heap
func New ¶
func New[T comparable, V int64 | float64](kind HeapKind) *PriorityQueue[T, V]
New creates a new priority queue, containing items of type T with priority V.
func (*PriorityQueue[T, V]) Get ¶
func (pq *PriorityQueue[T, V]) Get() *Item[T, V]
Get returns the next item from the priority queue
func (*PriorityQueue[T, V]) IsEmpty ¶
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 ¶
func (pq *PriorityQueue[T, V]) Less(i, j int) bool
Less implements sort.Interface
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 ¶
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 ¶
func (pq *PriorityQueue[T, V]) Swap(i, j int)
Swap implements sort.Interface
func (*PriorityQueue[T, V]) Update ¶
func (pq *PriorityQueue[T, V]) Update(value T, priority V)
Update updates the priority associated with the given value
Click to show internal directories.
Click to hide internal directories.