def test_push(self): queue = Queue() to_push = [33, 0.0, "thirty three"] for item in to_push: queue.push(item) self.assertEqual(len(queue), len(to_push)) self.assertEqual(queue.peek(), to_push[0])
class PriorityQueueElement: def __init__(self, key, value): self.key = key self.values = Queue() self.values.push(value) def pop(self): return self.values.pop() def peek(self): return self.values.peek() def __len__(self): return len(self.values) def __eq__(self, other): if hasattr(other, "key"): return self.key == other.key else: return self.key == other def __lt__(self, other): if hasattr(other, "key"): return self.key < other.key else: return self.key < other