|
@@ -3,10 +3,10 @@ package main
|
3
|
3
|
// Invariant: both children are bigger
|
4
|
4
|
|
5
|
5
|
type prioq struct {
|
6
|
|
- bintree []Car
|
|
6
|
+ bintree []*Car
|
7
|
7
|
}
|
8
|
8
|
|
9
|
|
-func (pq *prioq) Add(car Car) {
|
|
9
|
+func (pq *prioq) Add(car *Car) {
|
10
|
10
|
pq.bintree = append(pq.bintree, car)
|
11
|
11
|
|
12
|
12
|
// Rebalance tree to respect invariant
|
|
@@ -19,7 +19,7 @@ func (pq *prioq) Add(car Car) {
|
19
|
19
|
}
|
20
|
20
|
}
|
21
|
21
|
|
22
|
|
-func (pq *prioq) pop() Car {
|
|
22
|
+func (pq *prioq) pop() *Car {
|
23
|
23
|
if len(pq.bintree) == 0 {
|
24
|
24
|
panic("Trying to remove from empty queue")
|
25
|
25
|
}
|