浏览代码

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 {