Scala heap implementation