diff options
author | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-04-20 09:35:40 +0000 |
---|---|---|
committer | Antonio Cunei <antonio.cunei@epfl.ch> | 2011-04-20 09:35:40 +0000 |
commit | 7c3ec209bc28f83f008bad4d126293bcbb867113 (patch) | |
tree | 6e27c86d0b32e93ef6ebb24420dd383e702fa5be /src | |
parent | a387c9fd9b88861e5ca6bfae59c0f4f540fd4133 (diff) | |
download | scala-7c3ec209bc28f83f008bad4d126293bcbb867113.tar.gz scala-7c3ec209bc28f83f008bad4d126293bcbb867113.tar.bz2 scala-7c3ec209bc28f83f008bad4d126293bcbb867113.zip |
Merged revisions 24783-24788 via svnmerge from
https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk
........
r24783 | malayeri | 2011-04-19 16:51:42 +0200 (Tue, 19 Apr 2011) | 1 line
[scaladoc] CSS tweaks, changes to display of linear supertypes/known
subclasses. Closes #4458. No review. ........ r24784 | malayeri |
2011-04-19 17:30:26 +0200 (Tue, 19 Apr 2011) | 1 line
[scaladoc] Change URL when navigating Scaladoc, so as to allow linking
to individual pages with the left frame intact. Patch submitted by
Ruediger Keller. Closes #4473. No review. ........ r24785 | malayeri |
2011-04-19 17:38:17 +0200 (Tue, 19 Apr 2011) | 1 line
[scaladoc] Removed some drop shadows from CSS, to improve readability.
No review. ........ r24786 | prokopec | 2011-04-19 18:57:44 +0200 (Tue,
19 Apr 2011) | 5 lines
Removed GenTravOnceLike and TravOnceLike, put their functionality
to GenTravOnce and TravOnce. Remove immutable Gen* traits. Removing
mutable Gen* traits.
No review.
........
r24787 | pedrofurla | 2011-04-20 05:03:51 +0200 (Wed, 20 Apr 2011) | 1 line
Makes entire package area clickable in the left panel. Contributed by
Simon Ochsenreither (soc). Closes #4464. Review by malayeri. ........
r24788 | pedrofurla | 2011-04-20 05:33:58 +0200 (Wed, 20 Apr 2011) | 1
line
Shows deprecation message only once. Contributed by Simon
Ochsenreither (soc). Closes #4466. Review by malayeri. ........
Diffstat (limited to 'src')
42 files changed, 1027 insertions, 1047 deletions
diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Index.scala b/src/compiler/scala/tools/nsc/doc/html/page/Index.scala index 32ba06737b..4fc10b2ec2 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Index.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Index.scala @@ -72,7 +72,7 @@ class Index(universe: doc.Universe, index: doc.Index) extends HtmlPage { def packageElem(pack: model.Package): NodeSeq = { <xml:group> { if (!pack.isRootPackage) - <h3><a class="tplshow" href={ relativeLinkTo(pack) } target="template">{ pack.qualifiedName }</a></h3> + <a class="tplshow" href={ relativeLinkTo(pack) } target="template">{ pack.qualifiedName }</a> else NodeSeq.Empty } <ol class="templates">{ diff --git a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala index 58ed4961a5..f3e197d0be 100644 --- a/src/compiler/scala/tools/nsc/doc/html/page/Template.scala +++ b/src/compiler/scala/tools/nsc/doc/html/page/Template.scala @@ -320,18 +320,28 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { case _ => NodeSeq.Empty } - val annotations: Seq[scala.xml.Node] = + val annotations: Seq[scala.xml.Node] = { + // A list of annotations which don't show their arguments, e. g. because they are shown separately. + val annotationsWithHiddenArguments = List("deprecated", "Deprecated") + + def showArguments(annotation: Annotation) = { + if (annotationsWithHiddenArguments.contains(annotation.qualifiedName)) false else true + } + if (!mbr.annotations.isEmpty) { <dt>Annotations</dt> <dd>{ mbr.annotations.map { annot => <xml:group> - <span class="name">@{ templateToHtml(annot.annotationClass) }</span>{ argumentsToHtml(annot.arguments) } + <span class="name">@{ templateToHtml(annot.annotationClass) }</span>{ + if (showArguments(annot)) argumentsToHtml(annot.arguments) else NodeSeq.Empty + } </xml:group> } } </dd> } else NodeSeq.Empty + } val sourceLink: Seq[scala.xml.Node] = mbr match { case dtpl: DocTemplateEntity if (isSelf && dtpl.sourceUrl.isDefined && dtpl.inSource.isDefined && !isReduced) => @@ -398,28 +408,22 @@ class Template(tpl: DocTemplateEntity) extends HtmlPage { val linearization = mbr match { case dtpl: DocTemplateEntity if isSelf && !isReduced && dtpl.linearizationTemplates.nonEmpty => - <div class="toggleContainer"> - <div class="attributes block"> - <span class="link showElement">Linear Supertypes</span> - <span class="link hideElement">Linear Supertypes</span> - </div> - <div class="superTypes hiddenContent"> - <p>{ typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) }</p> - </div> + <div class="toggleContainer block"> + <span class="toggle">Linear Supertypes</span> + <div class="superTypes hiddenContent">{ + typesToHtml(dtpl.linearizationTypes, hasLinks = true, sep = xml.Text(", ")) + }</div> </div> case _ => NodeSeq.Empty } val subclasses = mbr match { case dtpl: DocTemplateEntity if isSelf && !isReduced && dtpl.subClasses.nonEmpty => - <div class="toggleContainer"> - <div class="attributes block"> - <span class="link showElement">Known Subclasses</span> - <span class="link hideElement">Known Subclasses</span> - </div> - <div class="subClasses hiddenContent"> - <p>{ templatesToHtml(dtpl.subClasses.sortBy(_.name), xml.Text(", ")) }</p> - </div> + <div class="toggleContainer block"> + <span class="toggle">Known Subclasses</span> + <div class="subClasses hiddenContent">{ + templatesToHtml(dtpl.subClasses.sortBy(_.name), xml.Text(", ")) + }</div> </div> case _ => NodeSeq.Empty } diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.css b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.css index df89781d10..e8c7bb961f 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.css +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.css @@ -226,7 +226,6 @@ h1 { float: right; font-weight: normal; color: white; - padding: 0 8px; } #tpl .packfocus { @@ -237,27 +236,31 @@ h1 { } #tpl .packages > ol { - background-color: #dadfe6; - /*margin-bottom: 5px;*/ + background-color: #dadfe6; + /*margin-bottom: 5px;*/ } /*#tpl .packages > ol > li { margin-bottom: 1px; }*/ -#tpl .packages > li > h3 { +#tpl .packages > li > a { + padding: 0px 5px; +} + +#tpl .packages > li > a.tplshow { display: block; color: white; font-weight: bold; display: block; - text-shadow: #000000 0 1px 0; + text-shadow: #000000 0 1px 0; } #tpl ol > li.pack { padding: 3px 5px; - background: url("packagesbg.gif"); - background-repeat:repeat-x; - min-height: 14px; + background: url("packagesbg.gif"); + background-repeat:repeat-x; + min-height: 14px; background-color: #6e808e; } @@ -266,24 +269,24 @@ h1 { } #tpl .templates > li { - padding-left: 5px; - min-height: 18px; + padding-left: 5px; + min-height: 18px; } #tpl ol > li .icon { - padding-right: 5px; + padding-right: 5px; bottom: -2px; position: relative; } #tpl .templates div.placeholder { - padding-right: 5px; - width: 13px; - display: inline-block; + padding-right: 5px; + width: 13px; + display: inline-block; } #tpl .templates span.tplLink { - padding-left: 5px; + padding-left: 5px; } #content { @@ -306,18 +309,18 @@ h1 { } .ui-layout-pane { - background: #FFF; - overflow: auto; + background: #FFF; + overflow: auto; } .ui-layout-resizer { - background-image:url('filterbg.gif'); - background-repeat:repeat-x; - background-color: #ededee; /* light gray */ - border:1px solid #bbbbbb; - border-top:0; - border-bottom:0; - border-left: 0; + background-image:url('filterbg.gif'); + background-repeat:repeat-x; + background-color: #ededee; /* light gray */ + border:1px solid #bbbbbb; + border-top:0; + border-bottom:0; + border-left: 0; } .ui-layout-toggler { diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js index 1a574a8752..0f25f024f4 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/index.js @@ -9,7 +9,9 @@ var scheduler = undefined; var kindFilterState = undefined; var focusFilterState = undefined; -var title = $(document).attr('title') +var title = $(document).attr('title'); + +var lastHash = ""; $(document).ready(function() { $('body').layout({ west__size: '20%' }); @@ -17,10 +19,12 @@ $(document).ready(function() { center__paneSelector: ".ui-west-center" //,center__initClosed:true ,north__paneSelector: ".ui-west-north" - }); + }); $('iframe').bind("load", function(){ var subtitle = $(this).contents().find('title').text(); $(document).attr('title', (title ? title + " - " : "") + subtitle); + + setUrlFragmentFromFrameSrc(); }); // workaround for IE's iframe sizing lack of smartness @@ -43,8 +47,60 @@ $(document).ready(function() { configureKindFilter(); configureEntityList(); + setFrameSrcFromUrlFragment(); + + // If the url fragment changes, adjust the src of iframe "template". + $(window).bind('hashchange', function() { + if(lastFragment != window.location.hash) { + lastFragment = window.location.hash; + setFrameSrcFromUrlFragment(); + } + }); }); +// Set the iframe's src according to the fragment of the current url. +// fragment = "#scala.Either" => iframe url = "scala/Either.html" +// fragment = "#scala.Either@isRight:Boolean" => iframe url = "scala/Either.html#isRight:Boolean" +function setFrameSrcFromUrlFragment() { + var fragment = location.hash.slice(1); + if(fragment) { + var loc = fragment.split("@")[0].replace(/\./g, "/"); + if(loc.indexOf(".html") < 0) loc += ".html"; + if(fragment.indexOf('@') > 0) loc += ("#" + fragment.split("@", 2)[1]); + frames["template"].location.replace(loc); + } + else + frames["template"].location.replace("package.html"); +} + +// Set the url fragment according to the src of the iframe "template". +// iframe url = "scala/Either.html" => url fragment = "#scala.Either" +// iframe url = "scala/Either.html#isRight:Boolean" => url fragment = "#scala.Either@isRight:Boolean" +function setUrlFragmentFromFrameSrc() { + try { + var commonLength = location.pathname.lastIndexOf("/"); + var frameLocation = frames["template"].location; + var relativePath = frameLocation.pathname.slice(commonLength + 1); + + if(!relativePath || frameLocation.pathname.indexOf("/") < 0) + return; + + // Add #, remove ".html" and replace "/" with "." + fragment = "#" + relativePath.replace(/\.html$/, "").replace(/\//g, "."); + + // Add the frame's hash after an @ + if(frameLocation.hash) fragment += ("@" + frameLocation.hash.slice(1)); + + // Use replace to not add history items + lastFragment = fragment; + location.replace(fragment); + } + catch(e) { + // Chrome doesn't allow reading the iframe's location when + // used on the local file system. + } +} + var Index = {}; (function (ns) { @@ -70,12 +126,11 @@ var Index = {}; return [ '<li class="pack">', '<a class="packfocus">focus</a><a class="packhide">hide</a>', - '<h3>', '<a class="tplshow" target="template" href="', pack.replace(/\./g, '/'), '/package.html">', pack, - '</a></h3></li>' + '</a></li>' ].join(''); }; @@ -139,13 +194,13 @@ var Index = {}; function subPackages(pack) { return $.grep($('#tpl ol.packages'), function (element, index) { - var pack = $('h3', element).text(); + var pack = $('li.pack > .tplshow', element).text(); return pack.indexOf(pack + '.') == 0; }); } ns.hidePackage = function (ol) { - var selected = $('h3', ol).text(); + var selected = $('li.pack > .tplshow', ol).text(); hiddenPackages[selected] = true; $('ol.templates', ol).hide(); @@ -156,7 +211,7 @@ var Index = {}; } ns.showPackage = function (ol, state) { - var selected = $('h3', ol).text(); + var selected = $('li.pack > .tplshow', ol).text(); hiddenPackages[selected] = false; $('ol.templates', ol).show(); @@ -166,7 +221,7 @@ var Index = {}; // When the filter is in "packs" state, // we don't want to show the `.templates` - var key = $('h3', element).text(); + var key = $('li.pack > .tplshow', element).text(); if (hiddenPackages[key] || state == 'packs') { $('ol.templates', element).hide(); } @@ -344,7 +399,7 @@ function configureFocusFilter() { function focusFilter(package) { scheduler.clear("filter"); - var currentFocus = $('h3', package).text(); + var currentFocus = $('li.pack > .tplshow', package).text(); $("#focusfilter > .focuscoll").empty(); $("#focusfilter > .focuscoll").append(currentFocus); diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css index 1fb2cbdbc2..0b2bc7f7b1 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.css @@ -30,7 +30,7 @@ input { border-width: 0px; } /* Page */ body { - font-family: Arial; + font-family: Arial, sans-serif; font-size: 10pt; } @@ -95,8 +95,9 @@ a[href]:hover { #definition > h1 { padding: 12px 0 12px 6px; color: white; - text-shadow: 3px black; +/* text-shadow: 3px black; text-shadow: black 0px 2px 0px; + */ font-size: 24pt; display: inline-block; } @@ -104,16 +105,18 @@ a[href]:hover { #definition h1 > a { color: #ffffff; /* text-decoration: none; */ - font-size: 24pt; +/* font-size: 24pt; text-shadow: black 0px 0px 0px; -} + */ + } #definition h1 > a:hover { color: #ffffff; text-decoration: none; font-size: 24pt; - text-shadow: black 0px 2px 0px; -} +/* text-shadow: black 0px 2px 0px; + */ + } #signature { background-image:url('signaturebg2.gif'); @@ -131,47 +134,40 @@ a[href]:hover { text-align: left; width: auto; position: static; - text-shadow: 2px white; +/* text-shadow: 2px white; text-shadow: white 0px 1px 0px; + */ } #signature > span.symbol { text-align: left; display: inline; padding-left: 0.7em; - text-shadow: 2px white; - text-shadow: white 0px 1px 0px; +/* text-shadow: 2px white; + text-shadow: white 0px 1px 0px; */ } /* Linear super types and known subclasses */ -.hideElement, .hiddenContent { display: none; } -div.superTypes > h1 { - font-style: italic; - padding-top: 0.5em; -} - -.link { - text-decoration: underline; +.toggleContainer .toggle { cursor: pointer; - color: #315479; + padding-left: 15px; + background: url("arrow-right.png") no-repeat 0 3px transparent; +} + +.toggleContainer.open .toggle { + background: url("arrow-down.png") no-repeat 0 3px transparent; } -.toggleContainer p { +.toggleContainer .hiddenContent { margin-top: 5px; } .toggleContainer .showElement { padding-left: 15px; - background: url("arrow-right.png") no-repeat 0 5px transparent; -} - -.toggleContainer .hideElement { - padding-left: 15px; - background: url("arrow-down.png") no-repeat 0 5px transparent; } .value #definition { @@ -214,7 +210,7 @@ dl.attributes > dd { background-color: #315479; /* grayish blue */ background: url("valuemembersbg.gif"); background-repeat:repeat-x; - height: 28px; + height: 18px; } #values ol li:last-child { @@ -225,14 +221,14 @@ dl.attributes > dd { background-color: #316555; /* green */ background: url("typebg.gif"); background-repeat:repeat-x; - height: 28px; + height: 18px; } #constructors > h3 { background-color: #333; background: url("constructorsbg.gif"); background-repeat:repeat-x; - height: 28px; + height: 18px; } #template > div.parent > h3 { @@ -243,7 +239,7 @@ dl.attributes > dd { background: url("constructorsbg.gif"); background-repeat:repeat-x; height: 17px; - margin-top: 10px; +/* margin-top: 10px;*/ /* color: black; text-shadow: white 0px 1px 0px; font-weight: normal;8*/ @@ -292,8 +288,8 @@ div.members > ol > li:last-child { line-height: 18px; clear: both; display: block; - text-shadow: 2px white; - text-shadow: white 0px 1px 0px; +/* text-shadow: 2px white; + text-shadow: white 0px 1px 0px; */ } .signature .kind { diff --git a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js index e848078aca..2479945299 100644 --- a/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js +++ b/src/compiler/scala/tools/nsc/doc/html/resource/lib/template.js @@ -42,8 +42,6 @@ $(document).ready(function(){ }; filter(); }); - -/* $("#ancestors > ol > li.hideall").click(function() { $("#linearization li.in").removeClass("in").addClass("out"); $("#linearization li:first").removeClass("out").addClass("in"); @@ -57,32 +55,6 @@ $(document).ready(function(){ filtered.removeClass("out").addClass("in"); filter(); }); -*/ - - - $("#ancestors > ol > li.hideall").click(function() { - if ($(this).hasClass("out")) { - $(this).removeClass("out").addClass("in"); - $("#ancestors > ol > li.showall").removeClass("in").addClass("out"); - $("#linearization li.in").removeClass("in").addClass("out"); - $("#linearization li:first").removeClass("out").addClass("in"); - filter(); - }; - }) - $("#ancestors > ol > li.showall").click(function() { - if($(this).hasClass("out")){ - $(this).removeClass("out").addClass("in"); - $("#ancestors > ol > li.hideall").removeClass("in").addClass("out"); - var filtered = - $("#linearization li.out").filter(function() { - return ! isHiddenClass($(this).attr("name")); - }); - filtered.removeClass("out").addClass("in"); - filter(); - }; - }); - - $("#visbl > ol > li.public").click(function() { if ($(this).hasClass("out")) { $(this).removeClass("out").addClass("in"); @@ -140,16 +112,12 @@ $(document).ready(function(){ var vis = $(":visible", fullComment); signature.toggleClass("closed").toggleClass("opened"); if (vis.length > 0) { - shortComment.slideDown(50); - fullComment.slideUp(50); - signature.addClass("closed"); - signature.removeClass("opened"); + shortComment.slideDown(100); + fullComment.slideUp(100); } else { - shortComment.slideUp(50); - fullComment.slideDown(50); - signature.removeClass("closed"); - signature.addClass("opened"); + shortComment.slideUp(100); + fullComment.slideDown(100); } }; docAllSigs.addClass("closed"); @@ -295,5 +263,11 @@ function filter() { function windowTitle() { - parent.document.title=document.title; + try { + parent.document.title=document.title; + } + catch(e) { + // Chrome doesn't allow settings the parent's title when + // used on the local file system. + } }; diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index e415e47ce8..44aae3053f 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -50,7 +50,7 @@ import annotation.migration * @author Aleksandar Prokopec * @since 2.9 */ -private[collection] trait GenTraversableLike[+A, +Repr] extends GenTraversableOnceLike[A] with Parallelizable[A, parallel.ParIterable[A]] { +private[collection] trait GenTraversableLike[+A, +Repr] extends GenTraversableOnce[A] with Parallelizable[A, parallel.ParIterable[A]] { def repr: Repr diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index 41dfa96e93..053a6d211a 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -8,13 +8,503 @@ package scala.collection -/** A trait for all traversable-once objects which may be +/** A template trait for all traversable-once objects which may be * traversed in parallel. * + * Methods in this trait are either abstract or can be implemented in terms + * of other methods. + * + * @define Coll GenTraversableOnce + * @define coll collection or iterator + * @define possiblyparinfo + * This trait may possibly have operations implemented in parallel. + * @define undefinedorder + * The order in which operations are performed on elements is unspecified and may be nondeterministic. + * @define orderDependent + * + * Note: might return different results for different runs, unless the underlying collection type is ordered. + * @define orderDependentFold + * + * Note: might return different results for different runs, unless the + * underlying collection type is ordered or the operator is associative + * and commutative. + * @define mayNotTerminateInf + * + * Note: may not terminate for infinite-sized collections. + * @define willNotTerminateInf + * + * Note: will not terminate for infinite-sized collections. + * * @author Martin Odersky * @author Aleksandar Prokopec * @since 2.9 */ -trait GenTraversableOnce[+A] extends GenTraversableOnceLike[A] { +private[collection] trait GenTraversableOnce[+A] { + + def foreach[U](f: A => U): Unit + + def hasDefiniteSize: Boolean + def seq: TraversableOnce[A] + + /** The size of this $coll. + * + * $willNotTerminateInf + * + * @return the number of elements in this $coll. + */ + def size: Int + + /** Tests whether the $coll is empty. + * + * @return `true` if the $coll contains no elements, `false` otherwise. + */ + def isEmpty: Boolean + + /** Tests whether the $coll is not empty. + * + * @return `true` if the $coll contains at least one element, `false` otherwise. + */ + def nonEmpty: Boolean + + /** Tests whether this $coll can be repeatedly traversed. Always + * true for Traversables and false for Iterators unless overridden. + * + * @return `true` if it is repeatedly traversable, `false` otherwise. + */ + def isTraversableAgain: Boolean + + /** Reduces the elements of this sequence using the specified associative binary operator. + * + * $undefinedorder + * + * Note this method has a different signature than the `reduceLeft` + * and `reduceRight` methods of the trait `Traversable`. + * The result of reducing may only be a supertype of this parallel collection's + * type parameter `T`. + * + * @tparam U A type parameter for the binary operator, a supertype of `T`. + * @param op A binary operator that must be associative. + * @return The result of applying reduce operator `op` between all the elements if the collection is nonempty. + * @throws UnsupportedOperationException + * if this $coll is empty. + */ + def reduce[A1 >: A](op: (A1, A1) => A1): A1 + + /** Optionally reduces the elements of this sequence using the specified associative binary operator. + * + * $undefinedorder + * + * Note this method has a different signature than the `reduceLeftOption` + * and `reduceRightOption` methods of the trait `Traversable`. + * The result of reducing may only be a supertype of this parallel collection's + * type parameter `T`. + * + * @tparam U A type parameter for the binary operator, a supertype of `T`. + * @param op A binary operator that must be associative. + * @return An option value containing result of applying reduce operator `op` between all + * the elements if the collection is nonempty, and `None` otherwise. + */ + def reduceOption[A1 >: A](op: (A1, A1) => A1): Option[A1] + + /** Folds the elements of this sequence using the specified associative binary operator. + * The order in which the elements are reduced is unspecified and may be nondeterministic. + * + * Note this method has a different signature than the `foldLeft` + * and `foldRight` methods of the trait `Traversable`. + * The result of folding may only be a supertype of this parallel collection's + * type parameter `T`. + * + * @tparam U a type parameter for the binary operator, a supertype of `T`. + * @param z a neutral element for the fold operation, it may be added to the result + * an arbitrary number of times, not changing the result (e.g. `Nil` for list concatenation, + * 0 for addition, or 1 for multiplication) + * @param op a binary operator that must be associative + * @return the result of applying fold operator `op` between all the elements and `z` + */ + def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 + + /** A syntactic sugar for out of order folding. See `fold`. */ + def /:\[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 = fold(z)(op) + + /** Applies a binary operator to a start value and all elements of this $coll, + * going left to right. + * + * Note: `/:` is alternate syntax for `foldLeft`; `z /: xs` is the same as + * `xs foldLeft z`. + * $willNotTerminateInf + * $orderDependentFold + * + * @param z the start value. + * @param op the binary operator. + * @tparam B the result type of the binary operator. + * @return the result of inserting `op` between consecutive elements of this $coll, + * going left to right with the start value `z` on the left: + * {{{ + * op(...op(op(z, x,,1,,), x,,2,,), ..., x,,n,,) + * }}} + * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. + */ + def /:[B](z: B)(op: (B, A) => B): B + + /** Applies a binary operator to all elements of this $coll and a start value, + * going right to left. + * + * Note: `:\` is alternate syntax for `foldRight`; `xs :\ z` is the same as + * `xs foldRight z`. + * $willNotTerminateInf + * $orderDependentFold + * + * @param z the start value + * @param op the binary operator + * @tparam B the result type of the binary operator. + * @return the result of inserting `op` between consecutive elements of this $coll, + * going right to left with the start value `z` on the right: + * {{{ + * op(x,,1,,, op(x,,2,,, ... op(x,,n,,, z)...)) + * }}} + * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. + */ + def :\[B](z: B)(op: (A, B) => B): B + + /** Applies a binary operator to a start value and all elements of this $coll, + * going left to right. + * + * $willNotTerminateInf + * $orderDependentFold + * + * @param z the start value. + * @param op the binary operator. + * @tparam B the result type of the binary operator. + * @return the result of inserting `op` between consecutive elements of this $coll, + * going left to right with the start value `z` on the left: + * {{{ + * op(...op(z, x,,1,,), x,,2,,, ..., x,,n,,) + * }}} + * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. + */ + def foldLeft[B](z: B)(op: (B, A) => B): B + + /** Applies a binary operator to all elements of this $coll and a start value, + * going right to left. + * + * $willNotTerminateInf + * $orderDependentFold + * @param z the start value. + * @param op the binary operator. + * @tparam B the result type of the binary operator. + * @return the result of inserting `op` between consecutive elements of this $coll, + * going right to left with the start value `z` on the right: + * {{{ + * op(x,,1,,, op(x,,2,,, ... op(x,,n,,, z)...)) + * }}} + * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. + */ + def foldRight[B](z: B)(op: (A, B) => B): B + + /** Aggregates the results of applying an operator to subsequent elements. + * + * This is a more general form of `fold` and `reduce`. It has similar semantics, but does + * not require the result to be a supertype of the element type. It traverses the elements in + * different partitions sequentially, using `seqop` to update the result, and then + * applies `combop` to results from different partitions. The implementation of this + * operation may operate on an arbitrary number of collection partitions, so `combop` + * may be invoked arbitrary number of times. + * + * For example, one might want to process some elements and then produce a `Set`. In this + * case, `seqop` would process an element and append it to the list, while `combop` + * would concatenate two lists from different partitions together. The initial value + * `z` would be an empty set. + * + * {{{ + * pc.aggregate(Set[Int]())(_ += process(_), _ ++ _) + * }}} + * + * Another example is calculating geometric mean from a collection of doubles + * (one would typically require big doubles for this). + * + * @tparam S the type of accumulated results + * @param z the initial value for the accumulated result of the partition - this + * will typically be the neutral element for the `seqop` operator (e.g. + * `Nil` for list concatenation or `0` for summation) + * @param seqop an operator used to accumulate results within a partition + * @param combop an associative operator used to combine results from different partitions + */ + def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B + + /** Applies a binary operator to all elements of this $coll, going right to left. + * $willNotTerminateInf + * $orderDependentFold + * + * @param op the binary operator. + * @tparam B the result type of the binary operator. + * @return the result of inserting `op` between consecutive elements of this $coll, + * going right to left: + * {{{ + * op(x,,1,,, op(x,,2,,, ..., op(x,,n-1,,, x,,n,,)...)) + * }}} + * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. + * @throws `UnsupportedOperationException` if this $coll is empty. + */ + def reduceRight[B >: A](op: (A, B) => B): B + + /** Optionally applies a binary operator to all elements of this $coll, going left to right. + * $willNotTerminateInf + * $orderDependentFold + * + * @param op the binary operator. + * @tparam B the result type of the binary operator. + * @return an option value containing the result of `reduceLeft(op)` is this $coll is nonempty, + * `None` otherwise. + */ + def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] + + /** Optionally applies a binary operator to all elements of this $coll, going + * right to left. + * $willNotTerminateInf + * $orderDependentFold + * + * @param op the binary operator. + * @tparam B the result type of the binary operator. + * @return an option value containing the result of `reduceRight(op)` is this $coll is nonempty, + * `None` otherwise. + */ + def reduceRightOption[B >: A](op: (A, B) => B): Option[B] + + /** Counts the number of elements in the $coll which satisfy a predicate. + * + * @param p the predicate used to test elements. + * @return the number of elements satisfying the predicate `p`. + */ + def count(p: A => Boolean): Int + + /** Sums up the elements of this collection. + * + * @param num an implicit parameter defining a set of numeric operations + * which includes the `+` operator to be used in forming the sum. + * @tparam B the result type of the `+` operator. + * @return the sum of all elements of this $coll with respect to the `+` operator in `num`. + * + * @usecase def sum: A + * + * @return the sum of all elements in this $coll of numbers of type `Int`. + * Instead of `Int`, any other type `T` with an implicit `Numeric[T]` implementation + * can be used as element type of the $coll and as result type of `sum`. + * Examples of such types are: `Long`, `Float`, `Double`, `BigInt`. + * + */ + def sum[A1 >: A](implicit num: Numeric[A1]): A1 + + /** Multiplies up the elements of this collection. + * + * @param num an implicit parameter defining a set of numeric operations + * which includes the `*` operator to be used in forming the product. + * @tparam B the result type of the `*` operator. + * @return the product of all elements of this $coll with respect to the `*` operator in `num`. + * + * @usecase def product: A + * + * @return the product of all elements in this $coll of numbers of type `Int`. + * Instead of `Int`, any other type `T` with an implicit `Numeric[T]` implementation + * can be used as element type of the $coll and as result type of `product`. + * Examples of such types are: `Long`, `Float`, `Double`, `BigInt`. + */ + def product[A1 >: A](implicit num: Numeric[A1]): A1 + + /** Finds the smallest element. + * + * @param cmp An ordering to be used for comparing elements. + * @tparam B The type over which the ordering is defined. + * @return the smallest element of this $coll with respect to the ordering `cmp`. + * + * @usecase def min: A + * @return the smallest element of this $coll + */ + def min[A1 >: A](implicit ord: Ordering[A1]): A + + /** Finds the largest element. + * + * @param cmp An ordering to be used for comparing elements. + * @tparam B The type over which the ordering is defined. + * @return the largest element of this $coll with respect to the ordering `cmp`. + * + * @usecase def max: A + * @return the largest element of this $coll. + */ + def max[A1 >: A](implicit ord: Ordering[A1]): A + + def maxBy[B](f: A => B)(implicit cmp: Ordering[B]): A + + def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A + + def forall(pred: A => Boolean): Boolean + + def exists(pred: A => Boolean): Boolean + + /** Finds the first element of the $coll satisfying a predicate, if any. + * + * $mayNotTerminateInf + * $orderDependent + * + * @param p the predicate used to test elements. + * @return an option value containing the first element in the $coll + * that satisfies `p`, or `None` if none exists. + */ + def find(pred: A => Boolean): Option[A] + + /** Copies values of this $coll to an array. + * Fills the given array `xs` with values of this $coll. + * Copying will stop once either the end of the current $coll is reached, + * or the end of the array is reached. + * + * $willNotTerminateInf + * + * @param xs the array to fill. + * @tparam B the type of the elements of the array. + * + * @usecase def copyToArray(xs: Array[A]): Unit + */ + def copyToArray[B >: A](xs: Array[B]): Unit + + /** Copies values of this $coll to an array. + * Fills the given array `xs` with values of this $coll, after skipping `start` values. + * Copying will stop once either the end of the current $coll is reached, + * or the end of the array is reached. + * + * $willNotTerminateInf + * + * @param xs the array to fill. + * @param start the starting index. + * @tparam B the type of the elements of the array. + * + * @usecase def copyToArray(xs: Array[A], start: Int): Unit + */ + def copyToArray[B >: A](xs: Array[B], start: Int): Unit + + def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit + + /** Displays all elements of this $coll in a string using start, end, and + * separator strings. + * + * @param start the starting string. + * @param sep the separator string. + * @param end the ending string. + * @return a string representation of this $coll. The resulting string + * begins with the string `start` and ends with the string + * `end`. Inside, the string representations (w.r.t. the method + * `toString`) of all elements of this $coll are separated by + * the string `sep`. + * + * @example `List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"` + */ + def mkString(start: String, sep: String, end: String): String + + /** Displays all elements of this $coll in a string using a separator string. + * + * @param sep the separator string. + * @return a string representation of this $coll. In the resulting string + * the string representations (w.r.t. the method `toString`) + * of all elements of this $coll are separated by the string `sep`. + * + * @example `List(1, 2, 3).mkString("|") = "1|2|3"` + */ + def mkString(sep: String): String + + /** Displays all elements of this $coll in a string. + * + * @return a string representation of this $coll. In the resulting string + * the string representations (w.r.t. the method `toString`) + * of all elements of this $coll follow each other without any + * separator string. + */ + def mkString: String + + /** Converts this $coll to an array. + * $willNotTerminateInf + * + * @tparam B the type of the elements of the array. A `ClassManifest` for + * this type must be available. + * @return an array containing all elements of this $coll. + * + * @usecase def toArray: Array[A] + * @return an array containing all elements of this $coll. + * A `ClassManifest` must be available for the element type of this $coll. + */ + def toArray[A1 >: A: ClassManifest]: Array[A1] + + /** Converts this $coll to a list. + * $willNotTerminateInf + * @return a list containing all elements of this $coll. + */ + def toList: List[A] + + /** Converts this $coll to an indexed sequence. + * $willNotTerminateInf + * @return an indexed sequence containing all elements of this $coll. + */ + def toIndexedSeq[A1 >: A]: immutable.IndexedSeq[A1] + + /** Converts this $coll to a stream. + * $willNotTerminateInf + * @return a stream containing all elements of this $coll. + */ + def toStream: Stream[A] + + /** Returns an Iterator over the elements in this $coll. Will return + * the same Iterator if this instance is already an Iterator. + * $willNotTerminateInf + * @return an Iterator containing all elements of this $coll. + */ + def toIterator: Iterator[A] + + /** Converts this $coll to a mutable buffer. + * $willNotTerminateInf + * @return a buffer containing all elements of this $coll. + */ + def toBuffer[A1 >: A]: collection.mutable.Buffer[A1] + + /** Converts this $coll to an unspecified Traversable. Will return + * the same collection if this instance is already Traversable. + * $willNotTerminateInf + * @return a Traversable containing all elements of this $coll. + */ + def toTraversable: GenTraversable[A] + + /** Converts this $coll to an iterable collection. Note that + * the choice of target `Iterable` is lazy in this default implementation + * as this `TraversableOnce` may be lazy and unevaluated (i.e. it may + * be an iterator which is only traversable once). + * + * $willNotTerminateInf + * @return an `Iterable` containing all elements of this $coll. + */ + def toIterable: GenIterable[A] + + /** Converts this $coll to a sequence. As with `toIterable`, it's lazy + * in this default implementation, as this `TraversableOnce` may be + * lazy and unevaluated. + * + * $willNotTerminateInf + * @return a sequence containing all elements of this $coll. + */ + def toSeq: GenSeq[A] + + /** Converts this $coll to a set. + * $willNotTerminateInf + * @return a set containing all elements of this $coll. + */ + def toSet[A1 >: A]: GenSet[A1] + + /** Converts this $coll to a map. This method is unavailable unless + * the elements are members of Tuple2, each ((T, U)) becoming a key-value + * pair in the map. Duplicate keys will be overwritten by later keys: + * if this is an unordered collection, which key is in the resulting map + * is undefined. + * $willNotTerminateInf + * @return a map containing all elements of this $coll. + * @usecase def toMap[T, U]: Map[T, U] + * @return a map of type `immutable.Map[T, U]` + * containing all key/value pairs of type `(T, U)` of this $coll. + */ + def toMap[K, V](implicit ev: A <:< (K, V)): GenMap[K, V] } diff --git a/src/library/scala/collection/GenTraversableOnceLike.scala b/src/library/scala/collection/GenTraversableOnceLike.scala deleted file mode 100644 index 6431b334cf..0000000000 --- a/src/library/scala/collection/GenTraversableOnceLike.scala +++ /dev/null @@ -1,510 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.collection - -/** A template trait for all traversable-once objects which may be - * traversed in parallel. - * - * Methods in this trait are either abstract or can be implemented in terms - * of other methods. - * - * @define Coll GenTraversableOnce - * @define coll collection or iterator - * @define possiblyparinfo - * This trait may possibly have operations implemented in parallel. - * @define undefinedorder - * The order in which operations are performed on elements is unspecified and may be nondeterministic. - * @define orderDependent - * - * Note: might return different results for different runs, unless the underlying collection type is ordered. - * @define orderDependentFold - * - * Note: might return different results for different runs, unless the - * underlying collection type is ordered or the operator is associative - * and commutative. - * @define mayNotTerminateInf - * - * Note: may not terminate for infinite-sized collections. - * @define willNotTerminateInf - * - * Note: will not terminate for infinite-sized collections. - * - * @author Martin Odersky - * @author Aleksandar Prokopec - * @since 2.9 - */ -private[collection] trait GenTraversableOnceLike[+A] { - - def foreach[U](f: A => U): Unit - - def hasDefiniteSize: Boolean - - def seq: TraversableOnce[A] - - /** The size of this $coll. - * - * $willNotTerminateInf - * - * @return the number of elements in this $coll. - */ - def size: Int - - /** Tests whether the $coll is empty. - * - * @return `true` if the $coll contains no elements, `false` otherwise. - */ - def isEmpty: Boolean - - /** Tests whether the $coll is not empty. - * - * @return `true` if the $coll contains at least one element, `false` otherwise. - */ - def nonEmpty: Boolean - - /** Tests whether this $coll can be repeatedly traversed. Always - * true for Traversables and false for Iterators unless overridden. - * - * @return `true` if it is repeatedly traversable, `false` otherwise. - */ - def isTraversableAgain: Boolean - - /** Reduces the elements of this sequence using the specified associative binary operator. - * - * $undefinedorder - * - * Note this method has a different signature than the `reduceLeft` - * and `reduceRight` methods of the trait `Traversable`. - * The result of reducing may only be a supertype of this parallel collection's - * type parameter `T`. - * - * @tparam U A type parameter for the binary operator, a supertype of `T`. - * @param op A binary operator that must be associative. - * @return The result of applying reduce operator `op` between all the elements if the collection is nonempty. - * @throws UnsupportedOperationException - * if this $coll is empty. - */ - def reduce[A1 >: A](op: (A1, A1) => A1): A1 - - /** Optionally reduces the elements of this sequence using the specified associative binary operator. - * - * $undefinedorder - * - * Note this method has a different signature than the `reduceLeftOption` - * and `reduceRightOption` methods of the trait `Traversable`. - * The result of reducing may only be a supertype of this parallel collection's - * type parameter `T`. - * - * @tparam U A type parameter for the binary operator, a supertype of `T`. - * @param op A binary operator that must be associative. - * @return An option value containing result of applying reduce operator `op` between all - * the elements if the collection is nonempty, and `None` otherwise. - */ - def reduceOption[A1 >: A](op: (A1, A1) => A1): Option[A1] - - /** Folds the elements of this sequence using the specified associative binary operator. - * The order in which the elements are reduced is unspecified and may be nondeterministic. - * - * Note this method has a different signature than the `foldLeft` - * and `foldRight` methods of the trait `Traversable`. - * The result of folding may only be a supertype of this parallel collection's - * type parameter `T`. - * - * @tparam U a type parameter for the binary operator, a supertype of `T`. - * @param z a neutral element for the fold operation, it may be added to the result - * an arbitrary number of times, not changing the result (e.g. `Nil` for list concatenation, - * 0 for addition, or 1 for multiplication) - * @param op a binary operator that must be associative - * @return the result of applying fold operator `op` between all the elements and `z` - */ - def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 - - /** A syntactic sugar for out of order folding. See `fold`. */ - def /:\[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 = fold(z)(op) - - /** Applies a binary operator to a start value and all elements of this $coll, - * going left to right. - * - * Note: `/:` is alternate syntax for `foldLeft`; `z /: xs` is the same as - * `xs foldLeft z`. - * $willNotTerminateInf - * $orderDependentFold - * - * @param z the start value. - * @param op the binary operator. - * @tparam B the result type of the binary operator. - * @return the result of inserting `op` between consecutive elements of this $coll, - * going left to right with the start value `z` on the left: - * {{{ - * op(...op(op(z, x,,1,,), x,,2,,), ..., x,,n,,) - * }}} - * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. - */ - def /:[B](z: B)(op: (B, A) => B): B - - /** Applies a binary operator to all elements of this $coll and a start value, - * going right to left. - * - * Note: `:\` is alternate syntax for `foldRight`; `xs :\ z` is the same as - * `xs foldRight z`. - * $willNotTerminateInf - * $orderDependentFold - * - * @param z the start value - * @param op the binary operator - * @tparam B the result type of the binary operator. - * @return the result of inserting `op` between consecutive elements of this $coll, - * going right to left with the start value `z` on the right: - * {{{ - * op(x,,1,,, op(x,,2,,, ... op(x,,n,,, z)...)) - * }}} - * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. - */ - def :\[B](z: B)(op: (A, B) => B): B - - /** Applies a binary operator to a start value and all elements of this $coll, - * going left to right. - * - * $willNotTerminateInf - * $orderDependentFold - * - * @param z the start value. - * @param op the binary operator. - * @tparam B the result type of the binary operator. - * @return the result of inserting `op` between consecutive elements of this $coll, - * going left to right with the start value `z` on the left: - * {{{ - * op(...op(z, x,,1,,), x,,2,,, ..., x,,n,,) - * }}} - * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. - */ - def foldLeft[B](z: B)(op: (B, A) => B): B - - /** Applies a binary operator to all elements of this $coll and a start value, - * going right to left. - * - * $willNotTerminateInf - * $orderDependentFold - * @param z the start value. - * @param op the binary operator. - * @tparam B the result type of the binary operator. - * @return the result of inserting `op` between consecutive elements of this $coll, - * going right to left with the start value `z` on the right: - * {{{ - * op(x,,1,,, op(x,,2,,, ... op(x,,n,,, z)...)) - * }}} - * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. - */ - def foldRight[B](z: B)(op: (A, B) => B): B - - /** Aggregates the results of applying an operator to subsequent elements. - * - * This is a more general form of `fold` and `reduce`. It has similar semantics, but does - * not require the result to be a supertype of the element type. It traverses the elements in - * different partitions sequentially, using `seqop` to update the result, and then - * applies `combop` to results from different partitions. The implementation of this - * operation may operate on an arbitrary number of collection partitions, so `combop` - * may be invoked arbitrary number of times. - * - * For example, one might want to process some elements and then produce a `Set`. In this - * case, `seqop` would process an element and append it to the list, while `combop` - * would concatenate two lists from different partitions together. The initial value - * `z` would be an empty set. - * - * {{{ - * pc.aggregate(Set[Int]())(_ += process(_), _ ++ _) - * }}} - * - * Another example is calculating geometric mean from a collection of doubles - * (one would typically require big doubles for this). - * - * @tparam S the type of accumulated results - * @param z the initial value for the accumulated result of the partition - this - * will typically be the neutral element for the `seqop` operator (e.g. - * `Nil` for list concatenation or `0` for summation) - * @param seqop an operator used to accumulate results within a partition - * @param combop an associative operator used to combine results from different partitions - */ - def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B - - /** Applies a binary operator to all elements of this $coll, going right to left. - * $willNotTerminateInf - * $orderDependentFold - * - * @param op the binary operator. - * @tparam B the result type of the binary operator. - * @return the result of inserting `op` between consecutive elements of this $coll, - * going right to left: - * {{{ - * op(x,,1,,, op(x,,2,,, ..., op(x,,n-1,,, x,,n,,)...)) - * }}} - * where `x,,1,,, ..., x,,n,,` are the elements of this $coll. - * @throws `UnsupportedOperationException` if this $coll is empty. - */ - def reduceRight[B >: A](op: (A, B) => B): B - - /** Optionally applies a binary operator to all elements of this $coll, going left to right. - * $willNotTerminateInf - * $orderDependentFold - * - * @param op the binary operator. - * @tparam B the result type of the binary operator. - * @return an option value containing the result of `reduceLeft(op)` is this $coll is nonempty, - * `None` otherwise. - */ - def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] - - /** Optionally applies a binary operator to all elements of this $coll, going - * right to left. - * $willNotTerminateInf - * $orderDependentFold - * - * @param op the binary operator. - * @tparam B the result type of the binary operator. - * @return an option value containing the result of `reduceRight(op)` is this $coll is nonempty, - * `None` otherwise. - */ - def reduceRightOption[B >: A](op: (A, B) => B): Option[B] - - /** Counts the number of elements in the $coll which satisfy a predicate. - * - * @param p the predicate used to test elements. - * @return the number of elements satisfying the predicate `p`. - */ - def count(p: A => Boolean): Int - - /** Sums up the elements of this collection. - * - * @param num an implicit parameter defining a set of numeric operations - * which includes the `+` operator to be used in forming the sum. - * @tparam B the result type of the `+` operator. - * @return the sum of all elements of this $coll with respect to the `+` operator in `num`. - * - * @usecase def sum: A - * - * @return the sum of all elements in this $coll of numbers of type `Int`. - * Instead of `Int`, any other type `T` with an implicit `Numeric[T]` implementation - * can be used as element type of the $coll and as result type of `sum`. - * Examples of such types are: `Long`, `Float`, `Double`, `BigInt`. - * - */ - def sum[A1 >: A](implicit num: Numeric[A1]): A1 - - /** Multiplies up the elements of this collection. - * - * @param num an implicit parameter defining a set of numeric operations - * which includes the `*` operator to be used in forming the product. - * @tparam B the result type of the `*` operator. - * @return the product of all elements of this $coll with respect to the `*` operator in `num`. - * - * @usecase def product: A - * - * @return the product of all elements in this $coll of numbers of type `Int`. - * Instead of `Int`, any other type `T` with an implicit `Numeric[T]` implementation - * can be used as element type of the $coll and as result type of `product`. - * Examples of such types are: `Long`, `Float`, `Double`, `BigInt`. - */ - def product[A1 >: A](implicit num: Numeric[A1]): A1 - - /** Finds the smallest element. - * - * @param cmp An ordering to be used for comparing elements. - * @tparam B The type over which the ordering is defined. - * @return the smallest element of this $coll with respect to the ordering `cmp`. - * - * @usecase def min: A - * @return the smallest element of this $coll - */ - def min[A1 >: A](implicit ord: Ordering[A1]): A - - /** Finds the largest element. - * - * @param cmp An ordering to be used for comparing elements. - * @tparam B The type over which the ordering is defined. - * @return the largest element of this $coll with respect to the ordering `cmp`. - * - * @usecase def max: A - * @return the largest element of this $coll. - */ - def max[A1 >: A](implicit ord: Ordering[A1]): A - - def maxBy[B](f: A => B)(implicit cmp: Ordering[B]): A - - def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A - - def forall(pred: A => Boolean): Boolean - - def exists(pred: A => Boolean): Boolean - - /** Finds the first element of the $coll satisfying a predicate, if any. - * - * $mayNotTerminateInf - * $orderDependent - * - * @param p the predicate used to test elements. - * @return an option value containing the first element in the $coll - * that satisfies `p`, or `None` if none exists. - */ - def find(pred: A => Boolean): Option[A] - - /** Copies values of this $coll to an array. - * Fills the given array `xs` with values of this $coll. - * Copying will stop once either the end of the current $coll is reached, - * or the end of the array is reached. - * - * $willNotTerminateInf - * - * @param xs the array to fill. - * @tparam B the type of the elements of the array. - * - * @usecase def copyToArray(xs: Array[A]): Unit - */ - def copyToArray[B >: A](xs: Array[B]): Unit - - /** Copies values of this $coll to an array. - * Fills the given array `xs` with values of this $coll, after skipping `start` values. - * Copying will stop once either the end of the current $coll is reached, - * or the end of the array is reached. - * - * $willNotTerminateInf - * - * @param xs the array to fill. - * @param start the starting index. - * @tparam B the type of the elements of the array. - * - * @usecase def copyToArray(xs: Array[A], start: Int): Unit - */ - def copyToArray[B >: A](xs: Array[B], start: Int): Unit - - def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit - - /** Displays all elements of this $coll in a string using start, end, and - * separator strings. - * - * @param start the starting string. - * @param sep the separator string. - * @param end the ending string. - * @return a string representation of this $coll. The resulting string - * begins with the string `start` and ends with the string - * `end`. Inside, the string representations (w.r.t. the method - * `toString`) of all elements of this $coll are separated by - * the string `sep`. - * - * @example `List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"` - */ - def mkString(start: String, sep: String, end: String): String - - /** Displays all elements of this $coll in a string using a separator string. - * - * @param sep the separator string. - * @return a string representation of this $coll. In the resulting string - * the string representations (w.r.t. the method `toString`) - * of all elements of this $coll are separated by the string `sep`. - * - * @example `List(1, 2, 3).mkString("|") = "1|2|3"` - */ - def mkString(sep: String): String - - /** Displays all elements of this $coll in a string. - * - * @return a string representation of this $coll. In the resulting string - * the string representations (w.r.t. the method `toString`) - * of all elements of this $coll follow each other without any - * separator string. - */ - def mkString: String - - /** Converts this $coll to an array. - * $willNotTerminateInf - * - * @tparam B the type of the elements of the array. A `ClassManifest` for - * this type must be available. - * @return an array containing all elements of this $coll. - * - * @usecase def toArray: Array[A] - * @return an array containing all elements of this $coll. - * A `ClassManifest` must be available for the element type of this $coll. - */ - def toArray[A1 >: A: ClassManifest]: Array[A1] - - /** Converts this $coll to a list. - * $willNotTerminateInf - * @return a list containing all elements of this $coll. - */ - def toList: List[A] - - /** Converts this $coll to an indexed sequence. - * $willNotTerminateInf - * @return an indexed sequence containing all elements of this $coll. - */ - def toIndexedSeq[A1 >: A]: immutable.IndexedSeq[A1] - - /** Converts this $coll to a stream. - * $willNotTerminateInf - * @return a stream containing all elements of this $coll. - */ - def toStream: Stream[A] - - /** Returns an Iterator over the elements in this $coll. Will return - * the same Iterator if this instance is already an Iterator. - * $willNotTerminateInf - * @return an Iterator containing all elements of this $coll. - */ - def toIterator: Iterator[A] - - /** Converts this $coll to a mutable buffer. - * $willNotTerminateInf - * @return a buffer containing all elements of this $coll. - */ - def toBuffer[A1 >: A]: collection.mutable.Buffer[A1] - - /** Converts this $coll to an unspecified Traversable. Will return - * the same collection if this instance is already Traversable. - * $willNotTerminateInf - * @return a Traversable containing all elements of this $coll. - */ - def toTraversable: GenTraversable[A] - - /** Converts this $coll to an iterable collection. Note that - * the choice of target `Iterable` is lazy in this default implementation - * as this `TraversableOnce` may be lazy and unevaluated (i.e. it may - * be an iterator which is only traversable once). - * - * $willNotTerminateInf - * @return an `Iterable` containing all elements of this $coll. - */ - def toIterable: GenIterable[A] - - /** Converts this $coll to a sequence. As with `toIterable`, it's lazy - * in this default implementation, as this `TraversableOnce` may be - * lazy and unevaluated. - * - * $willNotTerminateInf - * @return a sequence containing all elements of this $coll. - */ - def toSeq: GenSeq[A] - - /** Converts this $coll to a set. - * $willNotTerminateInf - * @return a set containing all elements of this $coll. - */ - def toSet[A1 >: A]: GenSet[A1] - - /** Converts this $coll to a map. This method is unavailable unless - * the elements are members of Tuple2, each ((T, U)) becoming a key-value - * pair in the map. Duplicate keys will be overwritten by later keys: - * if this is an unordered collection, which key is in the resulting map - * is undefined. - * $willNotTerminateInf - * @return a map containing all elements of this $coll. - * @usecase def toMap[T, U]: Map[T, U] - * @return a map of type `immutable.Map[T, U]` - * containing all key/value pairs of type `(T, U)` of this $coll. - */ - def toMap[K, V](implicit ev: A <:< (K, V)): GenMap[K, V] -} diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index 082ffb464e..7bd33cbb23 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -253,6 +253,8 @@ import Iterator.empty trait Iterator[+A] extends TraversableOnce[A] { self => + def seq: Iterator[A] = this + /** Tests whether this iterator can provide another element. * @return `true` if a subsequent call to `next` will yield an element, * `false` otherwise. diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index bffd46a72c..2d3a4c229c 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -68,7 +68,7 @@ import parallel.ParIterable */ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] with FilterMonadic[A, Repr] - with TraversableOnceLike[A] + with TraversableOnce[A] with GenTraversableLike[A, Repr] with Parallelizable[A, ParIterable[A]] { diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 23e3f2a866..90f1583c58 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -13,10 +13,6 @@ import annotation.unchecked.{ uncheckedVariance => uV } /** A template trait for collections which can be traversed either once only * or one or more times. - * - * All of the methods in this trait are guaranteed to be implemented - * in a single-threaded manner. - * * $traversableonceinfo * * @tparam A the element type of the collection @@ -27,6 +23,24 @@ import annotation.unchecked.{ uncheckedVariance => uV } * @since 2.8 * * @define coll traversable or iterator + * + * @tparam A the element type of the collection + * + * @define traversableonceinfo + * This trait exists primarily to eliminate code duplication between + * `Iterator` and `Traversable`, and thus implements some of the common + * methods that can be implemented solely in terms of foreach without + * access to a `Builder`. It also includes a number of abstract methods + * whose implementations are provided by `Iterator`, `Traversable`, etc. + * It contains implementations common to `Iterators` and + * `Traversables`, such as folds, conversions, and other operations which + * traverse some or all of the elements and return a derived value. + * Directly subclassing `TraversableOnce` is not recommended - instead, + * consider declaring an `Iterator` with a `next` and `hasNext` method, + * creating an `Iterator` with one of the methods on the `Iterator` object, + * or declaring a subclass of `Traversable`. + * + * @define coll traversable or iterator * @define orderDependent * * Note: might return different results for different runs, unless the underlying collection type is ordered. @@ -42,14 +56,270 @@ import annotation.unchecked.{ uncheckedVariance => uV } * * Note: will not terminate for infinite-sized collections. */ -trait TraversableOnce[+A] extends GenTraversableOnce[A] with TraversableOnceLike[A] { +trait TraversableOnce[+A] extends GenTraversableOnce[A] { self => - override def seq: TraversableOnce[A] = this + /** Self-documenting abstract methods. */ + def foreach[U](f: A => U): Unit + def isEmpty: Boolean + def hasDefiniteSize: Boolean + + // 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. + // Note 2: This is implemented in all collections _not_ inheriting `Traversable[A]` + // at least indirectly. Currently, these are `ArrayOps` and `StringOps`. + // It is also implemented in `TraversableOnce[A]`. + /** 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] + + /** 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. + */ + def forall(p: A => Boolean): Boolean + def exists(p: A => Boolean): Boolean + def find(p: A => Boolean): Option[A] + def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit + + // for internal use + protected[this] def reversed = { + var elems: List[A] = Nil + self.seq foreach (elems ::= _) + elems + } + + def size: Int = { + var result = 0 + for (x <- self) result += 1 + result + } + + def nonEmpty: Boolean = !isEmpty + + def count(p: A => Boolean): Int = { + var cnt = 0 + for (x <- this) + if (p(x)) cnt += 1 + + cnt + } + + /** Finds the first element of the $coll for which the given partial + * function is defined, and applies the partial function to it. + * + * $mayNotTerminateInf + * $orderDependent + * + * @param pf the partial function + * @return an option value containing pf applied to the first + * value for which it is defined, or `None` if none exists. + * @example `Seq("a", 1, 5L).collectFirst({ case x: Int => x*10 }) = Some(10)` + */ + def collectFirst[B](pf: PartialFunction[A, B]): Option[B] = { + for (x <- self.toIterator) { // make sure to use an iterator or `seq` + if (pf isDefinedAt x) + return Some(pf(x)) + } + None + } + + def /:[B](z: B)(op: (B, A) => B): B = foldLeft(z)(op) + + def :\[B](z: B)(op: (A, B) => B): B = foldRight(z)(op) + + def foldLeft[B](z: B)(op: (B, A) => B): B = { + var result = z + this.seq foreach (x => result = op(result, x)) + result + } + + def foldRight[B](z: B)(op: (A, B) => B): B = + reversed.foldLeft(z)((x, y) => op(y, x)) + + def reduceLeft[B >: A](op: (B, A) => B): B = { + if (isEmpty) + throw new UnsupportedOperationException("empty.reduceLeft") + + var first = true + var acc: B = 0.asInstanceOf[B] + + for (x <- self) { + if (first) { + acc = x + first = false + } + else acc = op(acc, x) + } + acc + } + + def reduceRight[B >: A](op: (A, B) => B): B = { + if (isEmpty) + throw new UnsupportedOperationException("empty.reduceRight") + + reversed.reduceLeft[B]((x, y) => op(y, x)) + } + + def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] = + if (isEmpty) None else Some(reduceLeft(op)) + + def reduceRightOption[B >: A](op: (A, B) => B): Option[B] = + if (isEmpty) None else Some(reduceRight(op)) + + def reduce[A1 >: A](op: (A1, A1) => A1): A1 = reduceLeft(op) + + def reduceOption[A1 >: A](op: (A1, A1) => A1): Option[A1] = reduceLeftOption(op) + + def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 = foldLeft(z)(op) + + def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B = foldLeft(z)(seqop) + + def sum[B >: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus) + def product[B >: A](implicit num: Numeric[B]): B = foldLeft(num.one)(num.times) + + def min[B >: A](implicit cmp: Ordering[B]): A = { + if (isEmpty) + throw new UnsupportedOperationException("empty.min") + + reduceLeft((x, y) => if (cmp.lteq(x, y)) x else y) + } + + def max[B >: A](implicit cmp: Ordering[B]): A = { + if (isEmpty) + throw new UnsupportedOperationException("empty.max") + + reduceLeft((x, y) => if (cmp.gteq(x, y)) x else y) + } + + def maxBy[B](f: A => B)(implicit cmp: Ordering[B]): A = { + if (isEmpty) + throw new UnsupportedOperationException("empty.maxBy") + + reduceLeft((x, y) => if (cmp.gteq(f(x), f(y))) x else y) + } + def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A = { + if (isEmpty) + throw new UnsupportedOperationException("empty.minBy") + + reduceLeft((x, y) => if (cmp.lteq(f(x), f(y))) x else y) + } + + /** Copies all elements of this $coll to a buffer. + * $willNotTerminateInf + * @param dest The buffer to which elements are copied. + */ + def copyToBuffer[B >: A](dest: Buffer[B]): Unit = dest ++= seq + + def copyToArray[B >: A](xs: Array[B], start: Int): Unit = + copyToArray(xs, start, xs.length - start) + + def copyToArray[B >: A](xs: Array[B]): Unit = + copyToArray(xs, 0, xs.length) + + def toArray[B >: A : ClassManifest]: Array[B] = { + if (isTraversableAgain) { + val result = new Array[B](size) + copyToArray(result, 0) + result + } + else toBuffer.toArray + } + + def toTraversable: Traversable[A] + + def toList: List[A] = new ListBuffer[A] ++= seq toList + + def toIterable: Iterable[A] = toStream + + def toSeq: Seq[A] = toStream + + def toIndexedSeq[B >: A]: immutable.IndexedSeq[B] = immutable.IndexedSeq() ++ seq + + def toBuffer[B >: A]: mutable.Buffer[B] = new ArrayBuffer[B] ++= seq + + def toSet[B >: A]: immutable.Set[B] = immutable.Set() ++ seq + + def toMap[T, U](implicit ev: A <:< (T, U)): immutable.Map[T, U] = { + val b = immutable.Map.newBuilder[T, U] + for (x <- self) + b += x + + b.result + } + + def mkString(start: String, sep: String, end: String): String = + addString(new StringBuilder(), start, sep, end).toString + + def mkString(sep: String): String = mkString("", sep, "") + + def mkString: String = mkString("") + + /** Appends all elements of this $coll to a string builder using start, end, + * and separator strings. + * The written text begins with the string `start` and ends with the string + * `end`. Inside, the string representations (w.r.t. the method `toString`) + * of all elements of this $coll are separated by the string `sep`. + * + * @param b the string builder to which elements are appended. + * @param start the starting string. + * @param sep the separator string. + * @param end the ending string. + * @return the string builder `b` to which elements were appended. + */ + def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = { + var first = true + + b append start + for (x <- self) { + if (first) { + b append x + first = false + } + else { + b append sep + b append x + } + } + b append end + + b + } + + /** Appends all elements of this $coll to a string builder using a separator + * string. The written text consists of the string representations (w.r.t. + * the method `toString`) of all elements of this $coll, separated by the + * string `sep`. + * + * @param b the string builder to which elements are appended. + * @param sep the separator string. + * @return the string builder `b` to which elements were appended. + */ + def addString(b: StringBuilder, sep: String): StringBuilder = addString(b, "", sep, "") + + /** Appends all elements of this $coll to a string builder. + * The written text consists of the string representations (w.r.t. the method + * `toString`) of all elements of this $coll without any separator string. + * + * @param b the string builder to which elements are appended. + * @return the string builder `b` to which elements were appended. + */ + def addString(b: StringBuilder): StringBuilder = addString(b, "") } + object TraversableOnce { implicit def traversableOnceCanBuildFrom[T] = new OnceCanBuildFrom[T] implicit def wrapTraversableOnce[A](trav: TraversableOnce[A]) = new MonadOps(trav) diff --git a/src/library/scala/collection/TraversableOnceLike.scala b/src/library/scala/collection/TraversableOnceLike.scala deleted file mode 100644 index 462265f14a..0000000000 --- a/src/library/scala/collection/TraversableOnceLike.scala +++ /dev/null @@ -1,304 +0,0 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ - -package scala.collection - -import mutable.{ Buffer, ListBuffer, ArrayBuffer } -import annotation.unchecked.{ uncheckedVariance => uV } - -/** A template trait for collections which can be traversed either once only - * or one or more times. - * $traversableonceinfo - * - * @tparam A the element type of the collection - * - * @define traversableonceinfo - * This trait exists primarily to eliminate code duplication between - * `Iterator` and `Traversable`, and thus implements some of the common - * methods that can be implemented solely in terms of foreach without - * access to a `Builder`. It also includes a number of abstract methods - * whose implementations are provided by `Iterator`, `Traversable`, etc. - * It contains implementations common to `Iterators` and - * `Traversables`, such as folds, conversions, and other operations which - * traverse some or all of the elements and return a derived value. - * Directly subclassing `TraversableOnce` is not recommended - instead, - * consider declaring an `Iterator` with a `next` and `hasNext` method, - * creating an `Iterator` with one of the methods on the `Iterator` object, - * or declaring a subclass of `Traversable`. - * - * @author Martin Odersky - * @author Paul Phillips - * @version 2.9 - * @since 2.9 - * - * @define coll traversable or iterator - */ -trait TraversableOnceLike[+A] extends GenTraversableOnceLike[A] { - self => - - /** Self-documenting abstract methods. */ - def foreach[U](f: A => U): Unit - def isEmpty: Boolean - def hasDefiniteSize: Boolean - - // 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. - // Note 2: This is implemented in all collections _not_ inheriting `Traversable[A]` - // at least indirectly. Currently, these are `ArrayOps` and `StringOps`. - // It is also implemented in `TraversableOnce[A]`. - /** 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] - - /** 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. - */ - def forall(p: A => Boolean): Boolean - def exists(p: A => Boolean): Boolean - def find(p: A => Boolean): Option[A] - def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit - - // for internal use - protected[this] def reversed = { - var elems: List[A] = Nil - self.seq foreach (elems ::= _) - elems - } - - def size: Int = { - var result = 0 - for (x <- self) result += 1 - result - } - - def nonEmpty: Boolean = !isEmpty - - def count(p: A => Boolean): Int = { - var cnt = 0 - for (x <- this) - if (p(x)) cnt += 1 - - cnt - } - - /** Finds the first element of the $coll for which the given partial - * function is defined, and applies the partial function to it. - * - * $mayNotTerminateInf - * $orderDependent - * - * @param pf the partial function - * @return an option value containing pf applied to the first - * value for which it is defined, or `None` if none exists. - * @example `Seq("a", 1, 5L).collectFirst({ case x: Int => x*10 }) = Some(10)` - */ - def collectFirst[B](pf: PartialFunction[A, B]): Option[B] = { - for (x <- self.toIterator) { // make sure to use an iterator or `seq` - if (pf isDefinedAt x) - return Some(pf(x)) - } - None - } - - def /:[B](z: B)(op: (B, A) => B): B = foldLeft(z)(op) - - def :\[B](z: B)(op: (A, B) => B): B = foldRight(z)(op) - - def foldLeft[B](z: B)(op: (B, A) => B): B = { - var result = z - this.seq foreach (x => result = op(result, x)) - result - } - - def foldRight[B](z: B)(op: (A, B) => B): B = - reversed.foldLeft(z)((x, y) => op(y, x)) - - def reduceLeft[B >: A](op: (B, A) => B): B = { - if (isEmpty) - throw new UnsupportedOperationException("empty.reduceLeft") - - var first = true - var acc: B = 0.asInstanceOf[B] - - for (x <- self) { - if (first) { - acc = x - first = false - } - else acc = op(acc, x) - } - acc - } - - def reduceRight[B >: A](op: (A, B) => B): B = { - if (isEmpty) - throw new UnsupportedOperationException("empty.reduceRight") - - reversed.reduceLeft[B]((x, y) => op(y, x)) - } - - def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] = - if (isEmpty) None else Some(reduceLeft(op)) - - def reduceRightOption[B >: A](op: (A, B) => B): Option[B] = - if (isEmpty) None else Some(reduceRight(op)) - - def reduce[A1 >: A](op: (A1, A1) => A1): A1 = reduceLeft(op) - - def reduceOption[A1 >: A](op: (A1, A1) => A1): Option[A1] = reduceLeftOption(op) - - def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1 = foldLeft(z)(op) - - def aggregate[B](z: B)(seqop: (B, A) => B, combop: (B, B) => B): B = foldLeft(z)(seqop) - - def sum[B >: A](implicit num: Numeric[B]): B = foldLeft(num.zero)(num.plus) - - def product[B >: A](implicit num: Numeric[B]): B = foldLeft(num.one)(num.times) - - def min[B >: A](implicit cmp: Ordering[B]): A = { - if (isEmpty) - throw new UnsupportedOperationException("empty.min") - - reduceLeft((x, y) => if (cmp.lteq(x, y)) x else y) - } - - def max[B >: A](implicit cmp: Ordering[B]): A = { - if (isEmpty) - throw new UnsupportedOperationException("empty.max") - - reduceLeft((x, y) => if (cmp.gteq(x, y)) x else y) - } - - def maxBy[B](f: A => B)(implicit cmp: Ordering[B]): A = { - if (isEmpty) - throw new UnsupportedOperationException("empty.maxBy") - - reduceLeft((x, y) => if (cmp.gteq(f(x), f(y))) x else y) - } - def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A = { - if (isEmpty) - throw new UnsupportedOperationException("empty.minBy") - - reduceLeft((x, y) => if (cmp.lteq(f(x), f(y))) x else y) - } - - /** Copies all elements of this $coll to a buffer. - * $willNotTerminateInf - * @param dest The buffer to which elements are copied. - */ - def copyToBuffer[B >: A](dest: Buffer[B]): Unit = dest ++= seq - - def copyToArray[B >: A](xs: Array[B], start: Int): Unit = - copyToArray(xs, start, xs.length - start) - - def copyToArray[B >: A](xs: Array[B]): Unit = - copyToArray(xs, 0, xs.length) - - def toArray[B >: A : ClassManifest]: Array[B] = { - if (isTraversableAgain) { - val result = new Array[B](size) - copyToArray(result, 0) - result - } - else toBuffer.toArray - } - - def toTraversable: Traversable[A] - - def toList: List[A] = new ListBuffer[A] ++= seq toList - - def toIterable: Iterable[A] = toStream - - def toSeq: Seq[A] = toStream - - def toIndexedSeq[B >: A]: immutable.IndexedSeq[B] = immutable.IndexedSeq() ++ seq - - def toBuffer[B >: A]: mutable.Buffer[B] = new ArrayBuffer[B] ++= seq - - def toSet[B >: A]: immutable.Set[B] = immutable.Set() ++ seq - - def toMap[T, U](implicit ev: A <:< (T, U)): immutable.Map[T, U] = { - val b = immutable.Map.newBuilder[T, U] - for (x <- self) - b += x - - b.result - } - - def mkString(start: String, sep: String, end: String): String = - addString(new StringBuilder(), start, sep, end).toString - - def mkString(sep: String): String = mkString("", sep, "") - - def mkString: String = mkString("") - - /** Appends all elements of this $coll to a string builder using start, end, - * and separator strings. - * The written text begins with the string `start` and ends with the string - * `end`. Inside, the string representations (w.r.t. the method `toString`) - * of all elements of this $coll are separated by the string `sep`. - * - * @param b the string builder to which elements are appended. - * @param start the starting string. - * @param sep the separator string. - * @param end the ending string. - * @return the string builder `b` to which elements were appended. - */ - def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder = { - var first = true - - b append start - for (x <- self) { - if (first) { - b append x - first = false - } - else { - b append sep - b append x - } - } - b append end - - b - } - - /** Appends all elements of this $coll to a string builder using a separator - * string. The written text consists of the string representations (w.r.t. - * the method `toString`) of all elements of this $coll, separated by the - * string `sep`. - * - * @param b the string builder to which elements are appended. - * @param sep the separator string. - * @return the string builder `b` to which elements were appended. - */ - def addString(b: StringBuilder, sep: String): StringBuilder = addString(b, "", sep, "") - - /** Appends all elements of this $coll to a string builder. - * The written text consists of the string representations (w.r.t. the method - * `toString`) of all elements of this $coll without any separator string. - * - * @param b the string builder to which elements are appended. - * @return the string builder `b` to which elements were appended. - */ - def addString(b: StringBuilder): StringBuilder = addString(b, "") -} - - - diff --git a/src/library/scala/collection/generic/MutableSetFactory.scala b/src/library/scala/collection/generic/MutableSetFactory.scala index 6151da6cb3..6130ef2042 100644 --- a/src/library/scala/collection/generic/MutableSetFactory.scala +++ b/src/library/scala/collection/generic/MutableSetFactory.scala @@ -11,7 +11,7 @@ package generic import mutable.{ Builder, GrowingBuilder } -abstract class MutableSetFactory[CC[X] <: mutable.GenSet[X] with GenSetLike[X, CC[X]]] +abstract class MutableSetFactory[CC[X] <: mutable.Set[X] with mutable.SetLike[X, CC[X]]] extends SetFactory[CC] { def newBuilder[A]: Builder[A, CC[A]] = new GrowingBuilder[A, CC[A]](empty[A]) diff --git a/src/library/scala/collection/immutable/GenIterable.scala b/src/library/scala/collection/immutable/GenIterable.scala.disabled index 217d3f9496..252c721271 100644 --- a/src/library/scala/collection/immutable/GenIterable.scala +++ b/src/library/scala/collection/immutable/GenIterable.scala.disabled @@ -17,21 +17,21 @@ import mutable.Builder /** A base trait for iterable collections that can be mutated. * * $possiblyparinfo - * + * * $iterableInfo */ -trait GenIterable[+A] extends GenTraversable[A] - with scala.collection.GenIterable[A] +trait GenIterable[+A] extends GenTraversable[A] + with scala.collection.GenIterable[A] with scala.collection.GenIterableLike[A, GenIterable[A]] - with GenericTraversableTemplate[A, GenIterable] +// with GenericTraversableTemplate[A, GenIterable] { def seq: Iterable[A] - override def companion: GenericCompanion[GenIterable] = GenIterable + //override def companion: GenericCompanion[GenIterable] = GenIterable } -object GenIterable extends TraversableFactory[GenIterable] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = new GenericCanBuildFrom[A] - def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder -} +// object GenIterable extends TraversableFactory[GenIterable] { +// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = new GenericCanBuildFrom[A] +// def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder +// } diff --git a/src/library/scala/collection/immutable/GenMap.scala b/src/library/scala/collection/immutable/GenMap.scala.disabled index 9dc7242f80..eb7ef2951c 100644 --- a/src/library/scala/collection/immutable/GenMap.scala +++ b/src/library/scala/collection/immutable/GenMap.scala.disabled @@ -19,18 +19,18 @@ import generic._ * @since 1.0 * @author Matthias Zenger */ -trait GenMap[A, +B] +trait GenMap[A, +B] extends GenIterable[(A, B)] - with scala.collection.GenMap[A, B] + with scala.collection.GenMap[A, B] with scala.collection.GenMapLike[A, B, GenMap[A, B]] { def seq: Map[A, B] } -object GenMap extends MapFactory[GenMap] { - def empty[A, B]: Map[A, B] = Map.empty - - /** $mapCanBuildFromInfo */ - implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), GenMap[A, B]] = new MapCanBuildFrom[A, B] -} +// object GenMap extends MapFactory[GenMap] { +// def empty[A, B]: Map[A, B] = Map.empty + +// /** $mapCanBuildFromInfo */ +// implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), GenMap[A, B]] = new MapCanBuildFrom[A, B] +// } diff --git a/src/library/scala/collection/immutable/GenSeq.scala b/src/library/scala/collection/immutable/GenSeq.scala.disabled index d710954a18..36aff8f8e6 100644 --- a/src/library/scala/collection/immutable/GenSeq.scala +++ b/src/library/scala/collection/immutable/GenSeq.scala.disabled @@ -20,28 +20,28 @@ import mutable.Builder * that can be mutated. * * $possiblyparinfo - * + * * $seqInfo - * + * * The class adds an `update` method to `collection.Seq`. - * + * * @define Coll mutable.Seq * @define coll mutable sequence */ -trait GenSeq[+A] extends GenIterable[A] - with scala.collection.GenSeq[A] +trait GenSeq[+A] extends GenIterable[A] + with scala.collection.GenSeq[A] with scala.collection.GenSeqLike[A, GenSeq[A]] - with GenericTraversableTemplate[A, GenSeq] +// with GenericTraversableTemplate[A, GenSeq] { def seq: Seq[A] - override def companion: GenericCompanion[GenSeq] = GenSeq + //override def companion: GenericCompanion[GenSeq] = GenSeq } -object GenSeq extends SeqFactory[GenSeq] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = new GenericCanBuildFrom[A] - def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder -} +// object GenSeq extends SeqFactory[GenSeq] { +// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = new GenericCanBuildFrom[A] +// def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder +// } diff --git a/src/library/scala/collection/immutable/GenSet.scala b/src/library/scala/collection/immutable/GenSet.scala.disabled index b222db90f6..3cca6ba66e 100644 --- a/src/library/scala/collection/immutable/GenSet.scala +++ b/src/library/scala/collection/immutable/GenSet.scala.disabled @@ -30,14 +30,14 @@ import mutable.Builder trait GenSet[A] extends GenIterable[A] with scala.collection.GenSet[A] with scala.collection.GenSetLike[A, GenSet[A]] - with GenericSetTemplate[A, GenSet] +// with GenericSetTemplate[A, GenSet] { - override def companion: GenericCompanion[GenSet] = GenSet + //override def companion: GenericCompanion[GenSet] = GenSet def seq: Set[A] } -object GenSet extends TraversableFactory[GenSet] { - implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] - def newBuilder[A] = Set.newBuilder -} +// object GenSet extends TraversableFactory[GenSet] { +// implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] +// def newBuilder[A] = Set.newBuilder +// } diff --git a/src/library/scala/collection/immutable/GenTraversable.scala b/src/library/scala/collection/immutable/GenTraversable.scala.disabled index 69b4d652fb..2ee9bd9d8c 100644 --- a/src/library/scala/collection/immutable/GenTraversable.scala +++ b/src/library/scala/collection/immutable/GenTraversable.scala.disabled @@ -19,23 +19,23 @@ import mutable.Builder /** A trait for traversable collections that can be mutated. * * $possiblyparinfo - * + * * $traversableInfo * @define mutability mutable */ -trait GenTraversable[+A] extends scala.collection.GenTraversable[A] +trait GenTraversable[+A] extends scala.collection.GenTraversable[A] with scala.collection.GenTraversableLike[A, GenTraversable[A]] - with GenericTraversableTemplate[A, GenTraversable] +// with GenericTraversableTemplate[A, GenTraversable] with Mutable { def seq: Traversable[A] - override def companion: GenericCompanion[GenTraversable] = GenTraversable + //override def companion: GenericCompanion[GenTraversable] = GenTraversable } -object GenTraversable extends TraversableFactory[GenTraversable] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenTraversable[A]] = new GenericCanBuildFrom[A] - def newBuilder[A]: Builder[A, GenTraversable[A]] = Traversable.newBuilder -} +// object GenTraversable extends TraversableFactory[GenTraversable] { +// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenTraversable[A]] = new GenericCanBuildFrom[A] +// def newBuilder[A]: Builder[A, GenTraversable[A]] = Traversable.newBuilder +// } diff --git a/src/library/scala/collection/immutable/Iterable.scala b/src/library/scala/collection/immutable/Iterable.scala index 411ff38095..81579ef3b7 100644 --- a/src/library/scala/collection/immutable/Iterable.scala +++ b/src/library/scala/collection/immutable/Iterable.scala @@ -22,7 +22,7 @@ import parallel.immutable.ParIterable * @define coll immutable iterable collection */ trait Iterable[+A] extends Traversable[A] - with GenIterable[A] +// with GenIterable[A] with scala.collection.Iterable[A] with GenericTraversableTemplate[A, Iterable] with IterableLike[A, Iterable[A]] diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala index 90bc63af16..df1cfa80cd 100644 --- a/src/library/scala/collection/immutable/Map.scala +++ b/src/library/scala/collection/immutable/Map.scala @@ -26,7 +26,7 @@ import generic._ * @since 1 */ trait Map[A, +B] extends Iterable[(A, B)] - with GenMap[A, B] +// with GenMap[A, B] with scala.collection.Map[A, B] with MapLike[A, B, Map[A, B]] { self => diff --git a/src/library/scala/collection/immutable/Seq.scala b/src/library/scala/collection/immutable/Seq.scala index 39b99e9e8b..11e56df354 100644 --- a/src/library/scala/collection/immutable/Seq.scala +++ b/src/library/scala/collection/immutable/Seq.scala @@ -23,7 +23,7 @@ import parallel.immutable.ParSeq * @define coll immutable sequence */ trait Seq[+A] extends Iterable[A] - with GenSeq[A] +// with GenSeq[A] with scala.collection.Seq[A] with GenericTraversableTemplate[A, Seq] with SeqLike[A, Seq[A]] diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala index 63c62d9049..ce2b3b1885 100644 --- a/src/library/scala/collection/immutable/Set.scala +++ b/src/library/scala/collection/immutable/Set.scala @@ -25,7 +25,7 @@ import parallel.immutable.ParSet * @define coll immutable set */ trait Set[A] extends Iterable[A] - with GenSet[A] +// with GenSet[A] with scala.collection.Set[A] with GenericSetTemplate[A, Set] with SetLike[A, Set[A]] diff --git a/src/library/scala/collection/immutable/Traversable.scala b/src/library/scala/collection/immutable/Traversable.scala index 7228642d27..80839db31c 100644 --- a/src/library/scala/collection/immutable/Traversable.scala +++ b/src/library/scala/collection/immutable/Traversable.scala @@ -19,7 +19,7 @@ import mutable.Builder * @define mutability immutable */ trait Traversable[+A] extends scala.collection.Traversable[A] - with GenTraversable[A] +// with GenTraversable[A] with GenericTraversableTemplate[A, Traversable] with TraversableLike[A, Traversable[A]] with Immutable { diff --git a/src/library/scala/collection/mutable/GenIterable.scala b/src/library/scala/collection/mutable/GenIterable.scala.disabled index 60caeb14f9..7fd6a8ca2c 100644 --- a/src/library/scala/collection/mutable/GenIterable.scala +++ b/src/library/scala/collection/mutable/GenIterable.scala.disabled @@ -16,22 +16,22 @@ import generic._ /** A base trait for iterable collections that can be mutated. * * $possiblyparinfo - * + * * $iterableInfo */ -trait GenIterable[A] extends GenTraversable[A] - with scala.collection.GenIterable[A] +trait GenIterable[A] extends GenTraversable[A] + with scala.collection.GenIterable[A] with scala.collection.GenIterableLike[A, GenIterable[A]] - with GenericTraversableTemplate[A, GenIterable] +// with GenericTraversableTemplate[A, GenIterable] { def seq: Iterable[A] - override def companion: GenericCompanion[GenIterable] = GenIterable + //override def companion: GenericCompanion[GenIterable] = GenIterable } -object GenIterable extends TraversableFactory[GenIterable] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = new GenericCanBuildFrom[A] - def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder -} +// object GenIterable extends TraversableFactory[GenIterable] { +// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = new GenericCanBuildFrom[A] +// def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder +// } diff --git a/src/library/scala/collection/mutable/GenMap.scala b/src/library/scala/collection/mutable/GenMap.scala.disabled index 810fa53926..eca63b43ce 100644 --- a/src/library/scala/collection/mutable/GenMap.scala +++ b/src/library/scala/collection/mutable/GenMap.scala.disabled @@ -22,19 +22,19 @@ import generic._ * @since 1.0 * @author Matthias Zenger */ -trait GenMap[A, B] +trait GenMap[A, B] extends GenIterable[(A, B)] - with scala.collection.GenMap[A, B] + with scala.collection.GenMap[A, B] with scala.collection.GenMapLike[A, B, GenMap[A, B]] { def seq: Map[A, B] } -object GenMap extends MapFactory[GenMap] { - def empty[A, B]: Map[A, B] = Map.empty - - /** $mapCanBuildFromInfo */ - implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), GenMap[A, B]] = new MapCanBuildFrom[A, B] -} +// object GenMap extends MapFactory[GenMap] { +// def empty[A, B]: Map[A, B] = Map.empty + +// /** $mapCanBuildFromInfo */ +// implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), GenMap[A, B]] = new MapCanBuildFrom[A, B] +// } diff --git a/src/library/scala/collection/mutable/GenSeq.scala b/src/library/scala/collection/mutable/GenSeq.scala.disabled index 8e1f727bbb..376a2ceb8b 100644 --- a/src/library/scala/collection/mutable/GenSeq.scala +++ b/src/library/scala/collection/mutable/GenSeq.scala.disabled @@ -19,26 +19,26 @@ import generic._ * that can be mutated. * * $possiblyparinfo - * + * * $seqInfo - * + * * The class adds an `update` method to `collection.Seq`. - * + * * @define Coll mutable.Seq * @define coll mutable sequence */ -trait GenSeq[A] extends GenIterable[A] - with scala.collection.GenSeq[A] +trait GenSeq[A] extends GenIterable[A] + with scala.collection.GenSeq[A] with scala.collection.GenSeqLike[A, GenSeq[A]] - with GenericTraversableTemplate[A, GenSeq] +// with GenericTraversableTemplate[A, GenSeq] { - override def companion: GenericCompanion[GenSeq] = GenSeq + //override def companion: GenericCompanion[GenSeq] = GenSeq def seq: Seq[A] } -object GenSeq extends SeqFactory[GenSeq] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = new GenericCanBuildFrom[A] - def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder -} +// object GenSeq extends SeqFactory[GenSeq] { +// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = new GenericCanBuildFrom[A] +// def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder +// } diff --git a/src/library/scala/collection/mutable/GenSet.scala b/src/library/scala/collection/mutable/GenSet.scala.disabled index d8f591d0ab..7416577a6a 100644 --- a/src/library/scala/collection/mutable/GenSet.scala +++ b/src/library/scala/collection/mutable/GenSet.scala.disabled @@ -31,16 +31,16 @@ trait GenSet[A] extends GenIterable[A] with Growable[A] with scala.collection.GenSet[A] with scala.collection.GenSetLike[A, GenSet[A]] - with GenericSetTemplate[A, GenSet] +// with GenericSetTemplate[A, GenSet] { - override def companion: GenericCompanion[GenSet] = GenSet + //override def companion: GenericCompanion[GenSet] = GenSet def seq: Set[A] } -object GenSet extends TraversableFactory[GenSet] { - implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSet[A]] = new GenericCanBuildFrom[A] - def newBuilder[A]: Builder[A, GenSet[A]] = Set.newBuilder -} +// object GenSet extends TraversableFactory[GenSet] { +// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSet[A]] = new GenericCanBuildFrom[A] +// def newBuilder[A]: Builder[A, GenSet[A]] = Set.newBuilder +// } diff --git a/src/library/scala/collection/mutable/GenTraversable.scala b/src/library/scala/collection/mutable/GenTraversable.scala.disabled index b1eec9f471..1ad9bfa9ca 100644 --- a/src/library/scala/collection/mutable/GenTraversable.scala +++ b/src/library/scala/collection/mutable/GenTraversable.scala.disabled @@ -18,21 +18,21 @@ import generic._ /** A trait for traversable collections that can be mutated. * * $possiblyparinfo - * + * * $traversableInfo * @define mutability mutable */ -trait GenTraversable[A] extends scala.collection.GenTraversable[A] +trait GenTraversable[A] extends scala.collection.GenTraversable[A] with scala.collection.GenTraversableLike[A, GenTraversable[A]] - with GenericTraversableTemplate[A, GenTraversable] +// with GenericTraversableTemplate[A, GenTraversable] with Mutable { def seq: Traversable[A] - override def companion: GenericCompanion[GenTraversable] = GenTraversable + //override def companion: GenericCompanion[GenTraversable] = GenTraversable } -object GenTraversable extends TraversableFactory[GenTraversable] { - implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] - def newBuilder[A] = Traversable.newBuilder -} +// object GenTraversable extends TraversableFactory[GenTraversable] { +// implicit def canBuildFrom[A] = new GenericCanBuildFrom[A] +// def newBuilder[A] = Traversable.newBuilder +// } diff --git a/src/library/scala/collection/mutable/Iterable.scala b/src/library/scala/collection/mutable/Iterable.scala index e9ec25ced3..1a5e58b504 100644 --- a/src/library/scala/collection/mutable/Iterable.scala +++ b/src/library/scala/collection/mutable/Iterable.scala @@ -15,7 +15,7 @@ import parallel.mutable.ParIterable * $iterableInfo */ trait Iterable[A] extends Traversable[A] - with GenIterable[A] +// with GenIterable[A] with scala.collection.Iterable[A] with GenericTraversableTemplate[A, Iterable] with IterableLike[A, Iterable[A]] diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala index e1e6115cfe..561dcc9399 100644 --- a/src/library/scala/collection/mutable/Map.scala +++ b/src/library/scala/collection/mutable/Map.scala @@ -21,7 +21,7 @@ import generic._ */ trait Map[A, B] extends Iterable[(A, B)] - with GenMap[A, B] +// with GenMap[A, B] with scala.collection.Map[A, B] with MapLike[A, B, Map[A, B]] { diff --git a/src/library/scala/collection/mutable/Seq.scala b/src/library/scala/collection/mutable/Seq.scala index d7f50b73ea..42b4ac5c15 100644 --- a/src/library/scala/collection/mutable/Seq.scala +++ b/src/library/scala/collection/mutable/Seq.scala @@ -25,7 +25,7 @@ import generic._ * @define coll mutable sequence */ trait Seq[A] extends Iterable[A] - with GenSeq[A] +// with GenSeq[A] with scala.collection.Seq[A] with GenericTraversableTemplate[A, Seq] with SeqLike[A, Seq[A]] { diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala index 124af46f76..30fc3682fd 100644 --- a/src/library/scala/collection/mutable/Set.scala +++ b/src/library/scala/collection/mutable/Set.scala @@ -23,7 +23,7 @@ import generic._ * @define coll mutable set */ trait Set[A] extends Iterable[A] - with GenSet[A] +// with GenSet[A] with scala.collection.Set[A] with GenericSetTemplate[A, Set] with SetLike[A, Set[A]] { diff --git a/src/library/scala/collection/mutable/Traversable.scala b/src/library/scala/collection/mutable/Traversable.scala index 64c6fb42d9..b711e0b4db 100644 --- a/src/library/scala/collection/mutable/Traversable.scala +++ b/src/library/scala/collection/mutable/Traversable.scala @@ -18,7 +18,7 @@ import generic._ * @define mutability mutable */ trait Traversable[A] extends scala.collection.Traversable[A] - with GenTraversable[A] +// with GenTraversable[A] with GenericTraversableTemplate[A, Traversable] with TraversableLike[A, Traversable[A]] with Mutable { diff --git a/src/library/scala/collection/parallel/immutable/ParIterable.scala b/src/library/scala/collection/parallel/immutable/ParIterable.scala index 8a03c8a57a..d8c42d74b0 100644 --- a/src/library/scala/collection/parallel/immutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/immutable/ParIterable.scala @@ -30,7 +30,7 @@ import scala.collection.GenIterable * @since 2.9 */ trait ParIterable[+T] -extends collection.immutable.GenIterable[T] +extends collection/*.immutable*/.GenIterable[T] with collection.parallel.ParIterable[T] with GenericParTemplate[T, ParIterable] with ParIterableLike[T, ParIterable[T], collection.immutable.Iterable[T]] diff --git a/src/library/scala/collection/parallel/immutable/ParMap.scala b/src/library/scala/collection/parallel/immutable/ParMap.scala index 5dd4c3f35f..a44a8c965e 100644 --- a/src/library/scala/collection/parallel/immutable/ParMap.scala +++ b/src/library/scala/collection/parallel/immutable/ParMap.scala @@ -38,7 +38,7 @@ import scala.collection.GenMapLike * @since 2.9 */ trait ParMap[K, +V] -extends collection.immutable.GenMap[K, V] +extends collection/*.immutable*/.GenMap[K, V] with GenericParMapTemplate[K, V, ParMap] with parallel.ParMap[K, V] with ParIterable[(K, V)] diff --git a/src/library/scala/collection/parallel/immutable/ParSeq.scala b/src/library/scala/collection/parallel/immutable/ParSeq.scala index 901d4f204d..bf3d3a5aa8 100644 --- a/src/library/scala/collection/parallel/immutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/immutable/ParSeq.scala @@ -28,7 +28,7 @@ import scala.collection.GenSeq * @define coll mutable parallel sequence */ trait ParSeq[+T] -extends collection.immutable.GenSeq[T] +extends collection/*.immutable*/.GenSeq[T] with collection.parallel.ParSeq[T] with ParIterable[T] with GenericParTemplate[T, ParSeq] diff --git a/src/library/scala/collection/parallel/immutable/ParSet.scala b/src/library/scala/collection/parallel/immutable/ParSet.scala index 64fb826d35..a39607ba03 100644 --- a/src/library/scala/collection/parallel/immutable/ParSet.scala +++ b/src/library/scala/collection/parallel/immutable/ParSet.scala @@ -30,7 +30,7 @@ import scala.collection.parallel.Combiner * @define coll mutable parallel set */ trait ParSet[T] -extends collection.immutable.GenSet[T] +extends collection/*.immutable*/.GenSet[T] with GenericParTemplate[T, ParSet] with parallel.ParSet[T] with ParIterable[T] diff --git a/src/library/scala/collection/parallel/mutable/ParIterable.scala b/src/library/scala/collection/parallel/mutable/ParIterable.scala index c07ed69ed5..700d21d0bb 100644 --- a/src/library/scala/collection/parallel/mutable/ParIterable.scala +++ b/src/library/scala/collection/parallel/mutable/ParIterable.scala @@ -26,7 +26,7 @@ import scala.collection.GenIterable * @author Aleksandar Prokopec * @since 2.9 */ -trait ParIterable[T] extends collection.mutable.GenIterable[T] +trait ParIterable[T] extends collection/*.mutable*/.GenIterable[T] with collection.parallel.ParIterable[T] with GenericParTemplate[T, ParIterable] with ParIterableLike[T, ParIterable[T], Iterable[T]] { diff --git a/src/library/scala/collection/parallel/mutable/ParMap.scala b/src/library/scala/collection/parallel/mutable/ParMap.scala index 477e111024..91c2b3d2b2 100644 --- a/src/library/scala/collection/parallel/mutable/ParMap.scala +++ b/src/library/scala/collection/parallel/mutable/ParMap.scala @@ -28,7 +28,7 @@ import collection.parallel.Combiner * @since 2.9 */ trait ParMap[K, V] -extends collection.mutable.GenMap[K, V] +extends collection/*.mutable*/.GenMap[K, V] with collection.parallel.ParMap[K, V] with /* mutable */ ParIterable[(K, V)] with GenericParMapTemplate[K, V, ParMap] diff --git a/src/library/scala/collection/parallel/mutable/ParSeq.scala b/src/library/scala/collection/parallel/mutable/ParSeq.scala index 401e4f900d..a48ba48d56 100644 --- a/src/library/scala/collection/parallel/mutable/ParSeq.scala +++ b/src/library/scala/collection/parallel/mutable/ParSeq.scala @@ -29,7 +29,7 @@ import scala.collection.GenSeq * @define Coll mutable.ParSeq * @define coll mutable parallel sequence */ -trait ParSeq[T] extends collection.mutable.GenSeq[T] // was: collection.mutable.Seq[T] +trait ParSeq[T] extends collection/*.mutable*/.GenSeq[T] // was: collection.mutable.Seq[T] with ParIterable[T] with collection.parallel.ParSeq[T] with GenericParTemplate[T, ParSeq] diff --git a/src/library/scala/collection/parallel/mutable/ParSet.scala b/src/library/scala/collection/parallel/mutable/ParSet.scala index 39e6f827cd..1d295fd5fe 100644 --- a/src/library/scala/collection/parallel/mutable/ParSet.scala +++ b/src/library/scala/collection/parallel/mutable/ParSet.scala @@ -27,7 +27,7 @@ import scala.collection.GenSet * @author Aleksandar Prokopec */ trait ParSet[T] -extends collection.mutable.GenSet[T] +extends collection/*.mutable*/.GenSet[T] with ParIterable[T] with collection.parallel.ParSet[T] with GenericParTemplate[T, ParSet] |