blob: 2c80916d50d7e4c93fe02835b7547e47c14cea7b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
package scalax.collection
trait Builder[+CC[B], A] extends generic.mutable.Growable[A] {
def +=(x: A)
def elements: Iterator[A]
def result: CC[A]
override def ++=(xs: Iterator[A]) { for (x <- xs) this += x }
override def ++=(xs: Iterable[A]) { for (x <- xs) this += x }
def mapResult[DD[B]](f: CC[A] => DD[A]) =
new Builder[DD, A] with Proxy {
val self = Builder.this
def +=(x: A) = self += x
def elements: Iterator[A] = self.elements
def clear() = self.clear()
override def ++=(xs: Iterator[A]) = self ++= xs
override def ++=(xs: collection.Iterable[A]) = self ++= xs
def result: DD[A] = f(Builder.this.result)
}
}
|