Sfoglia il codice sorgente

prioq return nil if empty queue

Gildas Chabot 7 anni fa
parent
commit
3d0fad1bb9
1 ha cambiato i file con 1 aggiunte e 1 eliminazioni
  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 {