On 3/1/07, Adam Olsen
On 3/1/07, Jason Orendorff
wrote:
class priorityqueue: Should inherit from object if this is going into 2.x.
def __init__(self, elements=(), *, cmp=None, key=None, reversed=False) def add(self, element) def pop(self) --> remove and return the min element def __iter__(self) --> (while self: yield self.pop())
__iter__ shouldn't modify the container.
generators do not need to be reiterable. lists are reiterable, but I wouldn't expect a socket (treated as a file) to be. For a queue that is already sorted, the natural use case is to take the task and do it, explicitly adding it back to the end if need be. I would expect an operation that *didn't* remove things from the queue to have view in the name somewhere. -jJ