summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable
Commit message (Collapse)AuthorAgeFilesLines
* Inline ScalaRunTime.arrayElementClass at call sites.Sébastien Doeraene2016-04-133-12/+9
| | | | | | | | | | This method was awful. Not only it was using run-time type tests to essentially encode compile-time overloading. But it also did 2 slightly different things for the Class case and ClassTag case. All in all, it is much more readable to inline the appropriate implementation at every call site.
* General cleanups and less warnings during a Scala buildsoc2016-04-042-4/+1
|
* Merge pull request #4971 from adriaanm/genbcode-delambdafyAdriaan Moors2016-03-311-1/+5
|\ | | | | Unify treatment of built-in functions and SAMs
| * Target FunctionN, not scala/runtime/java8/JFunction.Adriaan Moors2016-03-281-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We compile FunctionN to Java 8's idea of a function now, so no need to target the artisanal JFunction and friends, except when the function is specialized, as I don't yet see how we can use LMF with the way specialization handles FunctionN: First, the working status quo -- the hand-crafted specialized versions of JFunction0. Notice how `apply$mcB$sp` is looking pretty SAMmy: ``` @FunctionalInterface public interface JFunction0$mcB$sp extends JFunction0 { @Override public byte apply$mcB$sp(); @Override default public Object apply() { return BoxesRunTime.boxToByte(this.apply$mcB$sp()); } } ``` Contrast this with our specialized standard FunctionN: ``` public interface Function0<R> { public R apply(); default public byte apply$mcB$sp() { return BoxesRunTime.unboxToByte(this.apply()); } } public interface Function0$mcB$sp extends Function0<Object> { } ``` The single abstract method in `Function0$mcB$sp` is `apply`, and the method that would let us avoid boxing, if it were abstract, is `apply$mcB$sp`... TODO (after M4): - do same for specialized functions (issues with boxing?) - remove scala/runtime/java8/JFunction* (need new STARR?)
* | Make some collection classes final or sealedStefan Zeiger2016-03-236-221/+193
|/ | | | | | | They were all annotated with `@deprecatedInheritance` in 2.11.0. Some deprecated classes are moved to new source files in order to seal the parent class. The package-private class `DoublingUnrolledBuffer` is moved from `scala.collection.parallel.mutable` to `scala.collection.mutable` in order to seal `UnrolledBuffer`.
* Merge 2.11.x into 2.12.xAdriaan Moors2016-03-141-1/+1
|\ | | | | | | Resolved conflicts as in b0e05b67c7
| * Merge pull request #4994 from dk14/patch-1Seth Tisue2016-03-041-1/+1
| |\ | | | | | | explicitly specify insertion-order feature in docs
| | * explicitly specify insertion-order feature in docsdk142016-02-231-1/+1
| | |
* | | Clarified and expanded which Builders were reusableRex Kerr2016-01-3012-103/+170
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This additionally fixes both SI-8648 and SI-9564. Added documentation to Builder to clarify that in general Builders are NOT reusable. Altered implementation of GrowingBuilder to use Growable instance's clear (not valid for a reusable builder, but this one isn't reusable). Added a new marker trait ReusableBuilder that specifies that these builders should be reusable. This trait overrides the clear and result methods while leaving them abstract in order to supply appropriate scaladoc. Made all Array builders Reusable in all cases (by setting capacity to 0 if the original array is returned). (Fixed a poor implmentation of Array[Unit] builder along the way.) Documented which other builders were already reusable (maps, sets, Vector, LazyBuilder, StringBuilder, ListBuffer, etc.).
* | | Merge pull request #4870 from ruippeixotog/issue/9507Jason Zaugg2016-01-191-3/+4
|\ \ \ | | | | | | | | SI-9507 Make ArrayStack an IndexedSeqOptimized
| * | | SI-9507 Make ArrayStack an IndexedSeqOptimizedRui Gonçalves2015-11-271-3/+4
| | | | | | | | | | | | | | | | Just like `ArraySeq`, `ArrayBuffer` and all other collections that use an array as underlying data structure, `ArrayStack` should also be an instance of `IndexedSeq` and `IndexedSeqOptimized`. As expected by both of the traits, `ArrayStack` has constant-time random element access and length computation.
* | | | Remove unused imports and other minor cleanupsSimon Ochsenreither2015-12-187-14/+10
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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".
* | | Merge commit '8eb1d4c' into merge-2.11-to-2.12-nov-24Lukas Rytz2015-11-2410-134/+136
|\| |
| * | Merge pull request #4810 from ruippeixotog/fix-mutable-setlike-clearAdriaan Moors2015-11-121-1/+3
| |\ \ | | | | | | | | SI-9497 Fix SetLike#clear() default implementation
| | * | SI-9497 Fix SetLike#clear() default implementationRui Gonçalves2015-10-211-1/+3
| | | | | | | | | | | | | | | | When dealing with mutable collections, it is not safe to assume iterators will remain consistent when the collection is modified mid-traversal. The bug reported in SI-9497 is very similar to SI-7269, "ConcurrentModificationException when filtering converted Java HashMap". Then, only the `retain` method was fixed. This commit fixes `clear`, which had the same problem.
| * | | Conform foreach tparam to majority naming conventionvsalvis2015-10-219-128/+128
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 'U' is the common choice for the foreach function result tparam. This command summarises the naming diversity before and after this change. $ fgrep -r 'def foreach[' *|cut -f2 -d:|cut -f1 -d'('|tr -s ' '|sed 's/override //g'|sort|uniq -c|sort -nr Before, 80 def foreach[U] 6 def foreach[C] 6 def foreach[B] 4 final def foreach[U] 3 def foreach[S] 2 inline final def foreach[U] 2 def foreach[A] 1 inline final def foreach[specialized 1 final def foreach[B] 1 * def foreach[U] 1 def foreach[Q] 1 def foreach[D] 1 def foreach[A,B,U] After, 98 def foreach[U] 5 final def foreach[U] 2 inline final def foreach[U] 1 inline final def foreach[specialized 1 * def foreach[U] 1 def foreach[A,B,U] (@ symbols removed.)
* | | merge 2.11.x onto 2.12.x, Oct 16 2015Seth Tisue2015-10-161-1/+18
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | there were merge conflicts in the Eclipse config that I resolved with --ours. I invite @performantdata to submit a followup PR bringing the Eclipse stuff into a good state on 2.12.x. there was a test failure in test/junit/scala/collection/mutable/OpenHashMapTest.scala due to the 2.12 compiler emitting the field backing a private var differently (with an unmangled name). Lukas says the difference is expected, so I just updated the code in the test. there were no other merge conflicts. % git log --decorate --oneline -1 origin/2.11.x | cat ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508 % git log --decorate --oneline -1 origin/2.12.x | cat c99e53e (HEAD -> 2.12.x, origin/2.12.x) Merge pull request #4797 from lrytz/M3-versions % export MB=$(git merge-base 2.12.x origin/2.11.x) % echo $MB 42cafa21f3c4a08c6dd34608278f810b6ec2886f % git log --graph --oneline --decorate $MB...origin/2.11.x | cat * ae5f0de (origin/HEAD, origin/2.11.x) Merge pull request #4791 from performantdata/issue/9508 |\ | * 08dca37 (origin/pull/4791) SI-9508 fix classpaths in Eclipse configuration * | fe76232 Merge pull request #4798 from performantdata/issue/9513 |\ \ | * | 9c97a7f (origin/pull/4798) Suppress unneeded import. | * | 30d704d Document some OpenHashMap internal methods. | * | 1fb32fc SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reused | |/ * | 14f875c Merge pull request #4788 from dk14/patch-1 |\ \ | * | 42acd55 (origin/pull/4788) explicitly specify insertion-order feature in docs | / * | 68ce049 Merge pull request #4771 from som-snytt/issue/9492-here |\ \ | * | f290962 (origin/pull/4771) SI-9492 Line trimming paste | * | bc3589d SI-9492 REPL paste here doc | / * | 9834fc8 Merge pull request #4610 from todesking/spec-implicits-remove-obsolete |\ \ | * | 46009b1 (origin/pull/4610) Add view/context-bound parameter ordering rule | * | 6eba305 Spec: Implicit parameters with context/view bound is allowed since 2.10 | / * | d792e35 Merge pull request #4789 from janekdb/2.11.x-param-names-predicates-operations |\ \ | |/ |/| | * b19a07e (origin/pull/4789) Rename forall, exists and find predicate and operator params. |/ * 648c7a1 Merge pull request #4790 from SethTisue/issue/9501 |\ | * 40d12f1 (origin/pull/4790) SI-9501 link README to Scala Hacker Guide * e0b5891 Merge pull request #4786 from performantdata/issue/9506 * 39acad8 (origin/pull/4786) SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs * 74dc364 SI-9506 suppress Scala IDE-generated files in the Eclipse project dirs % git merge ae5f0de Auto-merging src/repl/scala/tools/nsc/interpreter/ILoop.scala Auto-merging src/library/scala/util/Either.scala Auto-merging src/library/scala/runtime/Tuple3Zipped.scala Auto-merging src/library/scala/runtime/Tuple2Zipped.scala Auto-merging src/library/scala/collection/parallel/ParIterableLike.scala Auto-merging src/library/scala/collection/immutable/ListMap.scala Auto-merging src/library/scala/collection/TraversableLike.scala Auto-merging src/eclipse/test-junit/.classpath CONFLICT (content): Merge conflict in src/eclipse/test-junit/.classpath Auto-merging src/eclipse/scaladoc/.classpath CONFLICT (content): Merge conflict in src/eclipse/scaladoc/.classpath Auto-merging src/eclipse/scala-compiler/.classpath Auto-merging src/eclipse/repl/.classpath CONFLICT (content): Merge conflict in src/eclipse/repl/.classpath Auto-merging src/eclipse/partest/.classpath CONFLICT (content): Merge conflict in src/eclipse/partest/.classpath Auto-merging src/eclipse/interactive/.classpath Auto-merging README.md Automatic merge failed; fix conflicts and then commit the result. % git checkout --ours src/eclipse/partest/.classpath % git checkout --ours src/eclipse/repl/.classpath % git checkout --ours src/eclipse/scaladoc/.classpath % git checkout --ours src/eclipse/test-junit/.classpath % git add -u % emacs test/junit/scala/collection/mutable/OpenHashMapTest.scala % git diff test/junit/scala/collection/mutable/OpenHashMapTest.scala | cat ... - val field = m.getClass.getDeclaredField("scala$collection$mutable$OpenHashMap$$deleted") + val field = m.getClass.getDeclaredField("deleted") ... % git add -u
| * | Document some OpenHashMap internal methods.Performant Data LLC2015-10-101-0/+13
| | |
| * | SI-9513 decrement "deleted" count in OpenHashMap.put() when slot reusedPerformant Data LLC2015-10-101-1/+5
| |/
* | Make AnyRefMap serializableJason Zaugg2015-09-251-0/+2
| |
* | Merge commit 'a170c99' into 2.12.xLukas Rytz2015-09-222-1/+1
|\|
| * Merge pull request #4728 from janekdb/2.11.x-urls-docs-codehaus-citeseerSeth Tisue2015-09-151-1/+1
| |\ | | | | | | Update links to docs, codehaus and citeseer
| | * Update links to docs, codehaus and citeseerJanek Bogucki2015-09-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | docs.scala-lang.org - Align some links to new layout for docs.scala-lang.org - Include link to concrete parallel collection performance characteristics codehaus - Subsitute a link to a JIRA email for the 404 JRUBY-3576 JIRA link in Codec.scala. jira.codehaus.org is not redirecting this. citeseer - Replace the citeseer link with a direct link to a PDF which is not behind a login challenge.
| * | Merge pull request #4727 from SethTisue/unset-stray-execute-bitsSeth Tisue2015-09-141-0/+0
| |\ \ | | |/ | |/| unset inappropriate execute bits
| | * unset inappropriate execute bitsSeth Tisue2015-09-021-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I imagine these date back to old Subversion days and are probably the result of inadvertent commits from Windows users with vcs client configs. having the bit set isn't really harmful most of the time, but it's just not right, and it makes the files stand out in directory listings for no reason
| * | SI-9424 Clarify behavior of PriorityQueue toStringRex Kerr2015-08-291-2/+13
| |/ | | | | | | | | | | Clarified that PriorityQueue will not print in order and gave an example of a workaround if one needs it. Documentation change only; no tests.
* | Merge pull request #4719 from Ichoran/issue/8647Lukas Rytz2015-09-181-1/+3
|\ \ | | | | | | SI-8647 Used immutable scheme for mutable.BitSet to resolve canBuildFrom
| * | SI-8647 Used immutable scheme for mutable.BitSet to resolve canBuildFromRex Kerr2015-08-301-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | mutable.BitSet had a conflict between its own implicit canBuildFrom and the one inherited from SortedSetFactory in mutable.SortedSet. The immutable hierarchy already had a workaround; this just copies it on the mutable side. Test written to verify compilation.
* | | Merge pull request #4732 from SethTisue/merge-2.11.x-sep-8Adriaan Moors2015-09-091-2/+13
|\ \ \ | | | | | | | | Merge 2.11.x into 2.12.x [ci: last-only]
| * | | Merge remote-tracking branch 'origin/2.11.x' into 2.12.xSeth Tisue2015-09-081-2/+13
| |/ / | | | | | | | | | | | | | | | | | | | | | only trivial merge conflicts here. not dealing with PR #4333 in this merge because there is a substantial conflict there -- so that's why I stopped at 63daba33ae99471175e9d7b20792324615f5999b for now
* / / SI-7155 Remove deprecated private s.c.m.AVLTreeSimon Ochsenreither2015-09-051-250/+0
|/ /
* | Merge pull request #4608 from ruippeixotog/improve-mutable-treesetSeth Tisue2015-08-064-54/+182
|\ \ | | | | | | SI-6938 Use mutable red-black tree in `mutable.TreeSet`
| * | SI-6938 Use mutable red-black tree in TreeSetRui Gonçalves2015-07-284-54/+182
| | | | | | | | | | | | | | | | | | | | | | | | The previous implementation of `mutable.TreeSet` uses a mutable reference to an immutable red-black tree as its underlying data structure. That leads to unnecessary objects being created, which can be a problem in systems with limited resources. It also has reduced performance when compared with common mutable implementations. In this commit `mutable.TreeSet` is changed so that it uses the recently created `mutable.RedBlackTree` as its underlying data structure. Specialized red-black tree methods were created for working with keys for efficiency reasons. The new implementation is source-compatible with the previous one, although its serialized representation obviously changes. Closes [SI-6938](https://issues.scala-lang.org/browse/SI-6938).
* | | SI-8554 Two-arg remove throws exception on large countRex Kerr2015-07-193-12/+19
|/ / | | | | | | | | | | | | | | ListBuffer now throws exceptions like other buffers do when trying to index out of range. Also harmonized the order of testing (`count < 0` tested before `n` in range). Test in scala-collection-laws (gated by SI8554 flag). Also modified test in run/t6634.scala
* | Fix size update on `mutable.TreeMap#clear()`Rui Gonçalves2015-06-262-2/+4
| | | | | | | | | | | | The previous implementation has a major bug - although `clear()` sets the root node to `null`, the `size` attribute of the `Tree` was not updated. This effectively meant that even after a `map.clear()`, a call to `map.size` would still yield the old size of the map. The scalacheck test suite was updated to contemplate this issue.
* | Merge pull request #4504 from ruippeixotog/mutable-treemapAdriaan Moors2015-06-253-0/+768
|\ \ | | | | | | SI-4147 Add an implementation of `mutable.TreeMap`
| * | SI-4147 Add an implementation of `mutable.TreeMap`Rui Gonçalves2015-05-303-0/+768
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit contains an implementation of a mutable red-black tree with focus on performance. It also contains a new `mutable.TreeMap` Scala collection that is backed by the aforementioned tree. The common generic factories and traits related to mutable sorted maps didn't exist yet, so this commit also adds them. Regarding performance, `TreeMap` overrides (from `MapLike` and `SortedMapLike`) all of the most common methods for maps and also those whose default implementations are asymptotically worse than direct red-black tree algorithms (e.g. `last`, `clear`). The `rangeImpl` method of `TreeMap` returns an instance of `TreeMapView`, an inner class of `TreeMap`. This view is backed by the same `RedBlackTree.Tree` instance, and therefore changes to the original map are reflected in the view and vice-versa. The semantics of mutating a view by adding and removing keys outside the view's range are the same of the current `mutable.TreeSet`. A bit less focus was given on the performance of views - in particular, getting the `size` of a `TreeMapView` is O(n) on the number of elements inside the view bounds. That can be improved in the future. In a future commit, `mutable.TreeSet` can be changed to be backed by this red-black tree implementation.
* | | Merge branch '2.11.x' into merge/2.11.x-to-2.12.x-20150624Jason Zaugg2015-06-241-1/+1
|\ \ \ | |/ / |/| / | |/
| * Improve API documentation for ListBuffer and TryJanek Bogucki2015-06-161-1/+1
| |
* | Merge remote-tracking branch 'origin/2.11.x' into ↵Jason Zaugg2015-05-014-10/+12
|\| | | | | | | merge/2.11.x-to-2.12.x-20150501
| * Merge pull request #4415 from Ichoran/issue/9254Adriaan Moors2015-04-221-5/+7
| |\ | | | | | | SI-9254 UnrolledBuffer appends in wrong position
| | * SI-9254 UnrolledBuffer appends in wrong positionRex Kerr2015-03-311-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixed two bugs in insertion (insertAll of Unrolled): 1. Incorrect recursion leading to an inability to insert past the first chunk 2. Incorect repositioning of `lastptr` leading to strange `append` behavior after early insertion Added tests checking that both of these things now work. Also added a comment that "waterlineDelim" is misnamed. But we can't fix it now--it's part of the public API. (Shouldn't be, but it is.)
| * | Fix many typosMichał Pociecha2015-04-214-5/+5
| |/ | | | | | | | | This commit corrects many typos found in scaladocs and comments. There's also fixed the name of a private method in ICodeCheckers.
* | Merge pull request #4424 from lrytz/merge/2.11-to-2.12-apr-1Jason Zaugg2015-04-095-5/+27
|\ \ | | | | | | Merge/2.11 to 2.12 apr 1
| * | Merge commit 'fcc20fe' into merge/2.11-to-2.12-apr-1Lukas Rytz2015-04-015-5/+27
| |\|
| | * Merge pull request #4330 from Ichoran/issue/8917Adriaan Moors2015-02-191-2/+4
| | |\ | | | | | | | | SI-8917 collection.mutable.BitSet's &= operator doesn't clear end
| | | * SI-8917 collection.mutable.BitSet's &= operator doesn't clear endRex Kerr2015-02-131-2/+4
| | | | | | | | | | | | | | | | Made &= run to the end of its own bitset, ignoring the size of what it's &-ing with (which is exactly what you want for &=).
| | * | Fix SI-7943 -- make `TrieMap.getOrElseUpdate` atomic.Aleksandar Prokopec2015-02-181-0/+4
| | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Override `getOrElseUpdate` method in `TrieMap`. The signature and contract of this method corresponds closely to the `computeIfAbsent` from `java.util.concurrent.ConcurrentMap`. Eventually, `computeIfAbsent` should be added to `scala.collection.concurrent.Map`. Add tests. Review by @Ichoran
| | * Merge pull request #4280 from kanielc/SI-9095Adriaan Moors2015-02-092-0/+2
| | |\ | | | | | | | | SI-9095 Memory leak in LinkedHasMap and LinkedHashSet
| | | * SI-9095 Memory leak in LinkedHasMap and LinkedHashSetDenton Cockburn2015-01-312-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The clear() method in scala.collection.mutable.LinkedHashSet and scala.collection.mutable.LinkedHashMap does not set lastEntry to null. In result it holds a reference to an object that was removed from the collection.