summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/generic/Growable.scala
blob: 7950dee9de9dbb4acecc6d2510150f074f071de5 (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
65
66
67
/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003-2010, LAMP/EPFL             **
**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$

package scala.collection
package generic

/** This trait forms part of collections that can be augmented
 *  using a `+=` operator and that can be cleared of all elements using
 *  a `clear` method.
 *
 *  @author   Martin Odersky
 *  @owner   Martin Odersky
 *  @version 2.8
 *  @since   2.8
 *  @define coll growable collection
 *  @define Coll Growable
 *  @define add  add
 *  @define Add  add
 */
trait Growable[-A] {

  /** ${Add}s a single element to this $coll.
   *
   *  @param elem  the element to $add.
   *  @return the $coll itself
   */
  def +=(elem: A): this.type

  /** ${Add}s two or more elements to this $coll.
   *
   *  @param elem1 the first element to $add.
   *  @param elem2 the second element to $add.
   *  @param elems the remaining elements to $add.
   *  @return the $coll itself
   */
  def +=(elem1: A, elem2: A, elems: A*): this.type = this += elem1 += elem2 ++= elems

  /** ${Add}s all elements produced by an iterator to this $coll.
   *
   *  @param iter  the iterator producing the elements to $add.
   *  @return  the $coll itself.
   */
  def ++=(iter: Iterator[A]): this.type = { iter foreach += ; this }

  /** ${Add}s all elements contained in a traversable collection to this $coll.
   *
   *  @param elems  the collection containing the elements to $add.
   *  @return  the $coll itself.
   */
  def ++=(elems: Traversable[A]): this.type = { elems foreach +=; this }

  /** Clears the $coll's contents. After this operation, the
   *  $coll is empty.
   */
  def clear()
}