diff options
Diffstat (limited to 'src/library/scalax/collection/generic/EmptyIterableFactory.scala')
-rwxr-xr-x | src/library/scalax/collection/generic/EmptyIterableFactory.scala | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/library/scalax/collection/generic/EmptyIterableFactory.scala b/src/library/scalax/collection/generic/EmptyIterableFactory.scala new file mode 100755 index 0000000000..7f110d13d2 --- /dev/null +++ b/src/library/scalax/collection/generic/EmptyIterableFactory.scala @@ -0,0 +1,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]] +} |