summaryrefslogtreecommitdiff
path: root/test/files/pos/tcpoly_seq.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2008-05-20 13:29:39 +0000
committermichelou <michelou@epfl.ch>2008-05-20 13:29:39 +0000
commitc1f07338ed21e551446a5c98d262d738a9b7b0ce (patch)
tree8143f69f0b97ff8bb02600991476b104afa652dc /test/files/pos/tcpoly_seq.scala
parent7d71e4cf09074f3d1cf7539d28bba64a976524d6 (diff)
downloadscala-c1f07338ed21e551446a5c98d262d738a9b7b0ce.tar.gz
scala-c1f07338ed21e551446a5c98d262d738a9b7b0ce.tar.bz2
scala-c1f07338ed21e551446a5c98d262d738a9b7b0ce.zip
int -> Int, etc..
Diffstat (limited to 'test/files/pos/tcpoly_seq.scala')
-rw-r--r--test/files/pos/tcpoly_seq.scala48
1 files changed, 24 insertions, 24 deletions
diff --git a/test/files/pos/tcpoly_seq.scala b/test/files/pos/tcpoly_seq.scala
index 85563488fd..e05a2322e4 100644
--- a/test/files/pos/tcpoly_seq.scala
+++ b/test/files/pos/tcpoly_seq.scala
@@ -54,13 +54,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)
@@ -81,13 +81,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
@@ -99,34 +99,34 @@ 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[List, t] {
- 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]
+ 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] {
@@ -172,4 +172,4 @@ trait HOSeq {
// @pre hasNext
// @post hasAdvanced
def advance: Unit
-}*/ \ No newline at end of file
+}*/