summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/SeqViewLike.scala
Commit message (Collapse)AuthorAgeFilesLines
* Merge commit 'fcc20fe' into merge/2.11-to-2.12-apr-1Lukas Rytz2015-04-011-1/+1
|\
| * SI-9172 FlatMapped views throw exception on filterRex Kerr2015-02-221-1/+1
| | | | | | | | | | | | Errant `self.length` changed to `length`. No tests; found and tested by collections-laws.
* | Merge commit '7ba38a0' into merge/2.11.x-to-2.12.x-20150129Jason Zaugg2015-01-291-1/+2
|\| | | | | | | | | | | | | | | Conflicts: build.number src/compiler/scala/tools/nsc/transform/ExtensionMethods.scala src/library/scala/collection/Iterator.scala versions.properties
| * SI-8950 SeqView and StreamView allow indexing out of a sliceRex Kerr2014-12-061-1/+1
| | | | | | | | | | | | Added `idx >= 0` tests for `SeqViewLike#Sliced` `apply` and `mutable.IndexedSeqViewLike#Sliced` `unapply`. Now you get `IndexOutOfBoundsException`s as you should. No tests; this was found by collections-laws and will be tested by them. (Exact variants in bug report were tested in the REPL.)
| * SI-8951 SeqView and StreamView stack-overflow on negative index after flatMapRex Kerr2014-11-211-0/+1
| | | | | | | | | | | | Checks and throws IndexOutOfBounds now. No test, caught and checked by scala-collections-laws (line 405 presently).
* | SI-8691 SeqView throws exception when prepending a collectionRex Kerr2014-12-061-12/+10
|/ | | | | | | | Prepend was throwing segfaults as it was handled differently from Append. This brings the two into line with each other. There are various optimizations that could be applied that have not been, however, such as intercepting sequential prepends and generating one multi-prepend instead of nested single-element prepends. Unit test added to verify minimally that bug is gone.
* SI-8474 Inconsistent behavior of patch methodRex Kerr2014-08-241-5/+18
| | | | | | | | Changed Iterator to be consistent with other collections. Also fixed SeqViewLike to validate/constrain inputs. No specific tests; quasi-comprehensive collection tests will cover this later.
* Merge pull request #3191 from retronym/ticket/deprecate-par-viewJason Zaugg2013-12-061-18/+126
|\ | | | | Remove parallel collection views and, with them, Gen*View
| * Removes Gen*View and Par*ViewJason Zaugg2013-11-261-18/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - code that used to be inherited in *View is now inlined - the `view` methods on `ParIteratoa` and `ParSeq` now convert to sequential collections, and are deprecated asking the user to do this explicitly in the future. Should be largely source compatible with 2.10.x, on the assumption that the removed classes, while being public, were internal implementation details. A few tests used now-removed classes to demonstrate compiler crashes. I managed to confirm that after my decoupling, t4365 still exercises the bug: % qbin/scalac test/files/pos/t4365/*.scala warning: there were 2 deprecation warning(s); re-run with -deprecation for details one warning found % scalac-hash 7b4e450 test/files/pos/t4365/*.scala warning: there were 2 deprecation warning(s); re-run with -deprecation for details one warning found % scalac-hash 7b4e450~1 test/files/pos/t4365/*.scala 2<&1 | grep -i wrong error: something is wrong: cannot make sense of type application something is wrong: cannot make sense of type application something is wrong: cannot make sense of type application I didn't manage to do the same for specializes-sym-crash.scala, and instead just made it compile.
* | SI-4332 Plugs the gaps in viewsJason Zaugg2013-11-261-0/+15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These currently result in runtime errors: scala> List(1).view.distinct.force java.lang.UnsupportedOperationException: SeqView(...).newBuilder scala> List(1).view.inits.toList java.lang.UnsupportedOperationException: SeqView(...).newBuilder Two tests are enclosed: 1. reflect on the views to make any method that returns `Repr` is overriden in `*ViewLike`. This guards against new additions to the collections API. 2. exercise the newly added overrides Some care is needed with `tail`, we must re-override it in `mutable.IndexedSeqView` to be explicit about the end point of the slice, because the `IndexedSeqView#Sliced` defines length in terms of that. (Higher up the chain, it is just `iterator.size`, that's why `SeqView#tail` just sets up a slice from `1 to Int.MaxValue`.) Parallel collections views are not touched, as these are likely to be deprecated or removed shortly. Before this change, the test reported the following. Not all of these methods were buggy. For instance, `sortBy`, `sortWith` are implemented in terms of `sorted` which was implemented in `SeqViewLike`. Even in those cases, I have opted to override the methods in the `ViewLike` to guard against changes in the base class implementation and to simplify the rules in the test. ====================================================================== Checking scala.collection.TraversableView ====================================================================== trait TraversableLike ---------------------------------------------------------------------- def filterNot(p: A => Boolean): Repr def inits: Iterator[Repr] def tails: Iterator[Repr] override def tail: Repr ====================================================================== Checking scala.collection.IterableView ====================================================================== trait IterableLike ---------------------------------------------------------------------- def dropRight(n: Int): Repr def sliding(size: Int): Iterator[Repr] def takeRight(n: Int): Repr trait TraversableLike ---------------------------------------------------------------------- def filterNot(p: A => Boolean): Repr def inits: Iterator[Repr] def tails: Iterator[Repr] override def tail: Repr ====================================================================== Checking scala.collection.SeqView ====================================================================== trait IterableLike ---------------------------------------------------------------------- def dropRight(n: Int): Repr def sliding(size: Int): Iterator[Repr] def takeRight(n: Int): Repr trait SeqLike ---------------------------------------------------------------------- def combinations(n: Int): Iterator[Repr] def distinct: Repr def permutations: Iterator[Repr] def sortBy[B](f: A => B)(implicit ord: scala.math.Ordering[B]): Repr def sortWith(lt: (A, A) => Boolean): Repr trait TraversableLike ---------------------------------------------------------------------- def filterNot(p: A => Boolean): Repr def inits: Iterator[Repr] def tails: Iterator[Repr] override def tail: Repr ====================================================================== Checking scala.collection.mutable.IndexedSeqView ====================================================================== trait IndexedSeqOptimized ---------------------------------------------------------------------- override def dropRight(n: Int): Repr override def tail: Repr override def takeRight(n: Int): Repr trait IterableLike ---------------------------------------------------------------------- def sliding(size: Int): Iterator[Repr] trait SeqLike ---------------------------------------------------------------------- def combinations(n: Int): Iterator[Repr] def distinct: Repr def permutations: Iterator[Repr] def sortBy[B](f: A => B)(implicit ord: scala.math.Ordering[B]): Repr def sortWith(lt: (A, A) => Boolean): Repr trait TraversableLike ---------------------------------------------------------------------- def filterNot(p: A => Boolean): Repr def inits: Iterator[Repr] def tails: Iterator[Repr] ====================================================================== Checking scala.collection.immutable.StreamView ====================================================================== trait IterableLike ---------------------------------------------------------------------- def dropRight(n: Int): Repr def sliding(size: Int): Iterator[Repr] def takeRight(n: Int): Repr trait SeqLike ---------------------------------------------------------------------- def combinations(n: Int): Iterator[Repr] def distinct: Repr def permutations: Iterator[Repr] def sortBy[B](f: A => B)(implicit ord: scala.math.Ordering[B]): Repr def sortWith(lt: (A, A) => Boolean): Repr trait TraversableLike ---------------------------------------------------------------------- def filterNot(p: A => Boolean): Repr def inits: Iterator[Repr] def tails: Iterator[Repr] override def tail: Repr
* Absolutized paths involving the scala package.Paul Phillips2013-05-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Confusing, now-it-happens now-it-doesn't mysteries lurk in the darkness. When scala packages are declared like this: package scala.collection.mutable Then paths relative to scala can easily be broken via the unlucky presence of an empty (or nonempty) directory. Example: // a.scala package scala.foo class Bar { new util.Random } % scalac ./a.scala % mkdir util % scalac ./a.scala ./a.scala:4: error: type Random is not a member of package util new util.Random ^ one error found There are two ways to play defense against this: - don't use relative paths; okay sometimes, less so others - don't "opt out" of the scala package This commit mostly pursues the latter, with occasional doses of the former. I created a scratch directory containing these empty directories: actors annotation ant api asm beans cmd collection compat concurrent control convert docutil dtd duration event factory forkjoin generic hashing immutable impl include internal io logging macros man1 matching math meta model mutable nsc parallel parsing partest persistent process pull ref reflect reify remote runtime scalap scheduler script swing sys text threadpool tools transform unchecked util xml I stopped when I could compile the main src directories even with all those empties on my classpath.
* Remove unused imports in library.Paul Phillips2012-11-191-1/+0
|
* Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013Heather Miller2012-11-021-1/+1
|
* Fix SI-5971.Aleksandar Prokopec2012-06-271-1/+1
| | | | | | | | | When using `AbstractTransformed` abstract inner class in views in order to force generating bridges, one must take care to push the corresponding collection trait (such as `Iterable` or `Seq`) as far as possible to the left in the linearization order -- otherwise, overridden methods from these traits can override the already overridden methods in view. This was the case with `takeWhile`.
* Removed all the imports of the bridge annotation.Paul Phillips2012-04-281-1/+0
| | | | Now that nothing uses it.
* Removes @bridge methods.Simon Ochsenreither2012-04-281-4/+0
|
* Dropped about 1.5 Mb off scala-library.jar.Paul Phillips2011-11-071-13/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit and the two subsequent commits were contributed by: Todd Vierling <tv@duh.org>. I combined some commits and mangled his commit messages, but all the credit is his. This pursues the same approach to classfile reduction seen in r19989 when AbstractFunctionN was introduced, but applies it to the collections. Thanks to -Xlint it's easy to verify that the private types don't escape. Design considerations as articulated by Todd: * Don't necessarily create concrete types for _everything_. Where a subtrait only provides a few additional methods, don't bother; instead, use the supertrait's concrete class and retain the "with". For example, "extends AbstractSeq[A] with LinearSeq[A]". * Examine all classes with .class file size greater than 10k. Named classes and class names ending in $$anon$<num> are candidates for analysis. * If a return type is currently inferred where an anon subclass would be returned, make the return type explicit. Don't allow the library-private abstract classes to leak into the public namespace [and scaladoc].
* 2nd round of clean ups (see r25285)michelou2011-07-151-5/+2
|
* More bridges in collections. Review by prokopec.Martin Odersky2011-04-271-0/+5
|
* One of the blips in the performance charts seem...Paul Phillips2011-04-201-0/+4
| | | | | | | | | | One of the blips in the performance charts seems to implicate some changes I made with slice to reduce the number of implementations and surface area for inconsistencies and bugs. Altering those changes in a more performance-mindful way, although I don't see anything here which is likely to help much. Also fixing some wrong documentation about copyToArray. No review.
* Refactoring the collections api to support diff...Aleksandar Pokopec2011-04-131-134/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactoring the collections api to support differentiation between referring to a sequential collection and a parallel collection, and to support referring to both types of collections. New set of traits Gen* are now superclasses of both their * and Par* subclasses. For example, GenIterable is a superclass of both Iterable and ParIterable. Iterable and ParIterable are not in a subclassing relation. The new class hierarchy is illustrated below (simplified, not all relations and classes are shown): TraversableOnce --> GenTraversableOnce ^ ^ | | Traversable --> GenTraversable ^ ^ | | Iterable --> GenIterable <-- ParIterable ^ ^ ^ | | | Seq --> GenSeq <-- ParSeq (the *Like, *View and *ViewLike traits have a similar hierarchy) General views extract common view functionality from parallel and sequential collections. This design also allows for more flexible extensions to the collections framework. It also allows slowly factoring out common functionality up into Gen* traits. From now on, it is possible to write this: import collection._ val p = parallel.ParSeq(1, 2, 3) val g: GenSeq[Int] = p // meaning a General Sequence val s = g.seq // type of s is Seq[Int] for (elem <- g) { // do something without guarantees on sequentiality of foreach // this foreach may be executed in parallel } for (elem <- s) { // do something with a guarantee that foreach is executed in order, sequentially } for (elem <- p) { // do something concurrently, in parallel } This also means that some signatures had to be changed. For example, method `flatMap` now takes `A => GenTraversableOnce[B]`, and `zip` takes a `GenIterable[B]`. Also, there are mutable & immutable Gen* trait variants. They have generic companion functionality.
* Fixed up the regression I slipped in with slice.Paul Phillips2011-03-121-1/+5
| | | | | for pointing me toward the problem. No review.
* A patch for views. Most relevant change:Paul Phillips2011-03-111-55/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Almost all view classes now list parents like trait Appended[B >: A] extends super.Appended[B] with Transformed[B] instead of the former trait Appended[B >: A] extends Transformed[B] with super.Appended[B] because as it was, the implementation of foreach in TraversableViewLike#Transformed was repeatedly trumping overrides found in e.g. IterableLike. This change was not without its own consequences, and much of the rest of the patch is dealing with that. A more general issue is clearly revealed here: there is no straightforward way to deal with trait composition and overrides when some methods should prefer B over A and some the reverse. (It's more like A through Z in this case.) That closes #4279, with some views being five orders of magnitude slower than necessary. There is a test that confirms they'll stay performance neighbors. In the view classes (Zipped, Mapped, etc.) I attended to them with comb and brush until they were reasonably consistent. I only use "override" where necessary and throw in some "final" in the interests of trying to anchor the composition outcome. I also switched the newSliced, newZipped, etc. methods to use early init syntax since a number have abstract vals and I found at least one bug originating with uninitialized access. There was a piece of a parallel collections scalacheck test failing, which I disabled out of expedience - am emailing prokopec. There is plenty of work left to do but paulp must get back to other 2.9 issues. This is the Zurich->SF airplane patch. No review.
* Updated copyright notices to 2011Antonio Cunei2011-01-201-1/+1
|
* The initial implementation of TraversableOnce c...Paul Phillips2010-11-291-1/+1
| | | | | | | | | | | | | | | | | | The initial implementation of TraversableOnce could not supply concrete methods or even signatures for map and flatMap because they have different signatures in Iterator and TraversableLike. But we can take another approach which works out as nicely: 1) Create implicits which install those methods and flatten on TraversableOnce instances. 2) Generalize the signatures of flatten and flatMap to work with A => TraversableOnce[B] instead of A => Traversable[B]. And voila, you can mix and match Iterators and Traversables in a for comprehension, map, flatMap, and flatten, without the tedious process of sprinkling .iterator or .toList around to appease the compiler. No review.
* Removed more than 3400 svn '$Id' keywords and r...Antonio Cunei2010-05-121-1/+0
| | | | | Removed more than 3400 svn '$Id' keywords and related junk.
* more documentationMartin Odersky2010-04-131-4/+13
|
* Spring cleaning of collection libraries.Martin Odersky2010-03-191-5/+44
| | | | | | If people think some operations can be more lazy, please provide patches/do changes. Also brought proxies and forwarders into line.
* Reverts r20311 since I'm not seeing what's goin...Paul Phillips2010-01-131-6/+20
| | | | | | Reverts r20311 since I'm not seeing what's going on in #2876 and the optimization can wait.
* Created team of private[collection] abstract cl...Paul Phillips2009-12-231-20/+6
| | | | | | | | | | | | Created team of private[collection] abstract classes and traits in scala.collection.views. Factored boilerplate and base Transformed traits out of *ViewLike classes. Executive summary and motivation: 4812029 Dec 23 09:47 scala-library.jar // before 4604150 Dec 23 09:24 scala-library.jar // after Direct size savings of 4.5%. Review by odersky.
* fixed #2548 - reverse, reverseIterator for view...Aleksandar Pokopec2009-12-221-1/+10
| | | | | | fixed #2548 - reverse, reverseIterator for views bug. Also - reverseMap for views now should work. review by phaller.
* Updated copyright notices to 2010Antonio Cunei2009-12-071-1/+1
|
* renamed BuilderFactory[El, To, From] -> CanBuil...Adriaan Moors2009-10-211-2/+2
| | | | | | | | | | | | | | | | | | | | | renamed BuilderFactory[El, To, From] -> CanBuildFrom[From, El, To] and added apply() overload to create collections from scratch generically added def apply() overload to BuilderFactory so that we can also create collections from scratch generically (see test test/files/pos/collectGenericCC.scala) renaming: - BuilderFactory[El, To, From] -> CanBuildFrom[From, El, To] bulk type-param reordering using: s/CanBuildFrom\[\s*([^,()\s]*)\s*,(\s+[^\s,()]*)\s*,\s+([^\s,()]*)\s*\]/CanBuildFrom[$3, $1,$2]/ some argument lists got mixed up because they contained 4 comma's... - builderFactory -> canBuildFrom removed explicit implicit value in DocDriver that was renamed renamed collection/generic/BuilderFactory.scala -> collection/generic/CanBuildFrom.scala tested with clean build using ant strap.done -- everything went well on my machine
* added methods updated +: :+ to SeqLikeTiark Rompf2009-10-141-0/+2
|
* reverted immutable.Vector because it gave rando...Martin Odersky2009-10-121-5/+19
| | | | | | reverted immutable.Vector because it gave random build errors on my machine. Fixed various tickets, updated test and check files.
* Sequence->SeqMartin Odersky2009-10-021-0/+156