Skip to content

Commit

Permalink
apply idea suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
email2liyang committed Jan 9, 2019
1 parent 62328ba commit 23bceca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scala/src/main/scala/ch29_heap_solutions/FileMerger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ object FileMerger {
val output = File.createTempFile("merged-file", ".txt")
val writer = new BufferedWriter(new FileWriter(output))
//init small top heap
val priorityQueue = new mutable.PriorityQueue[Tuple2[Char, Source]]()(Ordering.by((_: (Char, Source))._1).reverse)
val priorityQueue = new mutable.PriorityQueue[(Char, Source)]()(Ordering.by((_: (Char, Source))._1).reverse)
val sources = smallFiles.toArray.map(smallFile => Source.fromFile(smallFile))
//init fill the priority queue from each file
sources.foreach(source => priorityQueue.enqueue(Tuple2(source.next(), source)))
Expand Down

0 comments on commit 23bceca

Please sign in to comment.