Skip to content
Snippets Groups Projects
Commit 22b85bef authored by Manos Koukoutos's avatar Manos Koukoutos
Browse files

GrowableIterable did not actually sort the buffer

parent 15a2c731
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ package leon.utils ...@@ -5,7 +5,7 @@ package leon.utils
import scala.collection.mutable.ArrayBuffer import scala.collection.mutable.ArrayBuffer
class GrowableIterable[T](init: Seq[T], growth: Iterator[T], canGrow: () => Boolean) extends Iterable[T] { class GrowableIterable[T](init: Seq[T], growth: Iterator[T], canGrow: () => Boolean) extends Iterable[T] {
private val buffer = new ArrayBuffer[T]() ++ init private var buffer = new ArrayBuffer[T]() ++ init
private val cachingIterator = new Iterator[T] { private val cachingIterator = new Iterator[T] {
def hasNext = canGrow() && growth.hasNext def hasNext = canGrow() && growth.hasNext
...@@ -27,6 +27,6 @@ class GrowableIterable[T](init: Seq[T], growth: Iterator[T], canGrow: () => Bool ...@@ -27,6 +27,6 @@ class GrowableIterable[T](init: Seq[T], growth: Iterator[T], canGrow: () => Bool
} }
def sortBufferBy[B](f: T => B)(implicit ord: math.Ordering[B]) = { def sortBufferBy[B](f: T => B)(implicit ord: math.Ordering[B]) = {
buffer.sortBy(f) buffer = buffer.sortBy(f)
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment