which data structure to use?

Robert Voigtländer r.voigtlaender at gmail.com
Wed Jan 22 04:38:37 EST 2014


> Unlikely. Are you sure that .heap and .lookup contents are still in sync 
> with your modification?
No it's not. Atfer having read about heapq it's clear why.
Thanks for the hint.


> allows you to delete random nodes, but the lowest() method will slow down as 
> it has to iterate over all dict values.

Thanks a lot for the alternative class. I will go with two lists, each using one of the aproaches. In one list I always need to have only hte object with lowest .f.
With the other list I may have to delete random nodes.

So I can make perfect use of both classes.


> One important caveat: both Nodes classes lead to data corruption if you 
> modify a .pos attribute while the node is in a Nodes instance. The same goes 
> for the first implementation and the .f attribute.

That's fine. pos is static and identifies the node.


Thanks again to all who responded. I learned a lot.



More information about the Python-list mailing list