   rightChildIdx: (idx) ->
     2 * idx + 1
 
-module.exports = PriorityQueue+module.exports = PriorityQueue


  moveDown: (idx) ->
    store = @_store
    # this subtly relies on x <= undefined being false for all x to
    # do the right thing at leaf nodes
    lci = @leftChildIdx(idx)
    rci = @rightChildIdx(idx)
    if store[rci]? and ! @_comparator(store[lci], store[rci]) #store[lci = @leftChildIdx(idx)] <= store[rci = @rightChildIdx(idx)]
      child    = store[rci]
      childIdx = rci
    else
      child    = store[lci]
      childIdx = lci
    if child? and ! @_comparator(val = store[idx], child) #(val = store[idx]) <= child
      store[idx]      = child
      store[childIdx] = val
      console.dir [idx, val, childIdx, child]


  moveUp: (idx) ->
    store = @_store
    if @_comparator(val = store[idx], store[par = @parentIdx(idx)])
      store[idx] = store[par]
      store[par] = val
      @moveUp(par)
