Skip to content

Instantly share code, notes, and snippets.

@snsdigital
snsdigital / gist:2881881
Created June 6, 2012 13:33 — forked from newportandy/gist:241483
Investigating Recursive vs Iterative performance in Map traversal
NODES = 0..1
LENGTH = 2
INFINITY = 1.0/0
class PriorityQueue < Hash
def pop!
smallest_pair = self.min{ |a,b| a[1] <=> b[1]}
self.delete(smallest_pair[0]) if smallest_pair
smallest_pair
end