Iterator invalidation handling

The #each method now check if the priority queue changed during the
iteration. If so it raises an exception.