blob: d80e85c039ee252d16ee593846fda089ec1b5cf9 (
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
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
package scala.collection
package generic
/** This trait represents collection-like objects that can be added to
* using a '+' operator. It defines variants of `+` and `++`
* as convenience methods in terms of single-element addition `+`.
* @tparam A the type of the elements of the $coll
* @tparam Repr the type of the $coll itself
* @author Martin Odersky
* @version 2.8
* @since 2.8
* @define $coll collection
* @define $Coll Addable
*/
@deprecated("Will be removed after scala 2.9")
trait Addable[A, +Repr <: Addable[A, Repr]] { self =>
/** The representation object of type `Repr` which contains the collection's elements
*/
protected def repr: Repr
/** Creates a new $coll with an additional element, unless the element is already present.
* @param elem the element to add
* @return a fresh collection with `elem` added.
*/
def +(elem: A): Repr
/** Creates a new $coll with additional elements.
*
* This method takes two or more elements to be added. Another overloaded
* variant of this method handles the case where a single element is
* added.
* @param elem1 the first element to add.
* @param elem2 the second element to add.
* @param elems the remaining elements to add.
* @return a new $coll with the given elements added.
*/
def + (elem1: A, elem2: A, elems: A*): Repr =
this + elem1 + elem2 ++ elems
/** Creates a new $coll by adding all elements contained in another collection to this $coll.
*
* @param elems the collection containing the added elements.
* @return a new $coll with the given elements added.
*/
def ++ (xs: TraversableOnce[A]): Repr = (repr /: xs) (_ + _)
}
|