From c1f07338ed21e551446a5c98d262d738a9b7b0ce Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 20 May 2008 13:29:39 +0000 Subject: int -> Int, etc.. --- test/files/pos/tcpoly_seq_typealias.scala | 54 +++++++++++++++---------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'test/files/pos/tcpoly_seq_typealias.scala') diff --git a/test/files/pos/tcpoly_seq_typealias.scala b/test/files/pos/tcpoly_seq_typealias.scala index 0498c3b2f6..7a9312a60a 100644 --- a/test/files/pos/tcpoly_seq_typealias.scala +++ b/test/files/pos/tcpoly_seq_typealias.scala @@ -1,4 +1,4 @@ -package examples.tcpoly.collection; +package examples.tcpoly.collection trait HOSeq { // an internal interface that encapsulates the accumulation of elements (of type elT) to produce @@ -56,13 +56,13 @@ trait HOSeq { final class ListBuffer[A] { private var start: List[A] = Nil private var last: ::[A] = _ - private var exported: boolean = false + private var exported: Boolean = false /** Appends a single element to this buffer. * * @param x the element to append. */ - def += (x: A): unit = { + def += (x: A) { if (exported) copy if (start.isEmpty) { last = new HOSeq.this.:: (x, Nil) @@ -83,13 +83,13 @@ trait HOSeq { /** Clears the buffer contents. */ - def clear: unit = { + def clear { start = Nil exported = false } /** Copy contents of this buffer */ - private def copy = { + private def copy { var cursor = start val limit = last.tail clear @@ -101,36 +101,36 @@ trait HOSeq { } implicit def listAccumulator[elT]: Accumulator[List, elT] = new Accumulator[List, elT] { - private[this] val buff = new ListBuffer[elT] - def += (el: elT): Unit = buff += el - def result: List[elT] = buff.toList + private[this] val buff = new ListBuffer[elT] + def += (el: elT): Unit = buff += el + def result: List[elT] = buff.toList } trait List[+t] extends Iterable[t] { - type m[+x] = List[x] - - def head: t - def tail: List[t] - def isEmpty: Boolean - def elements: Iterator[t] = new Iterator[t] { - var these = List.this - def hasNext: Boolean = !these.isEmpty - def next: t = - if (!hasNext) - throw new NoSuchElementException("next on empty Iterator") - else { - val result = these.head; these = these.tail; result - } - } - // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t - def accumulator[t]: Accumulator[List, t] = listAccumulator[t] + type m[+x] = List[x] + + def head: t + def tail: List[t] + def isEmpty: Boolean + def elements: Iterator[t] = new Iterator[t] { + var these = List.this + def hasNext: Boolean = !these.isEmpty + def next: t = + if (!hasNext) + throw new NoSuchElementException("next on empty Iterator") + else { + val result = these.head; these = these.tail; result + } + } + // construct an empty accumulator that will produce the same structure as this iterable, with elements of type t + def accumulator[t]: Accumulator[List, t] = listAccumulator[t] } // TODO: the var tl approach does not seem to work because subtyping isn't fully working yet final case class ::[+b](hd: b, private val tl: List[b]) extends List[b] { def head = hd def tail = if(tl==null) this else tl // hack - override def isEmpty: boolean = false + override def isEmpty: Boolean = false } case object Nil extends List[Nothing] { @@ -140,4 +140,4 @@ trait HOSeq { def tail: List[Nothing] = throw new NoSuchElementException("tail of empty list") } -} \ No newline at end of file +} -- cgit v1.2.3