rubyworks / pqueue

Priority Queue in pure Ruby
Other
69 stars 7 forks source link

Push aliases #2

Closed ostatnicky closed 9 years ago

ostatnicky commented 10 years ago

I found bug! I think that alias for shift and deq is pop! https://github.com/rubyworks/pqueue/blob/master/lib/pqueue.rb#L109 and https://github.com/rubyworks/pqueue/blob/master/lib/pqueue.rb#L114

For example: http://www.ruby-doc.org/core-2.1.0/Hash.html#method-i-shift

trans commented 9 years ago

Indeed you have! deq most definitely should be an alias of pop. Shift was probably intended to be the same, but looking at it now I think it might make more sense as the opposite, such that it removes the lowest priority item. Is that a good idea? Or is that just antithetical to the whole idea of the priority queue?

trans commented 9 years ago

Well let me know if you think this new definition of shift and the addition of bottom are bad mojo. I can always change them. In the mean time I'll just go with it.