61 lines
1021 B
Go
61 lines
1021 B
Go
package pqueue
|
|
|
|
import (
|
|
"474420502.top/eson/structure/compare"
|
|
)
|
|
|
|
type PriorityQueue struct {
|
|
queue *vbTree
|
|
head *tNode
|
|
}
|
|
|
|
func (pq *PriorityQueue) Iterator() *Iterator {
|
|
return nil
|
|
}
|
|
|
|
func New(Compare compare.Compare) *PriorityQueue {
|
|
return &PriorityQueue{queue: newVBT(Compare)}
|
|
}
|
|
|
|
func (pq *PriorityQueue) Size() int {
|
|
return pq.queue.Size()
|
|
}
|
|
|
|
func (pq *PriorityQueue) Push(value interface{}) {
|
|
n := pq.queue.Put(value)
|
|
if pq.head == nil {
|
|
pq.head = n
|
|
return
|
|
}
|
|
if pq.queue.Compare(n, pq.head) == 1 {
|
|
pq.head = n
|
|
}
|
|
}
|
|
|
|
func (pq *PriorityQueue) Top() (result interface{}, ok bool) {
|
|
if pq.head != nil {
|
|
return pq.head.value, true
|
|
}
|
|
return nil, false
|
|
}
|
|
|
|
func (pq *PriorityQueue) Pop() (result interface{}, ok bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (pq *PriorityQueue) Get(idx int) (interface{}, bool) {
|
|
return nil, false
|
|
}
|
|
|
|
func (pq *PriorityQueue) RemoveWithIndex(idx int) {
|
|
|
|
}
|
|
|
|
func (pq *PriorityQueue) Remove(key interface{}) {
|
|
|
|
}
|
|
|
|
func (pq *PriorityQueue) Values() []interface{} {
|
|
return nil
|
|
}
|