summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/IterableLike.scala
Commit message (Collapse)AuthorAgeFilesLines
* Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-181-6/+5
| | | | | | | | | | - Language imports are preceding other imports - Deleted empty file: InlineErasure - Removed some unused private[parallel] methods in scala/collection/parallel/package.scala This removes hundreds of warnings when compiling with "-Xlint -Ywarn-dead-code -Ywarn-unused -Ywarn-unused-import".
* Optimization of IterableLike.scalaRex Kerr2015-02-161-6/+6
| | | | | | Changed takeRight to have two tighter loops instead of one with a conditional. See about 10% performance improvement. Other changes were (surprisingly, in some cases) not a win. Overall, IterableLike is pretty well optimized.
* Scala doc update (sliding method). Added info about default step set to 1. ↵BartekJanota2015-02-041-1/+2
| | | | | | | | Reading this doc (having no code) can be ambiguous. updated scala doc (overloaded sliding method) Step is a method parameter and must be always given explicit, so info about default value is wrong.
* Collections library tidying and deprecation. Separate parts are listed below.Rex Kerr2013-11-071-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Collections library tidying, part one: scripting. Everything in scala.collection.scripting is deprecated now, along with the << method that is implemented in a few other classes. Scripting does not seem used at all, and anyone who did can easily write a wrapper that does the same thing. Deprecated *Proxy collections. The only place proxies were used in the library was in swing.ListView, and that was easy to change to a lazy val. Proxy itself is used in ScalaNumberProxy and such, so it was left undeprecated. Deprecated Synchronized* traits from collections. Synchronizability does not compose well, and it requires careful examination of every method (which has not actually been done). Places where the Scala codebase needs to be fixed (eventually) include: scala.reflect.internal.util.Statistics$QuantMap scala.tools.nsc.interactive.Global (several places) Deprecated LinkedList (including Double- and -Like variants). Interface is idiosyncratic and dangerously low-level. Although some low-level functionality of this sort would be useful, this doesn't seem to be the ideal implementation. Also deprecated the extractFirst method in Queue as it exposes LinkedList. Cannot shift internal representations away from LinkedList at this time because of that method. Deprecated non-finality of several toX collection methods. Improved documentation of most toX collection methods to describe what the expectation is for their behavior. Additionally deprecated overriding of - toIterator in IterableLike (should always forward to iterator) - toTraversable in TraversableLike (should always return self) - toIndexedSeq in immutable.IndexedSeq (should always return self) - toMap in immutable.Map (should always return self) - toSet in immutable.Set (should always return self) Did not do anything with IterableLike.toIterable or Seq/SeqLike.toSeq since for some odd reason immutable.Range overrides those. Deprecated Forwarders from collections. Forwarding, without an automatic mechanism to keep up to date with changes in the forwarded class, is inherently unreliable. Absent a mechanism to keep current, they're deprecated. ListBuffer is the only class in the collections library that uses forwarders, and that functionality can be rolled into ListBuffer itself. Deprecating immutable set/map adaptors. They're a bad idea (barring compiler support) for the same reason that all the other adaptors are a bad idea: they get out of date and probably have a variety of performance bugs. Deprecated inheritance from leaf classes in immutable collections. Inheriting from leaf-classes in immutable collections is rarely a good idea since whenever you use any interesting collections method you'll revert to the original class. Also, the methods are often designed to work with only particular behavior, and an override would be difficult (at best) to make work. Fortunately, people seem to have realized this and there are few to no cases of people extending PagedSeq and TreeSet and the like. Note that in many cases the classes will become sealed not final. Deprecated overriding of methods and inheritance from various mutable collections. Some mutable collections seem unsuited for overriding since to override anything interesting you would need vast knowledge of internal data structures and/or access to private methods. These include - ArrayBuilder.ofX classes. - ArrayOps - Some methods of BitSet (moved others from private to protected final) - Some methods of HashTable and FlatHashTable - Some methods of HashMap and HashSet (esp += and -= which just forward) - Some methods of other maps and sets (LinkedHashX, ListMap, TreeSet) - PriorityQueue - UnrolledBuffer This is a somewhat aggressive deprecation, the theory being better to try it out now and back off if it's too much than not attempt the change and be stuck with collections that can neither be safely inherited nor have implementation details changed. Note that I have made no changes--in this commit--which would cause deprecation warnings in any of the Scala projects available on Maven (at least as gathered by Adriaan). There are deprecation warnings induced within the library (esp. for classes/traits that should become static) and the compiler. I have not attempted to fix all the deprecations in the compiler as some of them touch the IDE API (but these mostly involved Synchronized which is inherently unsafe, so this should be fixed eventually in coordination with the IDE code base(s)). Updated test checks to include new deprecations. Used a higher level implementation for messages in JavapClass.
* Collections: remove redundant calls to .seqJason Zaugg2013-10-311-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Students of Scala's history might recall that at introduction of parallel collections, GenIterable et al were *not* added; instead the parallel collections inherited from the existing interfaces. This of course was an invitation to widespread disaster as any existing code that foreach-ed over a collection might now experience unwanted concurrency. The first attempt to fix this was to add the `.seq` method to convert a parallel colleciton to a sequential one. This was added in e579152f732, and call sites in the standard library with side-effecting foreach calls were changed to use that. But this was (rightly) deemed inadequate, as we could hardly expect people to change existing code or remember to do this in new code. So later, in 3de96153e5b, GenIterable was sprouted, and parallel collections were re-parented. This commit removes residual needless calls to .seq when the static type of the receiver is already a plain Iterable, which are no-ops.
* IterableLike.grouped() : More explicit documentationValerian2013-10-141-1/+1
|
* IterableLike grouped : fix documentationValerian2013-10-101-1/+1
| | | | scala> Seq(1,2,3).grouped(2).toList res1: List[Seq[Int]] = List(List(1, 2), List(3))
* Cull extraneous whitespace.Paul Phillips2013-09-181-1/+1
| | | | | | | | | | | | | | | | | | | | | One last flurry with the broom before I leave you slobs to code in your own filth. Eliminated all the trailing whitespace I could manage, with special prejudice reserved for the test cases which depended on the preservation of trailing whitespace. Was reminded I cannot figure out how to eliminate the trailing space on the "scala> " prompt in repl transcripts. At least reduced the number of such empty prompts by trimming transcript code on the way in. Routed ConsoleReporter's "printMessage" through a trailing whitespace stripping method which might help futureproof against the future of whitespace diseases. Deleted the up-to-40 lines of trailing whitespace found in various library files. It seems like only yesterday we performed whitespace surgery on the whole repo. Clearly it doesn't stick very well. I suggest it would work better to enforce a few requirements on the way in.
* More explicit empty paren lists in method calls.Jason Zaugg2013-02-241-24/+24
|
* Fixes SI-6628, Revert "Fix for view isEmpty."Paul Phillips2012-11-151-2/+1
| | | | | | This reverts commit caf7eb6b56817fd1e1fbc1cf017f30e6f94c6bea. I don't have a better idea right now than wholesale reversion.
* Brings all copyrights (in comments) up-to-date, from 2011/12 to 2013Heather Miller2012-11-021-1/+1
|
* More relative path elimination.Paul Phillips2012-09-151-2/+2
| | | | | | | | | | | | | | | | Some names I missed in 55b609458fd . How one might know when one is done: mkdir scratch && cd scratch mkdir annotation beans collection compat concurrent io \ math parallel ref reflect runtime scala sys testing \ text tools util xml scalac $(find ../src/library -name '*.scala') Until recently that would fail with about a billion errors. When it compiles, that's when you're done. And that's where this commit takes us, for src/library at least.
* Eliminate breaking relative names in source.Paul Phillips2012-09-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These things are killing me. Constructions like package scala.foo.bar.baz import foo.Other DO NOT WORK in general. Such files are not really in the "scala" package, because it is not declared package scala package foo.bar.baz And there is a second problem: using a relative path name means compilation will fail in the presence of a directory of the same name, e.g. % mkdir reflect % scalac src/reflect/scala/reflect/internal/util/Position.scala src/reflect/scala/reflect/internal/util/Position.scala:9: error: object ClassTag is not a member of package reflect import reflect.ClassTag ^ src/reflect/scala/reflect/internal/util/Position.scala:10: error: object base is not a member of package reflect import reflect.base.Attachments ^ As a rule, do not use relative package paths unless you have explicitly imported the path to which you think you are relative. Better yet, don't use them at all. Unfortunately they mostly work because scala variously thinks everything scala.* is in the scala package and/or because you usually aren't bootstrapping and it falls through to an existing version of the class already on the classpath. Making the paths explicit is not a complete solution - in particular, we remain enormously vulnerable to any directory or package called "scala" which isn't ours - but it greatly limts the severity of the problem.
* Fix for view isEmpty.Paul Phillips2012-08-131-1/+2
| | | | | | | | | | Views have been inheriting the very inefficient isEmpty from Traversable, and since isEmpty is not specifically forwarded to the underlying collections, views miss out on all the important optimizations in those collections which tend to be implemented via method override. Not to mention, they miss out on correctness, because calling foreach has a habit of forcing the first element of the view.
* Corrects links in API documentationHeather Miller2012-05-161-3/+3
|
* Address doc comment rot in the standard library.Jason Zaugg2012-05-131-1/+11
| | | | | | | | | | | | | | | | | | | | | - Match @param/@tparam names to the actual parameter name - Use @tparam for type parameters - Whitespace is required between `*` and `@` - Fix incorrect references to @define macros. - Use of monospace `` and {{{}}} (much more needed) - Remove `@param p1 ...` stubs, which appear in the generated docss. - But, retainsed `@param p1` stubs, assuming they will be filtered from the generated docs by SI-5795. - Avoid use of the shorthand `@param doc for the solitary param` (which works, but isn't recognized by the code inspection in IntelliJ I used to sweep through the problems) The remaining warnings from `ant docs` seem spurious, I suspect they are an unintended consequence of documenting extension methods. [scaladoc] /Users/jason/code/scala/src/library/scala/collection/TraversableOnce.scala:181: warning: Variable coll undefined in comment for method reduceOption in class Tuple2Zipped [scaladoc] def reduceOption[A1 >: A](op: (A1, A1) => A1): Option[A1] = reduceLeftOption(op) [scaladoc] ^
* 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-11/+0
|
* Enabling postfix ops feature warning, and working on libs to avoid them.Martin Odersky2012-04-121-1/+1
|
* Adapted usecases to full signature displayVlad Ureche2012-03-201-0/+1
|
* A first bunch of Any-extending traits.Martin Odersky2012-02-061-1/+1
|
* Removed the type parameter from sliding, no rev...Paul Phillips2011-09-031-2/+2
| | | | | Removed the type parameter from sliding, no review.
* Removing the code which has been deprecated sin...Paul Phillips2011-08-151-19/+0
| | | | | | | Removing the code which has been deprecated since 2.8.0. Contributed by Simon Ochsenreither, although deleting code is such fun one hesitates to call it a contribution. Still, we will. Closes SI-4860, no review.
* Make IterableLike.toIterator more efficientPaul Phillips2011-07-161-0/+2
| | | | | | | Override TraversableLike.toIterator which uses unnecessary toStream. Fixes SI-4802. Contributed by Yang Zhang.
* Fixes #4490 and #4467.Kato Kazuyoshi2011-06-181-6/+7
|
* Added a bunch of bridges to make ameliorate bin...Martin Odersky2011-04-241-1/+12
| | | | | | Added a bunch of bridges to make ameliorate binary compatibility of new collections. Review by prokopec. Review by extempore.
* One of the blips in the performance charts seem...Paul Phillips2011-04-201-3/+43
| | | | | | | | | | 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.
* Adds "since" field to @deprecated.Paul Phillips2011-04-141-4/+4
| | | | | | for the patch, as it's a change I've always wanted. Moving up in the glamorous world of scala commits! No review.
* Adding some docs refactorings.Aleksandar Pokopec2011-04-141-99/+2
| | | | | | | Also, added some docs variables to Gen* traits that were missing. No review.
* Refactoring the collections api to support diff...Aleksandar Pokopec2011-04-131-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Implementing foreach to work in parallel in Par...Aleksandar Pokopec2011-03-221-1/+1
| | | | | | | | | | | | Implementing foreach to work in parallel in ParIterableLike. Doing a bunch of refactoring around in the collection framework to ensure a parallel foreach is never called with a side-effecting method. This still leaves other parts of the standard library and the compiler unguarded. No review.
* An overhaul of slice and related implementation...Paul Phillips2011-03-081-24/+4
| | | | | | | | | | | An overhaul of slice and related implementations (primarily that is drop and take.) In the course of trying to get it working consistently (mostly with respect to negative indices, which were dealt with arbitrarily differently across the 25+ concrete implementations) I fixed various bugs. Closes #4288, no review.
* Updated copyright notices to 2011Antonio Cunei2011-01-201-1/+1
|
* Some accumulated cleanup done while profiling a...Paul Phillips2010-12-291-2/+2
| | | | | | Some accumulated cleanup done while profiling and reducing uses of length. No review.
* A selection of collections additions from the l...Paul Phillips2010-12-041-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | A selection of collections additions from the lower end of the controversy scale. // TraversableOnce def collectFirst[B](pf: PartialFunction[A, B]): Option[B] def maxBy[B](f: A => B)(implicit cmp: Ordering[B]): A def minBy[B](f: A => B)(implicit cmp: Ordering[B]): A // Iterator def span(p: A => Boolean): (Iterator[A], Iterator[A]) // Traversable def inits: Iterator[Repr] def tails: Iterator[Repr] def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3)): (CC[A1], CC[A2], CC[A3]) // Sequences def permutations: Iterator[Repr] Review by odersky.
* Some collections overrides for more efficient t...Paul Phillips2010-12-011-7/+0
| | | | | | Some collections overrides for more efficient toSeq and toBuffer where possible. Closes #2972, review by malayeri.
* Added size maps to flat hash tables.Aleksandar Pokopec2010-11-081-1/+1
| | | | | | | | | | | Added parallel mutable hash sets. Implemented parallel mutable hash set iterators. Implemented parallel mutable hash set combiners. Factored out unrolled linked lists into a separate class UnrolledBuffer, added tests. Added parallel mutable hash set tests, and debugged hashsets. No review.
* Fixes #3563. Review by extempore.Aleksandar Pokopec2010-06-161-0/+7
|
* Fixes #3461. No review.pAleksandar Pokopec2010-06-081-1/+2
|
* 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.
* Added sizeHints to operations where it made sense.Martin Odersky2010-05-101-0/+4
|
* Updated documentationMartin Odersky2010-04-091-3/+3
|
* Another set of typos fixed.Aleksandar Pokopec2010-04-081-4/+4
|
* Spring cleaning of collection libraries.Martin Odersky2010-03-191-3/+3
| | | | | | If people think some operations can be more lazy, please provide patches/do changes. Also brought proxies and forwarders into line.
* Fixes #3088. No review.Aleksandar Pokopec2010-02-241-1/+1
|
* Made Iterator consistent with Iterable by addin...Paul Phillips2010-01-161-0/+32
| | | | | | Made Iterator consistent with Iterable by adding grouped and sliding to IterableLike. Closes #2837. Review by community.
* more docs. noreview.Martin Odersky2009-12-151-1/+1
|
* lost of documentation and some small adjustment...Martin Odersky2009-12-141-34/+29
| | | | | lost of documentation and some small adjustments to collection classes.
* refined doc comments generation; refactored cod...Martin Odersky2009-12-101-10/+0
| | | | | | | refined doc comments generation; refactored code into new Chars, DocStrings classes in util. Added some more doc comments to collection classes.
* new doc comment generation, including some new ...Martin Odersky2009-12-071-171/+162
| | | | | | new doc comment generation, including some new style doc comments in collection classes.