diff options
Diffstat (limited to 'src/library/scala/collection/generic/SortedMapFactory.scala')
-rw-r--r-- | src/library/scala/collection/generic/SortedMapFactory.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/library/scala/collection/generic/SortedMapFactory.scala b/src/library/scala/collection/generic/SortedMapFactory.scala new file mode 100644 index 0000000000..938ce145f9 --- /dev/null +++ b/src/library/scala/collection/generic/SortedMapFactory.scala @@ -0,0 +1,18 @@ +package scala.collection.generic + +/** A template for companion objects of mutable.Map and subclasses thereof. + */ +abstract class SortedMapFactory[CC[A, B] <: SortedMap[A, B] with SortedMapTemplate[A, B, CC[A, B]]] { + + type Coll = CC[_, _] + + def newBuilder[A, B](implicit ord: Ordering[A]): Builder[(A, B), CC[A, B]] + + def empty[A, B](implicit ord: Ordering[A]): CC[A, B] + + def apply[A, B](elems: (A, B)*)(implicit ord: Ordering[A]): CC[A, B] = (newBuilder[A, B](ord) ++= elems).result + + class SortedMapBuilderFactory[A, B](implicit ord: Ordering[A]) extends BuilderFactory[(A, B), CC[A, B], Coll] { + def apply(from: Coll) = newBuilder[A, B](ord) + } +} |