qiao / heap.js

A binary heap implementation in CoffeeScript/JavaScript.
MIT License
125 stars 27 forks source link

unpredictable mutation of list in heap.nsmallest(list,count) #18

Closed daywiss closed 1 year ago

daywiss commented 9 years ago

when count is small, the original array is not modified. when count is large the original array is reduced by count elements. the array should either be mutated or not, regardless of count imo.

list.length == 100
heap.nsmallest(list,1)  //list not modified at all list.length == 100
heap.nsmallest(list,11) //list modified, list.length == 89
ccarlile commented 8 years ago

Am getting this behavior with array size 5 and any count.