blob: 40a4f60e6e55cf0762f1eb8894dcf2baf5132d8a (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
package scalax.collection.generic
/** This class represents collections that can be augmented using a += operator.
*
* @autor Martin Odersky
* @owner Martin Odersky
* @version 2.8
*/
trait Addable[+C <: Addable[C, A], A] {
protected def thisCC: C
/** Adds a single element to this collection and returns
* either the collection itself (if it is mutable), or a new collection
* with the added element.
*
* @param elem the element to add.
*/
def +(elem: A): C
/** Adds two or more elements to this collection and returns
* either the collection itself (if it is mutable), or a new collection
* with the added elements.
*
* @param elem1 the first element to add.
* @param elem2 the second element to add.
* @param elems the remaining elements to add.
*/
def +(elem1: A, elem2: A, elems: A*): C =
thisCC + elem1 + elem2 ++ elems.asInstanceOf[Iterable[A]] // !@!
/** Adds a number of elements provided by an iterable object
* via its <code>elements</code> method and returns
* either the collection itself (if it is mutable), or a new collection
* with the added elements.
*
* @param iter the iterable object.
*/
def ++(iter: Iterable[A]): C = (thisCC /: iter) (_ + _)
/** Adds a number of elements provided by an iterator
* via its <code>elements</code> method and returns
* either the collection itself (if it is mutable), or a new collection
* with the added elements.
*
* @param iter the iterator
*/
def ++(iter: Iterator[A]): C = (thisCC /: iter) (_ + _)
}
|