123
This commit is contained in:
parent
8c05215122
commit
26ba5a9e0a
|
@ -20,9 +20,11 @@ type PriorityQueue struct {
|
|||
func (pq *PriorityQueue) String() string {
|
||||
|
||||
content := ""
|
||||
|
||||
iter := pq.avl.Iterator()
|
||||
iter.End()
|
||||
|
||||
for !iter.Last() {
|
||||
iter.Next()
|
||||
}
|
||||
|
||||
for iter.Prev() {
|
||||
pl := iter.Value().(*PriorityList)
|
||||
|
@ -79,9 +81,8 @@ func (pq *PriorityQueue) Push(value interface{}) {
|
|||
pq.avl.Put(plsp.head.value, plsp)
|
||||
log.Println("list:", pl.head.value, pl.String())
|
||||
log.Println("list:", plsp.head.value, plsp.String())
|
||||
log.Println("values:", pq.avl.Values())
|
||||
log.Println("pq:", pq.avl.Values())
|
||||
log.Println("pq:", pq.String(), "\n----------")
|
||||
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -99,7 +99,8 @@ func TestAvl(t *testing.T) {
|
|||
}
|
||||
|
||||
iter := avl.Iterator()
|
||||
iter.Next()
|
||||
iter.End()
|
||||
iter.Prev()
|
||||
t.Error(avl.Values(), iter.Value())
|
||||
|
||||
f, ok := avl.Floor(10)
|
||||
|
@ -111,6 +112,18 @@ func TestAvl(t *testing.T) {
|
|||
if ok {
|
||||
t.Error("Ceiling", f)
|
||||
}
|
||||
|
||||
for _, v := range []int{9, 2, 3, 45, 51, 16, 18, 11} {
|
||||
avl.Put(v, v)
|
||||
}
|
||||
|
||||
iter = avl.Iterator()
|
||||
iter.End()
|
||||
|
||||
for iter.Prev() {
|
||||
t.Error(iter.Value())
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestHeap(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user