diff options
author | aleksandar <aleksandar@lampmac14.epfl.ch> | 2012-01-12 15:28:25 +0100 |
---|---|---|
committer | aleksandar <aleksandar@lampmac14.epfl.ch> | 2012-01-12 15:30:42 +0100 |
commit | 51ddeb372b3f0b22041d9a51f3faee17acd7b749 (patch) | |
tree | 5f1156ed34f7cc429189e18cc88782f13a3bfc86 /src/library/scala/collection/mutable/SortedSet.scala | |
parent | 178d49df450904330c06cfea9955f120ba04d34c (diff) | |
download | scala-51ddeb372b3f0b22041d9a51f3faee17acd7b749.tar.gz scala-51ddeb372b3f0b22041d9a51f3faee17acd7b749.tar.bz2 scala-51ddeb372b3f0b22041d9a51f3faee17acd7b749.zip |
Add mutable tree sets to the standard library.
This implementation is based on AVL trees.
The current implementation is contributed by Lucien Pereira.
Fixes #4147.
Diffstat (limited to 'src/library/scala/collection/mutable/SortedSet.scala')
-rw-r--r-- | src/library/scala/collection/mutable/SortedSet.scala | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/library/scala/collection/mutable/SortedSet.scala b/src/library/scala/collection/mutable/SortedSet.scala new file mode 100644 index 0000000000..d87fc0b4a2 --- /dev/null +++ b/src/library/scala/collection/mutable/SortedSet.scala @@ -0,0 +1,49 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package mutable + +import generic._ + +/** + * Base trait for mutable sorted set. + * + * @define Coll mutable.SortedSet + * @define coll mutable sorted set + * + * @author Lucien Pereira + * + */ +trait SortedSet[A] extends collection.SortedSet[A] with collection.SortedSetLike[A,SortedSet[A]] + with mutable.Set[A] with mutable.SetLike[A, SortedSet[A]] { + + /** Needs to be overridden in subclasses. */ + override def empty: SortedSet[A] = SortedSet.empty[A] + +} + +/** + * A template for mutable sorted set companion objects. + * + * @define Coll mutable.SortedSet + * @define coll mutable sorted set + * @define factoryInfo + * This object provides a set of operations needed to create sorted sets of type mutable.SortedSet. + * @define sortedSetCanBuildFromInfo + * Standard `CanBuildFrom` instance for sorted sets. + * + * @author Lucien Pereira + * + */ +object SortedSet extends MutableSortedSetFactory[SortedSet] { + implicit def canBuildFrom[A](implicit ord: Ordering[A]): CanBuildFrom[Coll, A, SortedSet[A]] = new SortedSetCanBuildFrom[A] + + def empty[A](implicit ord: Ordering[A]): SortedSet[A] = TreeSet.empty[A] + +} |