summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/TraversableOnce.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/collection/TraversableOnce.scala')
-rw-r--r--src/library/scala/collection/TraversableOnce.scala16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index de3b4770f3..a062d5710d 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -81,6 +81,22 @@ trait TraversableOnce[+A] {
*/
def toStream: Stream[A]
+ // Note: We could redefine this in TraversableLike to always return `repr`
+ // of type `Repr`, only if `Repr` had type bounds, which it doesn't, because
+ // not all `Repr` are a subtype `TraversableOnce[A]`.
+ // The alternative is redefining it for maps, sets and seqs. For concrete implementations
+ // we don't have to do this anyway, since they are leaves in the inheritance hierarchy.
+ /** A version of this collection with all
+ * of the operations implemented sequentially (i.e. in a single-threaded manner).
+ *
+ * This method returns a reference to this collection. In parallel collections,
+ * it is redefined to return a sequential implementation of this collection. In
+ * both cases, it has O(1) complexity.
+ *
+ * @return a sequential view of the collection.
+ */
+ def seq: TraversableOnce[A] = this
+
/** Presently these are abstract because the Traversable versions use
* breakable/break, and I wasn't sure enough of how that's supposed to
* function to consolidate them with the Iterator versions.