summaryrefslogtreecommitdiff
path: root/src/library/scalax/collection/generic/EmptyIterableFactory.scala
blob: 7f110d13d2be52208cb7b997199e682da121c52b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package scalax.collection.generic

import annotation.unchecked.uncheckedVariance

trait EmptyIterableFactory[CC[+A] <: Iterable[A] with IterableTemplate[CC, A @uncheckedVariance]] extends IterableFactory[CC] {

  /** The empty collection of type CC */
  val empty: CC[Nothing]

  /** An override of newBuilder, to work off the empty object */
  override protected def newBuilder[A]: Builder[CC, A] =
    empty.newBuilder[A]

  /** Create CC collection of specified elements */
  override def apply[A](args: A*): CC[A] =
    empty ++ args.asInstanceOf[Iterable[A]]
}