Exemplo n.º 1
0
 def pop(self):
     if len(self.heap) == 0:
         raise HeapError("Popping off an empty hipster")
     return self.heap.pop()
Exemplo n.º 2
0
 def peek(self):
     if len(self.heap) == 0:
         raise HeapError("Peeking into an empty heap")
     with self.read_lock:
         return heapq.nsmallest(1, self.heap)[0]
Exemplo n.º 3
0
 def peek(self):
     if len(self.heap) == 0:
         raise HeapError("Peeking into an empty hipster")
     return heapq.nlargest(1, self.heap)[0]
Exemplo n.º 4
0
 def pop(self):
     if len(self.heap) == 0:
         raise HeapError("Popping off an empty heap")
     with self.write_lock:
         return heapq.heappop(self.heap)