ソースを参照

prioq return nil if empty queue

Gildas Chabot 7 年 前
コミット
3d0fad1bb9
共有1 個のファイルを変更した1 個の追加1 個の削除を含む
  1. 1 1
      prioq.go

+ 1 - 1
prioq.go

@@ -21,7 +21,7 @@ func (pq *prioq) Add(car *Car) {
21 21
 
22 22
 func (pq *prioq) Pop() *Car {
23 23
 	if len(pq.bintree) == 0 {
24
-		panic("Trying to remove from empty queue")
24
+		return nil
25 25
 	}
26 26
 
27 27
 	if len(pq.bintree) == 1 {