summaryrefslogtreecommitdiff
path: root/src/library
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-05-17 17:01:20 +0200
committerPaul Phillips <paulp@improving.org>2013-05-17 11:16:39 -0700
commitb7c352a57f65458c66c78a368f75aaaa4a08e443 (patch)
tree4b2b7fcea439948c5de65b05a392091a66eea0a4 /src/library
parent4f8c306aca703c63282295c9f74f0cb35f9f85d4 (diff)
parentbe405eed9bef9736f0142d6ddf53b6bf8af08696 (diff)
downloadscala-b7c352a57f65458c66c78a368f75aaaa4a08e443.tar.gz
scala-b7c352a57f65458c66c78a368f75aaaa4a08e443.tar.bz2
scala-b7c352a57f65458c66c78a368f75aaaa4a08e443.zip
Merge v2.10.1-326-g4f8c306' into merge/v2.10.1-326-g4f8c306-to-master
================================================================ Merge commit 'v2.10.1-326-g4f8c306' into merge/v2.10.1-326-g4f8c306-to-master Conflicts: src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala src/reflect/scala/reflect/runtime/JavaMirrors.scala ================================================================ Merge -s ours 4e64a27 ([nomaster commit range]) ================================================================ Merge commit '0ae7e55' into merge/v2.10.1-326-g4f8c306-to-master Conflicts: src/compiler/scala/tools/nsc/typechecker/Macros.scala
Diffstat (limited to 'src/library')
-rw-r--r--src/library/scala/AnyVal.scala2
-rw-r--r--src/library/scala/Application.scala79
-rw-r--r--src/library/scala/Array.scala14
-rw-r--r--src/library/scala/Boolean.scala6
-rw-r--r--src/library/scala/Byte.scala6
-rw-r--r--src/library/scala/Char.scala6
-rw-r--r--src/library/scala/Console.scala344
-rw-r--r--src/library/scala/Double.scala6
-rw-r--r--src/library/scala/Enumeration.scala19
-rw-r--r--src/library/scala/Float.scala6
-rw-r--r--src/library/scala/Function0.scala4
-rw-r--r--src/library/scala/Function1.scala2
-rw-r--r--src/library/scala/Function10.scala2
-rw-r--r--src/library/scala/Function11.scala2
-rw-r--r--src/library/scala/Function12.scala2
-rw-r--r--src/library/scala/Function13.scala2
-rw-r--r--src/library/scala/Function14.scala2
-rw-r--r--src/library/scala/Function15.scala2
-rw-r--r--src/library/scala/Function16.scala2
-rw-r--r--src/library/scala/Function17.scala2
-rw-r--r--src/library/scala/Function18.scala2
-rw-r--r--src/library/scala/Function19.scala2
-rw-r--r--src/library/scala/Function2.scala2
-rw-r--r--src/library/scala/Function20.scala2
-rw-r--r--src/library/scala/Function21.scala2
-rw-r--r--src/library/scala/Function22.scala2
-rw-r--r--src/library/scala/Function3.scala2
-rw-r--r--src/library/scala/Function4.scala2
-rw-r--r--src/library/scala/Function5.scala2
-rw-r--r--src/library/scala/Function6.scala2
-rw-r--r--src/library/scala/Function7.scala2
-rw-r--r--src/library/scala/Function8.scala2
-rw-r--r--src/library/scala/Function9.scala2
-rw-r--r--src/library/scala/Int.scala6
-rw-r--r--src/library/scala/Long.scala6
-rw-r--r--src/library/scala/LowPriorityImplicits.scala95
-rw-r--r--src/library/scala/NotNull.scala2
-rw-r--r--src/library/scala/Option.scala11
-rw-r--r--src/library/scala/Predef.scala271
-rw-r--r--src/library/scala/Product.scala2
-rw-r--r--src/library/scala/Product1.scala2
-rw-r--r--src/library/scala/Product10.scala2
-rw-r--r--src/library/scala/Product11.scala2
-rw-r--r--src/library/scala/Product12.scala2
-rw-r--r--src/library/scala/Product13.scala2
-rw-r--r--src/library/scala/Product14.scala2
-rw-r--r--src/library/scala/Product15.scala2
-rw-r--r--src/library/scala/Product16.scala2
-rw-r--r--src/library/scala/Product17.scala2
-rw-r--r--src/library/scala/Product18.scala2
-rw-r--r--src/library/scala/Product19.scala2
-rw-r--r--src/library/scala/Product2.scala2
-rw-r--r--src/library/scala/Product20.scala2
-rw-r--r--src/library/scala/Product21.scala2
-rw-r--r--src/library/scala/Product22.scala2
-rw-r--r--src/library/scala/Product3.scala2
-rw-r--r--src/library/scala/Product4.scala2
-rw-r--r--src/library/scala/Product5.scala2
-rw-r--r--src/library/scala/Product6.scala2
-rw-r--r--src/library/scala/Product7.scala2
-rw-r--r--src/library/scala/Product8.scala2
-rw-r--r--src/library/scala/Product9.scala2
-rw-r--r--src/library/scala/SerialVersionUID.scala2
-rw-r--r--src/library/scala/Short.scala6
-rw-r--r--src/library/scala/Specializable.scala2
-rw-r--r--src/library/scala/SpecializableCompanion.scala14
-rw-r--r--src/library/scala/Tuple1.scala3
-rw-r--r--src/library/scala/Tuple10.scala3
-rw-r--r--src/library/scala/Tuple11.scala3
-rw-r--r--src/library/scala/Tuple12.scala3
-rw-r--r--src/library/scala/Tuple13.scala3
-rw-r--r--src/library/scala/Tuple14.scala3
-rw-r--r--src/library/scala/Tuple15.scala3
-rw-r--r--src/library/scala/Tuple16.scala3
-rw-r--r--src/library/scala/Tuple17.scala3
-rw-r--r--src/library/scala/Tuple18.scala3
-rw-r--r--src/library/scala/Tuple19.scala3
-rw-r--r--src/library/scala/Tuple2.scala3
-rw-r--r--src/library/scala/Tuple20.scala3
-rw-r--r--src/library/scala/Tuple21.scala3
-rw-r--r--src/library/scala/Tuple22.scala3
-rw-r--r--src/library/scala/Tuple3.scala3
-rw-r--r--src/library/scala/Tuple4.scala3
-rw-r--r--src/library/scala/Tuple5.scala3
-rw-r--r--src/library/scala/Tuple6.scala3
-rw-r--r--src/library/scala/Tuple7.scala3
-rw-r--r--src/library/scala/Tuple8.scala3
-rw-r--r--src/library/scala/Tuple9.scala3
-rw-r--r--src/library/scala/UninitializedFieldError.scala6
-rw-r--r--src/library/scala/Unit.scala2
-rw-r--r--src/library/scala/annotation/serializable.scala15
-rw-r--r--src/library/scala/annotation/target/package.scala29
-rw-r--r--src/library/scala/beans/ScalaBeanInfo.scala6
-rw-r--r--src/library/scala/collection/BitSet.scala3
-rw-r--r--src/library/scala/collection/BitSetLike.scala30
-rw-r--r--src/library/scala/collection/BufferedIterator.scala3
-rw-r--r--src/library/scala/collection/CustomParallelizable.scala3
-rw-r--r--src/library/scala/collection/DefaultMap.scala13
-rw-r--r--src/library/scala/collection/GenIterable.scala3
-rw-r--r--src/library/scala/collection/GenIterableLike.scala5
-rw-r--r--src/library/scala/collection/GenIterableView.scala10
-rw-r--r--src/library/scala/collection/GenIterableViewLike.scala10
-rw-r--r--src/library/scala/collection/GenMap.scala3
-rw-r--r--src/library/scala/collection/GenMapLike.scala3
-rw-r--r--src/library/scala/collection/GenSeq.scala3
-rw-r--r--src/library/scala/collection/GenSeqLike.scala3
-rw-r--r--src/library/scala/collection/GenSeqView.scala10
-rw-r--r--src/library/scala/collection/GenSeqViewLike.scala3
-rw-r--r--src/library/scala/collection/GenSet.scala3
-rw-r--r--src/library/scala/collection/GenSetLike.scala3
-rw-r--r--src/library/scala/collection/GenTraversable.scala3
-rw-r--r--src/library/scala/collection/GenTraversableLike.scala5
-rw-r--r--src/library/scala/collection/GenTraversableOnce.scala21
-rw-r--r--src/library/scala/collection/GenTraversableView.scala10
-rw-r--r--src/library/scala/collection/GenTraversableViewLike.scala5
-rw-r--r--src/library/scala/collection/IndexedSeq.scala10
-rw-r--r--src/library/scala/collection/IndexedSeqLike.scala9
-rwxr-xr-xsrc/library/scala/collection/IndexedSeqOptimized.scala20
-rw-r--r--src/library/scala/collection/Iterable.scala4
-rw-r--r--src/library/scala/collection/IterableLike.scala48
-rw-r--r--src/library/scala/collection/IterableProxy.scala5
-rw-r--r--src/library/scala/collection/IterableProxyLike.scala3
-rw-r--r--src/library/scala/collection/IterableView.scala3
-rw-r--r--src/library/scala/collection/IterableViewLike.scala4
-rw-r--r--src/library/scala/collection/Iterator.scala77
-rw-r--r--src/library/scala/collection/JavaConversions.scala41
-rwxr-xr-xsrc/library/scala/collection/JavaConverters.scala40
-rw-r--r--src/library/scala/collection/LinearSeq.scala3
-rw-r--r--src/library/scala/collection/LinearSeqLike.scala11
-rwxr-xr-xsrc/library/scala/collection/LinearSeqOptimized.scala19
-rw-r--r--src/library/scala/collection/Map.scala3
-rw-r--r--src/library/scala/collection/MapLike.scala8
-rw-r--r--src/library/scala/collection/MapProxy.scala3
-rw-r--r--src/library/scala/collection/MapProxyLike.scala5
-rw-r--r--src/library/scala/collection/Parallel.scala3
-rw-r--r--src/library/scala/collection/Parallelizable.scala5
-rw-r--r--src/library/scala/collection/Searching.scala118
-rw-r--r--src/library/scala/collection/Seq.scala3
-rw-r--r--src/library/scala/collection/SeqExtractors.scala3
-rw-r--r--src/library/scala/collection/SeqLike.scala64
-rw-r--r--src/library/scala/collection/SeqProxy.scala3
-rw-r--r--src/library/scala/collection/SeqProxyLike.scala5
-rw-r--r--src/library/scala/collection/SeqView.scala3
-rw-r--r--src/library/scala/collection/SeqViewLike.scala4
-rw-r--r--src/library/scala/collection/Sequentializable.scala.disabled10
-rw-r--r--src/library/scala/collection/Set.scala4
-rw-r--r--src/library/scala/collection/SetLike.scala12
-rw-r--r--src/library/scala/collection/SetProxy.scala3
-rw-r--r--src/library/scala/collection/SetProxyLike.scala6
-rw-r--r--src/library/scala/collection/SortedMap.scala7
-rw-r--r--src/library/scala/collection/SortedMapLike.scala34
-rw-r--r--src/library/scala/collection/SortedSet.scala3
-rw-r--r--src/library/scala/collection/SortedSetLike.scala13
-rw-r--r--src/library/scala/collection/Traversable.scala7
-rw-r--r--src/library/scala/collection/TraversableLike.scala28
-rw-r--r--src/library/scala/collection/TraversableOnce.scala32
-rw-r--r--src/library/scala/collection/TraversableProxy.scala3
-rw-r--r--src/library/scala/collection/TraversableProxyLike.scala3
-rw-r--r--src/library/scala/collection/TraversableView.scala4
-rw-r--r--src/library/scala/collection/TraversableViewLike.scala8
-rw-r--r--src/library/scala/collection/concurrent/Map.scala3
-rw-r--r--src/library/scala/collection/concurrent/TrieMap.scala25
-rw-r--r--src/library/scala/collection/convert/DecorateAsJava.scala25
-rw-r--r--src/library/scala/collection/convert/DecorateAsScala.scala22
-rw-r--r--src/library/scala/collection/convert/Decorators.scala5
-rw-r--r--src/library/scala/collection/convert/WrapAsJava.scala24
-rw-r--r--src/library/scala/collection/convert/WrapAsScala.scala47
-rw-r--r--src/library/scala/collection/convert/Wrappers.scala64
-rw-r--r--src/library/scala/collection/convert/package.scala3
-rw-r--r--src/library/scala/collection/generic/BitOperations.scala3
-rw-r--r--src/library/scala/collection/generic/BitSetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/CanBuildFrom.scala3
-rw-r--r--src/library/scala/collection/generic/CanCombineFrom.scala3
-rw-r--r--src/library/scala/collection/generic/ClassTagTraversableFactory.scala3
-rw-r--r--src/library/scala/collection/generic/Clearable.scala3
-rwxr-xr-xsrc/library/scala/collection/generic/FilterMonadic.scala5
-rw-r--r--src/library/scala/collection/generic/GenMapFactory.scala5
-rw-r--r--src/library/scala/collection/generic/GenSeqFactory.scala3
-rw-r--r--src/library/scala/collection/generic/GenSetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/GenTraversableFactory.scala22
-rw-r--r--src/library/scala/collection/generic/GenericClassTagCompanion.scala9
-rw-r--r--src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala3
-rw-r--r--src/library/scala/collection/generic/GenericCompanion.scala9
-rw-r--r--src/library/scala/collection/generic/GenericOrderedCompanion.scala9
-rw-r--r--src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala3
-rw-r--r--src/library/scala/collection/generic/GenericParCompanion.scala4
-rw-r--r--src/library/scala/collection/generic/GenericParTemplate.scala4
-rw-r--r--src/library/scala/collection/generic/GenericSeqCompanion.scala3
-rw-r--r--src/library/scala/collection/generic/GenericSetTemplate.scala3
-rw-r--r--src/library/scala/collection/generic/GenericTraversableTemplate.scala67
-rw-r--r--src/library/scala/collection/generic/Growable.scala20
-rwxr-xr-xsrc/library/scala/collection/generic/HasNewBuilder.scala3
-rw-r--r--src/library/scala/collection/generic/HasNewCombiner.scala4
-rw-r--r--src/library/scala/collection/generic/ImmutableMapFactory.scala3
-rw-r--r--src/library/scala/collection/generic/ImmutableSetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/ImmutableSortedMapFactory.scala3
-rw-r--r--src/library/scala/collection/generic/ImmutableSortedSetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/IndexedSeqFactory.scala (renamed from src/library/scala/ScalaObject.scala)16
-rw-r--r--src/library/scala/collection/generic/IsSeqLike.scala58
-rw-r--r--src/library/scala/collection/generic/IsTraversableLike.scala3
-rw-r--r--src/library/scala/collection/generic/IsTraversableOnce.scala3
-rw-r--r--src/library/scala/collection/generic/IterableForwarder.scala7
-rw-r--r--src/library/scala/collection/generic/MapFactory.scala3
-rw-r--r--src/library/scala/collection/generic/MutableMapFactory.scala3
-rw-r--r--src/library/scala/collection/generic/MutableSetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/MutableSortedSetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/OrderedTraversableFactory.scala3
-rw-r--r--src/library/scala/collection/generic/ParFactory.scala4
-rw-r--r--src/library/scala/collection/generic/ParMapFactory.scala4
-rw-r--r--src/library/scala/collection/generic/ParSetFactory.scala4
-rw-r--r--src/library/scala/collection/generic/SeqFactory.scala3
-rw-r--r--src/library/scala/collection/generic/SeqForwarder.scala6
-rw-r--r--src/library/scala/collection/generic/SetFactory.scala3
-rw-r--r--src/library/scala/collection/generic/Shrinkable.scala3
-rw-r--r--src/library/scala/collection/generic/Signalling.scala10
-rw-r--r--src/library/scala/collection/generic/Sizing.scala4
-rw-r--r--src/library/scala/collection/generic/SliceInterval.scala3
-rw-r--r--src/library/scala/collection/generic/Sorted.scala35
-rw-r--r--src/library/scala/collection/generic/SortedMapFactory.scala5
-rw-r--r--src/library/scala/collection/generic/SortedSetFactory.scala7
-rw-r--r--src/library/scala/collection/generic/Subtractable.scala3
-rw-r--r--src/library/scala/collection/generic/TraversableFactory.scala3
-rw-r--r--src/library/scala/collection/generic/TraversableForwarder.scala4
-rw-r--r--src/library/scala/collection/generic/package.scala3
-rw-r--r--src/library/scala/collection/immutable/BitSet.scala12
-rwxr-xr-xsrc/library/scala/collection/immutable/DefaultMap.scala11
-rw-r--r--src/library/scala/collection/immutable/GenIterable.scala.disabled37
-rw-r--r--src/library/scala/collection/immutable/GenMap.scala.disabled36
-rw-r--r--src/library/scala/collection/immutable/GenSeq.scala.disabled49
-rw-r--r--src/library/scala/collection/immutable/GenSet.scala.disabled43
-rw-r--r--src/library/scala/collection/immutable/GenTraversable.scala.disabled41
-rw-r--r--src/library/scala/collection/immutable/HashMap.scala8
-rw-r--r--src/library/scala/collection/immutable/HashSet.scala4
-rw-r--r--src/library/scala/collection/immutable/IndexedSeq.scala8
-rw-r--r--src/library/scala/collection/immutable/IntMap.scala9
-rw-r--r--src/library/scala/collection/immutable/Iterable.scala3
-rw-r--r--src/library/scala/collection/immutable/LinearSeq.scala3
-rw-r--r--src/library/scala/collection/immutable/List.scala287
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala3
-rw-r--r--src/library/scala/collection/immutable/ListSet.scala13
-rw-r--r--src/library/scala/collection/immutable/LongMap.scala22
-rw-r--r--src/library/scala/collection/immutable/Map.scala3
-rw-r--r--src/library/scala/collection/immutable/MapLike.scala5
-rw-r--r--src/library/scala/collection/immutable/MapProxy.scala3
-rw-r--r--src/library/scala/collection/immutable/NumericRange.scala43
-rw-r--r--src/library/scala/collection/immutable/PagedSeq.scala7
-rw-r--r--src/library/scala/collection/immutable/Queue.scala3
-rw-r--r--src/library/scala/collection/immutable/Range.scala32
-rw-r--r--src/library/scala/collection/immutable/RedBlack.scala293
-rw-r--r--src/library/scala/collection/immutable/RedBlackTree.scala215
-rw-r--r--src/library/scala/collection/immutable/Seq.scala3
-rw-r--r--src/library/scala/collection/immutable/Set.scala3
-rw-r--r--src/library/scala/collection/immutable/SetProxy.scala3
-rw-r--r--src/library/scala/collection/immutable/SortedMap.scala13
-rw-r--r--src/library/scala/collection/immutable/SortedSet.scala3
-rw-r--r--src/library/scala/collection/immutable/Stack.scala3
-rw-r--r--src/library/scala/collection/immutable/Stream.scala58
-rw-r--r--src/library/scala/collection/immutable/StreamView.scala3
-rw-r--r--src/library/scala/collection/immutable/StreamViewLike.scala3
-rw-r--r--src/library/scala/collection/immutable/StringLike.scala17
-rw-r--r--src/library/scala/collection/immutable/StringOps.scala5
-rw-r--r--src/library/scala/collection/immutable/Traversable.scala3
-rw-r--r--src/library/scala/collection/immutable/TreeMap.scala16
-rw-r--r--src/library/scala/collection/immutable/TreeSet.scala13
-rw-r--r--src/library/scala/collection/immutable/TrieIterator.scala10
-rw-r--r--src/library/scala/collection/immutable/Vector.scala58
-rw-r--r--src/library/scala/collection/immutable/WrappedString.scala3
-rw-r--r--src/library/scala/collection/immutable/package.scala93
-rw-r--r--src/library/scala/collection/mutable/AVLTree.scala18
-rw-r--r--src/library/scala/collection/mutable/ArrayBuffer.scala3
-rw-r--r--src/library/scala/collection/mutable/ArrayBuilder.scala6
-rw-r--r--src/library/scala/collection/mutable/ArrayLike.scala6
-rw-r--r--src/library/scala/collection/mutable/ArrayOps.scala16
-rw-r--r--src/library/scala/collection/mutable/ArraySeq.scala5
-rw-r--r--src/library/scala/collection/mutable/ArrayStack.scala4
-rw-r--r--src/library/scala/collection/mutable/BitSet.scala59
-rw-r--r--src/library/scala/collection/mutable/Buffer.scala3
-rw-r--r--src/library/scala/collection/mutable/BufferLike.scala7
-rw-r--r--src/library/scala/collection/mutable/BufferProxy.scala8
-rw-r--r--src/library/scala/collection/mutable/Builder.scala2
-rw-r--r--src/library/scala/collection/mutable/Cloneable.scala3
-rw-r--r--src/library/scala/collection/mutable/ConcurrentMap.scala90
-rw-r--r--src/library/scala/collection/mutable/DefaultEntry.scala3
-rw-r--r--src/library/scala/collection/mutable/DefaultMapModel.scala3
-rw-r--r--src/library/scala/collection/mutable/DoubleLinkedList.scala5
-rw-r--r--src/library/scala/collection/mutable/DoubleLinkedListLike.scala3
-rw-r--r--src/library/scala/collection/mutable/FlatHashTable.scala128
-rw-r--r--src/library/scala/collection/mutable/GenIterable.scala.disabled37
-rw-r--r--src/library/scala/collection/mutable/GenMap.scala.disabled40
-rw-r--r--src/library/scala/collection/mutable/GenSeq.scala.disabled44
-rw-r--r--src/library/scala/collection/mutable/GenSet.scala.disabled46
-rw-r--r--src/library/scala/collection/mutable/GenTraversable.scala.disabled38
-rw-r--r--src/library/scala/collection/mutable/GrowingBuilder.scala3
-rw-r--r--src/library/scala/collection/mutable/HashEntry.scala3
-rw-r--r--src/library/scala/collection/mutable/HashMap.scala15
-rw-r--r--src/library/scala/collection/mutable/HashSet.scala23
-rw-r--r--src/library/scala/collection/mutable/HashTable.scala23
-rw-r--r--src/library/scala/collection/mutable/History.scala11
-rw-r--r--src/library/scala/collection/mutable/ImmutableMapAdaptor.scala3
-rw-r--r--src/library/scala/collection/mutable/ImmutableSetAdaptor.scala3
-rw-r--r--src/library/scala/collection/mutable/IndexedSeq.scala3
-rw-r--r--src/library/scala/collection/mutable/IndexedSeqLike.scala6
-rwxr-xr-xsrc/library/scala/collection/mutable/IndexedSeqOptimized.scala6
-rw-r--r--src/library/scala/collection/mutable/IndexedSeqView.scala5
-rw-r--r--src/library/scala/collection/mutable/Iterable.scala3
-rw-r--r--src/library/scala/collection/mutable/LazyBuilder.scala3
-rw-r--r--src/library/scala/collection/mutable/LinearSeq.scala3
-rw-r--r--src/library/scala/collection/mutable/LinkedEntry.scala3
-rw-r--r--src/library/scala/collection/mutable/LinkedHashMap.scala9
-rw-r--r--src/library/scala/collection/mutable/LinkedHashSet.scala5
-rw-r--r--src/library/scala/collection/mutable/LinkedList.scala3
-rw-r--r--src/library/scala/collection/mutable/LinkedListLike.scala8
-rw-r--r--src/library/scala/collection/mutable/ListBuffer.scala57
-rw-r--r--src/library/scala/collection/mutable/ListMap.scala3
-rw-r--r--src/library/scala/collection/mutable/Map.scala5
-rw-r--r--src/library/scala/collection/mutable/MapBuilder.scala3
-rw-r--r--src/library/scala/collection/mutable/MapLike.scala9
-rw-r--r--src/library/scala/collection/mutable/MapProxy.scala3
-rw-r--r--src/library/scala/collection/mutable/MultiMap.scala3
-rw-r--r--src/library/scala/collection/mutable/MutableList.scala8
-rw-r--r--src/library/scala/collection/mutable/ObservableBuffer.scala5
-rw-r--r--src/library/scala/collection/mutable/ObservableMap.scala5
-rw-r--r--src/library/scala/collection/mutable/ObservableSet.scala5
-rw-r--r--src/library/scala/collection/mutable/OpenHashMap.scala40
-rw-r--r--src/library/scala/collection/mutable/PriorityQueue.scala17
-rw-r--r--src/library/scala/collection/mutable/PriorityQueueProxy.scala15
-rw-r--r--src/library/scala/collection/mutable/Publisher.scala5
-rw-r--r--src/library/scala/collection/mutable/Queue.scala12
-rw-r--r--src/library/scala/collection/mutable/QueueProxy.scala7
-rw-r--r--src/library/scala/collection/mutable/RevertibleHistory.scala7
-rw-r--r--src/library/scala/collection/mutable/Seq.scala3
-rw-r--r--src/library/scala/collection/mutable/SeqLike.scala4
-rw-r--r--src/library/scala/collection/mutable/Set.scala3
-rw-r--r--src/library/scala/collection/mutable/SetBuilder.scala6
-rw-r--r--src/library/scala/collection/mutable/SetLike.scala7
-rw-r--r--src/library/scala/collection/mutable/SetProxy.scala3
-rw-r--r--src/library/scala/collection/mutable/SortedSet.scala3
-rw-r--r--src/library/scala/collection/mutable/Stack.scala3
-rw-r--r--src/library/scala/collection/mutable/StackProxy.scala7
-rw-r--r--src/library/scala/collection/mutable/StringBuilder.scala3
-rw-r--r--src/library/scala/collection/mutable/Subscriber.scala3
-rw-r--r--src/library/scala/collection/mutable/SynchronizedBuffer.scala5
-rw-r--r--src/library/scala/collection/mutable/SynchronizedMap.scala5
-rw-r--r--src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala15
-rw-r--r--src/library/scala/collection/mutable/SynchronizedQueue.scala9
-rw-r--r--src/library/scala/collection/mutable/SynchronizedSet.scala7
-rw-r--r--src/library/scala/collection/mutable/SynchronizedStack.scala7
-rw-r--r--src/library/scala/collection/mutable/Traversable.scala3
-rw-r--r--src/library/scala/collection/mutable/TreeSet.scala113
-rw-r--r--src/library/scala/collection/mutable/Undoable.scala3
-rw-r--r--src/library/scala/collection/mutable/UnrolledBuffer.scala7
-rw-r--r--src/library/scala/collection/mutable/WeakHashMap.scala3
-rw-r--r--src/library/scala/collection/mutable/WrappedArray.scala3
-rw-r--r--src/library/scala/collection/mutable/WrappedArrayBuilder.scala4
-rw-r--r--src/library/scala/collection/parallel/Combiner.scala17
-rw-r--r--src/library/scala/collection/parallel/ParIterable.scala4
-rw-r--r--src/library/scala/collection/parallel/ParIterableLike.scala124
-rw-r--r--src/library/scala/collection/parallel/ParIterableView.scala3
-rw-r--r--src/library/scala/collection/parallel/ParIterableViewLike.scala10
-rw-r--r--src/library/scala/collection/parallel/ParMap.scala3
-rw-r--r--src/library/scala/collection/parallel/ParMapLike.scala7
-rw-r--r--src/library/scala/collection/parallel/ParSeq.scala32
-rw-r--r--src/library/scala/collection/parallel/ParSeqLike.scala19
-rw-r--r--src/library/scala/collection/parallel/ParSeqView.scala6
-rw-r--r--src/library/scala/collection/parallel/ParSeqViewLike.scala11
-rw-r--r--src/library/scala/collection/parallel/ParSet.scala56
-rw-r--r--src/library/scala/collection/parallel/ParSetLike.scala11
-rw-r--r--src/library/scala/collection/parallel/PreciseSplitter.scala3
-rw-r--r--src/library/scala/collection/parallel/RemainsIterator.scala135
-rw-r--r--src/library/scala/collection/parallel/Splitter.scala5
-rw-r--r--src/library/scala/collection/parallel/TaskSupport.scala27
-rw-r--r--src/library/scala/collection/parallel/Tasks.scala90
-rw-r--r--src/library/scala/collection/parallel/immutable/ParHashMap.scala5
-rw-r--r--src/library/scala/collection/parallel/immutable/ParHashSet.scala5
-rw-r--r--src/library/scala/collection/parallel/immutable/ParIterable.scala30
-rw-r--r--src/library/scala/collection/parallel/immutable/ParMap.scala3
-rw-r--r--src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled128
-rw-r--r--src/library/scala/collection/parallel/immutable/ParRange.scala10
-rw-r--r--src/library/scala/collection/parallel/immutable/ParSeq.scala6
-rw-r--r--src/library/scala/collection/parallel/immutable/ParSet.scala4
-rw-r--r--src/library/scala/collection/parallel/immutable/ParVector.scala3
-rw-r--r--src/library/scala/collection/parallel/immutable/package.scala3
-rw-r--r--src/library/scala/collection/parallel/mutable/LazyCombiner.scala3
-rw-r--r--src/library/scala/collection/parallel/mutable/ParArray.scala61
-rw-r--r--src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala15
-rw-r--r--src/library/scala/collection/parallel/mutable/ParHashMap.scala31
-rw-r--r--src/library/scala/collection/parallel/mutable/ParHashSet.scala80
-rw-r--r--src/library/scala/collection/parallel/mutable/ParHashTable.scala5
-rw-r--r--src/library/scala/collection/parallel/mutable/ParIterable.scala30
-rw-r--r--src/library/scala/collection/parallel/mutable/ParMap.scala40
-rw-r--r--src/library/scala/collection/parallel/mutable/ParMapLike.scala6
-rw-r--r--src/library/scala/collection/parallel/mutable/ParSeq.scala26
-rw-r--r--src/library/scala/collection/parallel/mutable/ParSet.scala12
-rw-r--r--src/library/scala/collection/parallel/mutable/ParSetLike.scala9
-rw-r--r--src/library/scala/collection/parallel/mutable/ParTrieMap.scala5
-rw-r--r--src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala5
-rw-r--r--src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala8
-rw-r--r--src/library/scala/collection/parallel/mutable/package.scala3
-rw-r--r--src/library/scala/collection/parallel/package.scala6
-rw-r--r--src/library/scala/collection/script/Location.scala3
-rw-r--r--src/library/scala/collection/script/Message.scala5
-rw-r--r--src/library/scala/collection/script/Scriptable.scala3
-rw-r--r--src/library/scala/compat/Platform.scala5
-rw-r--r--src/library/scala/concurrent/BatchingExecutor.scala117
-rw-r--r--src/library/scala/concurrent/Future.scala114
-rw-r--r--src/library/scala/concurrent/FutureTaskRunner.scala6
-rw-r--r--src/library/scala/concurrent/JavaConversions.scala32
-rw-r--r--src/library/scala/concurrent/ManagedBlocker.scala2
-rw-r--r--src/library/scala/concurrent/SyncVar.scala10
-rw-r--r--src/library/scala/concurrent/TaskRunner.scala2
-rw-r--r--src/library/scala/concurrent/TaskRunners.scala36
-rw-r--r--src/library/scala/concurrent/ThreadPoolRunner.scala2
-rw-r--r--src/library/scala/concurrent/ThreadRunner.scala60
-rw-r--r--src/library/scala/concurrent/duration/Duration.scala9
-rw-r--r--src/library/scala/concurrent/impl/ExecutionContextImpl.scala35
-rw-r--r--src/library/scala/concurrent/impl/Future.scala2
-rw-r--r--src/library/scala/concurrent/impl/Promise.scala6
-rw-r--r--src/library/scala/concurrent/ops.scala73
-rw-r--r--src/library/scala/deprecatedInheritance.scala3
-rw-r--r--src/library/scala/io/AnsiColor.scala53
-rw-r--r--src/library/scala/io/BufferedSource.scala2
-rw-r--r--src/library/scala/io/BytePickle.scala318
-rw-r--r--src/library/scala/io/Codec.scala59
-rw-r--r--src/library/scala/io/Position.scala11
-rw-r--r--src/library/scala/io/ReadStdin.scala228
-rw-r--r--src/library/scala/io/Source.scala15
-rw-r--r--src/library/scala/io/UTF8Codec.scala32
-rw-r--r--src/library/scala/math/BigDecimal.scala19
-rw-r--r--src/library/scala/math/BigInt.scala16
-rw-r--r--src/library/scala/math/Equiv.scala3
-rw-r--r--src/library/scala/math/Fractional.scala3
-rw-r--r--src/library/scala/math/Integral.scala3
-rw-r--r--src/library/scala/math/Numeric.scala3
-rw-r--r--src/library/scala/math/Ordered.scala3
-rw-r--r--src/library/scala/math/Ordering.scala8
-rw-r--r--src/library/scala/math/PartialOrdering.scala3
-rw-r--r--src/library/scala/math/PartiallyOrdered.scala3
-rw-r--r--src/library/scala/math/ScalaNumber.java2
-rw-r--r--src/library/scala/math/ScalaNumericConversions.scala19
-rw-r--r--src/library/scala/package.scala13
-rw-r--r--src/library/scala/parallel/Future.scala39
-rw-r--r--src/library/scala/parallel/package.scala.disabled178
-rw-r--r--src/library/scala/ref/SoftReference.scala3
-rw-r--r--src/library/scala/reflect/ClassManifestDeprecatedApis.scala3
-rw-r--r--src/library/scala/reflect/Manifest.scala3
-rwxr-xr-xsrc/library/scala/reflect/NameTransformer.scala13
-rw-r--r--src/library/scala/reflect/NoManifest.scala3
-rw-r--r--src/library/scala/reflect/OptManifest.scala3
-rw-r--r--src/library/scala/reflect/package.scala14
-rw-r--r--src/library/scala/runtime/AbstractFunction0.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction1.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction10.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction11.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction12.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction13.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction14.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction15.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction16.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction17.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction18.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction19.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction2.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction20.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction21.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction22.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction3.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction4.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction5.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction6.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction7.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction8.scala2
-rw-r--r--src/library/scala/runtime/AbstractFunction9.scala2
-rw-r--r--src/library/scala/runtime/AbstractPartialFunction.scala5
-rw-r--r--src/library/scala/runtime/BooleanRef.java3
-rw-r--r--src/library/scala/runtime/Boxed.scala4
-rw-r--r--src/library/scala/runtime/ByteRef.java3
-rw-r--r--src/library/scala/runtime/CharRef.java3
-rw-r--r--src/library/scala/runtime/DoubleRef.java3
-rw-r--r--src/library/scala/runtime/FloatRef.java3
-rw-r--r--src/library/scala/runtime/IntRef.java3
-rw-r--r--src/library/scala/runtime/LongRef.java3
-rw-r--r--src/library/scala/runtime/MethodCache.scala4
-rw-r--r--src/library/scala/runtime/NonLocalReturnControl.scala4
-rw-r--r--src/library/scala/runtime/Nothing$.scala4
-rw-r--r--src/library/scala/runtime/Null$.scala9
-rw-r--r--src/library/scala/runtime/ObjectRef.java3
-rw-r--r--src/library/scala/runtime/RichBoolean.scala4
-rw-r--r--src/library/scala/runtime/RichByte.scala4
-rw-r--r--src/library/scala/runtime/RichChar.scala4
-rw-r--r--src/library/scala/runtime/RichException.scala4
-rw-r--r--src/library/scala/runtime/RichInt.scala4
-rw-r--r--src/library/scala/runtime/RichLong.scala4
-rw-r--r--src/library/scala/runtime/RichShort.scala4
-rw-r--r--src/library/scala/runtime/ScalaNumberProxy.scala7
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala13
-rw-r--r--src/library/scala/runtime/SeqCharSequence.scala3
-rw-r--r--src/library/scala/runtime/ShortRef.java3
-rw-r--r--src/library/scala/runtime/StringAdd.scala5
-rw-r--r--src/library/scala/runtime/StringFormat.scala5
-rw-r--r--src/library/scala/runtime/Tuple2Zipped.scala30
-rw-r--r--src/library/scala/runtime/Tuple3Zipped.scala30
-rwxr-xr-xsrc/library/scala/runtime/VolatileBooleanRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileByteRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileCharRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileDoubleRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileFloatRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileIntRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileLongRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileObjectRef.java3
-rwxr-xr-xsrc/library/scala/runtime/VolatileShortRef.java3
-rw-r--r--src/library/scala/sys/BooleanProp.scala3
-rw-r--r--src/library/scala/sys/PropImpl.scala3
-rw-r--r--src/library/scala/sys/ShutdownHookThread.scala3
-rw-r--r--src/library/scala/sys/SystemProperties.scala4
-rw-r--r--src/library/scala/sys/process/BasicIO.scala5
-rw-r--r--src/library/scala/sys/process/Process.scala3
-rw-r--r--src/library/scala/sys/process/ProcessBuilder.scala49
-rw-r--r--src/library/scala/sys/process/ProcessBuilderImpl.scala33
-rw-r--r--src/library/scala/sys/process/ProcessIO.scala3
-rw-r--r--src/library/scala/sys/process/ProcessImpl.scala15
-rw-r--r--src/library/scala/sys/process/ProcessLogger.scala3
-rw-r--r--src/library/scala/sys/process/package.scala2
-rw-r--r--src/library/scala/testing/Benchmark.scala114
-rw-r--r--src/library/scala/testing/Show.scala75
-rw-r--r--src/library/scala/text/Document.scala2
-rw-r--r--src/library/scala/throws.scala2
-rw-r--r--src/library/scala/util/DynamicVariable.scala3
-rw-r--r--src/library/scala/util/Either.scala9
-rw-r--r--src/library/scala/util/Marshal.scala50
-rw-r--r--src/library/scala/util/MurmurHash.scala197
-rw-r--r--src/library/scala/util/Properties.scala7
-rw-r--r--src/library/scala/util/Random.scala7
-rw-r--r--src/library/scala/util/Try.scala5
-rw-r--r--src/library/scala/util/control/Breaks.scala3
-rw-r--r--src/library/scala/util/control/ControlThrowable.scala3
-rw-r--r--src/library/scala/util/control/Exception.scala3
-rw-r--r--src/library/scala/util/control/NonFatal.scala7
-rw-r--r--src/library/scala/util/control/TailCalls.scala3
-rw-r--r--src/library/scala/util/grammar/HedgeRHS.scala26
-rw-r--r--src/library/scala/util/grammar/TreeRHS.scala22
-rw-r--r--src/library/scala/util/hashing/ByteswapHashing.scala13
-rw-r--r--src/library/scala/util/hashing/Hashing.scala3
-rw-r--r--src/library/scala/util/hashing/MurmurHash3.scala11
-rw-r--r--src/library/scala/util/hashing/package.scala9
-rw-r--r--src/library/scala/util/logging/ConsoleLogger.scala26
-rw-r--r--src/library/scala/util/logging/Logged.scala33
-rw-r--r--src/library/scala/util/matching/Regex.scala115
-rw-r--r--src/library/scala/util/parsing/ast/AbstractSyntax.scala32
-rw-r--r--src/library/scala/util/parsing/ast/Binders.scala347
-rw-r--r--src/library/scala/util/parsing/combinator/ImplicitConversions.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/JavaTokenParsers.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/PackratParsers.scala4
-rw-r--r--src/library/scala/util/parsing/combinator/Parsers.scala11
-rw-r--r--src/library/scala/util/parsing/combinator/RegexParsers.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/Lexical.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/Scanners.scala6
-rw-r--r--src/library/scala/util/parsing/combinator/lexical/StdLexical.scala5
-rw-r--r--src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/testing/RegexTest.scala27
-rw-r--r--src/library/scala/util/parsing/combinator/testing/Tester.scala45
-rw-r--r--src/library/scala/util/parsing/combinator/token/StdTokens.scala3
-rw-r--r--src/library/scala/util/parsing/combinator/token/Tokens.scala3
-rw-r--r--src/library/scala/util/parsing/input/CharArrayReader.scala3
-rw-r--r--src/library/scala/util/parsing/input/CharSequenceReader.scala3
-rw-r--r--src/library/scala/util/parsing/input/NoPosition.scala3
-rw-r--r--src/library/scala/util/parsing/input/OffsetPosition.scala5
-rw-r--r--src/library/scala/util/parsing/input/PagedSeqReader.scala3
-rw-r--r--src/library/scala/util/parsing/input/Position.scala7
-rw-r--r--src/library/scala/util/parsing/input/Positional.scala3
-rw-r--r--src/library/scala/util/parsing/input/Reader.scala3
-rw-r--r--src/library/scala/util/parsing/input/StreamReader.scala5
-rw-r--r--src/library/scala/util/parsing/json/JSON.scala6
-rw-r--r--src/library/scala/util/parsing/json/Lexer.scala4
-rw-r--r--src/library/scala/util/parsing/json/Parser.scala4
-rw-r--r--src/library/scala/xml/Atom.scala3
-rw-r--r--src/library/scala/xml/Attribute.scala5
-rw-r--r--src/library/scala/xml/Comment.scala3
-rw-r--r--src/library/scala/xml/Document.scala3
-rwxr-xr-xsrc/library/scala/xml/Elem.scala5
-rw-r--r--src/library/scala/xml/EntityRef.scala3
-rw-r--r--src/library/scala/xml/Equality.scala7
-rw-r--r--src/library/scala/xml/Group.scala5
-rw-r--r--src/library/scala/xml/MalformedAttributeException.scala3
-rw-r--r--src/library/scala/xml/MetaData.scala3
-rw-r--r--src/library/scala/xml/NamespaceBinding.scala25
-rwxr-xr-xsrc/library/scala/xml/Node.scala15
-rw-r--r--src/library/scala/xml/NodeBuffer.scala3
-rw-r--r--src/library/scala/xml/NodeSeq.scala8
-rw-r--r--src/library/scala/xml/Null.scala3
-rw-r--r--src/library/scala/xml/PCData.scala3
-rw-r--r--src/library/scala/xml/PrefixedAttribute.scala3
-rwxr-xr-xsrc/library/scala/xml/PrettyPrinter.scala8
-rw-r--r--src/library/scala/xml/ProcInstr.scala3
-rw-r--r--src/library/scala/xml/QNode.scala3
-rw-r--r--src/library/scala/xml/SpecialNode.scala3
-rw-r--r--src/library/scala/xml/Text.scala3
-rw-r--r--src/library/scala/xml/TextBuffer.scala3
-rw-r--r--src/library/scala/xml/TopScope.scala3
-rw-r--r--src/library/scala/xml/TypeSymbol.scala3
-rw-r--r--src/library/scala/xml/Unparsed.scala3
-rw-r--r--src/library/scala/xml/UnprefixedAttribute.scala3
-rwxr-xr-xsrc/library/scala/xml/Utility.scala25
-rwxr-xr-xsrc/library/scala/xml/XML.scala5
-rw-r--r--src/library/scala/xml/Xhtml.scala3
-rw-r--r--src/library/scala/xml/dtd/ContentModel.scala8
-rw-r--r--src/library/scala/xml/dtd/ContentModelParser.scala77
-rw-r--r--src/library/scala/xml/dtd/DTD.scala3
-rw-r--r--src/library/scala/xml/dtd/Decl.scala5
-rw-r--r--src/library/scala/xml/dtd/DocType.scala15
-rw-r--r--src/library/scala/xml/dtd/ElementValidator.scala19
-rw-r--r--src/library/scala/xml/dtd/ExternalID.scala17
-rw-r--r--src/library/scala/xml/dtd/Scanner.scala33
-rw-r--r--src/library/scala/xml/dtd/Tokens.scala3
-rw-r--r--src/library/scala/xml/dtd/ValidationException.scala5
-rw-r--r--src/library/scala/xml/dtd/impl/Base.scala (renamed from src/library/scala/util/regexp/Base.scala)5
-rw-r--r--src/library/scala/xml/dtd/impl/BaseBerrySethi.scala (renamed from src/library/scala/util/automata/BaseBerrySethi.scala)6
-rw-r--r--src/library/scala/xml/dtd/impl/DetWordAutom.scala (renamed from src/library/scala/util/automata/DetWordAutom.scala)5
-rw-r--r--src/library/scala/xml/dtd/impl/Inclusion.scala (renamed from src/library/scala/util/automata/Inclusion.scala)5
-rw-r--r--src/library/scala/xml/dtd/impl/NondetWordAutom.scala (renamed from src/library/scala/util/automata/NondetWordAutom.scala)11
-rw-r--r--src/library/scala/xml/dtd/impl/PointedHedgeExp.scala (renamed from src/library/scala/util/regexp/PointedHedgeExp.scala)5
-rw-r--r--src/library/scala/xml/dtd/impl/SubsetConstruction.scala (renamed from src/library/scala/util/automata/SubsetConstruction.scala)7
-rw-r--r--src/library/scala/xml/dtd/impl/SyntaxError.scala (renamed from src/library/scala/util/regexp/SyntaxError.scala)5
-rw-r--r--src/library/scala/xml/dtd/impl/WordBerrySethi.scala (renamed from src/library/scala/util/automata/WordBerrySethi.scala)10
-rw-r--r--src/library/scala/xml/dtd/impl/WordExp.scala (renamed from src/library/scala/util/regexp/WordExp.scala)5
-rwxr-xr-xsrc/library/scala/xml/factory/Binder.scala5
-rw-r--r--src/library/scala/xml/factory/LoggedNodeFactory.scala23
-rw-r--r--src/library/scala/xml/factory/NodeFactory.scala3
-rw-r--r--src/library/scala/xml/factory/XMLLoader.scala7
-rw-r--r--src/library/scala/xml/include/CircularIncludeException.scala3
-rw-r--r--src/library/scala/xml/include/UnavailableResourceException.scala3
-rw-r--r--src/library/scala/xml/include/XIncludeException.scala3
-rw-r--r--src/library/scala/xml/include/sax/EncodingHeuristics.scala5
-rw-r--r--src/library/scala/xml/include/sax/Main.scala82
-rw-r--r--src/library/scala/xml/include/sax/XIncludeFilter.scala21
-rw-r--r--src/library/scala/xml/include/sax/XIncluder.scala35
-rwxr-xr-xsrc/library/scala/xml/parsing/ConstructingHandler.scala3
-rw-r--r--src/library/scala/xml/parsing/ConstructingParser.scala3
-rwxr-xr-xsrc/library/scala/xml/parsing/DefaultMarkupHandler.scala3
-rw-r--r--src/library/scala/xml/parsing/ExternalSources.scala3
-rw-r--r--src/library/scala/xml/parsing/FactoryAdapter.scala13
-rw-r--r--src/library/scala/xml/parsing/FatalError.scala3
-rwxr-xr-xsrc/library/scala/xml/parsing/MarkupHandler.scala11
-rwxr-xr-xsrc/library/scala/xml/parsing/MarkupParser.scala227
-rw-r--r--src/library/scala/xml/parsing/MarkupParserCommon.scala34
-rw-r--r--src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala3
-rw-r--r--src/library/scala/xml/parsing/TokenTests.scala3
-rw-r--r--src/library/scala/xml/parsing/ValidatingMarkupHandler.scala27
-rw-r--r--src/library/scala/xml/parsing/XhtmlEntities.scala3
-rw-r--r--src/library/scala/xml/parsing/XhtmlParser.scala5
-rw-r--r--src/library/scala/xml/persistent/CachedFileStorage.scala22
-rw-r--r--src/library/scala/xml/persistent/Index.scala3
-rw-r--r--src/library/scala/xml/persistent/SetStorage.scala9
-rw-r--r--src/library/scala/xml/pull/XMLEvent.scala3
-rwxr-xr-xsrc/library/scala/xml/pull/XMLEventReader.scala9
-rw-r--r--src/library/scala/xml/pull/package.scala3
-rw-r--r--src/library/scala/xml/transform/BasicTransformer.scala5
-rw-r--r--src/library/scala/xml/transform/RewriteRule.scala7
-rw-r--r--src/library/scala/xml/transform/RuleTransformer.scala5
660 files changed, 3883 insertions, 6786 deletions
diff --git a/src/library/scala/AnyVal.scala b/src/library/scala/AnyVal.scala
index 0d6ba2454c..9def6cb054 100644
--- a/src/library/scala/AnyVal.scala
+++ b/src/library/scala/AnyVal.scala
@@ -52,6 +52,6 @@ package scala
* as well as in [[http://docs.scala-lang.org/sips/pending/value-classes.html SIP-15: Value Classes]],
* the Scala Improvement Proposal.
*/
-abstract class AnyVal extends Any with NotNull {
+abstract class AnyVal extends Any {
def getClass(): Class[_ <: AnyVal] = null
}
diff --git a/src/library/scala/Application.scala b/src/library/scala/Application.scala
deleted file mode 100644
index e7db0d2db8..0000000000
--- a/src/library/scala/Application.scala
+++ /dev/null
@@ -1,79 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala
-
-import scala.compat.Platform.currentTime
-
-/** The `Application` trait can be used to quickly turn objects
- * into executable programs, but is ''not recommended''.
- * Here is an example:
- * {{{
- * object Main extends Application {
- * Console.println("Hello World!")
- * }
- * }}}
- * Here, object `Main` inherits the `main` method of `Application`.
- * The body of the `Main` object defines the main program. This technique
- * does not work if the main program depends on command-line arguments
- * (which are not accessible with the technique presented here).
- *
- * It is possible to time the execution of objects that inherit from class
- * `Application` by setting the global `scala.time`
- * property. Here is an example for benchmarking object `Main`:
- * {{{
- * java -Dscala.time Main
- * }}}
- * In practice the `Application` trait has a number of serious pitfalls:
- *
- * - Threaded code that references the object will block until static
- * initialization is complete. However, because the entire execution
- * of an `object` extending `Application` takes place during
- * static initialization, concurrent code will ''always'' deadlock if
- * it must synchronize with the enclosing object.
- * - As described above, there is no way to obtain the
- * command-line arguments because all code in body of an `object`
- * extending `Application` is run as part of the static initialization
- * which occurs before `Application`'s `main` method
- * even begins execution.
- * - Static initializers are run only once during program execution, and
- * JVM authors usually assume their execution to be relatively short.
- * Therefore, certain JVM configurations may become confused, or simply
- * fail to optimize or JIT the code in the body of an `object` extending
- * `Application`. This can lead to a significant performance degradation.
- *
- * It is recommended to use the [[scala.App]] trait instead.
- * {{{
- * object Main {
- * def main(args: Array[String]) {
- * //..
- * }
- * }
- * }}}
- *
- * @author Matthias Zenger
- * @version 1.0, 10/09/2003
- */
-@deprecated("use App instead", "2.9.0")
-trait Application {
-
- /** The time when the execution of this program started,
- * in milliseconds since 1 January 1970 UTC. */
- val executionStart: Long = currentTime
-
- /** The default main method.
- *
- * @param args the arguments passed to the main method
- */
- def main(args: Array[String]) {
- if (util.Properties propIsSet "scala.time") {
- val total = currentTime - executionStart
- Console.println("[total " + total + "ms]")
- }
- }
-}
diff --git a/src/library/scala/Array.scala b/src/library/scala/Array.scala
index b9f51803ec..6ab82d998e 100644
--- a/src/library/scala/Array.scala
+++ b/src/library/scala/Array.scala
@@ -240,9 +240,9 @@ object Array extends FallbackArrayBuilding {
*/
def concat[T: ClassTag](xss: Array[T]*): Array[T] = {
val b = newBuilder[T]
- b.sizeHint(xss.map(_.size).sum)
+ b.sizeHint(xss.map(_.length).sum)
for (xs <- xss) b ++= xs
- b.result
+ b.result()
}
/** Returns an array that contains the results of some element computation a number
@@ -267,7 +267,7 @@ object Array extends FallbackArrayBuilding {
b += elem
i += 1
}
- b.result
+ b.result()
}
/** Returns a two-dimensional array that contains the results of some element
@@ -331,7 +331,7 @@ object Array extends FallbackArrayBuilding {
b += f(i)
i += 1
}
- b.result
+ b.result()
}
/** Returns a two-dimensional array containing values of a given function
@@ -399,14 +399,14 @@ object Array extends FallbackArrayBuilding {
def range(start: Int, end: Int, step: Int): Array[Int] = {
if (step == 0) throw new IllegalArgumentException("zero step")
val b = newBuilder[Int]
- b.sizeHint(immutable.Range.count(start, end, step, false))
+ b.sizeHint(immutable.Range.count(start, end, step, isInclusive = false))
var i = start
while (if (step < 0) end < i else i < end) {
b += i
i += step
}
- b.result
+ b.result()
}
/** Returns an array containing repeated applications of a function to a start value.
@@ -431,7 +431,7 @@ object Array extends FallbackArrayBuilding {
b += acc
}
}
- b.result
+ b.result()
}
/** Called in a pattern match like `{ case Array(x,y,z) => println('3 elements')}`.
diff --git a/src/library/scala/Boolean.scala b/src/library/scala/Boolean.scala
index 440e546f19..ddd11257c6 100644
--- a/src/library/scala/Boolean.scala
+++ b/src/library/scala/Boolean.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -116,6 +116,8 @@ object Boolean extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToBoolean`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Boolean to be boxed
* @return a java.lang.Boolean offering `x` as its underlying value.
*/
@@ -125,6 +127,8 @@ object Boolean extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Boolean.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToBoolean`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Boolean to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Boolean
* @return the Boolean resulting from calling booleanValue() on `x`
diff --git a/src/library/scala/Byte.scala b/src/library/scala/Byte.scala
index df0d2c73b1..2510e859c0 100644
--- a/src/library/scala/Byte.scala
+++ b/src/library/scala/Byte.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -606,6 +606,8 @@ object Byte extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToByte`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Byte to be boxed
* @return a java.lang.Byte offering `x` as its underlying value.
*/
@@ -615,6 +617,8 @@ object Byte extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Byte.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToByte`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Byte to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Byte
* @return the Byte resulting from calling byteValue() on `x`
diff --git a/src/library/scala/Char.scala b/src/library/scala/Char.scala
index 1fa0c0d9e8..1c9a2ba44f 100644
--- a/src/library/scala/Char.scala
+++ b/src/library/scala/Char.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -606,6 +606,8 @@ object Char extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToCharacter`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Char to be boxed
* @return a java.lang.Character offering `x` as its underlying value.
*/
@@ -615,6 +617,8 @@ object Char extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Character.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToChar`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Character to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Character
* @return the Char resulting from calling charValue() on `x`
diff --git a/src/library/scala/Console.scala b/src/library/scala/Console.scala
index 5b015502ea..275d7629ee 100644
--- a/src/library/scala/Console.scala
+++ b/src/library/scala/Console.scala
@@ -6,16 +6,12 @@
** |/ **
\* */
-
-
package scala
-import java.io.{BufferedReader, InputStream, InputStreamReader,
- IOException, OutputStream, PrintStream, Reader}
-import java.text.MessageFormat
+import java.io.{ BufferedReader, InputStream, InputStreamReader, OutputStream, PrintStream, Reader }
+import scala.io.{ AnsiColor, ReadStdin }
import scala.util.DynamicVariable
-
/** Implements functionality for
* printing Scala values on the terminal as well as reading specific values.
* Also defines constants for marking up text on ANSI terminals.
@@ -23,60 +19,16 @@ import scala.util.DynamicVariable
* @author Matthias Zenger
* @version 1.0, 03/09/2003
*/
-object Console {
-
- /** Foreground color for ANSI black */
- final val BLACK = "\033[30m"
- /** Foreground color for ANSI red */
- final val RED = "\033[31m"
- /** Foreground color for ANSI green */
- final val GREEN = "\033[32m"
- /** Foreground color for ANSI yellow */
- final val YELLOW = "\033[33m"
- /** Foreground color for ANSI blue */
- final val BLUE = "\033[34m"
- /** Foreground color for ANSI magenta */
- final val MAGENTA = "\033[35m"
- /** Foreground color for ANSI cyan */
- final val CYAN = "\033[36m"
- /** Foreground color for ANSI white */
- final val WHITE = "\033[37m"
-
- /** Background color for ANSI black */
- final val BLACK_B = "\033[40m"
- /** Background color for ANSI red */
- final val RED_B = "\033[41m"
- /** Background color for ANSI green */
- final val GREEN_B = "\033[42m"
- /** Background color for ANSI yellow */
- final val YELLOW_B = "\033[43m"
- /** Background color for ANSI blue */
- final val BLUE_B = "\033[44m"
- /** Background color for ANSI magenta */
- final val MAGENTA_B = "\033[45m"
- /** Background color for ANSI cyan */
- final val CYAN_B = "\033[46m"
- /** Background color for ANSI white */
- final val WHITE_B = "\033[47m"
-
- /** Reset ANSI styles */
- final val RESET = "\033[0m"
- /** ANSI bold */
- final val BOLD = "\033[1m"
- /** ANSI underlines */
- final val UNDERLINED = "\033[4m"
- /** ANSI blink */
- final val BLINK = "\033[5m"
- /** ANSI reversed */
- final val REVERSED = "\033[7m"
- /** ANSI invisible */
- final val INVISIBLE = "\033[8m"
-
+object Console extends DeprecatedConsole with AnsiColor {
private val outVar = new DynamicVariable[PrintStream](java.lang.System.out)
private val errVar = new DynamicVariable[PrintStream](java.lang.System.err)
- private val inVar = new DynamicVariable[BufferedReader](
+ private val inVar = new DynamicVariable[BufferedReader](
new BufferedReader(new InputStreamReader(java.lang.System.in)))
+ protected def setOutDirect(out: PrintStream): Unit = outVar.value = out
+ protected def setErrDirect(err: PrintStream): Unit = errVar.value = err
+ protected def setInDirect(in: BufferedReader): Unit = inVar.value = in
+
/** The default output, can be overridden by `setOut` */
def out = outVar.value
/** The default error, can be overridden by `setErr` */
@@ -84,12 +36,6 @@ object Console {
/** The default input, can be overridden by `setIn` */
def in = inVar.value
- /** Sets the default output stream.
- *
- * @param out the new output stream.
- */
- def setOut(out: PrintStream) { outVar.value = out }
-
/** Sets the default output stream for the duration
* of execution of one thunk.
*
@@ -106,13 +52,6 @@ object Console {
def withOut[T](out: PrintStream)(thunk: =>T): T =
outVar.withValue(out)(thunk)
- /** Sets the default output stream.
- *
- * @param out the new output stream.
- */
- def setOut(out: OutputStream): Unit =
- setOut(new PrintStream(out))
-
/** Sets the default output stream for the duration
* of execution of one thunk.
*
@@ -125,13 +64,6 @@ object Console {
def withOut[T](out: OutputStream)(thunk: =>T): T =
withOut(new PrintStream(out))(thunk)
-
- /** Sets the default error stream.
- *
- * @param err the new error stream.
- */
- def setErr(err: PrintStream) { errVar.value = err }
-
/** Set the default error stream for the duration
* of execution of one thunk.
* @example {{{
@@ -147,13 +79,6 @@ object Console {
def withErr[T](err: PrintStream)(thunk: =>T): T =
errVar.withValue(err)(thunk)
- /** Sets the default error stream.
- *
- * @param err the new error stream.
- */
- def setErr(err: OutputStream): Unit =
- setErr(new PrintStream(err))
-
/** Sets the default error stream for the duration
* of execution of one thunk.
*
@@ -166,15 +91,6 @@ object Console {
def withErr[T](err: OutputStream)(thunk: =>T): T =
withErr(new PrintStream(err))(thunk)
-
- /** Sets the default input stream.
- *
- * @param reader specifies the new input stream.
- */
- def setIn(reader: Reader) {
- inVar.value = new BufferedReader(reader)
- }
-
/** Sets the default input stream for the duration
* of execution of one thunk.
*
@@ -195,14 +111,6 @@ object Console {
def withIn[T](reader: Reader)(thunk: =>T): T =
inVar.withValue(new BufferedReader(reader))(thunk)
- /** Sets the default input stream.
- *
- * @param in the new input stream.
- */
- def setIn(in: InputStream) {
- setIn(new InputStreamReader(in))
- }
-
/** Sets the default input stream for the duration
* of execution of one thunk.
*
@@ -251,218 +159,64 @@ object Console {
* @throws java.lang.IllegalArgumentException if there was a problem with the format string or arguments
*/
def printf(text: String, args: Any*) { out.print(text format (args : _*)) }
+}
- /** Read a full line from the default input. Returns `null` if the end of the
- * input stream has been reached.
- *
- * @return the string read from the terminal or null if the end of stream was reached.
- */
- def readLine(): String = in.readLine()
-
- /** Print formatted text to the default output and read a full line from the default input.
- * Returns `null` if the end of the input stream has been reached.
- *
- * @param text the format of the text to print out, as in `printf`.
- * @param args the parameters used to instantiate the format, as in `printf`.
- * @return the string read from the default input
- */
- def readLine(text: String, args: Any*): String = {
- printf(text, args: _*)
- readLine()
- }
-
- /** Reads a boolean value from an entire line of the default input.
- * Has a fairly liberal interpretation of the input.
- *
- * @return the boolean value read, or false if it couldn't be converted to a boolean
- * @throws java.io.EOFException if the end of the input stream has been reached.
- */
- def readBoolean(): Boolean = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toLowerCase() match {
- case "true" => true
- case "t" => true
- case "yes" => true
- case "y" => true
- case _ => false
- }
- }
-
- /** Reads a byte value from an entire line of the default input.
- *
- * @return the Byte that was read
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.NumberFormatException if the value couldn't be converted to a Byte
- */
- def readByte(): Byte = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toByte
- }
-
- /** Reads a short value from an entire line of the default input.
- *
- * @return the short that was read
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.NumberFormatException if the value couldn't be converted to a Short
- */
- def readShort(): Short = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toShort
- }
-
- /** Reads a char value from an entire line of the default input.
- *
- * @return the Char that was read
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.StringIndexOutOfBoundsException if the line read from default input was empty
- */
- def readChar(): Char = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s charAt 0
- }
-
- /** Reads an int value from an entire line of the default input.
- *
- * @return the Int that was read
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.NumberFormatException if the value couldn't be converted to an Int
- */
- def readInt(): Int = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toInt
- }
-
- /** Reads an long value from an entire line of the default input.
- *
- * @return the Long that was read
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.NumberFormatException if the value couldn't be converted to a Long
- */
- def readLong(): Long = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toLong
- }
+private[scala] abstract class DeprecatedConsole {
+ self: Console.type =>
+
+ /** Internal usage only. */
+ protected def setOutDirect(out: PrintStream): Unit
+ protected def setErrDirect(err: PrintStream): Unit
+ protected def setInDirect(in: BufferedReader): Unit
+
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readBoolean(): Boolean = ReadStdin.readBoolean()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readByte(): Byte = ReadStdin.readByte()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readChar(): Char = ReadStdin.readChar()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readDouble(): Double = ReadStdin.readDouble()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readFloat(): Float = ReadStdin.readFloat()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readInt(): Int = ReadStdin.readInt()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readLine(): String = ReadStdin.readLine()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readLine(text: String, args: Any*): String = ReadStdin.readLine(text, args: _*)
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readLong(): Long = ReadStdin.readLong()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readShort(): Short = ReadStdin.readShort()
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf(format: String): List[Any] = ReadStdin.readf(format)
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf1(format: String): Any = ReadStdin.readf1(format)
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf2(format: String): (Any, Any) = ReadStdin.readf2(format)
+ @deprecated("Use the method in scala.io.ReadStdin", "2.11.0") def readf3(format: String): (Any, Any, Any) = ReadStdin.readf3(format)
- /** Reads a float value from an entire line of the default input.
- * @return the Float that was read.
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float
+ /** Sets the default output stream.
*
+ * @param out the new output stream.
*/
- def readFloat(): Float = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toFloat
- }
+ @deprecated("Use withOut", "2.11.0") def setOut(out: PrintStream): Unit = setOutDirect(out)
- /** Reads a double value from an entire line of the default input.
+ /** Sets the default output stream.
*
- * @return the Double that was read.
- * @throws java.io.EOFException if the end of the
- * input stream has been reached.
- * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float
+ * @param out the new output stream.
*/
- def readDouble(): Double = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- s.toDouble
- }
+ @deprecated("Use withOut", "2.11.0") def setOut(out: OutputStream): Unit = setOutDirect(new PrintStream(out))
- /** Reads in some structured input (from the default input), specified by
- * a format specifier. See class `java.text.MessageFormat` for details of
- * the format specification.
+ /** Sets the default error stream.
*
- * @param format the format of the input.
- * @return a list of all extracted values.
- * @throws java.io.EOFException if the end of the input stream has been
- * reached.
+ * @param err the new error stream.
*/
- def readf(format: String): List[Any] = {
- val s = readLine()
- if (s == null)
- throw new java.io.EOFException("Console has reached end of input")
- else
- textComponents(new MessageFormat(format).parse(s))
- }
+ @deprecated("Use withErr", "2.11.0") def setErr(err: PrintStream): Unit = setErrDirect(err)
- /** Reads in some structured input (from the default input), specified by
- * a format specifier, returning only the first value extracted, according
- * to the format specification.
+ /** Sets the default error stream.
*
- * @param format format string, as accepted by `readf`.
- * @return The first value that was extracted from the input
+ * @param err the new error stream.
*/
- def readf1(format: String): Any = readf(format).head
+ @deprecated("Use withErr", "2.11.0") def setErr(err: OutputStream): Unit = setErrDirect(new PrintStream(err))
- /** Reads in some structured input (from the default input), specified
- * by a format specifier, returning only the first two values extracted,
- * according to the format specification.
+ /** Sets the default input stream.
*
- * @param format format string, as accepted by `readf`.
- * @return A [[scala.Tuple2]] containing the first two values extracted
+ * @param reader specifies the new input stream.
*/
- def readf2(format: String): (Any, Any) = {
- val res = readf(format)
- (res.head, res.tail.head)
- }
+ @deprecated("Use withIn", "2.11.0") def setIn(reader: Reader): Unit = setInDirect(new BufferedReader(reader))
- /** Reads in some structured input (from the default input), specified
- * by a format specifier, returning only the first three values extracted,
- * according to the format specification.
+ /** Sets the default input stream.
*
- * @param format format string, as accepted by `readf`.
- * @return A [[scala.Tuple3]] containing the first three values extracted
+ * @param in the new input stream.
*/
- def readf3(format: String): (Any, Any, Any) = {
- val res = readf(format)
- (res.head, res.tail.head, res.tail.tail.head)
- }
-
- private def textComponents(a: Array[AnyRef]): List[Any] = {
- var i: Int = a.length - 1
- var res: List[Any] = Nil
- while (i >= 0) {
- res = (a(i) match {
- case x: java.lang.Boolean => x.booleanValue()
- case x: java.lang.Byte => x.byteValue()
- case x: java.lang.Short => x.shortValue()
- case x: java.lang.Character => x.charValue()
- case x: java.lang.Integer => x.intValue()
- case x: java.lang.Long => x.longValue()
- case x: java.lang.Float => x.floatValue()
- case x: java.lang.Double => x.doubleValue()
- case x => x
- }) :: res;
- i -= 1
- }
- res
- }
+ @deprecated("Use withIn", "2.11.0") def setIn(in: InputStream): Unit = setInDirect(new BufferedReader(new InputStreamReader(in)))
}
diff --git a/src/library/scala/Double.scala b/src/library/scala/Double.scala
index f058d7c26b..ce081bbec1 100644
--- a/src/library/scala/Double.scala
+++ b/src/library/scala/Double.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -382,6 +382,8 @@ object Double extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToDouble`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Double to be boxed
* @return a java.lang.Double offering `x` as its underlying value.
*/
@@ -391,6 +393,8 @@ object Double extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Double.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToDouble`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Double to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Double
* @return the Double resulting from calling doubleValue() on `x`
diff --git a/src/library/scala/Enumeration.scala b/src/library/scala/Enumeration.scala
index 47d7840e27..59be0cdfa3 100644
--- a/src/library/scala/Enumeration.scala
+++ b/src/library/scala/Enumeration.scala
@@ -56,14 +56,6 @@ abstract class Enumeration (initial: Int) extends Serializable {
def this() = this(0)
- @deprecated("Names should be specified individually or discovered via reflection", "2.10.0")
- def this(initial: Int, names: String*) = {
- this(initial)
- this.nextName = names.iterator
- }
- @deprecated("Names should be specified individually or discovered via reflection", "2.10.0")
- def this(names: String*) = this(0, names: _*)
-
/* Note that `readResolve` cannot be private, since otherwise
the JVM does not invoke it when deserializing subclasses. */
protected def readResolve(): AnyRef = thisenum.getClass.getField(MODULE_INSTANCE_NAME).get(null)
@@ -71,7 +63,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
/** The name of this enumeration.
*/
override def toString =
- ((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
+ ((getClass.getName stripSuffix MODULE_SUFFIX_STRING split '.').last split
Pattern.quote(NAME_JOIN_STRING)).last
/** The mapping from the integer used to identify values to the actual
@@ -103,7 +95,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
protected var nextName: Iterator[String] = _
private def nextNameOrNull =
- if (nextName != null && nextName.hasNext) nextName.next else null
+ if (nextName != null && nextName.hasNext) nextName.next() else null
/** The highest integer amongst those used to identify values in this
* enumeration. */
@@ -126,7 +118,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
*
* @param s an `Enumeration` name
* @return the `Value` of this `Enumeration` if its name matches `s`
- * @throws java.util.NoSuchElementException if no `Value` with a matching
+ * @throws NoSuchElementException if no `Value` with a matching
* name is in this `Enumeration`
*/
final def withName(s: String): Value = values.find(_.toString == s).get
@@ -262,7 +254,8 @@ abstract class Enumeration (initial: Int) extends Serializable {
def contains(v: Value) = nnIds contains (v.id - bottomId)
def + (value: Value) = new ValueSet(nnIds + (value.id - bottomId))
def - (value: Value) = new ValueSet(nnIds - (value.id - bottomId))
- def iterator = nnIds.iterator map (id => thisenum.apply(id + bottomId))
+ def iterator = nnIds.iterator map (id => thisenum.apply(bottomId + id))
+ override def keysIteratorFrom(start: Value) = nnIds keysIteratorFrom start.id map (id => thisenum.apply(bottomId + id))
override def stringPrefix = thisenum + ".ValueSet"
/** Creates a bit mask for the zero-adjusted ids in this set as a
* new array of longs */
@@ -284,7 +277,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
def newBuilder: mutable.Builder[Value, ValueSet] = new mutable.Builder[Value, ValueSet] {
private[this] val b = new mutable.BitSet
def += (x: Value) = { b += (x.id - bottomId); this }
- def clear() = b.clear
+ def clear() = b.clear()
def result() = new ValueSet(b.toImmutable)
}
/** The implicit builder for value sets */
diff --git a/src/library/scala/Float.scala b/src/library/scala/Float.scala
index d942acec23..4ff2d509b8 100644
--- a/src/library/scala/Float.scala
+++ b/src/library/scala/Float.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -382,6 +382,8 @@ object Float extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToFloat`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Float to be boxed
* @return a java.lang.Float offering `x` as its underlying value.
*/
@@ -391,6 +393,8 @@ object Float extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Float.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToFloat`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Float to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Float
* @return the Float resulting from calling floatValue() on `x`
diff --git a/src/library/scala/Function0.scala b/src/library/scala/Function0.scala
index 5f87b38057..54cba021e0 100644
--- a/src/library/scala/Function0.scala
+++ b/src/library/scala/Function0.scala
@@ -1,12 +1,12 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// GENERATED CODE: DO NOT EDIT.
-// genprod generated these sources at: Tue Aug 07 11:54:44 CEST 2012
+// genprod generated these sources at: Sun Mar 24 14:14:12 CET 2013
package scala
diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala
index 22393c65dd..2e3de54c5a 100644
--- a/src/library/scala/Function1.scala
+++ b/src/library/scala/Function1.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function10.scala b/src/library/scala/Function10.scala
index f7e5d414f2..7789970a44 100644
--- a/src/library/scala/Function10.scala
+++ b/src/library/scala/Function10.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function11.scala b/src/library/scala/Function11.scala
index 53742bf733..d4276f3fd1 100644
--- a/src/library/scala/Function11.scala
+++ b/src/library/scala/Function11.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function12.scala b/src/library/scala/Function12.scala
index e349d9017d..dfa8bcfce6 100644
--- a/src/library/scala/Function12.scala
+++ b/src/library/scala/Function12.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function13.scala b/src/library/scala/Function13.scala
index 10ec64b87a..5404c208bf 100644
--- a/src/library/scala/Function13.scala
+++ b/src/library/scala/Function13.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function14.scala b/src/library/scala/Function14.scala
index 82dd409223..3145290bcf 100644
--- a/src/library/scala/Function14.scala
+++ b/src/library/scala/Function14.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function15.scala b/src/library/scala/Function15.scala
index be5fbeeca1..309ef53e71 100644
--- a/src/library/scala/Function15.scala
+++ b/src/library/scala/Function15.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function16.scala b/src/library/scala/Function16.scala
index 7a185b369c..c4cb107e87 100644
--- a/src/library/scala/Function16.scala
+++ b/src/library/scala/Function16.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function17.scala b/src/library/scala/Function17.scala
index 94e0000802..005ae2ab79 100644
--- a/src/library/scala/Function17.scala
+++ b/src/library/scala/Function17.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function18.scala b/src/library/scala/Function18.scala
index a3ee6776ba..371630dae3 100644
--- a/src/library/scala/Function18.scala
+++ b/src/library/scala/Function18.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function19.scala b/src/library/scala/Function19.scala
index 038dcbb778..95c60a467e 100644
--- a/src/library/scala/Function19.scala
+++ b/src/library/scala/Function19.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function2.scala b/src/library/scala/Function2.scala
index 0794a4048a..5690adb56a 100644
--- a/src/library/scala/Function2.scala
+++ b/src/library/scala/Function2.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function20.scala b/src/library/scala/Function20.scala
index 727684d6d5..a93f999d44 100644
--- a/src/library/scala/Function20.scala
+++ b/src/library/scala/Function20.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function21.scala b/src/library/scala/Function21.scala
index 2441278be8..7ebbb06798 100644
--- a/src/library/scala/Function21.scala
+++ b/src/library/scala/Function21.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function22.scala b/src/library/scala/Function22.scala
index 1f70b190a6..e5a3d83fb9 100644
--- a/src/library/scala/Function22.scala
+++ b/src/library/scala/Function22.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function3.scala b/src/library/scala/Function3.scala
index bbbde82056..850290d244 100644
--- a/src/library/scala/Function3.scala
+++ b/src/library/scala/Function3.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function4.scala b/src/library/scala/Function4.scala
index f100860a97..c9ac6df32e 100644
--- a/src/library/scala/Function4.scala
+++ b/src/library/scala/Function4.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function5.scala b/src/library/scala/Function5.scala
index cba9b6ce52..360a460306 100644
--- a/src/library/scala/Function5.scala
+++ b/src/library/scala/Function5.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function6.scala b/src/library/scala/Function6.scala
index 0b8addf7de..d30877e765 100644
--- a/src/library/scala/Function6.scala
+++ b/src/library/scala/Function6.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function7.scala b/src/library/scala/Function7.scala
index 2098658fa9..b19caf2b50 100644
--- a/src/library/scala/Function7.scala
+++ b/src/library/scala/Function7.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function8.scala b/src/library/scala/Function8.scala
index 08a480dce5..3aff0b034c 100644
--- a/src/library/scala/Function8.scala
+++ b/src/library/scala/Function8.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Function9.scala b/src/library/scala/Function9.scala
index 2e35f7949c..f80ccf48f9 100644
--- a/src/library/scala/Function9.scala
+++ b/src/library/scala/Function9.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Int.scala b/src/library/scala/Int.scala
index ae36413469..6a27195b10 100644
--- a/src/library/scala/Int.scala
+++ b/src/library/scala/Int.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -606,6 +606,8 @@ object Int extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToInteger`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Int to be boxed
* @return a java.lang.Integer offering `x` as its underlying value.
*/
@@ -615,6 +617,8 @@ object Int extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Integer.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToInt`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Integer to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Integer
* @return the Int resulting from calling intValue() on `x`
diff --git a/src/library/scala/Long.scala b/src/library/scala/Long.scala
index 4ee9383c2a..4d369ae010 100644
--- a/src/library/scala/Long.scala
+++ b/src/library/scala/Long.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -606,6 +606,8 @@ object Long extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToLong`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Long to be boxed
* @return a java.lang.Long offering `x` as its underlying value.
*/
@@ -615,6 +617,8 @@ object Long extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Long.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToLong`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Long to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Long
* @return the Long resulting from calling longValue() on `x`
diff --git a/src/library/scala/LowPriorityImplicits.scala b/src/library/scala/LowPriorityImplicits.scala
deleted file mode 100644
index bf6e494c11..0000000000
--- a/src/library/scala/LowPriorityImplicits.scala
+++ /dev/null
@@ -1,95 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala
-
-import scala.collection.{ mutable, immutable, generic }
-import mutable.WrappedArray
-import immutable.WrappedString
-import generic.CanBuildFrom
-import scala.language.implicitConversions
-
-/** The `LowPriorityImplicits` class provides implicit values that
- * are valid in all Scala compilation units without explicit qualification,
- * but that are partially overridden by higher-priority conversions in object
- * `Predef`.
- *
- * @author Martin Odersky
- * @since 2.8
- */
-class LowPriorityImplicits {
- /** We prefer the java.lang.* boxed types to these wrappers in
- * any potential conflicts. Conflicts do exist because the wrappers
- * need to implement ScalaNumber in order to have a symmetric equals
- * method, but that implies implementing java.lang.Number as well.
- *
- * Note - these are inlined because they are value classes, but
- * the call to xxxWrapper is not eliminated even though it does nothing.
- * Even inlined, every call site does a no-op retrieval of Predef's MODULE$
- * because maybe loading Predef has side effects!
- */
- @inline implicit def byteWrapper(x: Byte) = new runtime.RichByte(x)
- @inline implicit def shortWrapper(x: Short) = new runtime.RichShort(x)
- @inline implicit def intWrapper(x: Int) = new runtime.RichInt(x)
- @inline implicit def charWrapper(c: Char) = new runtime.RichChar(c)
- @inline implicit def longWrapper(x: Long) = new runtime.RichLong(x)
- @inline implicit def floatWrapper(x: Float) = new runtime.RichFloat(x)
- @inline implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x)
- @inline implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
-
- // These eight implicits exist solely to exclude Null from the domain of
- // the boxed types, so that e.g. "var x: Int = null" is a compile time
- // error rather than a delayed null pointer exception by way of the
- // conversion from java.lang.Integer. If defined in the same file as
- // Integer2int, they would have higher priority because Null is a subtype
- // of Integer. We balance that out and create conflict by moving the
- // definition into the superclass.
- //
- // Caution: do not adjust tightrope tension without safety goggles in place.
- implicit def Byte2byteNullConflict(x: Null): Byte = sys.error("value error")
- implicit def Short2shortNullConflict(x: Null): Short = sys.error("value error")
- implicit def Character2charNullConflict(x: Null): Char = sys.error("value error")
- implicit def Integer2intNullConflict(x: Null): Int = sys.error("value error")
- implicit def Long2longNullConflict(x: Null): Long = sys.error("value error")
- implicit def Float2floatNullConflict(x: Null): Float = sys.error("value error")
- implicit def Double2doubleNullConflict(x: Null): Double = sys.error("value error")
- implicit def Boolean2booleanNullConflict(x: Null): Boolean = sys.error("value error")
-
- implicit def genericWrapArray[T](xs: Array[T]): WrappedArray[T] =
- if (xs eq null) null
- else WrappedArray.make(xs)
-
- // Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef]
- // is as good as another for all T <: AnyRef. Instead of creating 100,000,000
- // unique ones by way of this implicit, let's share one.
- implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = {
- if (xs eq null) null
- else if (xs.length == 0) WrappedArray.empty[T]
- else new WrappedArray.ofRef[T](xs)
- }
-
- implicit def wrapIntArray(xs: Array[Int]): WrappedArray[Int] = if (xs ne null) new WrappedArray.ofInt(xs) else null
- implicit def wrapDoubleArray(xs: Array[Double]): WrappedArray[Double] = if (xs ne null) new WrappedArray.ofDouble(xs) else null
- implicit def wrapLongArray(xs: Array[Long]): WrappedArray[Long] = if (xs ne null) new WrappedArray.ofLong(xs) else null
- implicit def wrapFloatArray(xs: Array[Float]): WrappedArray[Float] = if (xs ne null) new WrappedArray.ofFloat(xs) else null
- implicit def wrapCharArray(xs: Array[Char]): WrappedArray[Char] = if (xs ne null) new WrappedArray.ofChar(xs) else null
- implicit def wrapByteArray(xs: Array[Byte]): WrappedArray[Byte] = if (xs ne null) new WrappedArray.ofByte(xs) else null
- implicit def wrapShortArray(xs: Array[Short]): WrappedArray[Short] = if (xs ne null) new WrappedArray.ofShort(xs) else null
- implicit def wrapBooleanArray(xs: Array[Boolean]): WrappedArray[Boolean] = if (xs ne null) new WrappedArray.ofBoolean(xs) else null
- implicit def wrapUnitArray(xs: Array[Unit]): WrappedArray[Unit] = if (xs ne null) new WrappedArray.ofUnit(xs) else null
-
- implicit def wrapString(s: String): WrappedString = if (s ne null) new WrappedString(s) else null
- implicit def unwrapString(ws: WrappedString): String = if (ws ne null) ws.self else null
-
- implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]] =
- new CanBuildFrom[String, T, immutable.IndexedSeq[T]] {
- def apply(from: String) = immutable.IndexedSeq.newBuilder[T]
- def apply() = immutable.IndexedSeq.newBuilder[T]
- }
-}
-
diff --git a/src/library/scala/NotNull.scala b/src/library/scala/NotNull.scala
index f87416b49d..3cbe9ed4ac 100644
--- a/src/library/scala/NotNull.scala
+++ b/src/library/scala/NotNull.scala
@@ -12,4 +12,6 @@ package scala
* A marker trait for things that are not allowed to be null
* @since 2.5
*/
+
+@deprecated("This trait will be removed", "2.11.0")
trait NotNull extends Any {}
diff --git a/src/library/scala/Option.scala b/src/library/scala/Option.scala
index 3873df99e9..4b071166c7 100644
--- a/src/library/scala/Option.scala
+++ b/src/library/scala/Option.scala
@@ -209,6 +209,15 @@ sealed abstract class Option[+A] extends Product with Serializable {
def withFilter(q: A => Boolean): WithFilter = new WithFilter(x => p(x) && q(x))
}
+ /** Tests whether the option contains a given value as an element.
+ *
+ * @param elem the element to test.
+ * @return `true` if the option has an element that is equal (as
+ * determined by `==`) to `elem`, `false` otherwise.
+ */
+ final def contains[A1 >: A](elem: A1): Boolean =
+ !isEmpty && this.get == elem
+
/** Returns true if this option is nonempty '''and''' the predicate
* $p returns true when applied to this $option's value.
* Otherwise, returns false.
@@ -247,7 +256,7 @@ sealed abstract class Option[+A] extends Product with Serializable {
* value (if possible), or $none.
*/
@inline final def collect[B](pf: PartialFunction[A, B]): Option[B] =
- if (!isEmpty && pf.isDefinedAt(this.get)) Some(pf(this.get)) else None
+ if (!isEmpty) pf.lift(this.get) else None
/** Returns this $option if it is nonempty,
* otherwise return the result of evaluating `alternative`.
diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala
index 9bb57877d9..569157de20 100644
--- a/src/library/scala/Predef.scala
+++ b/src/library/scala/Predef.scala
@@ -15,6 +15,7 @@ import generic.CanBuildFrom
import scala.annotation.{ elidable, implicitNotFound }
import scala.annotation.elidable.ASSERTION
import scala.language.{implicitConversions, existentials}
+import scala.io.ReadStdin
/** The `Predef` object provides definitions that are accessible in all Scala
* compilation units without explicit qualification.
@@ -68,7 +69,7 @@ import scala.language.{implicitConversions, existentials}
* Short value to a Long value as required, and to add additional higher-order
* functions to Array values. These are described in more detail in the documentation of [[scala.Array]].
*/
-object Predef extends LowPriorityImplicits {
+object Predef extends LowPriorityImplicits with DeprecatedPredef {
/**
* Retrieve the runtime representation of a class type. `classOf[T]` is equivalent to
* the class literal `T.class` in Java.
@@ -101,19 +102,19 @@ object Predef extends LowPriorityImplicits {
// Manifest types, companions, and incantations for summoning
@annotation.implicitNotFound(msg = "No ClassManifest available for ${T}.")
- @deprecated("Use scala.reflect.ClassTag instead", "2.10.0")
+ @deprecated("Use `scala.reflect.ClassTag` instead", "2.10.0")
type ClassManifest[T] = scala.reflect.ClassManifest[T]
// TODO undeprecated until Scala reflection becomes non-experimental
// @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0")
type OptManifest[T] = scala.reflect.OptManifest[T]
@annotation.implicitNotFound(msg = "No Manifest available for ${T}.")
// TODO undeprecated until Scala reflection becomes non-experimental
- // @deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0")
+ // @deprecated("Use `scala.reflect.ClassTag` (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0")
type Manifest[T] = scala.reflect.Manifest[T]
- @deprecated("Use scala.reflect.ClassTag instead", "2.10.0")
+ @deprecated("Use `scala.reflect.ClassTag` instead", "2.10.0")
val ClassManifest = scala.reflect.ClassManifest
// TODO undeprecated until Scala reflection becomes non-experimental
- // @deprecated("Use scala.reflect.ClassTag (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0")
+ // @deprecated("Use `scala.reflect.ClassTag` (to capture erasures) or scala.reflect.runtime.universe.TypeTag (to capture types) or both instead", "2.10.0")
val Manifest = scala.reflect.Manifest
// TODO undeprecated until Scala reflection becomes non-experimental
// @deprecated("This notion doesn't have a corresponding concept in 2.10, because scala.reflect.runtime.universe.TypeTag can capture arbitrary types. Use type tags instead of manifests, and there will be no need in opt manifests.", "2.10.0")
@@ -136,22 +137,14 @@ object Predef extends LowPriorityImplicits {
// Apparently needed for the xml library
val $scope = scala.xml.TopScope
- // Deprecated
+ // errors and asserts -------------------------------------------------
+ // !!! Remove this when possible - ideally for 2.11.
+ // We are stuck with it a while longer because sbt's compiler interface
+ // still calls it as of 0.12.2.
@deprecated("Use `sys.error(message)` instead", "2.9.0")
def error(message: String): Nothing = sys.error(message)
- @deprecated("Use `sys.exit()` instead", "2.9.0")
- def exit(): Nothing = sys.exit()
-
- @deprecated("Use `sys.exit(status)` instead", "2.9.0")
- def exit(status: Int): Nothing = sys.exit(status)
-
- @deprecated("Use `formatString.format(args: _*)` or `arg.formatted(formatString)` instead", "2.9.0")
- def format(text: String, xs: Any*) = augmentString(text).format(xs: _*)
-
- // errors and asserts -------------------------------------------------
-
/** Tests an expression, throwing an `AssertionError` if false.
* Calls to this method will not be generated if `-Xelide-below`
* is at least `ASSERTION`.
@@ -233,19 +226,6 @@ object Predef extends LowPriorityImplicits {
throw new IllegalArgumentException("requirement failed: "+ message)
}
- final class Ensuring[A](val __resultOfEnsuring: A) extends AnyVal {
- // `__resultOfEnsuring` must be a public val to allow inlining.
- // See comments in ArrowAssoc for more.
- @deprecated("Use `__resultOfEnsuring` instead", "2.10.0")
- def x = __resultOfEnsuring
-
- def ensuring(cond: Boolean): A = { assert(cond); __resultOfEnsuring }
- def ensuring(cond: Boolean, msg: => Any): A = { assert(cond, msg); __resultOfEnsuring }
- def ensuring(cond: A => Boolean): A = { assert(cond(__resultOfEnsuring)); __resultOfEnsuring }
- def ensuring(cond: A => Boolean, msg: => Any): A = { assert(cond(__resultOfEnsuring), msg); __resultOfEnsuring }
- }
- @inline implicit def any2Ensuring[A](x: A): Ensuring[A] = new Ensuring(x)
-
/** `???` can be used for marking methods that remain to be implemented.
* @throws A `NotImplementedError`
*/
@@ -265,20 +245,58 @@ object Predef extends LowPriorityImplicits {
def unapply[A, B, C](x: Tuple3[A, B, C]): Option[Tuple3[A, B, C]] = Some(x)
}
- final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal {
- // `__leftOfArrow` must be a public val to allow inlining. The val
- // used to be called `x`, but now goes by `__leftOfArrow`, as that
- // reduces the chances of a user's writing `foo.__leftOfArrow` and
- // being confused why they get an ambiguous implicit conversion
- // error. (`foo.x` used to produce this error since both
- // any2Ensuring and any2ArrowAssoc pimped an `x` onto everything)
- @deprecated("Use `__leftOfArrow` instead", "2.10.0")
- def x = __leftOfArrow
+ // implicit classes -----------------------------------------------------
+ implicit final class ArrowAssoc[A](val __leftOfArrow: A) extends AnyVal {
@inline def -> [B](y: B): Tuple2[A, B] = Tuple2(__leftOfArrow, y)
def →[B](y: B): Tuple2[A, B] = ->(y)
}
- @inline implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x)
+
+ implicit final class Ensuring[A](val __resultOfEnsuring: A) extends AnyVal {
+ def ensuring(cond: Boolean): A = { assert(cond); __resultOfEnsuring }
+ def ensuring(cond: Boolean, msg: => Any): A = { assert(cond, msg); __resultOfEnsuring }
+ def ensuring(cond: A => Boolean): A = { assert(cond(__resultOfEnsuring)); __resultOfEnsuring }
+ def ensuring(cond: A => Boolean, msg: => Any): A = { assert(cond(__resultOfEnsuring), msg); __resultOfEnsuring }
+ }
+
+ implicit final class StringFormat[A](val __stringToFormat: A) extends AnyVal {
+ /** Returns string formatted according to given `format` string.
+ * Format strings are as for `String.format`
+ * (@see java.lang.String.format).
+ */
+ @inline def formatted(fmtstr: String): String = fmtstr format __stringToFormat
+ }
+
+ implicit final class StringAdd[A](val __thingToAdd: A) extends AnyVal {
+ def +(other: String) = String.valueOf(__thingToAdd) + other
+ }
+
+ implicit final class RichException(val __throwableToEnrich: Throwable) extends AnyVal {
+ import scala.compat.Platform.EOL
+ @deprecated("Use Throwable#getStackTrace", "2.11.0") def getStackTraceString = __throwableToEnrich.getStackTrace().mkString("", EOL, EOL)
+ }
+
+ implicit final class SeqCharSequence(val __sequenceOfChars: scala.collection.IndexedSeq[Char]) extends CharSequence {
+ def length: Int = __sequenceOfChars.length
+ def charAt(index: Int): Char = __sequenceOfChars(index)
+ def subSequence(start: Int, end: Int): CharSequence = new SeqCharSequence(__sequenceOfChars.slice(start, end))
+ override def toString = __sequenceOfChars mkString ""
+ }
+
+ implicit final class ArrayCharSequence(val __arrayOfChars: Array[Char]) extends CharSequence {
+ def length: Int = __arrayOfChars.length
+ def charAt(index: Int): Char = __arrayOfChars(index)
+ def subSequence(start: Int, end: Int): CharSequence = new runtime.ArrayCharSequence(__arrayOfChars, start, end)
+ override def toString = __arrayOfChars mkString ""
+ }
+
+ implicit val StringCanBuildFrom: CanBuildFrom[String, Char, String] = new CanBuildFrom[String, Char, String] {
+ def apply(from: String) = apply()
+ def apply() = mutable.StringBuilder.newBuilder
+ }
+
+ @inline implicit def augmentString(x: String): StringOps = new StringOps(x)
+ @inline implicit def unaugmentString(x: StringOps): String = x.repr
// printing and reading -----------------------------------------------
@@ -287,28 +305,10 @@ object Predef extends LowPriorityImplicits {
def println(x: Any) = Console.println(x)
def printf(text: String, xs: Any*) = Console.print(text.format(xs: _*))
- def readLine(): String = Console.readLine()
- def readLine(text: String, args: Any*) = Console.readLine(text, args: _*)
- def readBoolean() = Console.readBoolean()
- def readByte() = Console.readByte()
- def readShort() = Console.readShort()
- def readChar() = Console.readChar()
- def readInt() = Console.readInt()
- def readLong() = Console.readLong()
- def readFloat() = Console.readFloat()
- def readDouble() = Console.readDouble()
- def readf(format: String) = Console.readf(format)
- def readf1(format: String) = Console.readf1(format)
- def readf2(format: String) = Console.readf2(format)
- def readf3(format: String) = Console.readf3(format)
-
// views --------------------------------------------------------------
- implicit def exceptionWrapper(exc: Throwable) = new runtime.RichException(exc)
implicit def tuple2ToZippedOps[T1, T2](x: (T1, T2)) = new runtime.Tuple2Zipped.Ops(x)
implicit def tuple3ToZippedOps[T1, T2, T3](x: (T1, T2, T3)) = new runtime.Tuple3Zipped.Ops(x)
- implicit def seqToCharSequence(xs: scala.collection.IndexedSeq[Char]): CharSequence = new runtime.SeqCharSequence(xs)
- implicit def arrayToCharSequence(xs: Array[Char]): CharSequence = new runtime.ArrayCharSequence(xs, 0, xs.length)
implicit def genericArrayOps[T](xs: Array[T]): ArrayOps[T] = (xs match {
case x: Array[AnyRef] => refArrayOps[AnyRef](x)
@@ -335,33 +335,6 @@ object Predef extends LowPriorityImplicits {
implicit def shortArrayOps(xs: Array[Short]): ArrayOps[Short] = new ArrayOps.ofShort(xs)
implicit def unitArrayOps(xs: Array[Unit]): ArrayOps[Unit] = new ArrayOps.ofUnit(xs)
- // Primitive Widenings --------------------------------------------------------------
-
- @deprecated("Use `.toShort` for explicit conversion and `Byte.byte2short` for implicit conversion", "2.10.0") def byte2short(x: Byte): Short = x.toShort
- @deprecated("Use `.toInt` for explicit conversion and `Byte.byte2int` for implicit conversion", "2.10.0") def byte2int(x: Byte): Int = x.toInt
- @deprecated("Use `.toLong` for explicit conversion and `Byte.byte2long for implicit conversion", "2.10.0") def byte2long(x: Byte): Long = x.toLong
- @deprecated("Use `.toFloat` for explicit conversion and `Byte.byte2float` for implicit conversion", "2.10.0") def byte2float(x: Byte): Float = x.toFloat
- @deprecated("Use `.toDouble` for explicit conversion and `Byte.byte2double` for implicit conversion", "2.10.0") def byte2double(x: Byte): Double = x.toDouble
-
- @deprecated("Use `.toInt` for explicit conversion and `Short.short2int` for implicit conversion", "2.10.0") def short2int(x: Short): Int = x.toInt
- @deprecated("Use `.toLong` for explicit conversion and `Short.short2long` for implicit conversion", "2.10.0") def short2long(x: Short): Long = x.toLong
- @deprecated("Use `.toFloat` for explicit conversion and `Short.short2float` for implicit conversion", "2.10.0") def short2float(x: Short): Float = x.toFloat
- @deprecated("Use `.toDouble` for explicit conversion and `Short.short2double` for implicit conversion", "2.10.0") def short2double(x: Short): Double = x.toDouble
-
- @deprecated("Use `.toInt` for explicit conversion and `Char.char2int` for implicit conversion", "2.10.0") def char2int(x: Char): Int = x.toInt
- @deprecated("Use `.toLong` for explicit conversion and `Char.char2long` for implicit conversion", "2.10.0") def char2long(x: Char): Long = x.toLong
- @deprecated("Use `.toFloat` for explicit conversion and `Char.char2float` for implicit conversion", "2.10.0") def char2float(x: Char): Float = x.toFloat
- @deprecated("Use `.toDouble` for explicit conversion and `Char.char2double` for implicit conversion", "2.10.0") def char2double(x: Char): Double = x.toDouble
-
- @deprecated("Use `.toLong` for explicit conversion and `Int.int2long` for implicit conversion", "2.10.0") def int2long(x: Int): Long = x.toLong
- @deprecated("Use `.toFloat` for explicit conversion and `Int.int2float` for implicit conversion", "2.10.0") def int2float(x: Int): Float = x.toFloat
- @deprecated("Use `.toDouble` for explicit conversion and `Int.int2double` for implicit conversion", "2.10.0") def int2double(x: Int): Double = x.toDouble
-
- @deprecated("Use `.toFloat` for explicit conversion and `Long.long2float` for implicit conversion", "2.10.0") def long2float(x: Long): Float = x.toFloat
- @deprecated("Use `.toDouble` for explicit conversion and `Long.long2double` for implicit conversion", "2.10.0") def long2double(x: Long): Double = x.toDouble
-
- @deprecated("Use `.toDouble` for explicit conversion and `Float.float2double` for implicit conversion", "2.10.0") def float2double(x: Float): Double = x.toDouble
-
// "Autoboxing" and "Autounboxing" ---------------------------------------------------
implicit def byte2Byte(x: Byte) = java.lang.Byte.valueOf(x)
@@ -395,21 +368,6 @@ object Predef extends LowPriorityImplicits {
implicit def Double2double(x: java.lang.Double): Double = x.doubleValue
implicit def Boolean2boolean(x: java.lang.Boolean): Boolean = x.booleanValue
- // Strings and CharSequences --------------------------------------------------------------
-
- @inline implicit def any2stringfmt(x: Any) = new runtime.StringFormat(x)
- @inline implicit def augmentString(x: String): StringOps = new StringOps(x)
- implicit def any2stringadd(x: Any) = new runtime.StringAdd(x)
- implicit def unaugmentString(x: StringOps): String = x.repr
-
- @deprecated("Use `StringCanBuildFrom`", "2.10.0")
- def stringCanBuildFrom: CanBuildFrom[String, Char, String] = StringCanBuildFrom
-
- implicit val StringCanBuildFrom: CanBuildFrom[String, Char, String] = new CanBuildFrom[String, Char, String] {
- def apply(from: String) = apply()
- def apply() = mutable.StringBuilder.newBuilder
- }
-
// Type Constraints --------------------------------------------------------------
/**
@@ -460,3 +418,116 @@ object Predef extends LowPriorityImplicits {
implicit def dummyImplicit: DummyImplicit = new DummyImplicit
}
}
+
+private[scala] trait DeprecatedPredef {
+ self: Predef.type =>
+
+ // Deprecated stubs for any who may have been calling these methods directly.
+ @deprecated("Use `ArrowAssoc`", "2.11.0") def any2ArrowAssoc[A](x: A): ArrowAssoc[A] = new ArrowAssoc(x)
+ @deprecated("Use `Ensuring`", "2.11.0") def any2Ensuring[A](x: A): Ensuring[A] = new Ensuring(x)
+ @deprecated("Use `StringFormat`", "2.11.0") def any2stringfmt(x: Any): StringFormat[Any] = new StringFormat(x)
+ @deprecated("Use String interpolation", "2.11.0") def any2stringadd(x: Any): StringAdd[Any] = new StringAdd(x)
+ @deprecated("Use `Throwable` directly", "2.11.0") def exceptionWrapper(exc: Throwable) = new RichException(exc)
+ @deprecated("Use `SeqCharSequence`", "2.11.0") def seqToCharSequence(xs: scala.collection.IndexedSeq[Char]): CharSequence = new SeqCharSequence(xs)
+ @deprecated("Use `ArrayCharSequence`", "2.11.0") def arrayToCharSequence(xs: Array[Char]): CharSequence = new ArrayCharSequence(xs)
+
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readLine(): String = ReadStdin.readLine()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readLine(text: String, args: Any*) = ReadStdin.readLine(text, args: _*)
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readBoolean() = ReadStdin.readBoolean()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readByte() = ReadStdin.readByte()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readShort() = ReadStdin.readShort()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readChar() = ReadStdin.readChar()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readInt() = ReadStdin.readInt()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readLong() = ReadStdin.readLong()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readFloat() = ReadStdin.readFloat()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readDouble() = ReadStdin.readDouble()
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf(format: String) = ReadStdin.readf(format)
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf1(format: String) = ReadStdin.readf1(format)
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf2(format: String) = ReadStdin.readf2(format)
+ @deprecated("Use the method in `scala.io.ReadStdin`", "2.11.0") def readf3(format: String) = ReadStdin.readf3(format)
+}
+
+/** The `LowPriorityImplicits` class provides implicit values that
+* are valid in all Scala compilation units without explicit qualification,
+* but that are partially overridden by higher-priority conversions in object
+* `Predef`.
+*
+* @author Martin Odersky
+* @since 2.8
+*/
+// SI-7335 Parents of Predef are defined in the same compilation unit to avoid
+// cyclic reference errors compiling the standard library *without* a previously
+// compiled copy on the classpath.
+private[scala] abstract class LowPriorityImplicits {
+ import mutable.WrappedArray
+ import immutable.WrappedString
+
+ /** We prefer the java.lang.* boxed types to these wrappers in
+ * any potential conflicts. Conflicts do exist because the wrappers
+ * need to implement ScalaNumber in order to have a symmetric equals
+ * method, but that implies implementing java.lang.Number as well.
+ *
+ * Note - these are inlined because they are value classes, but
+ * the call to xxxWrapper is not eliminated even though it does nothing.
+ * Even inlined, every call site does a no-op retrieval of Predef's MODULE$
+ * because maybe loading Predef has side effects!
+ */
+ @inline implicit def byteWrapper(x: Byte) = new runtime.RichByte(x)
+ @inline implicit def shortWrapper(x: Short) = new runtime.RichShort(x)
+ @inline implicit def intWrapper(x: Int) = new runtime.RichInt(x)
+ @inline implicit def charWrapper(c: Char) = new runtime.RichChar(c)
+ @inline implicit def longWrapper(x: Long) = new runtime.RichLong(x)
+ @inline implicit def floatWrapper(x: Float) = new runtime.RichFloat(x)
+ @inline implicit def doubleWrapper(x: Double) = new runtime.RichDouble(x)
+ @inline implicit def booleanWrapper(x: Boolean) = new runtime.RichBoolean(x)
+
+ // These eight implicits exist solely to exclude Null from the domain of
+ // the boxed types, so that e.g. "var x: Int = null" is a compile time
+ // error rather than a delayed null pointer exception by way of the
+ // conversion from java.lang.Integer. If defined in the same template as
+ // Integer2int, they would have higher priority because Null is a subtype
+ // of Integer. We balance that out and create conflict by moving the
+ // definition into the superclass.
+ //
+ // Caution: do not adjust tightrope tension without safety goggles in place.
+ implicit def Byte2byteNullConflict(x: Null): Byte = sys.error("value error")
+ implicit def Short2shortNullConflict(x: Null): Short = sys.error("value error")
+ implicit def Character2charNullConflict(x: Null): Char = sys.error("value error")
+ implicit def Integer2intNullConflict(x: Null): Int = sys.error("value error")
+ implicit def Long2longNullConflict(x: Null): Long = sys.error("value error")
+ implicit def Float2floatNullConflict(x: Null): Float = sys.error("value error")
+ implicit def Double2doubleNullConflict(x: Null): Double = sys.error("value error")
+ implicit def Boolean2booleanNullConflict(x: Null): Boolean = sys.error("value error")
+
+ implicit def genericWrapArray[T](xs: Array[T]): WrappedArray[T] =
+ if (xs eq null) null
+ else WrappedArray.make(xs)
+
+ // Since the JVM thinks arrays are covariant, one 0-length Array[AnyRef]
+ // is as good as another for all T <: AnyRef. Instead of creating 100,000,000
+ // unique ones by way of this implicit, let's share one.
+ implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): WrappedArray[T] = {
+ if (xs eq null) null
+ else if (xs.length == 0) WrappedArray.empty[T]
+ else new WrappedArray.ofRef[T](xs)
+ }
+
+ implicit def wrapIntArray(xs: Array[Int]): WrappedArray[Int] = if (xs ne null) new WrappedArray.ofInt(xs) else null
+ implicit def wrapDoubleArray(xs: Array[Double]): WrappedArray[Double] = if (xs ne null) new WrappedArray.ofDouble(xs) else null
+ implicit def wrapLongArray(xs: Array[Long]): WrappedArray[Long] = if (xs ne null) new WrappedArray.ofLong(xs) else null
+ implicit def wrapFloatArray(xs: Array[Float]): WrappedArray[Float] = if (xs ne null) new WrappedArray.ofFloat(xs) else null
+ implicit def wrapCharArray(xs: Array[Char]): WrappedArray[Char] = if (xs ne null) new WrappedArray.ofChar(xs) else null
+ implicit def wrapByteArray(xs: Array[Byte]): WrappedArray[Byte] = if (xs ne null) new WrappedArray.ofByte(xs) else null
+ implicit def wrapShortArray(xs: Array[Short]): WrappedArray[Short] = if (xs ne null) new WrappedArray.ofShort(xs) else null
+ implicit def wrapBooleanArray(xs: Array[Boolean]): WrappedArray[Boolean] = if (xs ne null) new WrappedArray.ofBoolean(xs) else null
+ implicit def wrapUnitArray(xs: Array[Unit]): WrappedArray[Unit] = if (xs ne null) new WrappedArray.ofUnit(xs) else null
+
+ implicit def wrapString(s: String): WrappedString = if (s ne null) new WrappedString(s) else null
+ implicit def unwrapString(ws: WrappedString): String = if (ws ne null) ws.self else null
+
+ implicit def fallbackStringCanBuildFrom[T]: CanBuildFrom[String, T, immutable.IndexedSeq[T]] =
+ new CanBuildFrom[String, T, immutable.IndexedSeq[T]] {
+ def apply(from: String) = immutable.IndexedSeq.newBuilder[T]
+ def apply() = immutable.IndexedSeq.newBuilder[T]
+ }
+}
diff --git a/src/library/scala/Product.scala b/src/library/scala/Product.scala
index 2c6838f6b3..0798587772 100644
--- a/src/library/scala/Product.scala
+++ b/src/library/scala/Product.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product1.scala b/src/library/scala/Product1.scala
index edd095c5c6..dbc34ba66a 100644
--- a/src/library/scala/Product1.scala
+++ b/src/library/scala/Product1.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product10.scala b/src/library/scala/Product10.scala
index 8daefde699..70de79d49a 100644
--- a/src/library/scala/Product10.scala
+++ b/src/library/scala/Product10.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product11.scala b/src/library/scala/Product11.scala
index 90b4e8013e..1bb79ac017 100644
--- a/src/library/scala/Product11.scala
+++ b/src/library/scala/Product11.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product12.scala b/src/library/scala/Product12.scala
index d5997ea05a..d7e1e1b05c 100644
--- a/src/library/scala/Product12.scala
+++ b/src/library/scala/Product12.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product13.scala b/src/library/scala/Product13.scala
index db8e0f3722..8571b45a40 100644
--- a/src/library/scala/Product13.scala
+++ b/src/library/scala/Product13.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product14.scala b/src/library/scala/Product14.scala
index 113c07e8c4..a2f5140370 100644
--- a/src/library/scala/Product14.scala
+++ b/src/library/scala/Product14.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product15.scala b/src/library/scala/Product15.scala
index a6ad9c7594..1c6ad0011c 100644
--- a/src/library/scala/Product15.scala
+++ b/src/library/scala/Product15.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product16.scala b/src/library/scala/Product16.scala
index cbf47ece94..f03b0b34a2 100644
--- a/src/library/scala/Product16.scala
+++ b/src/library/scala/Product16.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product17.scala b/src/library/scala/Product17.scala
index f56836bfd8..72df1b496a 100644
--- a/src/library/scala/Product17.scala
+++ b/src/library/scala/Product17.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product18.scala b/src/library/scala/Product18.scala
index 5b86bcff65..0402f90a01 100644
--- a/src/library/scala/Product18.scala
+++ b/src/library/scala/Product18.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product19.scala b/src/library/scala/Product19.scala
index ed4bf36c93..b9770db47b 100644
--- a/src/library/scala/Product19.scala
+++ b/src/library/scala/Product19.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product2.scala b/src/library/scala/Product2.scala
index e27e54eff9..a43a4a285c 100644
--- a/src/library/scala/Product2.scala
+++ b/src/library/scala/Product2.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product20.scala b/src/library/scala/Product20.scala
index 47437a20af..7b0df201ec 100644
--- a/src/library/scala/Product20.scala
+++ b/src/library/scala/Product20.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product21.scala b/src/library/scala/Product21.scala
index 319d2725c0..f81347aac0 100644
--- a/src/library/scala/Product21.scala
+++ b/src/library/scala/Product21.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product22.scala b/src/library/scala/Product22.scala
index 6ab3737acd..7a25891c6e 100644
--- a/src/library/scala/Product22.scala
+++ b/src/library/scala/Product22.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product3.scala b/src/library/scala/Product3.scala
index 1cfbd7956b..9976240935 100644
--- a/src/library/scala/Product3.scala
+++ b/src/library/scala/Product3.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product4.scala b/src/library/scala/Product4.scala
index 843571fd60..d6c1543390 100644
--- a/src/library/scala/Product4.scala
+++ b/src/library/scala/Product4.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product5.scala b/src/library/scala/Product5.scala
index df73bba3dd..5f1b11a30d 100644
--- a/src/library/scala/Product5.scala
+++ b/src/library/scala/Product5.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product6.scala b/src/library/scala/Product6.scala
index 36906ca54e..efd9408d73 100644
--- a/src/library/scala/Product6.scala
+++ b/src/library/scala/Product6.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product7.scala b/src/library/scala/Product7.scala
index e7b2c13ad1..fab0a997a1 100644
--- a/src/library/scala/Product7.scala
+++ b/src/library/scala/Product7.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product8.scala b/src/library/scala/Product8.scala
index 916e57ec39..41391f7050 100644
--- a/src/library/scala/Product8.scala
+++ b/src/library/scala/Product8.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/Product9.scala b/src/library/scala/Product9.scala
index d5e72edc0b..e22538e1ee 100644
--- a/src/library/scala/Product9.scala
+++ b/src/library/scala/Product9.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/SerialVersionUID.scala b/src/library/scala/SerialVersionUID.scala
index 1f7d047060..77094f0bbf 100644
--- a/src/library/scala/SerialVersionUID.scala
+++ b/src/library/scala/SerialVersionUID.scala
@@ -12,4 +12,4 @@ package scala
* Annotation for specifying the `static SerialVersionUID` field
* of a serializable class.
*/
-class SerialVersionUID(uid: Long) extends scala.annotation.StaticAnnotation
+class SerialVersionUID(value: Long) extends scala.annotation.ClassfileAnnotation
diff --git a/src/library/scala/Short.scala b/src/library/scala/Short.scala
index 35c5fe3ff0..4f91c51550 100644
--- a/src/library/scala/Short.scala
+++ b/src/library/scala/Short.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -606,6 +606,8 @@ object Short extends AnyValCompanion {
/** Transform a value type into a boxed reference type.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.boxToShort`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the Short to be boxed
* @return a java.lang.Short offering `x` as its underlying value.
*/
@@ -615,6 +617,8 @@ object Short extends AnyValCompanion {
* method is not typesafe: it accepts any Object, but will throw
* an exception if the argument is not a java.lang.Short.
*
+ * Runtime implementation determined by `scala.runtime.BoxesRunTime.unboxToShort`. See [[https://github.com/scala/scala src/library/scala/runtime/BoxesRunTime.java]].
+ *
* @param x the java.lang.Short to be unboxed.
* @throws ClassCastException if the argument is not a java.lang.Short
* @return the Short resulting from calling shortValue() on `x`
diff --git a/src/library/scala/Specializable.scala b/src/library/scala/Specializable.scala
index c7a6091a65..137598c28d 100644
--- a/src/library/scala/Specializable.scala
+++ b/src/library/scala/Specializable.scala
@@ -11,7 +11,7 @@ package scala
/** A common supertype for companions of specializable types.
* Should not be extended in user code.
*/
-trait Specializable extends SpecializableCompanion
+trait Specializable
object Specializable {
// No type parameter in @specialized annotation.
diff --git a/src/library/scala/SpecializableCompanion.scala b/src/library/scala/SpecializableCompanion.scala
deleted file mode 100644
index 1a9ce71d2a..0000000000
--- a/src/library/scala/SpecializableCompanion.scala
+++ /dev/null
@@ -1,14 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala
-
-/** A common supertype for companion classes which specialization takes into account.
- */
-@deprecated("Use Specializable instead", "2.10.0")
-private[scala] trait SpecializableCompanion
diff --git a/src/library/scala/Tuple1.scala b/src/library/scala/Tuple1.scala
index 02fdd0cba5..5898b63e21 100644
--- a/src/library/scala/Tuple1.scala
+++ b/src/library/scala/Tuple1.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -15,6 +15,7 @@ package scala
* @constructor Create a new tuple with 1 elements.
* @param _1 Element 1 of this Tuple1
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple1[@specialized(Int, Long, Double) +T1](_1: T1)
extends Product1[T1]
{
diff --git a/src/library/scala/Tuple10.scala b/src/library/scala/Tuple10.scala
index ba2a02a8b2..2b0239561d 100644
--- a/src/library/scala/Tuple10.scala
+++ b/src/library/scala/Tuple10.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -24,6 +24,7 @@ package scala
* @param _9 Element 9 of this Tuple10
* @param _10 Element 10 of this Tuple10
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple10[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10)
extends Product10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]
{
diff --git a/src/library/scala/Tuple11.scala b/src/library/scala/Tuple11.scala
index 7f51d172d4..0d5294d547 100644
--- a/src/library/scala/Tuple11.scala
+++ b/src/library/scala/Tuple11.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -25,6 +25,7 @@ package scala
* @param _10 Element 10 of this Tuple11
* @param _11 Element 11 of this Tuple11
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple11[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11)
extends Product11[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11]
{
diff --git a/src/library/scala/Tuple12.scala b/src/library/scala/Tuple12.scala
index 4bbc6a0eab..d36c8275c1 100644
--- a/src/library/scala/Tuple12.scala
+++ b/src/library/scala/Tuple12.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -26,6 +26,7 @@ package scala
* @param _11 Element 11 of this Tuple12
* @param _12 Element 12 of this Tuple12
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple12[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12)
extends Product12[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12]
{
diff --git a/src/library/scala/Tuple13.scala b/src/library/scala/Tuple13.scala
index 77bd59bf2e..edc37456fe 100644
--- a/src/library/scala/Tuple13.scala
+++ b/src/library/scala/Tuple13.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -27,6 +27,7 @@ package scala
* @param _12 Element 12 of this Tuple13
* @param _13 Element 13 of this Tuple13
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple13[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13)
extends Product13[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13]
{
diff --git a/src/library/scala/Tuple14.scala b/src/library/scala/Tuple14.scala
index bf7a4ce016..9896e736c9 100644
--- a/src/library/scala/Tuple14.scala
+++ b/src/library/scala/Tuple14.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -28,6 +28,7 @@ package scala
* @param _13 Element 13 of this Tuple14
* @param _14 Element 14 of this Tuple14
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple14[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14)
extends Product14[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14]
{
diff --git a/src/library/scala/Tuple15.scala b/src/library/scala/Tuple15.scala
index 582c359bc6..45cd4f751f 100644
--- a/src/library/scala/Tuple15.scala
+++ b/src/library/scala/Tuple15.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -29,6 +29,7 @@ package scala
* @param _14 Element 14 of this Tuple15
* @param _15 Element 15 of this Tuple15
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple15[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15)
extends Product15[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15]
{
diff --git a/src/library/scala/Tuple16.scala b/src/library/scala/Tuple16.scala
index a1e9a790ff..2e370a5b31 100644
--- a/src/library/scala/Tuple16.scala
+++ b/src/library/scala/Tuple16.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -30,6 +30,7 @@ package scala
* @param _15 Element 15 of this Tuple16
* @param _16 Element 16 of this Tuple16
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple16[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16)
extends Product16[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16]
{
diff --git a/src/library/scala/Tuple17.scala b/src/library/scala/Tuple17.scala
index f531766c18..2242a15fda 100644
--- a/src/library/scala/Tuple17.scala
+++ b/src/library/scala/Tuple17.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -31,6 +31,7 @@ package scala
* @param _16 Element 16 of this Tuple17
* @param _17 Element 17 of this Tuple17
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple17[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17)
extends Product17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17]
{
diff --git a/src/library/scala/Tuple18.scala b/src/library/scala/Tuple18.scala
index a96db25e4b..68f245c6ce 100644
--- a/src/library/scala/Tuple18.scala
+++ b/src/library/scala/Tuple18.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -32,6 +32,7 @@ package scala
* @param _17 Element 17 of this Tuple18
* @param _18 Element 18 of this Tuple18
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple18[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18)
extends Product18[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18]
{
diff --git a/src/library/scala/Tuple19.scala b/src/library/scala/Tuple19.scala
index 718280d68a..a8a49549fb 100644
--- a/src/library/scala/Tuple19.scala
+++ b/src/library/scala/Tuple19.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -33,6 +33,7 @@ package scala
* @param _18 Element 18 of this Tuple19
* @param _19 Element 19 of this Tuple19
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple19[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19)
extends Product19[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19]
{
diff --git a/src/library/scala/Tuple2.scala b/src/library/scala/Tuple2.scala
index 35d5a441c8..9ea1469c5c 100644
--- a/src/library/scala/Tuple2.scala
+++ b/src/library/scala/Tuple2.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -16,6 +16,7 @@ package scala
* @param _1 Element 1 of this Tuple2
* @param _2 Element 2 of this Tuple2
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple2[@specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T1, @specialized(Int, Long, Double, Char, Boolean/*, AnyRef*/) +T2](_1: T1, _2: T2)
extends Product2[T1, T2]
{
diff --git a/src/library/scala/Tuple20.scala b/src/library/scala/Tuple20.scala
index 4a44c0bb89..0118d382ab 100644
--- a/src/library/scala/Tuple20.scala
+++ b/src/library/scala/Tuple20.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -34,6 +34,7 @@ package scala
* @param _19 Element 19 of this Tuple20
* @param _20 Element 20 of this Tuple20
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple20[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19, +T20](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19, _20: T20)
extends Product20[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20]
{
diff --git a/src/library/scala/Tuple21.scala b/src/library/scala/Tuple21.scala
index 580a169e39..ceae94af41 100644
--- a/src/library/scala/Tuple21.scala
+++ b/src/library/scala/Tuple21.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -35,6 +35,7 @@ package scala
* @param _20 Element 20 of this Tuple21
* @param _21 Element 21 of this Tuple21
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple21[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19, +T20, +T21](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19, _20: T20, _21: T21)
extends Product21[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21]
{
diff --git a/src/library/scala/Tuple22.scala b/src/library/scala/Tuple22.scala
index fd3392ddea..ecd567a710 100644
--- a/src/library/scala/Tuple22.scala
+++ b/src/library/scala/Tuple22.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -36,6 +36,7 @@ package scala
* @param _21 Element 21 of this Tuple22
* @param _22 Element 22 of this Tuple22
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple22[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10, +T11, +T12, +T13, +T14, +T15, +T16, +T17, +T18, +T19, +T20, +T21, +T22](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9, _10: T10, _11: T11, _12: T12, _13: T13, _14: T14, _15: T15, _16: T16, _17: T17, _18: T18, _19: T19, _20: T20, _21: T21, _22: T22)
extends Product22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19, T20, T21, T22]
{
diff --git a/src/library/scala/Tuple3.scala b/src/library/scala/Tuple3.scala
index 5ed13602e3..6e71d3ae8c 100644
--- a/src/library/scala/Tuple3.scala
+++ b/src/library/scala/Tuple3.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -17,6 +17,7 @@ package scala
* @param _2 Element 2 of this Tuple3
* @param _3 Element 3 of this Tuple3
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple3[+T1, +T2, +T3](_1: T1, _2: T2, _3: T3)
extends Product3[T1, T2, T3]
{
diff --git a/src/library/scala/Tuple4.scala b/src/library/scala/Tuple4.scala
index a859078bcf..4c84cfc674 100644
--- a/src/library/scala/Tuple4.scala
+++ b/src/library/scala/Tuple4.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -18,6 +18,7 @@ package scala
* @param _3 Element 3 of this Tuple4
* @param _4 Element 4 of this Tuple4
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple4[+T1, +T2, +T3, +T4](_1: T1, _2: T2, _3: T3, _4: T4)
extends Product4[T1, T2, T3, T4]
{
diff --git a/src/library/scala/Tuple5.scala b/src/library/scala/Tuple5.scala
index 1edfb673ee..fe8e853f12 100644
--- a/src/library/scala/Tuple5.scala
+++ b/src/library/scala/Tuple5.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -19,6 +19,7 @@ package scala
* @param _4 Element 4 of this Tuple5
* @param _5 Element 5 of this Tuple5
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple5[+T1, +T2, +T3, +T4, +T5](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5)
extends Product5[T1, T2, T3, T4, T5]
{
diff --git a/src/library/scala/Tuple6.scala b/src/library/scala/Tuple6.scala
index 5b74937e58..6bf1c73d4b 100644
--- a/src/library/scala/Tuple6.scala
+++ b/src/library/scala/Tuple6.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -20,6 +20,7 @@ package scala
* @param _5 Element 5 of this Tuple6
* @param _6 Element 6 of this Tuple6
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple6[+T1, +T2, +T3, +T4, +T5, +T6](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6)
extends Product6[T1, T2, T3, T4, T5, T6]
{
diff --git a/src/library/scala/Tuple7.scala b/src/library/scala/Tuple7.scala
index a7f572e9f0..ea42709cb7 100644
--- a/src/library/scala/Tuple7.scala
+++ b/src/library/scala/Tuple7.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -21,6 +21,7 @@ package scala
* @param _6 Element 6 of this Tuple7
* @param _7 Element 7 of this Tuple7
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple7[+T1, +T2, +T3, +T4, +T5, +T6, +T7](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7)
extends Product7[T1, T2, T3, T4, T5, T6, T7]
{
diff --git a/src/library/scala/Tuple8.scala b/src/library/scala/Tuple8.scala
index 9bb427d689..c24f9454e0 100644
--- a/src/library/scala/Tuple8.scala
+++ b/src/library/scala/Tuple8.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -22,6 +22,7 @@ package scala
* @param _7 Element 7 of this Tuple8
* @param _8 Element 8 of this Tuple8
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple8[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8)
extends Product8[T1, T2, T3, T4, T5, T6, T7, T8]
{
diff --git a/src/library/scala/Tuple9.scala b/src/library/scala/Tuple9.scala
index 4d50539e0c..ed02b30df2 100644
--- a/src/library/scala/Tuple9.scala
+++ b/src/library/scala/Tuple9.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -23,6 +23,7 @@ package scala
* @param _8 Element 8 of this Tuple9
* @param _9 Element 9 of this Tuple9
*/
+@deprecatedInheritance("Tuples will be made final in a future version.", "2.11.0")
case class Tuple9[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9](_1: T1, _2: T2, _3: T3, _4: T4, _5: T5, _6: T6, _7: T7, _8: T8, _9: T9)
extends Product9[T1, T2, T3, T4, T5, T6, T7, T8, T9]
{
diff --git a/src/library/scala/UninitializedFieldError.scala b/src/library/scala/UninitializedFieldError.scala
index 10c6cccf15..0dfba2a187 100644
--- a/src/library/scala/UninitializedFieldError.scala
+++ b/src/library/scala/UninitializedFieldError.scala
@@ -18,8 +18,6 @@ package scala
*
* @since 2.7
*/
-final case class UninitializedFieldError(msg: String)
- extends RuntimeException(msg) {
- def this(obj: Any) =
- this(if (null != obj) obj.toString() else "null")
+final case class UninitializedFieldError(msg: String) extends RuntimeException(msg) {
+ def this(obj: Any) = this("" + obj)
}
diff --git a/src/library/scala/Unit.scala b/src/library/scala/Unit.scala
index dc67e60314..0e59a184d1 100644
--- a/src/library/scala/Unit.scala
+++ b/src/library/scala/Unit.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/annotation/serializable.scala b/src/library/scala/annotation/serializable.scala
deleted file mode 100644
index 1e1aff19d3..0000000000
--- a/src/library/scala/annotation/serializable.scala
+++ /dev/null
@@ -1,15 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.annotation
-
-/**
- * An annotation that designates the class to which it is applied as serializable
- */
-@deprecated("instead of `@serializable class C`, use `class C extends Serializable`", "2.9.0")
-class serializable extends scala.annotation.StaticAnnotation
diff --git a/src/library/scala/annotation/target/package.scala b/src/library/scala/annotation/target/package.scala
deleted file mode 100644
index ac2836c0a8..0000000000
--- a/src/library/scala/annotation/target/package.scala
+++ /dev/null
@@ -1,29 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.annotation
-
-package object target {
- @deprecated("Use `@scala.annotation.meta.beanGetter` instead", "2.10.0")
- type beanGetter = scala.annotation.meta.beanGetter
-
- @deprecated("Use `@scala.annotation.meta.beanSetter` instead", "2.10.0")
- type beanSetter = scala.annotation.meta.beanSetter
-
- @deprecated("Use `@scala.annotation.meta.field` instead", "2.10.0")
- type field = scala.annotation.meta.field
-
- @deprecated("Use `@scala.annotation.meta.getter` instead", "2.10.0")
- type getter = scala.annotation.meta.getter
-
- @deprecated("Use `@scala.annotation.meta.param` instead", "2.10.0")
- type param = scala.annotation.meta.param
-
- @deprecated("Use `@scala.annotation.meta.setter` instead", "2.10.0")
- type setter = scala.annotation.meta.setter
-}
diff --git a/src/library/scala/beans/ScalaBeanInfo.scala b/src/library/scala/beans/ScalaBeanInfo.scala
index 3a95335d71..ac8fa263d7 100644
--- a/src/library/scala/beans/ScalaBeanInfo.scala
+++ b/src/library/scala/beans/ScalaBeanInfo.scala
@@ -27,7 +27,7 @@ abstract class ScalaBeanInfo(clazz: java.lang.Class[_],
for (m <- clazz.getMethods if methods.exists(_ == m.getName))
yield new MethodDescriptor(m)
- init
+ init()
override def getPropertyDescriptors() = pd
override def getMethodDescriptors() = md
@@ -35,10 +35,10 @@ abstract class ScalaBeanInfo(clazz: java.lang.Class[_],
// override def getAdditionalBeanInfo() = Array(Introspector getBeanInfo clazz.getSuperclass)
private def init() {
- var i = 0;
+ var i = 0
while (i < props.length) {
pd(i/3) = new PropertyDescriptor(props(i), clazz, props(i+1), props(i+2))
- i = i + 3;
+ i = i + 3
}
}
diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala
index 6985563da2..e255e96140 100644
--- a/src/library/scala/collection/BitSet.scala
+++ b/src/library/scala/collection/BitSet.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/BitSetLike.scala b/src/library/scala/collection/BitSetLike.scala
index 4a1c0beaa6..f11f3757a6 100644
--- a/src/library/scala/collection/BitSetLike.scala
+++ b/src/library/scala/collection/BitSetLike.scala
@@ -8,10 +8,10 @@
-package scala.collection
+package scala
+package collection
import BitSetLike._
-import generic._
import mutable.StringBuilder
/** A template trait for bitsets.
@@ -70,6 +70,8 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe
s
}
+ override def isEmpty: Boolean = 0 until nwords forall (i => word(i) == 0)
+
implicit def ordering: Ordering[Int] = Ordering.Int
def rangeImpl(from: Option[Int], until: Option[Int]): This = {
@@ -99,22 +101,27 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe
fromBitMaskNoCopy(a)
}
- def iterator: Iterator[Int] = new AbstractIterator[Int] {
- private var current = 0
+ def iterator: Iterator[Int] = iteratorFrom(0)
+
+ override def keysIteratorFrom(start: Int) = new AbstractIterator[Int] {
+ private var current = start
private val end = nwords * WordLength
def hasNext: Boolean = {
- while (current < end && !self.contains(current)) current += 1
- current < end
+ while (current != end && !self.contains(current)) current += 1
+ current != end
}
def next(): Int =
if (hasNext) { val r = current; current += 1; r }
- else Iterator.empty.next
+ else Iterator.empty.next()
}
override def foreach[B](f: Int => B) {
for (i <- 0 until nwords) {
val w = word(i)
- for (j <- i * WordLength until (i + 1) * WordLength) {
+ /* NOTE: `until` instead of `to` will not work here because
+ the maximum value of `(i + 1) * WordLength` could be
+ `Int.MaxValue + 1` (i.e. `Int.MinValue`). */
+ for (j <- i * WordLength to (i + 1) * WordLength - 1) {
if ((w & (1L << j)) != 0L) f(j)
}
}
@@ -194,11 +201,15 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe
override def addString(sb: StringBuilder, start: String, sep: String, end: String) = {
sb append start
var pre = ""
- for (i <- 0 until nwords * WordLength)
+ val max = nwords * WordLength
+ var i = 0
+ while(i != max) {
if (contains(i)) {
sb append pre append i
pre = sep
}
+ i += 1
+ }
sb append end
}
@@ -209,6 +220,7 @@ trait BitSetLike[+This <: BitSetLike[This] with SortedSet[Int]] extends SortedSe
object BitSetLike {
private[collection] val LogWL = 6
private val WordLength = 64
+ private[collection] val MaxSize = (Int.MaxValue >> LogWL) + 1
private[collection] def updateArray(elems: Array[Long], idx: Int, w: Long): Array[Long] = {
var len = elems.length
diff --git a/src/library/scala/collection/BufferedIterator.scala b/src/library/scala/collection/BufferedIterator.scala
index 741bca4e46..e6e97d584c 100644
--- a/src/library/scala/collection/BufferedIterator.scala
+++ b/src/library/scala/collection/BufferedIterator.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
/** Buffered iterators are iterators which provide a method `head`
* that inspects the next element without discarding it.
diff --git a/src/library/scala/collection/CustomParallelizable.scala b/src/library/scala/collection/CustomParallelizable.scala
index 53fe32b89f..cbeb28d643 100644
--- a/src/library/scala/collection/CustomParallelizable.scala
+++ b/src/library/scala/collection/CustomParallelizable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import parallel.Combiner
diff --git a/src/library/scala/collection/DefaultMap.scala b/src/library/scala/collection/DefaultMap.scala
index 5c91183891..8afda7cfcf 100644
--- a/src/library/scala/collection/DefaultMap.scala
+++ b/src/library/scala/collection/DefaultMap.scala
@@ -6,11 +6,8 @@
** |/ **
\* */
-
-
-package scala.collection
-
-import generic._
+package scala
+package collection
/** A default map which implements the `+` and `-` methods of maps.
*
@@ -27,14 +24,14 @@ import generic._
* @since 2.8
*/
trait DefaultMap[A, +B] extends Map[A, B] { self =>
-
+
/** A default implementation which creates a new immutable map.
*/
override def +[B1 >: B](kv: (A, B1)): Map[A, B1] = {
val b = Map.newBuilder[A, B1]
b ++= this
b += ((kv._1, kv._2))
- b.result
+ b.result()
}
/** A default implementation which creates a new immutable map.
@@ -42,6 +39,6 @@ trait DefaultMap[A, +B] extends Map[A, B] { self =>
override def - (key: A): Map[A, B] = {
val b = newBuilder
b ++= this filter (key != _._1)
- b.result
+ b.result()
}
}
diff --git a/src/library/scala/collection/GenIterable.scala b/src/library/scala/collection/GenIterable.scala
index b4e7a14ade..6fd4158726 100644
--- a/src/library/scala/collection/GenIterable.scala
+++ b/src/library/scala/collection/GenIterable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/GenIterableLike.scala b/src/library/scala/collection/GenIterableLike.scala
index 2ba9a7283d..1dbb54ddc7 100644
--- a/src/library/scala/collection/GenIterableLike.scala
+++ b/src/library/scala/collection/GenIterableLike.scala
@@ -6,9 +6,10 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
-import generic.{ CanBuildFrom => CBF, _ }
+import generic.{ CanBuildFrom => CBF }
/** A template trait for all iterable collections which may possibly
* have their operations implemented in parallel.
diff --git a/src/library/scala/collection/GenIterableView.scala b/src/library/scala/collection/GenIterableView.scala
index ca0332e9ad..cd052ddf79 100644
--- a/src/library/scala/collection/GenIterableView.scala
+++ b/src/library/scala/collection/GenIterableView.scala
@@ -6,13 +6,7 @@
** |/ **
\* */
-package scala.collection
-
-
-import generic._
-
-
+package scala
+package collection
trait GenIterableView[+A, +Coll] extends GenIterableViewLike[A, Coll, GenIterableView[A, Coll]] { }
-
-
diff --git a/src/library/scala/collection/GenIterableViewLike.scala b/src/library/scala/collection/GenIterableViewLike.scala
index 4e4ceb4cea..b519e99ae5 100644
--- a/src/library/scala/collection/GenIterableViewLike.scala
+++ b/src/library/scala/collection/GenIterableViewLike.scala
@@ -6,14 +6,8 @@
** |/ **
\* */
-package scala.collection
-
-
-
-import generic._
-import TraversableView.NoBuilder
-
-
+package scala
+package collection
trait GenIterableViewLike[+A,
+Coll,
diff --git a/src/library/scala/collection/GenMap.scala b/src/library/scala/collection/GenMap.scala
index f7b2ae4d70..3d7427981d 100644
--- a/src/library/scala/collection/GenMap.scala
+++ b/src/library/scala/collection/GenMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/GenMapLike.scala b/src/library/scala/collection/GenMapLike.scala
index 367377a59c..4e7d359251 100644
--- a/src/library/scala/collection/GenMapLike.scala
+++ b/src/library/scala/collection/GenMapLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
/** A trait for all maps upon which operations may be
* implemented in parallel.
diff --git a/src/library/scala/collection/GenSeq.scala b/src/library/scala/collection/GenSeq.scala
index 4c5488d7e2..480562cab5 100644
--- a/src/library/scala/collection/GenSeq.scala
+++ b/src/library/scala/collection/GenSeq.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/GenSeqLike.scala b/src/library/scala/collection/GenSeqLike.scala
index 78d63348c0..27b75c0491 100644
--- a/src/library/scala/collection/GenSeqLike.scala
+++ b/src/library/scala/collection/GenSeqLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/GenSeqView.scala b/src/library/scala/collection/GenSeqView.scala
index 92c8b779e9..0a214832ad 100644
--- a/src/library/scala/collection/GenSeqView.scala
+++ b/src/library/scala/collection/GenSeqView.scala
@@ -6,13 +6,7 @@
** |/ **
\* */
-package scala.collection
-
-
-import generic._
-
-
+package scala
+package collection
trait GenSeqView[+A, +Coll] extends GenSeqViewLike[A, Coll, GenSeqView[A, Coll]] { }
-
-
diff --git a/src/library/scala/collection/GenSeqViewLike.scala b/src/library/scala/collection/GenSeqViewLike.scala
index 51600218ad..d3af953f72 100644
--- a/src/library/scala/collection/GenSeqViewLike.scala
+++ b/src/library/scala/collection/GenSeqViewLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
diff --git a/src/library/scala/collection/GenSet.scala b/src/library/scala/collection/GenSet.scala
index 832177b128..2467860095 100644
--- a/src/library/scala/collection/GenSet.scala
+++ b/src/library/scala/collection/GenSet.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/GenSetLike.scala b/src/library/scala/collection/GenSetLike.scala
index f22a7c8f09..c5355e58ec 100644
--- a/src/library/scala/collection/GenSetLike.scala
+++ b/src/library/scala/collection/GenSetLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
/** A template trait for sets which may possibly
diff --git a/src/library/scala/collection/GenTraversable.scala b/src/library/scala/collection/GenTraversable.scala
index 3db2dd77a9..b700f49cf6 100644
--- a/src/library/scala/collection/GenTraversable.scala
+++ b/src/library/scala/collection/GenTraversable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala
index 46134c921e..f4aa063d8a 100644
--- a/src/library/scala/collection/GenTraversableLike.scala
+++ b/src/library/scala/collection/GenTraversableLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
@@ -238,7 +239,7 @@ trait GenTraversableLike[+A, +Repr] extends Any with GenTraversableOnce[A] with
* // lettersOf will return a Set[Char], not a Seq
* def lettersOf(words: Seq[String]) = words.toSet flatMap (word => word.toSeq)
*
- * // xs will be a an Iterable[Int]
+ * // xs will be an Iterable[Int]
* val xs = Map("a" -> List(11,111), "b" -> List(22,222)).flatMap(_._2)
*
* // ys will be a Map[Int, Int]
diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala
index 093db2a972..d966c7324b 100644
--- a/src/library/scala/collection/GenTraversableOnce.scala
+++ b/src/library/scala/collection/GenTraversableOnce.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import scala.reflect.ClassTag
import scala.collection.generic.CanBuildFrom
@@ -119,19 +120,6 @@ trait GenTraversableOnce[+A] extends Any {
*/
def fold[A1 >: A](z: A1)(op: (A1, A1) => A1): A1
- /** A syntactic sugar for out of order folding. See `fold`.
- *
- * Example:
- * {{{
- * scala> val a = LinkedList(1,2,3,4)
- * a: scala.collection.mutable.LinkedList[Int] = LinkedList(1, 2, 3, 4)
- *
- * scala> val b = (a /:\ 5)(_+_)
- * b: Int = 15
- * }}}*/
- @deprecated("use fold instead", "2.10.0")
- 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.
*
@@ -261,11 +249,12 @@ trait GenTraversableOnce[+A] extends Any {
* @tparam B 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)
+ * `Nil` for list concatenation or `0` for summation) and may be evaluated
+ * more than once
* @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
+ 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
diff --git a/src/library/scala/collection/GenTraversableView.scala b/src/library/scala/collection/GenTraversableView.scala
index cceb06882e..7d9a6e9777 100644
--- a/src/library/scala/collection/GenTraversableView.scala
+++ b/src/library/scala/collection/GenTraversableView.scala
@@ -6,13 +6,7 @@
** |/ **
\* */
-package scala.collection
-
-
-import generic._
-
-
+package scala
+package collection
trait GenTraversableView[+A, +Coll] extends GenTraversableViewLike[A, Coll, GenTraversableView[A, Coll]] { }
-
-
diff --git a/src/library/scala/collection/GenTraversableViewLike.scala b/src/library/scala/collection/GenTraversableViewLike.scala
index 77fe0802bf..dde18a7a32 100644
--- a/src/library/scala/collection/GenTraversableViewLike.scala
+++ b/src/library/scala/collection/GenTraversableViewLike.scala
@@ -6,13 +6,12 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import mutable.{ Builder, ArrayBuffer }
-import TraversableView.NoBuilder
-
trait GenTraversableViewLike[+A,
+Coll,
diff --git a/src/library/scala/collection/IndexedSeq.scala b/src/library/scala/collection/IndexedSeq.scala
index 2de0043c96..1a33026101 100644
--- a/src/library/scala/collection/IndexedSeq.scala
+++ b/src/library/scala/collection/IndexedSeq.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
import generic._
import mutable.Builder
@@ -28,14 +27,13 @@ trait IndexedSeq[+A] extends Seq[A]
* @define coll indexed sequence
* @define Coll `IndexedSeq`
*/
-object IndexedSeq extends SeqFactory[IndexedSeq] {
+object IndexedSeq extends IndexedSeqFactory[IndexedSeq] {
// A single CBF which can be checked against to identify
// an indexed collection type.
- override lazy val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] {
+ override val ReusableCBF: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] {
override def apply() = newBuilder[Nothing]
}
def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A]
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] =
ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
}
-
diff --git a/src/library/scala/collection/IndexedSeqLike.scala b/src/library/scala/collection/IndexedSeqLike.scala
index 9d0e9cbaea..18c9175ee1 100644
--- a/src/library/scala/collection/IndexedSeqLike.scala
+++ b/src/library/scala/collection/IndexedSeqLike.scala
@@ -6,9 +6,9 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
-import generic._
import mutable.ArrayBuffer
import scala.annotation.tailrec
@@ -53,7 +53,6 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] {
// pre: start >= 0, end <= self.length
@SerialVersionUID(1756321872811029277L)
protected class Elements(start: Int, end: Int) extends AbstractIterator[A] with BufferedIterator[A] with Serializable {
- private def initialSize = if (end <= start) 0 else end - start
private var index = start
private def available = (end - index) max 0
@@ -61,7 +60,7 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] {
def next(): A = {
if (index >= end)
- Iterator.empty.next
+ Iterator.empty.next()
val x = self(index)
index += 1
@@ -70,7 +69,7 @@ trait IndexedSeqLike[+A, +Repr] extends Any with SeqLike[A, Repr] {
def head = {
if (index >= end)
- Iterator.empty.next
+ Iterator.empty.next()
self(index)
}
diff --git a/src/library/scala/collection/IndexedSeqOptimized.scala b/src/library/scala/collection/IndexedSeqOptimized.scala
index 09c4b14ba0..ade04e4de8 100755
--- a/src/library/scala/collection/IndexedSeqOptimized.scala
+++ b/src/library/scala/collection/IndexedSeqOptimized.scala
@@ -33,11 +33,17 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] {
while (i < len) { f(this(i)); i += 1 }
}
+ private def prefixLengthImpl(p: A => Boolean, expectTrue: Boolean): Int = {
+ var i = 0
+ while (i < length && p(apply(i)) == expectTrue) i += 1
+ i
+ }
+
override /*IterableLike*/
- def forall(p: A => Boolean): Boolean = prefixLength(p(_)) == length
+ def forall(p: A => Boolean): Boolean = prefixLengthImpl(p, expectTrue = true) == length
override /*IterableLike*/
- def exists(p: A => Boolean): Boolean = prefixLength(!p(_)) != length
+ def exists(p: A => Boolean): Boolean = prefixLengthImpl(p, expectTrue = false) != length
override /*IterableLike*/
def find(p: A => Boolean): Option[A] = {
@@ -82,7 +88,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] {
b += ((this(i), that(i).asInstanceOf[B]))
i += 1
}
- b.result
+ b.result()
case _ =>
super.zip[A1, B, That](that)(bf)
}
@@ -97,7 +103,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] {
b += ((this(i), i))
i += 1
}
- b.result
+ b.result()
}
override /*IterableLike*/
@@ -113,7 +119,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] {
b += self(i)
i += 1
}
- b.result
+ b.result()
}
override /*IterableLike*/
@@ -214,7 +220,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] {
i -= 1
b += this(i)
}
- b.result
+ b.result()
}
override /*SeqLike*/
@@ -225,7 +231,7 @@ trait IndexedSeqOptimized[+A, +Repr] extends Any with IndexedSeqLike[A, Repr] {
if (0 < i) {
i -= 1
self(i)
- } else Iterator.empty.next
+ } else Iterator.empty.next()
}
override /*SeqLike*/
diff --git a/src/library/scala/collection/Iterable.scala b/src/library/scala/collection/Iterable.scala
index 5b73d720a8..973efc447e 100644
--- a/src/library/scala/collection/Iterable.scala
+++ b/src/library/scala/collection/Iterable.scala
@@ -8,10 +8,10 @@
-package scala.collection
+package scala
+package collection
import generic._
-import scala.util.control.Breaks._
import mutable.Builder
/** A base trait for iterable collections.
diff --git a/src/library/scala/collection/IterableLike.scala b/src/library/scala/collection/IterableLike.scala
index 540bd84b79..b043d1f2a6 100644
--- a/src/library/scala/collection/IterableLike.scala
+++ b/src/library/scala/collection/IterableLike.scala
@@ -88,13 +88,13 @@ self =>
override /*TraversableLike*/ def toIterator: Iterator[A] =
iterator
override /*TraversableLike*/ def head: A =
- iterator.next
+ iterator.next()
override /*TraversableLike*/ def slice(from: Int, until: Int): Repr = {
val lo = math.max(from, 0)
val elems = until - lo
val b = newBuilder
- if (elems <= 0) b.result
+ if (elems <= 0) b.result()
else {
b.sizeHintBounded(elems, this)
var i = 0
@@ -103,14 +103,14 @@ self =>
b += it.next
i += 1
}
- b.result
+ b.result()
}
}
override /*TraversableLike*/ def take(n: Int): Repr = {
val b = newBuilder
- if (n <= 0) b.result
+ if (n <= 0) b.result()
else {
b.sizeHintBounded(n, this)
var i = 0
@@ -119,7 +119,7 @@ self =>
b += it.next
i += 1
}
- b.result
+ b.result()
}
}
@@ -130,21 +130,21 @@ self =>
var i = 0
val it = iterator
while (i < n && it.hasNext) {
- it.next
+ it.next()
i += 1
}
- (b ++= it).result
+ (b ++= it).result()
}
override /*TraversableLike*/ def takeWhile(p: A => Boolean): Repr = {
val b = newBuilder
val it = iterator
while (it.hasNext) {
- val x = it.next
- if (!p(x)) return b.result
+ val x = it.next()
+ if (!p(x)) return b.result()
b += x
}
- b.result
+ b.result()
}
/** Partitions elements in fixed size ${coll}s.
@@ -158,7 +158,7 @@ self =>
for (xs <- iterator grouped size) yield {
val b = newBuilder
b ++= xs
- b.result
+ b.result()
}
/** Groups elements in fixed size blocks by passing a "sliding window"
@@ -187,7 +187,7 @@ self =>
for (xs <- iterator.sliding(size, step)) yield {
val b = newBuilder
b ++= xs
- b.result
+ b.result()
}
/** Selects last ''n'' elements.
@@ -203,11 +203,11 @@ self =>
val lead = this.iterator drop n
var go = false
for (x <- this.seq) {
- if (lead.hasNext) lead.next
+ if (lead.hasNext) lead.next()
else go = true
if (go) b += x
}
- b.result
+ b.result()
}
/** Selects all elements except last ''n'' ones.
@@ -224,9 +224,9 @@ self =>
val it = iterator
while (lead.hasNext) {
b += it.next
- lead.next
+ lead.next()
}
- b.result
+ b.result()
}
override /*TraversableLike*/ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
@@ -234,7 +234,7 @@ self =>
val end = (start + len) min xs.length
val it = iterator
while (i < end && it.hasNext) {
- xs(i) = it.next
+ xs(i) = it.next()
i += 1
}
}
@@ -244,8 +244,8 @@ self =>
val these = this.iterator
val those = that.iterator
while (these.hasNext && those.hasNext)
- b += ((these.next, those.next))
- b.result
+ b += ((these.next(), those.next()))
+ b.result()
}
def zipAll[B, A1 >: A, That](that: GenIterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = {
@@ -253,12 +253,12 @@ self =>
val these = this.iterator
val those = that.iterator
while (these.hasNext && those.hasNext)
- b += ((these.next, those.next))
+ b += ((these.next(), those.next()))
while (these.hasNext)
- b += ((these.next, thatElem))
+ b += ((these.next(), thatElem))
while (those.hasNext)
- b += ((thisElem, those.next))
- b.result
+ b += ((thisElem, those.next()))
+ b.result()
}
def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[Repr, (A1, Int), That]): That = {
@@ -268,7 +268,7 @@ self =>
b += ((x, i))
i +=1
}
- b.result
+ b.result()
}
def sameElements[B >: A](that: GenIterable[B]): Boolean = {
diff --git a/src/library/scala/collection/IterableProxy.scala b/src/library/scala/collection/IterableProxy.scala
index 2d041928cc..3a0e2ab115 100644
--- a/src/library/scala/collection/IterableProxy.scala
+++ b/src/library/scala/collection/IterableProxy.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-package scala.collection
-
-import generic._
+package scala
+package collection
/** This trait implements a proxy for iterable objects. It forwards all calls
* to a different iterable object.
diff --git a/src/library/scala/collection/IterableProxyLike.scala b/src/library/scala/collection/IterableProxyLike.scala
index 6968a54399..9b8f6f3742 100644
--- a/src/library/scala/collection/IterableProxyLike.scala
+++ b/src/library/scala/collection/IterableProxyLike.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
import mutable.Buffer
diff --git a/src/library/scala/collection/IterableView.scala b/src/library/scala/collection/IterableView.scala
index 985556e0d4..1d631739aa 100644
--- a/src/library/scala/collection/IterableView.scala
+++ b/src/library/scala/collection/IterableView.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
import TraversableView.NoBuilder
diff --git a/src/library/scala/collection/IterableViewLike.scala b/src/library/scala/collection/IterableViewLike.scala
index 3a81a3422f..236bfd154c 100644
--- a/src/library/scala/collection/IterableViewLike.scala
+++ b/src/library/scala/collection/IterableViewLike.scala
@@ -6,10 +6,10 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
-import TraversableView.NoBuilder
import immutable.Stream
import scala.language.implicitConversions
diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala
index 2bb5bd1df9..72a23a0dd0 100644
--- a/src/library/scala/collection/Iterator.scala
+++ b/src/library/scala/collection/Iterator.scala
@@ -161,6 +161,41 @@ object Iterator {
def hasNext = true
def next = elem
}
+
+ /** Avoid stack overflows when applying ++ to lots of iterators by
+ * flattening the unevaluated iterators out into a vector of closures.
+ */
+ private[scala] final class ConcatIterator[+A](initial: Vector[() => Iterator[A]]) extends Iterator[A] {
+ // current set to null when all iterators are exhausted
+ private[this] var current: Iterator[A] = Iterator.empty
+ private[this] var queue: Vector[() => Iterator[A]] = initial
+ // Advance current to the next non-empty iterator
+ private[this] def advance(): Boolean = {
+ if (queue.isEmpty) {
+ current = null
+ false
+ }
+ else {
+ current = queue.head()
+ queue = queue.tail
+ current.hasNext || advance()
+ }
+ }
+ def hasNext = (current ne null) && (current.hasNext || advance())
+ def next() = if (hasNext) current.next else Iterator.empty.next
+
+ override def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] =
+ new ConcatIterator(queue :+ (() => that.toIterator))
+ }
+
+ private[scala] final class JoinIterator[+A](lhs: Iterator[A], that: => GenTraversableOnce[A]) extends Iterator[A] {
+ private[this] lazy val rhs: Iterator[A] = that.toIterator
+ def hasNext = lhs.hasNext || rhs.hasNext
+ def next = if (lhs.hasNext) lhs.next else rhs.next
+
+ override def ++[B >: A](that: => GenTraversableOnce[B]) =
+ new ConcatIterator(Vector(() => this, () => that.toIterator))
+ }
}
import Iterator.empty
@@ -338,24 +373,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
* @usecase def ++(that: => Iterator[A]): Iterator[A]
* @inheritdoc
*/
- def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] = new AbstractIterator[B] {
- // optimize a little bit to prevent n log n behavior.
- private var cur : Iterator[B] = self
- private var selfExhausted : Boolean = false
- // since that is by-name, make sure it's only referenced once -
- // if "val it = that" is inside the block, then hasNext on an empty
- // iterator will continually reevaluate it. (ticket #3269)
- lazy val it = that.toIterator
- // the eq check is to avoid an infinite loop on "x ++ x"
- def hasNext = cur.hasNext || (!selfExhausted && {
- it.hasNext && {
- cur = it
- selfExhausted = true
- true
- }
- })
- def next() = { hasNext; cur.next() }
- }
+ def ++[B >: A](that: => GenTraversableOnce[B]): Iterator[B] = new Iterator.JoinIterator(self, that)
/** Creates a new iterator by applying a function to all values produced by this iterator
* and concatenating the results.
@@ -368,7 +386,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
def flatMap[B](f: A => GenTraversableOnce[B]): Iterator[B] = new AbstractIterator[B] {
private var cur: Iterator[B] = empty
def hasNext: Boolean =
- cur.hasNext || self.hasNext && { cur = f(self.next).toIterator; hasNext }
+ cur.hasNext || self.hasNext && { cur = f(self.next()).toIterator; hasNext }
def next(): B = (if (hasNext) cur else empty).next()
}
@@ -408,7 +426,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
def corresponds[B](that: GenTraversableOnce[B])(p: (A, B) => Boolean): Boolean = {
val that0 = that.toIterator
while (hasNext && that0.hasNext)
- if (!p(next, that0.next)) return false
+ if (!p(next(), that0.next())) return false
hasNext == that0.hasNext
}
@@ -555,14 +573,13 @@ trait Iterator[+A] extends TraversableOnce[A] {
def span(p: A => Boolean): (Iterator[A], Iterator[A]) = {
val self = buffered
- /**
+ /*
* Giving a name to following iterator (as opposed to trailing) because
* anonymous class is represented as a structural type that trailing
* iterator is referring (the finish() method) and thus triggering
* handling of structural calls. It's not what's intended here.
*/
class Leading extends AbstractIterator[A] {
- private var isDone = false
val lookahead = new mutable.Queue[A]
def advance() = {
self.hasNext && p(self.head) && {
@@ -572,7 +589,6 @@ trait Iterator[+A] extends TraversableOnce[A] {
}
def finish() = {
while (advance()) ()
- isDone = true
}
def hasNext = lookahead.nonEmpty || advance()
def next() = {
@@ -632,7 +648,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
*/
def zip[B](that: Iterator[B]): Iterator[(A, B)] = new AbstractIterator[(A, B)] {
def hasNext = self.hasNext && that.hasNext
- def next = (self.next, that.next)
+ def next = (self.next(), that.next())
}
/** Appends an element value to this iterator until a given target length is reached.
@@ -652,9 +668,9 @@ trait Iterator[+A] extends TraversableOnce[A] {
def hasNext = self.hasNext || count < len
def next = {
count += 1
- if (self.hasNext) self.next
+ if (self.hasNext) self.next()
else if (count <= len) elem
- else empty.next
+ else empty.next()
}
}
@@ -669,7 +685,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
var idx = 0
def hasNext = self.hasNext
def next = {
- val ret = (self.next, idx)
+ val ret = (self.next(), idx)
idx += 1
ret
}
@@ -1054,12 +1070,12 @@ trait Iterator[+A] extends TraversableOnce[A] {
val e = self.next()
gap enqueue e
e
- } else gap.dequeue
+ } else gap.dequeue()
}
// to verify partnerhood we use reference equality on gap because
// type testing does not discriminate based on origin.
private def compareGap(queue: scala.collection.mutable.Queue[A]) = gap eq queue
- override def hashCode = gap.hashCode
+ override def hashCode = gap.hashCode()
override def equals(other: Any) = other match {
case x: Partner => x.compareGap(gap) && gap.isEmpty
case _ => super.equals(other)
@@ -1118,6 +1134,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
xs(i) = next()
i += 1
}
+ // TODO: return i - start so the caller knows how many values read?
}
/** Tests if another iterator produces the same values as this one.
@@ -1140,7 +1157,7 @@ trait Iterator[+A] extends TraversableOnce[A] {
def toTraversable: Traversable[A] = toStream
def toIterator: Iterator[A] = self
def toStream: Stream[A] =
- if (self.hasNext) Stream.cons(self.next, self.toStream)
+ if (self.hasNext) Stream.cons(self.next(), self.toStream)
else Stream.empty[A]
diff --git a/src/library/scala/collection/JavaConversions.scala b/src/library/scala/collection/JavaConversions.scala
index 59d4259c70..b527b34f10 100644
--- a/src/library/scala/collection/JavaConversions.scala
+++ b/src/library/scala/collection/JavaConversions.scala
@@ -6,9 +6,9 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
-import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
import convert._
/** A collection of implicit conversions supporting interoperability between
@@ -22,7 +22,6 @@ import convert._
* scala.collection.mutable.Buffer <=> java.util.List
* scala.collection.mutable.Set <=> java.util.Set
* scala.collection.mutable.Map <=> java.util.{ Map, Dictionary }
- * scala.collection.mutable.ConcurrentMap (deprecated since 2.10) <=> java.util.concurrent.ConcurrentMap
* scala.collection.concurrent.Map <=> java.util.concurrent.ConcurrentMap
*}}}
* In all cases, converting from a source type to a target type and back
@@ -91,42 +90,6 @@ object JavaConversions extends WrapAsScala with WrapAsJava {
@deprecated("Use a member of scala.collection.convert.Wrappers", "2.10.0") val MutableSeqWrapper = Wrappers.MutableSeqWrapper
@deprecated("Use a member of scala.collection.convert.Wrappers", "2.10.0") val MutableSetWrapper = Wrappers.MutableSetWrapper
@deprecated("Use a member of scala.collection.convert.Wrappers", "2.10.0") val SeqWrapper = Wrappers.SeqWrapper
-
- // Note to implementors: the cavalcade of deprecated methods herein should
- // serve as a warning to any who follow: don't overload implicit methods.
-
- @deprecated("use bufferAsJavaList instead", "2.9.0")
- def asJavaList[A](b : mutable.Buffer[A]): ju.List[A] = bufferAsJavaList[A](b)
-
- @deprecated("use mutableSeqAsJavaList instead", "2.9.0")
- def asJavaList[A](b : mutable.Seq[A]): ju.List[A] = mutableSeqAsJavaList[A](b)
-
- @deprecated("use seqAsJavaList instead", "2.9.0")
- def asJavaList[A](b : Seq[A]): ju.List[A] = seqAsJavaList[A](b)
-
- @deprecated("use mutableSetAsJavaSet instead", "2.9.0")
- def asJavaSet[A](s : mutable.Set[A]): ju.Set[A] = mutableSetAsJavaSet[A](s)
-
- @deprecated("use setAsJavaSet instead", "2.9.0")
- def asJavaSet[A](s: Set[A]): ju.Set[A] = setAsJavaSet[A](s)
-
- @deprecated("use mutableMapAsJavaMap instead", "2.9.0")
- def asJavaMap[A, B](m : mutable.Map[A, B]): ju.Map[A, B] = mutableMapAsJavaMap[A, B](m)
-
- @deprecated("use mapAsJavaMap instead", "2.9.0")
- def asJavaMap[A, B](m : Map[A, B]): ju.Map[A, B] = mapAsJavaMap[A, B](m)
-
- @deprecated("use iterableAsScalaIterable instead", "2.9.0")
- def asScalaIterable[A](i : jl.Iterable[A]): Iterable[A] = iterableAsScalaIterable[A](i)
-
- @deprecated("use collectionAsScalaIterable instead", "2.9.0")
- def asScalaIterable[A](i : ju.Collection[A]): Iterable[A] = collectionAsScalaIterable[A](i)
-
- @deprecated("use mapAsScalaMap instead", "2.9.0")
- def asScalaMap[A, B](m: ju.Map[A, B]): mutable.Map[A, B] = mapAsScalaMap[A, B](m)
-
- @deprecated("use propertiesAsScalaMap instead", "2.9.0")
- def asScalaMap(p: ju.Properties): mutable.Map[String, String] = propertiesAsScalaMap(p)
}
diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala
index ab3ac8925c..80dbf4b19d 100755
--- a/src/library/scala/collection/JavaConverters.scala
+++ b/src/library/scala/collection/JavaConverters.scala
@@ -6,16 +6,15 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
-import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
import convert._
// TODO: I cleaned all this documentation up in JavaConversions, but the
// documentation in here is basically the pre-cleaned-up version with minor
// additions. Would be nice to have in one place.
-
/** A collection of decorators that allow converting between
* Scala and Java collections using `asScala` and `asJava` methods.
*
@@ -26,7 +25,7 @@ import convert._
* - `scala.collection.mutable.Buffer` <=> `java.util.List`
* - `scala.collection.mutable.Set` <=> `java.util.Set`
* - `scala.collection.mutable.Map` <=> `java.util.Map`
- * - `scala.collection.mutable.ConcurrentMap` <=> `java.util.concurrent.ConcurrentMap`
+ * - `scala.collection.mutable.concurrent.Map` <=> `java.util.concurrent.ConcurrentMap`
*
* In all cases, converting from a source type to a target type and back
* again will return the original source object, e.g.
@@ -67,37 +66,4 @@ object JavaConverters extends DecorateAsJava with DecorateAsScala {
type AsJavaEnumeration[A] = Decorators.AsJavaEnumeration[A]
@deprecated("Don't access these decorators directly.", "2.10.0")
type AsJavaDictionary[A, B] = Decorators.AsJavaDictionary[A, B]
-
- @deprecated("Use bufferAsJavaListConverter instead", "2.9.0")
- def asJavaListConverter[A](b : mutable.Buffer[A]): AsJava[ju.List[A]] = bufferAsJavaListConverter(b)
-
- @deprecated("Use mutableSeqAsJavaListConverter instead", "2.9.0")
- def asJavaListConverter[A](b : mutable.Seq[A]): AsJava[ju.List[A]] = mutableSeqAsJavaListConverter(b)
-
- @deprecated("Use seqAsJavaListConverter instead", "2.9.0")
- def asJavaListConverter[A](b : Seq[A]): AsJava[ju.List[A]] = seqAsJavaListConverter(b)
-
- @deprecated("Use mutableSetAsJavaSetConverter instead", "2.9.0")
- def asJavaSetConverter[A](s : mutable.Set[A]): AsJava[ju.Set[A]] = mutableSetAsJavaSetConverter(s)
-
- @deprecated("Use setAsJavaSetConverter instead", "2.9.0")
- def asJavaSetConverter[A](s : Set[A]): AsJava[ju.Set[A]] = setAsJavaSetConverter(s)
-
- @deprecated("use mutableMapAsJavaMapConverter instead", "2.9.0")
- def asJavaMapConverter[A, B](m : mutable.Map[A, B]): AsJava[ju.Map[A, B]] = mutableMapAsJavaMapConverter(m)
-
- @deprecated("Use mapAsJavaMapConverter instead", "2.9.0")
- def asJavaMapConverter[A, B](m : Map[A, B]): AsJava[ju.Map[A, B]] = mapAsJavaMapConverter(m)
-
- @deprecated("Use iterableAsScalaIterableConverter instead", "2.9.0")
- def asScalaIterableConverter[A](i : jl.Iterable[A]): AsScala[Iterable[A]] = iterableAsScalaIterableConverter(i)
-
- @deprecated("Use collectionAsScalaIterableConverter instead", "2.9.0")
- def asScalaIterableConverter[A](i : ju.Collection[A]): AsScala[Iterable[A]] = collectionAsScalaIterableConverter(i)
-
- @deprecated("Use mapAsScalaMapConverter instead", "2.9.0")
- def asScalaMapConverter[A, B](m : ju.Map[A, B]): AsScala[mutable.Map[A, B]] = mapAsScalaMapConverter(m)
-
- @deprecated("Use propertiesAsScalaMapConverter instead", "2.9.0")
- def asScalaMapConverter(p: ju.Properties): AsScala[mutable.Map[String, String]] = propertiesAsScalaMapConverter(p)
}
diff --git a/src/library/scala/collection/LinearSeq.scala b/src/library/scala/collection/LinearSeq.scala
index e52a1936fe..1e4975a0a7 100644
--- a/src/library/scala/collection/LinearSeq.scala
+++ b/src/library/scala/collection/LinearSeq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
import mutable.Builder
diff --git a/src/library/scala/collection/LinearSeqLike.scala b/src/library/scala/collection/LinearSeqLike.scala
index 78108a9c0f..ff7985bf0d 100644
--- a/src/library/scala/collection/LinearSeqLike.scala
+++ b/src/library/scala/collection/LinearSeqLike.scala
@@ -6,13 +6,10 @@
** |/ **
\* */
+package scala
+package collection
-package scala.collection
-
-import generic._
-import mutable.ListBuffer
import immutable.List
-import scala.util.control.Breaks._
import scala.annotation.tailrec
/** A template trait for linear sequences of type `LinearSeq[A]`.
@@ -59,14 +56,14 @@ trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr
def next(): A =
if (hasNext) {
val result = these.head; these = these.tail; result
- } else Iterator.empty.next
+ } else Iterator.empty.next()
/** Have to clear `these` so the iterator is exhausted like
* it would be without the optimization.
*/
override def toList: List[A] = {
val xs = these.toList
- these = newBuilder.result
+ these = newBuilder.result()
xs
}
}
diff --git a/src/library/scala/collection/LinearSeqOptimized.scala b/src/library/scala/collection/LinearSeqOptimized.scala
index 81cccea519..21bfedf5de 100755
--- a/src/library/scala/collection/LinearSeqOptimized.scala
+++ b/src/library/scala/collection/LinearSeqOptimized.scala
@@ -6,12 +6,11 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
-import generic._
import mutable.ListBuffer
import immutable.List
-import scala.util.control.Breaks._
import scala.annotation.tailrec
/** A template trait for linear sequences of type `LinearSeq[A]` which optimizes
@@ -84,7 +83,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
}
override /*SeqLike*/
- def contains(elem: Any): Boolean = {
+ def contains[A1 >: A](elem: A1): Boolean = {
var these = this
while (!these.isEmpty) {
if (these.head == elem) return true
@@ -152,7 +151,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
b += these.head
these = these.tail
}
- b.result
+ b.result()
}
override /*TraversableLike*/
@@ -187,7 +186,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
these = these.tail
lead = lead.tail
}
- b.result
+ b.result()
}
override /*IterableLike*/
@@ -195,7 +194,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
var these: Repr = repr
var count = from max 0
if (until <= count)
- return newBuilder.result
+ return newBuilder.result()
val b = newBuilder
var sliceElems = until - count
@@ -208,7 +207,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
b += these.head
these = these.tail
}
- b.result
+ b.result()
}
override /*IterableLike*/
@@ -219,7 +218,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
b += these.head
these = these.tail
}
- b.result
+ b.result()
}
override /*TraversableLike*/
@@ -230,7 +229,7 @@ trait LinearSeqOptimized[+A, +Repr <: LinearSeqOptimized[A, Repr]] extends Linea
b += these.head
these = these.tail
}
- (b.result, these)
+ (b.result(), these)
}
override /*IterableLike*/
diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala
index 18ad20a855..f37c0993d4 100644
--- a/src/library/scala/collection/Map.scala
+++ b/src/library/scala/collection/Map.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/MapLike.scala b/src/library/scala/collection/MapLike.scala
index 93d02a435c..5ec7d5c615 100644
--- a/src/library/scala/collection/MapLike.scala
+++ b/src/library/scala/collection/MapLike.scala
@@ -6,8 +6,8 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
import generic._
import mutable.{ Builder, MapBuilder }
@@ -181,7 +181,7 @@ self =>
def keysIterator: Iterator[A] = new AbstractIterator[A] {
val iter = self.iterator
def hasNext = iter.hasNext
- def next() = iter.next._1
+ def next() = iter.next()._1
}
/** Collects all keys of this map in an iterable collection.
@@ -213,7 +213,7 @@ self =>
def valuesIterator: Iterator[B] = new AbstractIterator[B] {
val iter = self.iterator
def hasNext = iter.hasNext
- def next() = iter.next._2
+ def next() = iter.next()._2
}
/** Defines the default value computation for the map,
diff --git a/src/library/scala/collection/MapProxy.scala b/src/library/scala/collection/MapProxy.scala
index e85d306e6f..941c1f5a4a 100644
--- a/src/library/scala/collection/MapProxy.scala
+++ b/src/library/scala/collection/MapProxy.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
/** This is a simple wrapper class for [[scala.collection.Map]].
* It is most useful for assembling customized map abstractions
diff --git a/src/library/scala/collection/MapProxyLike.scala b/src/library/scala/collection/MapProxyLike.scala
index 44b39f65da..44481131aa 100644
--- a/src/library/scala/collection/MapProxyLike.scala
+++ b/src/library/scala/collection/MapProxyLike.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-package scala.collection
-
-import generic._
+package scala
+package collection
// Methods could be printed by cat MapLike.scala | egrep '^ (override )?def'
diff --git a/src/library/scala/collection/Parallel.scala b/src/library/scala/collection/Parallel.scala
index 6731f74bea..174e3ab75e 100644
--- a/src/library/scala/collection/Parallel.scala
+++ b/src/library/scala/collection/Parallel.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
/** A marker trait for collections which have their operations parallelised.
*
diff --git a/src/library/scala/collection/Parallelizable.scala b/src/library/scala/collection/Parallelizable.scala
index d97c44abc0..b737752458 100644
--- a/src/library/scala/collection/Parallelizable.scala
+++ b/src/library/scala/collection/Parallelizable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import parallel.Combiner
@@ -39,7 +40,7 @@ trait Parallelizable[+A, +ParRepr <: Parallel] extends Any {
def par: ParRepr = {
val cb = parCombiner
for (x <- seq) cb += x
- cb.result
+ cb.result()
}
/** The default `par` implementation uses the combiner provided by this method
diff --git a/src/library/scala/collection/Searching.scala b/src/library/scala/collection/Searching.scala
new file mode 100644
index 0000000000..fec4bbf502
--- /dev/null
+++ b/src/library/scala/collection/Searching.scala
@@ -0,0 +1,118 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala
+package collection
+
+import scala.language.implicitConversions
+import scala.annotation.tailrec
+import scala.collection.generic.IsSeqLike
+import scala.math.Ordering
+
+/** A collection of wrappers that provide sequence classes with search functionality.
+ *
+ * Example usage:
+ * {{{
+ * import scala.collection.Searching._
+ * val l = List(1, 2, 3, 4, 5)
+ * l.search(3)
+ * // == Found(2)
+ * }}}
+ */
+object Searching {
+ sealed abstract class SearchResult {
+ def insertionPoint: Int
+ }
+
+ case class Found(foundIndex: Int) extends SearchResult {
+ override def insertionPoint = foundIndex
+ }
+ case class InsertionPoint(insertionPoint: Int) extends SearchResult
+
+ class SearchImpl[A, Repr](val coll: SeqLike[A, Repr]) {
+ /** Search the sorted sequence for a specific element. If the sequence is an
+ * `IndexedSeq`, a binary search is used. Otherwise, a linear search is used.
+ *
+ * The sequence should be sorted with the same `Ordering` before calling; otherwise,
+ * the results are undefined.
+ *
+ * @see [[scala.collection.IndexedSeq]]
+ * @see [[scala.math.Ordering]]
+ * @see [[scala.collection.SeqLike]], method `sorted`
+ *
+ * @param elem the element to find.
+ * @param ord the ordering to be used to compare elements.
+ *
+ * @return a `Found` value containing the index corresponding to the element in the
+ * sequence, or the `InsertionPoint` where the element would be inserted if
+ * the element is not in the sequence.
+ */
+ final def search[B >: A](elem: B)(implicit ord: Ordering[B]): SearchResult =
+ coll match {
+ case _: IndexedSeq[A] => binarySearch(elem, -1, coll.length)(ord)
+ case _ => linearSearch(coll.view, elem, 0)(ord)
+ }
+
+ /** Search within an interval in the sorted sequence for a specific element. If the
+ * sequence is an IndexedSeq, a binary search is used. Otherwise, a linear search
+ * is used.
+ *
+ * The sequence should be sorted with the same `Ordering` before calling; otherwise,
+ * the results are undefined.
+ *
+ * @see [[scala.collection.IndexedSeq]]
+ * @see [[scala.math.Ordering]]
+ * @see [[scala.collection.SeqLike]], method `sorted`
+ *
+ * @param elem the element to find.
+ * @param from the index where the search starts.
+ * @param to the index following where the search ends.
+ * @param ord the ordering to be used to compare elements.
+ *
+ * @return a `Found` value containing the index corresponding to the element in the
+ * sequence, or the `InsertionPoint` where the element would be inserted if
+ * the element is not in the sequence.
+ */
+ final def search[B >: A](elem: B, from: Int, to: Int)
+ (implicit ord: Ordering[B]): SearchResult =
+ coll match {
+ case _: IndexedSeq[A] => binarySearch(elem, from-1, to)(ord)
+ case _ => linearSearch(coll.view(from, to), elem, from)(ord)
+ }
+
+ @tailrec
+ private def binarySearch[B >: A](elem: B, from: Int, to: Int)
+ (implicit ord: Ordering[B]): SearchResult = {
+ if ((to-from) == 1) InsertionPoint(from) else {
+ val idx = from+(to-from)/2
+ math.signum(ord.compare(elem, coll(idx))) match {
+ case -1 => binarySearch(elem, from, idx)(ord)
+ case 1 => binarySearch(elem, idx, to)(ord)
+ case _ => Found(idx)
+ }
+ }
+ }
+
+ private def linearSearch[B >: A](c: SeqView[A, Repr], elem: B, offset: Int)
+ (implicit ord: Ordering[B]): SearchResult = {
+ var idx = offset
+ val it = c.iterator
+ while (it.hasNext) {
+ val cur = it.next()
+ if (ord.equiv(elem, cur)) return Found(idx)
+ else if (ord.lt(elem, cur)) return InsertionPoint(idx-1)
+ idx += 1
+ }
+ InsertionPoint(idx)
+ }
+
+ }
+
+ implicit def search[Repr, A](coll: Repr)
+ (implicit fr: IsSeqLike[Repr]): SearchImpl[fr.A, Repr] = new SearchImpl(fr.conversion(coll))
+}
diff --git a/src/library/scala/collection/Seq.scala b/src/library/scala/collection/Seq.scala
index 33e66c0874..b21acdd9b7 100644
--- a/src/library/scala/collection/Seq.scala
+++ b/src/library/scala/collection/Seq.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import mutable.Builder
diff --git a/src/library/scala/collection/SeqExtractors.scala b/src/library/scala/collection/SeqExtractors.scala
index 20ea7f54b7..2398313c77 100644
--- a/src/library/scala/collection/SeqExtractors.scala
+++ b/src/library/scala/collection/SeqExtractors.scala
@@ -1,4 +1,5 @@
-package scala.collection
+package scala
+package collection
/** An extractor used to head/tail deconstruct sequences. */
object +: {
diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala
index 1be0dba29f..c02ea98914 100644
--- a/src/library/scala/collection/SeqLike.scala
+++ b/src/library/scala/collection/SeqLike.scala
@@ -107,7 +107,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
def segmentLength(p: A => Boolean, from: Int): Int = {
var i = 0
- var it = iterator.drop(from)
+ val it = iterator.drop(from)
while (it.hasNext && p(it.next()))
i += 1
i
@@ -115,7 +115,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
def indexWhere(p: A => Boolean, from: Int): Int = {
var i = from
- var it = iterator.drop(from)
+ val it = iterator.drop(from)
while (it.hasNext) {
if (p(it.next())) return i
else i += 1
@@ -127,7 +127,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
def lastIndexWhere(p: A => Boolean, end: Int): Int = {
var i = length - 1
val it = reverseIterator
- while (it.hasNext && { val elem = it.next; (i > end || !p(elem)) }) i -= 1
+ while (it.hasNext && { val elem = it.next(); (i > end || !p(elem)) }) i -= 1
i
}
@@ -156,10 +156,10 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
def hasNext = _hasNext
def next(): Repr = {
if (!hasNext)
- Iterator.empty.next
+ Iterator.empty.next()
val forcedElms = new mutable.ArrayBuffer[A](elms.size) ++= elms
- val result = (self.newBuilder ++= forcedElms).result
+ val result = (self.newBuilder ++= forcedElms).result()
var i = idxs.length - 2
while(i >= 0 && idxs(i) >= idxs(i+1))
i -= 1
@@ -181,10 +181,10 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
result
}
private def swap(i: Int, j: Int) {
- var tmpI = idxs(i)
+ val tmpI = idxs(i)
idxs(i) = idxs(j)
idxs(j) = tmpI
- var tmpE = elms(i)
+ val tmpE = elms(i)
elms(i) = elms(j)
elms(j) = tmpE
}
@@ -208,15 +208,15 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
def hasNext = _hasNext
def next(): Repr = {
if (!hasNext)
- Iterator.empty.next
+ Iterator.empty.next()
- /** Calculate this result. */
+ /* Calculate this result. */
val buf = self.newBuilder
for(k <- 0 until nums.length; j <- 0 until nums(k))
buf += elms(offs(k)+j)
- val res = buf.result
+ val res = buf.result()
- /** Prepare for the next call to next. */
+ /* Prepare for the next call to next. */
var idx = nums.length - 1
while (idx >= 0 && nums(idx) == cnts(idx))
idx -= 1
@@ -268,7 +268,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
b.sizeHint(this)
for (x <- xs)
b += x
- b.result
+ b.result()
}
def reverseMap[B, That](f: A => B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
@@ -279,7 +279,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
for (x <- xs)
b += f(x)
- b.result
+ b.result()
}
/** An iterator yielding elements in reversed order.
@@ -335,7 +335,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
if (from > l) -1
else if (tl < 1) clippedFrom
else if (l < tl) -1
- else SeqLike.kmpSearch(thisCollection, clippedFrom, l, that.seq, 0, tl, true)
+ else SeqLike.kmpSearch(thisCollection, clippedFrom, l, that.seq, 0, tl, forward = true)
}
else {
var i = from
@@ -372,7 +372,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
if (end < 0) -1
else if (tl < 1) clippedL
else if (l < tl) -1
- else SeqLike.kmpSearch(thisCollection, 0, clippedL+tl, that.seq, 0, tl, false)
+ else SeqLike.kmpSearch(thisCollection, 0, clippedL+tl, that.seq, 0, tl, forward = false)
}
/** Tests whether this $coll contains a given sequence as a slice.
@@ -390,7 +390,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
* @return `true` if this $coll has an element that is equal (as
* determined by `==`) to `elem`, `false` otherwise.
*/
- def contains(elem: Any): Boolean = exists (_ == elem)
+ def contains[A1 >: A](elem: A1): Boolean = exists (_ == elem)
/** Produces a new sequence which contains all elements of this $coll and also all elements of
* a given sequence. `xs union ys` is equivalent to `xs ++ ys`.
@@ -442,7 +442,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
for (x <- this)
if (occ(x) == 0) b += x
else occ(x) -= 1
- b.result
+ b.result()
}
/** Computes the multiset intersection between this $coll and another sequence.
@@ -473,7 +473,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
b += x
occ(x) -= 1
}
- b.result
+ b.result()
}
private def occCounts[B](sq: Seq[B]): mutable.Map[B, Int] = {
@@ -496,7 +496,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
seen += x
}
}
- b.result
+ b.result()
}
def patch[B >: A, That](from: Int, patch: GenSeq[B], replaced: Int)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
@@ -505,7 +505,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
b ++= toCollection(prefix)
b ++= patch.seq
b ++= toCollection(rest).view drop replaced
- b.result
+ b.result()
}
def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
@@ -514,21 +514,21 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
b ++= toCollection(prefix)
b += elem
b ++= toCollection(rest).view.tail
- b.result
+ b.result()
}
def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
b += elem
b ++= thisCollection
- b.result
+ b.result()
}
def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
b ++= thisCollection
b += elem
- b.result
+ b.result()
}
def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
@@ -540,14 +540,14 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
b += elem
diff -= 1
}
- b.result
+ b.result()
}
def corresponds[B](that: GenSeq[B])(p: (A,B) => Boolean): Boolean = {
val i = this.iterator
val j = that.iterator
while (i.hasNext && j.hasNext)
- if (!p(i.next, j.next))
+ if (!p(i.next(), j.next()))
return false
!i.hasNext && !j.hasNext
@@ -616,7 +616,7 @@ trait SeqLike[+A, +Repr] extends Any with IterableLike[A, Repr] with GenSeqLike[
val b = newBuilder
b.sizeHint(len)
for (x <- arr) b += x
- b.result
+ b.result()
}
/** Converts this $coll to a sequence.
@@ -682,7 +682,7 @@ object SeqLike {
val wit = W.iterator.drop(n0)
var i = if (forward) 0 else (n1-n0-1)
while (i != done) {
- Warr(i) = wit.next.asInstanceOf[AnyRef]
+ Warr(i) = wit.next().asInstanceOf[AnyRef]
i += delta
}
@@ -778,15 +778,15 @@ object SeqLike {
case _ =>
// We had better not index into S directly!
val iter = S.iterator.drop(m0)
- val Wopt = kmpOptimizeWord(W, n0, n1, true)
+ val Wopt = kmpOptimizeWord(W, n0, n1, forward = true)
val T = kmpJumpTable(Wopt, n1-n0)
- var cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind
+ val cache = new Array[AnyRef](n1-n0) // Ring buffer--need a quick way to do a look-behind
var largest = 0
var i, m = 0
var answer = -1
while (m+m0+n1-n0 <= m1) {
while (i+m >= largest) {
- cache(largest%(n1-n0)) = iter.next.asInstanceOf[AnyRef]
+ cache(largest%(n1-n0)) = iter.next().asInstanceOf[AnyRef]
largest += 1
}
if (Wopt(i) == cache((i+m)%(n1-n0))) {
@@ -851,7 +851,7 @@ object SeqLike {
else if (s1 - s0 < t1 - t0) -1 // Source is too short to find target
else {
// Nontrivial search
- val ans = kmpSearch(source, s0, s1, target, t0, t1, true)
+ val ans = kmpSearch(source, s0, s1, target, t0, t1, forward = true)
if (ans < 0) ans else ans - math.min(slen, sourceOffset)
}
}
@@ -883,7 +883,7 @@ object SeqLike {
else if (fixed_s1 - s0 < t1 - t0) -1 // Source is too short to find target
else {
// Nontrivial search
- val ans = kmpSearch(source, s0, fixed_s1, target, t0, t1, false)
+ val ans = kmpSearch(source, s0, fixed_s1, target, t0, t1, forward = false)
if (ans < 0) ans else ans - s0
}
}
diff --git a/src/library/scala/collection/SeqProxy.scala b/src/library/scala/collection/SeqProxy.scala
index 1f8dc4aad1..9c5424a3a6 100644
--- a/src/library/scala/collection/SeqProxy.scala
+++ b/src/library/scala/collection/SeqProxy.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
/** This trait implements a proxy for sequence objects. It forwards
* all calls to a different sequence object.
diff --git a/src/library/scala/collection/SeqProxyLike.scala b/src/library/scala/collection/SeqProxyLike.scala
index 5e8030d1e4..161b23d3f8 100644
--- a/src/library/scala/collection/SeqProxyLike.scala
+++ b/src/library/scala/collection/SeqProxyLike.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
@@ -50,7 +51,7 @@ trait SeqProxyLike[+A, +Repr <: SeqLike[A, Repr] with Seq[A]] extends SeqLike[A,
override def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int = self.lastIndexOfSlice(that)
override def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int = self.lastIndexOfSlice(that, end)
override def containsSlice[B](that: GenSeq[B]): Boolean = self.indexOfSlice(that) != -1
- override def contains(elem: Any): Boolean = self.contains(elem)
+ override def contains[A1 >: A](elem: A1): Boolean = self.contains(elem)
override def union[B >: A, That](that: GenSeq[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = self.union(that)(bf)
override def diff[B >: A](that: GenSeq[B]): Repr = self.diff(that)
override def intersect[B >: A](that: GenSeq[B]): Repr = self.intersect(that)
diff --git a/src/library/scala/collection/SeqView.scala b/src/library/scala/collection/SeqView.scala
index c26124cf6f..40dfd50212 100644
--- a/src/library/scala/collection/SeqView.scala
+++ b/src/library/scala/collection/SeqView.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
import TraversableView.NoBuilder
diff --git a/src/library/scala/collection/SeqViewLike.scala b/src/library/scala/collection/SeqViewLike.scala
index 5f2bf902b1..1194cd7199 100644
--- a/src/library/scala/collection/SeqViewLike.scala
+++ b/src/library/scala/collection/SeqViewLike.scala
@@ -6,11 +6,11 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import Seq.fill
-import TraversableView.NoBuilder
/** A template trait for non-strict views of sequences.
* $seqViewInfo
diff --git a/src/library/scala/collection/Sequentializable.scala.disabled b/src/library/scala/collection/Sequentializable.scala.disabled
deleted file mode 100644
index df457671a6..0000000000
--- a/src/library/scala/collection/Sequentializable.scala.disabled
+++ /dev/null
@@ -1,10 +0,0 @@
-package scala.collection
-
-
-
-
-trait Sequentializable[+T, +Repr] {
-
- def seq: Repr
-
-}
diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala
index c304323d28..46d5dfa056 100644
--- a/src/library/scala/collection/Set.scala
+++ b/src/library/scala/collection/Set.scala
@@ -6,8 +6,8 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
import generic._
diff --git a/src/library/scala/collection/SetLike.scala b/src/library/scala/collection/SetLike.scala
index a6ebcc0e20..0c5c7e0b29 100644
--- a/src/library/scala/collection/SetLike.scala
+++ b/src/library/scala/collection/SetLike.scala
@@ -6,8 +6,8 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
import generic._
import mutable.{ Builder, SetBuilder }
@@ -180,14 +180,14 @@ self =>
def hasNext = len <= elms.size || itr.hasNext
def next = {
if (!itr.hasNext) {
- if (len > elms.size) Iterator.empty.next
+ if (len > elms.size) Iterator.empty.next()
else {
itr = new SubsetsItr(elms, len)
len += 1
}
}
- itr.next
+ itr.next()
}
}
@@ -205,11 +205,11 @@ self =>
def hasNext = _hasNext
def next(): This = {
- if (!hasNext) Iterator.empty.next
+ if (!hasNext) Iterator.empty.next()
val buf = self.newBuilder
idxs.slice(0, len) foreach (idx => buf += elms(idx))
- val result = buf.result
+ val result = buf.result()
var i = len - 1
while (i >= 0 && idxs(i) == idxs(i+1)-1) i -= 1
diff --git a/src/library/scala/collection/SetProxy.scala b/src/library/scala/collection/SetProxy.scala
index 08075a7121..f9f38f148a 100644
--- a/src/library/scala/collection/SetProxy.scala
+++ b/src/library/scala/collection/SetProxy.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
/** This is a simple wrapper class for [[scala.collection.Set]].
* It is most useful for assembling customized set abstractions
diff --git a/src/library/scala/collection/SetProxyLike.scala b/src/library/scala/collection/SetProxyLike.scala
index 5196f39917..ac3d34dbab 100644
--- a/src/library/scala/collection/SetProxyLike.scala
+++ b/src/library/scala/collection/SetProxyLike.scala
@@ -6,10 +6,8 @@
** |/ **
\* */
-
-package scala.collection
-
-import generic._
+package scala
+package collection
// Methods could be printed by cat SetLike.scala | egrep '^ (override )?def'
diff --git a/src/library/scala/collection/SortedMap.scala b/src/library/scala/collection/SortedMap.scala
index c81c16e8bb..0705a1e9e0 100644
--- a/src/library/scala/collection/SortedMap.scala
+++ b/src/library/scala/collection/SortedMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import mutable.Builder
@@ -40,13 +41,13 @@ object SortedMap extends SortedMapFactory[SortedMap] {
val b = SortedMap.newBuilder[A, B1]
b ++= this
b += ((kv._1, kv._2))
- b.result
+ b.result()
}
override def - (key: A): SortedMap[A, B] = {
val b = newBuilder
for (kv <- this; if kv._1 != key) b += kv
- b.result
+ b.result()
}
}
diff --git a/src/library/scala/collection/SortedMapLike.scala b/src/library/scala/collection/SortedMapLike.scala
index 57ad3497c7..3fc8b0dadc 100644
--- a/src/library/scala/collection/SortedMapLike.scala
+++ b/src/library/scala/collection/SortedMapLike.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
@@ -42,6 +43,7 @@ self =>
val map = self.rangeImpl(from, until)
new map.DefaultKeySortedSet
}
+ override def keysIteratorFrom(start: A) = self.keysIteratorFrom(start)
}
/** Add a key/value pair to this map.
@@ -68,7 +70,7 @@ self =>
* @param elems the remaining elements to add.
*/
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): SortedMap[A, B1] = {
- var m = this + elem1 + elem2;
+ var m = this + elem1 + elem2
for (e <- elems) m = m + e
m
}
@@ -76,11 +78,17 @@ self =>
override def filterKeys(p: A => Boolean): SortedMap[A, B] = new FilteredKeys(p) with SortedMap.Default[A, B] {
implicit def ordering: Ordering[A] = self.ordering
override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, B] = self.rangeImpl(from, until).filterKeys(p)
+ override def iteratorFrom(start: A) = self iteratorFrom start filter {case (k, _) => p(k)}
+ override def keysIteratorFrom(start: A) = self keysIteratorFrom start filter p
+ override def valuesIteratorFrom(start: A) = self iteratorFrom start collect {case (k,v) if p(k) => v}
}
override def mapValues[C](f: B => C): SortedMap[A, C] = new MappedValues(f) with SortedMap.Default[A, C] {
implicit def ordering: Ordering[A] = self.ordering
override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, C] = self.rangeImpl(from, until).mapValues(f)
+ override def iteratorFrom(start: A) = (self iteratorFrom start) map {case (k,v) => (k, f(v))}
+ override def keysIteratorFrom(start: A) = self keysIteratorFrom start
+ override def valuesIteratorFrom(start: A) = self valuesIteratorFrom start map f
}
/** Adds a number of elements provided by a traversable object
@@ -91,6 +99,28 @@ self =>
override def ++[B1 >: B](xs: GenTraversableOnce[(A, B1)]): SortedMap[A, B1] =
((repr: SortedMap[A, B1]) /: xs.seq) (_ + _)
+ /**
+ * Creates an iterator over all the key/value pairs
+ * contained in this map having a key greater than or
+ * equal to `start` according to the ordering of
+ * this map. x.iteratorFrom(y) is equivalent
+ * to but often more efficient than x.from(y).iterator.
+ *
+ * @param start The lower bound (inclusive)
+ * on the keys to be returned
+ */
+ def iteratorFrom(start: A): Iterator[(A, B)]
+ /**
+ * Creates an iterator over all the values contained in this
+ * map that are associated with a key greater than or equal to `start`
+ * according to the ordering of this map. x.valuesIteratorFrom(y) is
+ * equivalent to but often more efficient than
+ * x.from(y).valuesIterator.
+ *
+ * @param start The lower bound (inclusive)
+ * on the keys to be returned
+ */
+ def valuesIteratorFrom(start: A): Iterator[B]
}
diff --git a/src/library/scala/collection/SortedSet.scala b/src/library/scala/collection/SortedSet.scala
index 2d5d4fb55e..43189d2e8c 100644
--- a/src/library/scala/collection/SortedSet.scala
+++ b/src/library/scala/collection/SortedSet.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
import generic._
/** A sorted set.
diff --git a/src/library/scala/collection/SortedSetLike.scala b/src/library/scala/collection/SortedSetLike.scala
index 71b45c72ff..eb2ac38c59 100644
--- a/src/library/scala/collection/SortedSetLike.scala
+++ b/src/library/scala/collection/SortedSetLike.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
import generic._
/** A template for sets which are sorted.
@@ -40,4 +41,14 @@ self =>
case that: SortedSet[_] if that.ordering == ordering => that.hasAll(this.iterator)
case that => super.subsetOf(that)
}
+
+ /**
+ * Creates an iterator that contains all values from this collection
+ * greater than or equal to `start` according to the ordering of
+ * this collection. x.iteratorFrom(y) is equivalent to but will usually
+ * be more efficient than x.from(y).iterator
+ *
+ * @param start The lower-bound (inclusive) of the iterator
+ */
+ def iteratorFrom(start: A): Iterator[A] = keysIteratorFrom(start)
}
diff --git a/src/library/scala/collection/Traversable.scala b/src/library/scala/collection/Traversable.scala
index 36ef230a42..61d9a42f04 100644
--- a/src/library/scala/collection/Traversable.scala
+++ b/src/library/scala/collection/Traversable.scala
@@ -6,12 +6,11 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
import generic._
-import mutable.{Builder, Buffer, ArrayBuffer, ListBuffer}
+import mutable.Builder
import scala.util.control.Breaks
/** A trait for traversable collections.
diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala
index 5f193eb211..00f4de82cd 100644
--- a/src/library/scala/collection/TraversableLike.scala
+++ b/src/library/scala/collection/TraversableLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import mutable.{ Builder }
@@ -77,7 +78,7 @@ trait TraversableLike[+A, +Repr] extends Any
import Traversable.breaks._
/** The type implementing this traversable */
- protected type Self = Repr
+ protected[this] type Self = Repr
/** The collection of type $coll underlying this `TraversableLike` object.
* By default this is implemented as the `TraversableLike` object itself,
@@ -86,7 +87,7 @@ trait TraversableLike[+A, +Repr] extends Any
def repr: Repr = this.asInstanceOf[Repr]
final def isTraversableAgain: Boolean = true
-
+
/** The underlying collection seen as an instance of `$Coll`.
* By default this is implemented as the current collection object itself,
* but this can be overridden.
@@ -174,7 +175,7 @@ trait TraversableLike[+A, +Repr] extends Any
*
* @usecase def ++:[B](that: TraversableOnce[B]): $Coll[B]
* @inheritdoc
- *
+ *
* Example:
* {{{
* scala> val x = List(1)
@@ -252,18 +253,21 @@ trait TraversableLike[+A, +Repr] extends Any
b.result
}
+ private def filterImpl(p: A => Boolean, isFlipped: Boolean): Repr = {
+ val b = newBuilder
+ for (x <- this)
+ if (p(x) != isFlipped) b += x
+
+ b.result
+ }
+
/** Selects all elements of this $coll which satisfy a predicate.
*
* @param p the predicate used to test elements.
* @return a new $coll consisting of all elements of this $coll that satisfy the given
* predicate `p`. The order of the elements is preserved.
*/
- def filter(p: A => Boolean): Repr = {
- val b = newBuilder
- for (x <- this)
- if (p(x)) b += x
- b.result
- }
+ def filter(p: A => Boolean): Repr = filterImpl(p, isFlipped = false)
/** Selects all elements of this $coll which do not satisfy a predicate.
*
@@ -271,11 +275,11 @@ trait TraversableLike[+A, +Repr] extends Any
* @return a new $coll consisting of all elements of this $coll that do not satisfy the given
* predicate `p`. The order of the elements is preserved.
*/
- def filterNot(p: A => Boolean): Repr = filter(!p(_))
+ def filterNot(p: A => Boolean): Repr = filterImpl(p, isFlipped = true)
def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That = {
val b = bf(repr)
- for (x <- this) if (pf.isDefinedAt(x)) b += pf(x)
+ foreach(pf.runWith(b += _))
b.result
}
diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala
index a448ac2c09..526c36dda7 100644
--- a/src/library/scala/collection/TraversableOnce.scala
+++ b/src/library/scala/collection/TraversableOnce.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import mutable.{ Buffer, Builder, ListBuffer, ArrayBuffer }
import generic.CanBuildFrom
@@ -128,10 +129,8 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
* @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))
- }
+ // make sure to use an iterator or `seq`
+ self.toIterator.foreach(pf.runWith(b => return Some(b)))
None
}
@@ -198,7 +197,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
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 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)
@@ -271,7 +270,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, A, Col[A @uV]]): Col[A @uV] = {
val b = cbf()
b ++= seq
- b.result
+ b.result()
}
def toMap[T, U](implicit ev: A <:< (T, U)): immutable.Map[T, U] = {
@@ -279,7 +278,7 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
for (x <- self)
b += x
- b.result
+ b.result()
}
def mkString(start: String, sep: String, end: String): String =
@@ -380,27 +379,22 @@ trait TraversableOnce[+A] extends Any with GenTraversableOnce[A] {
object TraversableOnce {
- @deprecated("use OnceCanBuildFrom instead", "2.10.0")
- def traversableOnceCanBuildFrom[T] = new OnceCanBuildFrom[T]
- @deprecated("use MonadOps instead", "2.10.0")
- def wrapTraversableOnce[A](trav: TraversableOnce[A]) = new MonadOps(trav)
-
implicit def alternateImplicit[A](trav: TraversableOnce[A]) = new ForceImplicitAmbiguity
implicit def flattenTraversableOnce[A, CC[_]](travs: TraversableOnce[CC[A]])(implicit ev: CC[A] => TraversableOnce[A]) =
new FlattenOps[A](travs map ev)
/* Functionality reused in Iterator.CanBuildFrom */
- private[collection] abstract class BufferedCanBuildFrom[A, Coll[X] <: TraversableOnce[X]] extends generic.CanBuildFrom[Coll[_], A, Coll[A]] {
- def bufferToColl[B](buff: ArrayBuffer[B]): Coll[B]
- def traversableToColl[B](t: GenTraversable[B]): Coll[B]
+ private[collection] abstract class BufferedCanBuildFrom[A, CC[X] <: TraversableOnce[X]] extends generic.CanBuildFrom[CC[_], A, CC[A]] {
+ def bufferToColl[B](buff: ArrayBuffer[B]): CC[B]
+ def traversableToColl[B](t: GenTraversable[B]): CC[B]
- def newIterator: Builder[A, Coll[A]] = new ArrayBuffer[A] mapResult bufferToColl
+ def newIterator: Builder[A, CC[A]] = new ArrayBuffer[A] mapResult bufferToColl
/** Creates a new builder on request of a collection.
* @param from the collection requesting the builder to be created.
* @return the result of invoking the `genericBuilder` method on `from`.
*/
- def apply(from: Coll[_]): Builder[A, Coll[A]] = from match {
+ def apply(from: CC[_]): Builder[A, CC[A]] = from match {
case xs: generic.GenericTraversableTemplate[_, _] => xs.genericBuilder.asInstanceOf[Builder[A, Traversable[A]]] mapResult {
case res => traversableToColl(res.asInstanceOf[GenTraversable[A]])
}
@@ -429,7 +423,7 @@ object TraversableOnce {
def flatten: Iterator[A] = new AbstractIterator[A] {
val its = travs.toIterator
private var it: Iterator[A] = Iterator.empty
- def hasNext: Boolean = it.hasNext || its.hasNext && { it = its.next.toIterator; hasNext }
+ def hasNext: Boolean = it.hasNext || its.hasNext && { it = its.next().toIterator; hasNext }
def next(): A = if (hasNext) it.next() else Iterator.empty.next()
}
}
diff --git a/src/library/scala/collection/TraversableProxy.scala b/src/library/scala/collection/TraversableProxy.scala
index 568298a9d9..65936da0e4 100644
--- a/src/library/scala/collection/TraversableProxy.scala
+++ b/src/library/scala/collection/TraversableProxy.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
// Methods could be printed by cat TraversableLike.scala | egrep '^ (override )?def'
diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala
index 8896cd1b0f..77d651c5f2 100644
--- a/src/library/scala/collection/TraversableProxyLike.scala
+++ b/src/library/scala/collection/TraversableProxyLike.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
import generic._
import mutable.{Buffer, StringBuilder}
diff --git a/src/library/scala/collection/TraversableView.scala b/src/library/scala/collection/TraversableView.scala
index cce6b72257..bbb5bde464 100644
--- a/src/library/scala/collection/TraversableView.scala
+++ b/src/library/scala/collection/TraversableView.scala
@@ -6,11 +6,11 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import mutable.Builder
-import TraversableView.NoBuilder
/** A base trait for non-strict views of traversable collections.
* $traversableViewInfo
diff --git a/src/library/scala/collection/TraversableViewLike.scala b/src/library/scala/collection/TraversableViewLike.scala
index 14f865c2f0..c507e000ee 100644
--- a/src/library/scala/collection/TraversableViewLike.scala
+++ b/src/library/scala/collection/TraversableViewLike.scala
@@ -6,11 +6,11 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
import generic._
import mutable.{ Builder, ArrayBuffer }
-import TraversableView.NoBuilder
import scala.annotation.migration
import scala.language.implicitConversions
@@ -59,7 +59,7 @@ trait ViewMkString[+A] {
* $viewInfo
*
* All views for traversable collections are defined by creating a new `foreach` method.
- *
+ *
* @author Martin Odersky
* @version 2.8
* @since 2.8
@@ -162,7 +162,7 @@ trait TraversableViewLike[+A,
// if (b.isInstanceOf[NoBuilder[_]]) newFlatMapped(f).asInstanceOf[That]
// else super.flatMap[B, That](f)(bf)
}
- override def flatten[B](implicit asTraversable: A => /*<:<!!!*/ GenTraversableOnce[B]) =
+ override def flatten[B](implicit asTraversable: A => /*<:<!!!*/ GenTraversableOnce[B]) =
newFlatMapped(asTraversable)
private[this] implicit def asThis(xs: Transformed[A]): This = xs.asInstanceOf[This]
diff --git a/src/library/scala/collection/concurrent/Map.scala b/src/library/scala/collection/concurrent/Map.scala
index b2276ce5aa..02e5dd01f5 100644
--- a/src/library/scala/collection/concurrent/Map.scala
+++ b/src/library/scala/collection/concurrent/Map.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.concurrent
+package scala
+package collection.concurrent
/** A template trait for mutable maps that allow concurrent access.
*
diff --git a/src/library/scala/collection/concurrent/TrieMap.scala b/src/library/scala/collection/concurrent/TrieMap.scala
index 6c11c5bcb5..0b5ceeb1c7 100644
--- a/src/library/scala/collection/concurrent/TrieMap.scala
+++ b/src/library/scala/collection/concurrent/TrieMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package concurrent
import java.util.concurrent.atomic._
@@ -41,7 +42,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
@tailrec private def GCAS_Complete(m: MainNode[K, V], ct: TrieMap[K, V]): MainNode[K, V] = if (m eq null) null else {
// complete the GCAS
val prev = /*READ*/m.prev
- val ctr = ct.readRoot(true)
+ val ctr = ct.readRoot(abort = true)
prev match {
case null =>
@@ -250,7 +251,7 @@ private[collection] final class INode[K, V](bn: MainNode[K, V], g: Gen) extends
if (ct.isReadOnly || (startgen eq in.gen)) in.rec_lookup(k, hc, lev + 5, this, startgen, ct)
else {
if (GCAS(cn, cn.renewed(startgen, ct), ct)) rec_lookup(k, hc, lev, parent, startgen, ct)
- else return RESTART // used to be throw RestartException
+ else RESTART // used to be throw RestartException
}
case sn: SNode[K, V] => // 2) singleton node
if (sn.hc == hc && equal(sn.k, k, ct)) sn.v.asInstanceOf[AnyRef]
@@ -428,16 +429,16 @@ extends MainNode[K, V] with KVNode[K, V] {
}
-private[collection] final class LNode[K, V](final val listmap: ImmutableListMap[K, V])
+private[collection] final class LNode[K, V](final val listmap: immutable.ListMap[K, V])
extends MainNode[K, V] {
- def this(k: K, v: V) = this(ImmutableListMap(k -> v))
- def this(k1: K, v1: V, k2: K, v2: V) = this(ImmutableListMap(k1 -> v1, k2 -> v2))
+ def this(k: K, v: V) = this(immutable.ListMap(k -> v))
+ def this(k1: K, v1: V, k2: K, v2: V) = this(immutable.ListMap(k1 -> v1, k2 -> v2))
def inserted(k: K, v: V) = new LNode(listmap + ((k, v)))
def removed(k: K, ct: TrieMap[K, V]): MainNode[K, V] = {
val updmap = listmap - k
if (updmap.size > 1) new LNode(updmap)
else {
- val (k, v) = updmap.iterator.next
+ val (k, v) = updmap.iterator.next()
new TNode(k, v, ct.computeHash(k)) // create it tombed so that it gets compressed on subsequent accesses
}
}
@@ -545,7 +546,7 @@ private[collection] final class CNode[K, V](val bitmap: Int, val array: Array[Ba
// removed (those existing when the op began)
// - if there are only null-i-nodes below, returns null
def toCompressed(ct: TrieMap[K, V], lev: Int, gen: Gen) = {
- var bmp = bitmap
+ val bmp = bitmap
var i = 0
val arr = array
val tmparray = new Array[BasicNode](arr.length)
@@ -723,7 +724,7 @@ extends scala.collection.concurrent.Map[K, V]
private def RDCSS_ROOT(ov: INode[K, V], expectedmain: MainNode[K, V], nv: INode[K, V]): Boolean = {
val desc = RDCSS_Descriptor(ov, expectedmain, nv)
if (CAS_ROOT(ov, desc)) {
- RDCSS_Complete(false)
+ RDCSS_Complete(abort = false)
/*READ*/desc.committed
} else false
}
@@ -920,8 +921,8 @@ object TrieMap extends MutableMapFactory[TrieMap] {
private[collection] class TrieMapIterator[K, V](var level: Int, private var ct: TrieMap[K, V], mustInit: Boolean = true) extends Iterator[(K, V)] {
- private var stack = new Array[Array[BasicNode]](7)
- private var stackpos = new Array[Int](7)
+ private val stack = new Array[Array[BasicNode]](7)
+ private val stackpos = new Array[Int](7)
private var depth = -1
private var subiter: Iterator[(K, V)] = null
private var current: KVNode[K, V] = null
@@ -1027,7 +1028,7 @@ private[collection] class TrieMapIterator[K, V](var level: Int, private var ct:
val (arr1, arr2) = stack(d).drop(stackpos(d) + 1).splitAt(rem / 2)
stack(d) = arr1
stackpos(d) = -1
- val it = newIterator(level + 1, ct, false)
+ val it = newIterator(level + 1, ct, _mustInit = false)
it.stack(0) = arr2
it.stackpos(0) = -1
it.depth = 0
diff --git a/src/library/scala/collection/convert/DecorateAsJava.scala b/src/library/scala/collection/convert/DecorateAsJava.scala
index 87bcae3923..498bdc5943 100644
--- a/src/library/scala/collection/convert/DecorateAsJava.scala
+++ b/src/library/scala/collection/convert/DecorateAsJava.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package convert
import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
@@ -25,7 +26,7 @@ import scala.language.implicitConversions
* - `scala.collection.mutable.Buffer` <=> `java.util.List`
* - `scala.collection.mutable.Set` <=> `java.util.Set`
* - `scala.collection.mutable.Map` <=> `java.util.Map`
- * - `scala.collection.mutable.ConcurrentMap` <=> `java.util.concurrent.ConcurrentMap`
+ * - `scala.collection.mutable.concurrent.Map` <=> `java.util.concurrent.ConcurrentMap`
*
* In all cases, converting from a source type to a target type and back
* again will return the original source object, e.g.
@@ -279,26 +280,6 @@ trait DecorateAsJava {
/**
* Adds an `asJava` method that implicitly converts a Scala mutable
- * `ConcurrentMap` to a Java `ConcurrentMap`.
- *
- * The returned Java `ConcurrentMap` is backed by the provided Scala
- * `ConcurrentMap` and any side-effects of using it via the Java interface
- * will be visible via the Scala interface and vice versa.
- *
- * If the Scala `ConcurrentMap` was previously obtained from an implicit or
- * explicit call of `asConcurrentMap(java.util.concurrect.ConcurrentMap)`
- * then the original Java `ConcurrentMap` will be returned.
- *
- * @param m The `ConcurrentMap` to be converted.
- * @return An object with an `asJava` method that returns a Java
- * `ConcurrentMap` view of the argument.
- */
- @deprecated("Use `concurrent.Map` instead of `ConcurrentMap`.", "2.10.0")
- implicit def asJavaConcurrentMapConverter[A, B](m: mutable.ConcurrentMap[A, B]): AsJava[juc.ConcurrentMap[A, B]] =
- new AsJava(asJavaConcurrentMap(m))
-
- /**
- * Adds an `asJava` method that implicitly converts a Scala mutable
* `concurrent.Map` to a Java `ConcurrentMap`.
*
* The returned Java `ConcurrentMap` is backed by the provided Scala
diff --git a/src/library/scala/collection/convert/DecorateAsScala.scala b/src/library/scala/collection/convert/DecorateAsScala.scala
index 94847a76e3..c724831c54 100644
--- a/src/library/scala/collection/convert/DecorateAsScala.scala
+++ b/src/library/scala/collection/convert/DecorateAsScala.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package convert
import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
@@ -144,25 +145,6 @@ trait DecorateAsScala {
/**
* Adds an `asScala` method that implicitly converts a Java `ConcurrentMap`
- * to a Scala mutable `ConcurrentMap`. The returned Scala `ConcurrentMap` is
- * backed by the provided Java `ConcurrentMap` and any side-effects of using
- * it via the Scala interface will be visible via the Java interface and
- * vice versa.
- *
- * If the Java `ConcurrentMap` was previously obtained from an implicit or
- * explicit call of `asConcurrentMap(scala.collection.mutable.ConcurrentMap)`
- * then the original Scala `ConcurrentMap` will be returned.
- *
- * @param m The `ConcurrentMap` to be converted.
- * @return An object with an `asScala` method that returns a Scala mutable
- * `ConcurrentMap` view of the argument.
- */
- @deprecated("Use `mapAsScalaConcurrentMapConverter` instead, and use `concurrent.Map` instead of `ConcurrentMap`.", "2.10.0")
- def asScalaConcurrentMapConverter[A, B](m: juc.ConcurrentMap[A, B]): AsScala[mutable.ConcurrentMap[A, B]] =
- new AsScala(asScalaConcurrentMap(m))
-
- /**
- * Adds an `asScala` method that implicitly converts a Java `ConcurrentMap`
* to a Scala mutable `concurrent.Map`. The returned Scala `concurrent.Map` is
* backed by the provided Java `ConcurrentMap` and any side-effects of using
* it via the Scala interface will be visible via the Java interface and
diff --git a/src/library/scala/collection/convert/Decorators.scala b/src/library/scala/collection/convert/Decorators.scala
index e2c46c1e4f..d232fa04e1 100644
--- a/src/library/scala/collection/convert/Decorators.scala
+++ b/src/library/scala/collection/convert/Decorators.scala
@@ -6,10 +6,11 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package convert
-import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
+import java.{ util => ju }
private[collection] trait Decorators {
/** Generic class containing the `asJava` converter method */
diff --git a/src/library/scala/collection/convert/WrapAsJava.scala b/src/library/scala/collection/convert/WrapAsJava.scala
index 5e6126a7cf..e75a0e2981 100644
--- a/src/library/scala/collection/convert/WrapAsJava.scala
+++ b/src/library/scala/collection/convert/WrapAsJava.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package convert
import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
@@ -235,27 +236,6 @@ trait WrapAsJava {
}
/**
- * Implicitly converts a Scala mutable `ConcurrentMap` to a Java
- * `ConcurrentMap`.
- *
- * The returned Java `ConcurrentMap` is backed by the provided Scala
- * `ConcurrentMap` and any side-effects of using it via the Java interface
- * will be visible via the Scala interface and vice versa.
- *
- * If the Scala `ConcurrentMap` was previously obtained from an implicit or
- * explicit call of `asScalaConcurrentMap(java.util.concurrect.ConcurrentMap)`
- * then the original Java ConcurrentMap will be returned.
- *
- * @param m The `ConcurrentMap` to be converted.
- * @return A Java `ConcurrentMap` view of the argument.
- */
- @deprecated("Use `concurrent.Map` instead of `ConcurrentMap`.", "2.10.0")
- implicit def asJavaConcurrentMap[A, B](m: mutable.ConcurrentMap[A, B]): juc.ConcurrentMap[A, B] = m match {
- case JConcurrentMapDeprecatedWrapper(wrapped) => wrapped
- case _ => new ConcurrentMapDeprecatedWrapper(m)
- }
-
- /**
* Implicitly converts a Scala mutable `concurrent.Map` to a Java
* `ConcurrentMap`.
*
diff --git a/src/library/scala/collection/convert/WrapAsScala.scala b/src/library/scala/collection/convert/WrapAsScala.scala
index ffcca62291..d4ab451b0d 100644
--- a/src/library/scala/collection/convert/WrapAsScala.scala
+++ b/src/library/scala/collection/convert/WrapAsScala.scala
@@ -6,36 +6,14 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package convert
import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
import scala.language.implicitConversions
-trait LowPriorityWrapAsScala {
- this: WrapAsScala =>
-
- import Wrappers._
-
- /**
- * Implicitly converts a Java ConcurrentMap to a Scala mutable ConcurrentMap.
- * The returned Scala ConcurrentMap is backed by the provided Java
- * ConcurrentMap and any side-effects of using it via the Scala interface will
- * be visible via the Java interface and vice versa.
- *
- * If the Java ConcurrentMap was previously obtained from an implicit or
- * explicit call of `asConcurrentMap(scala.collection.mutable.ConcurrentMap)`
- * then the original Scala ConcurrentMap will be returned.
- *
- * @param m The ConcurrentMap to be converted.
- * @return A Scala mutable ConcurrentMap view of the argument.
- */
- @deprecated("Use `mapAsScalaConcurrentMap` instead, and use `concurrent.Map` instead of `ConcurrentMap`.", "2.10.0")
- implicit def mapAsScalaDeprecatedConcurrentMap[A, B](m: juc.ConcurrentMap[A, B]): mutable.ConcurrentMap[A, B] =
- asScalaConcurrentMap(m)
-}
-
-trait WrapAsScala extends LowPriorityWrapAsScala {
+trait WrapAsScala {
import Wrappers._
/**
* Implicitly converts a Java `Iterator` to a Scala `Iterator`.
@@ -178,25 +156,6 @@ trait WrapAsScala extends LowPriorityWrapAsScala {
* @param m The ConcurrentMap to be converted.
* @return A Scala mutable ConcurrentMap view of the argument.
*/
- @deprecated("Use `mapAsScalaConcurrentMap` instead, and use `concurrent.Map` instead of `ConcurrentMap`.", "2.10.0")
- def asScalaConcurrentMap[A, B](m: juc.ConcurrentMap[A, B]): mutable.ConcurrentMap[A, B] = m match {
- case cmw: ConcurrentMapDeprecatedWrapper[a, b] => cmw.underlying
- case _ => new JConcurrentMapDeprecatedWrapper(m)
- }
-
- /**
- * Implicitly converts a Java ConcurrentMap to a Scala mutable ConcurrentMap.
- * The returned Scala ConcurrentMap is backed by the provided Java
- * ConcurrentMap and any side-effects of using it via the Scala interface will
- * be visible via the Java interface and vice versa.
- *
- * If the Java ConcurrentMap was previously obtained from an implicit or
- * explicit call of `asConcurrentMap(scala.collection.mutable.ConcurrentMap)`
- * then the original Scala ConcurrentMap will be returned.
- *
- * @param m The ConcurrentMap to be converted.
- * @return A Scala mutable ConcurrentMap view of the argument.
- */
implicit def mapAsScalaConcurrentMap[A, B](m: juc.ConcurrentMap[A, B]): concurrent.Map[A, B] = m match {
case cmw: ConcurrentMapWrapper[a, b] => cmw.underlying
case _ => new JConcurrentMapWrapper(m)
diff --git a/src/library/scala/collection/convert/Wrappers.scala b/src/library/scala/collection/convert/Wrappers.scala
index 20add3365d..4410ddc7d8 100644
--- a/src/library/scala/collection/convert/Wrappers.scala
+++ b/src/library/scala/collection/convert/Wrappers.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package convert
import java.{ lang => jl, util => ju }, java.util.{ concurrent => juc }
@@ -27,9 +28,9 @@ private[collection] trait Wrappers {
case class IteratorWrapper[A](underlying: Iterator[A]) extends ju.Iterator[A] with ju.Enumeration[A] {
def hasNext = underlying.hasNext
- def next() = underlying.next
+ def next() = underlying.next()
def hasMoreElements = underlying.hasNext
- def nextElement() = underlying.next
+ def nextElement() = underlying.next()
def remove() = throw new UnsupportedOperationException
}
@@ -81,7 +82,7 @@ private[collection] trait Wrappers {
override def remove(i: Int) = underlying remove i
}
- case class JListWrapper[A](val underlying: ju.List[A]) extends mutable.AbstractBuffer[A] with mutable.Buffer[A] {
+ case class JListWrapper[A](underlying: ju.List[A]) extends mutable.AbstractBuffer[A] with mutable.Buffer[A] {
def length = underlying.size
override def isEmpty = underlying.isEmpty
override def iterator: Iterator[A] = underlying.iterator
@@ -108,7 +109,7 @@ private[collection] trait Wrappers {
val ui = underlying.iterator
var prev: Option[A] = None
def hasNext = ui.hasNext
- def next = { val e = ui.next; prev = Some(e); e }
+ def next = { val e = ui.next(); prev = Some(e); e }
def remove = prev match {
case Some(e) =>
underlying match {
@@ -180,7 +181,7 @@ private[collection] trait Wrappers {
def hasNext = ui.hasNext
def next() = {
- val (k, v) = ui.next
+ val (k, v) = ui.next()
prev = Some(k)
new ju.Map.Entry[A, B] {
import scala.util.hashing.byteswap32
@@ -272,32 +273,10 @@ private[collection] trait Wrappers {
override def empty: Repr = null.asInstanceOf[Repr]
}
- case class JMapWrapper[A, B](val underlying : ju.Map[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JMapWrapper[A, B]] {
+ case class JMapWrapper[A, B](underlying : ju.Map[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JMapWrapper[A, B]] {
override def empty = JMapWrapper(new ju.HashMap[A, B])
}
- class ConcurrentMapDeprecatedWrapper[A, B](override val underlying: mutable.ConcurrentMap[A, B]) extends MutableMapWrapper[A, B](underlying) with juc.ConcurrentMap[A, B] {
-
- def putIfAbsent(k: A, v: B) = underlying.putIfAbsent(k, v) match {
- case Some(v) => v
- case None => null.asInstanceOf[B]
- }
-
- def remove(k: AnyRef, v: AnyRef) = try {
- underlying.remove(k.asInstanceOf[A], v.asInstanceOf[B])
- } catch {
- case ex: ClassCastException =>
- false
- }
-
- def replace(k: A, v: B): B = underlying.replace(k, v) match {
- case Some(v) => v
- case None => null.asInstanceOf[B]
- }
-
- def replace(k: A, oldval: B, newval: B) = underlying.replace(k, oldval, newval)
- }
-
class ConcurrentMapWrapper[A, B](override val underlying: concurrent.Map[A, B]) extends MutableMapWrapper[A, B](underlying) with juc.ConcurrentMap[A, B] {
def putIfAbsent(k: A, v: B) = underlying.putIfAbsent(k, v) match {
@@ -320,32 +299,7 @@ private[collection] trait Wrappers {
def replace(k: A, oldval: B, newval: B) = underlying.replace(k, oldval, newval)
}
- case class JConcurrentMapDeprecatedWrapper[A, B](val underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapDeprecatedWrapper[A, B]] with mutable.ConcurrentMap[A, B] {
- override def get(k: A) = {
- val v = underlying get k
- if (v != null) Some(v)
- else None
- }
-
- override def empty = new JConcurrentMapDeprecatedWrapper(new juc.ConcurrentHashMap[A, B])
-
- def putIfAbsent(k: A, v: B): Option[B] = {
- val r = underlying.putIfAbsent(k, v)
- if (r != null) Some(r) else None
- }
-
- def remove(k: A, v: B): Boolean = underlying.remove(k, v)
-
- def replace(k: A, v: B): Option[B] = {
- val prev = underlying.replace(k, v)
- if (prev != null) Some(prev) else None
- }
-
- def replace(k: A, oldvalue: B, newvalue: B): Boolean =
- underlying.replace(k, oldvalue, newvalue)
- }
-
- case class JConcurrentMapWrapper[A, B](val underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] {
+ case class JConcurrentMapWrapper[A, B](underlying: juc.ConcurrentMap[A, B]) extends mutable.AbstractMap[A, B] with JMapWrapperLike[A, B, JConcurrentMapWrapper[A, B]] with concurrent.Map[A, B] {
override def get(k: A) = {
val v = underlying get k
if (v != null) Some(v)
diff --git a/src/library/scala/collection/convert/package.scala b/src/library/scala/collection/convert/package.scala
index ea66101aca..13970f9a3e 100644
--- a/src/library/scala/collection/convert/package.scala
+++ b/src/library/scala/collection/convert/package.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package object convert {
val decorateAsJava = new DecorateAsJava { }
diff --git a/src/library/scala/collection/generic/BitOperations.scala b/src/library/scala/collection/generic/BitOperations.scala
index c45ebcf982..d430ece2f5 100644
--- a/src/library/scala/collection/generic/BitOperations.scala
+++ b/src/library/scala/collection/generic/BitOperations.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
/** Some bit operations.
diff --git a/src/library/scala/collection/generic/BitSetFactory.scala b/src/library/scala/collection/generic/BitSetFactory.scala
index 46e2d29612..2e3aae31ac 100644
--- a/src/library/scala/collection/generic/BitSetFactory.scala
+++ b/src/library/scala/collection/generic/BitSetFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import scala.collection._
diff --git a/src/library/scala/collection/generic/CanBuildFrom.scala b/src/library/scala/collection/generic/CanBuildFrom.scala
index 73fd4fc026..24e5b2a1dd 100644
--- a/src/library/scala/collection/generic/CanBuildFrom.scala
+++ b/src/library/scala/collection/generic/CanBuildFrom.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/CanCombineFrom.scala b/src/library/scala/collection/generic/CanCombineFrom.scala
index 9ca3332ba0..7f70b4580a 100644
--- a/src/library/scala/collection/generic/CanCombineFrom.scala
+++ b/src/library/scala/collection/generic/CanCombineFrom.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.collection.parallel._
diff --git a/src/library/scala/collection/generic/ClassTagTraversableFactory.scala b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala
index 85cdbd7276..e3db40123d 100644
--- a/src/library/scala/collection/generic/ClassTagTraversableFactory.scala
+++ b/src/library/scala/collection/generic/ClassTagTraversableFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/Clearable.scala b/src/library/scala/collection/generic/Clearable.scala
index a04ecb2a68..3c496051c4 100644
--- a/src/library/scala/collection/generic/Clearable.scala
+++ b/src/library/scala/collection/generic/Clearable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
/** This trait forms part of collections that can be cleared
diff --git a/src/library/scala/collection/generic/FilterMonadic.scala b/src/library/scala/collection/generic/FilterMonadic.scala
index e21f0be898..8aefbdb926 100755
--- a/src/library/scala/collection/generic/FilterMonadic.scala
+++ b/src/library/scala/collection/generic/FilterMonadic.scala
@@ -6,8 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
-
+package scala
+package collection
+package generic
/** A template trait that contains just the `map`, `flatMap`, `foreach` and `withFilter` methods
* of trait `TraversableLike`.
diff --git a/src/library/scala/collection/generic/GenMapFactory.scala b/src/library/scala/collection/generic/GenMapFactory.scala
index e869bba51a..ae3150115f 100644
--- a/src/library/scala/collection/generic/GenMapFactory.scala
+++ b/src/library/scala/collection/generic/GenMapFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.{Builder, MapBuilder}
@@ -44,7 +45,7 @@ abstract class GenMapFactory[CC[A, B] <: GenMap[A, B] with GenMapLike[A, B, CC[A
* @tparam B the type of the associated values
* @return a new $coll consisting key/value pairs given by `elems`.
*/
- def apply[A, B](elems: (A, B)*): CC[A, B] = (newBuilder[A, B] ++= elems).result
+ def apply[A, B](elems: (A, B)*): CC[A, B] = (newBuilder[A, B] ++= elems).result()
/** The default builder for $Coll objects.
* @tparam A the type of the keys
diff --git a/src/library/scala/collection/generic/GenSeqFactory.scala b/src/library/scala/collection/generic/GenSeqFactory.scala
index dd375c567c..6afbb2e2fb 100644
--- a/src/library/scala/collection/generic/GenSeqFactory.scala
+++ b/src/library/scala/collection/generic/GenSeqFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/GenSetFactory.scala b/src/library/scala/collection/generic/GenSetFactory.scala
index 9774805cf8..800f66eb53 100644
--- a/src/library/scala/collection/generic/GenSetFactory.scala
+++ b/src/library/scala/collection/generic/GenSetFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/GenTraversableFactory.scala b/src/library/scala/collection/generic/GenTraversableFactory.scala
index 2d3f7e609b..2092c0c5f5 100644
--- a/src/library/scala/collection/generic/GenTraversableFactory.scala
+++ b/src/library/scala/collection/generic/GenTraversableFactory.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
@@ -38,12 +39,10 @@ import scala.language.higherKinds
abstract class GenTraversableFactory[CC[X] <: GenTraversable[X] with GenericTraversableTemplate[X, CC]]
extends GenericCompanion[CC] {
- // A default implementation of GenericCanBuildFrom which can be cast
- // to whatever is desired.
- private class ReusableCBF extends GenericCanBuildFrom[Nothing] {
+ private[this] val ReusableCBFInstance: GenericCanBuildFrom[Nothing] = new GenericCanBuildFrom[Nothing] {
override def apply() = newBuilder[Nothing]
}
- lazy val ReusableCBF: GenericCanBuildFrom[Nothing] = new ReusableCBF
+ def ReusableCBF: GenericCanBuildFrom[Nothing] = ReusableCBFInstance
/** A generic implementation of the `CanBuildFrom` trait, which forwards
* all calls to `apply(from)` to the `genericBuilder` method of
@@ -75,7 +74,7 @@ extends GenericCompanion[CC] {
b.sizeHint(xss.map(_.size).sum)
for (xs <- xss.seq) b ++= xs
- b.result
+ b.result()
}
/** Produces a $coll containing the results of some element computation a number of times.
@@ -91,7 +90,7 @@ extends GenericCompanion[CC] {
b += elem
i += 1
}
- b.result
+ b.result()
}
/** Produces a two-dimensional $coll containing the results of some element computation a number of times.
@@ -149,7 +148,7 @@ extends GenericCompanion[CC] {
b += f(i)
i += 1
}
- b.result
+ b.result()
}
/** Produces a two-dimensional $coll containing values of a given function over ranges of integer values starting from 0.
@@ -218,13 +217,13 @@ extends GenericCompanion[CC] {
if (step == zero) throw new IllegalArgumentException("zero step")
val b = newBuilder[T]
- b sizeHint immutable.NumericRange.count(start, end, step, false)
+ b sizeHint immutable.NumericRange.count(start, end, step, isInclusive = false)
var i = start
while (if (step < zero) end < i else i < end) {
b += i
i += step
}
- b.result
+ b.result()
}
/** Produces a $coll containing repeated applications of a function to a start value.
@@ -248,7 +247,6 @@ extends GenericCompanion[CC] {
b += acc
}
}
- b.result
+ b.result()
}
}
-
diff --git a/src/library/scala/collection/generic/GenericClassTagCompanion.scala b/src/library/scala/collection/generic/GenericClassTagCompanion.scala
index a587bbf544..a8ac2bf738 100644
--- a/src/library/scala/collection/generic/GenericClassTagCompanion.scala
+++ b/src/library/scala/collection/generic/GenericClassTagCompanion.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
@@ -19,15 +20,15 @@ import scala.reflect.ClassTag
* @author Aleksandar Prokopec
*/
abstract class GenericClassTagCompanion[+CC[X] <: Traversable[X]] {
- type Coll = CC[_]
+ protected[this] type Coll = CC[_]
def newBuilder[A](implicit ord: ClassTag[A]): Builder[A, CC[A]]
- def empty[A: ClassTag]: CC[A] = newBuilder[A].result
+ def empty[A: ClassTag]: CC[A] = newBuilder[A].result()
def apply[A](elems: A*)(implicit ord: ClassTag[A]): CC[A] = {
val b = newBuilder[A]
b ++= elems
- b.result
+ b.result()
}
}
diff --git a/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala
index f327710848..090cd729a4 100644
--- a/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala
+++ b/src/library/scala/collection/generic/GenericClassTagTraversableTemplate.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/GenericCompanion.scala b/src/library/scala/collection/generic/GenericCompanion.scala
index 5b03f8e5c6..67d0a9c7f7 100644
--- a/src/library/scala/collection/generic/GenericCompanion.scala
+++ b/src/library/scala/collection/generic/GenericCompanion.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
@@ -24,7 +25,7 @@ import scala.language.higherKinds
*/
abstract class GenericCompanion[+CC[X] <: GenTraversable[X]] {
/** The underlying collection type with unknown element type */
- type Coll = CC[_]
+ protected[this] type Coll = CC[_]
/** The default builder for `$Coll` objects.
* @tparam A the type of the ${coll}'s elements
@@ -34,7 +35,7 @@ abstract class GenericCompanion[+CC[X] <: GenTraversable[X]] {
/** An empty collection of type `$Coll[A]`
* @tparam A the type of the ${coll}'s elements
*/
- def empty[A]: CC[A] = newBuilder[A].result
+ def empty[A]: CC[A] = newBuilder[A].result()
/** Creates a $coll with the specified elements.
* @tparam A the type of the ${coll}'s elements
@@ -46,7 +47,7 @@ abstract class GenericCompanion[+CC[X] <: GenTraversable[X]] {
else {
val b = newBuilder[A]
b ++= elems
- b.result
+ b.result()
}
}
}
diff --git a/src/library/scala/collection/generic/GenericOrderedCompanion.scala b/src/library/scala/collection/generic/GenericOrderedCompanion.scala
index a9a50a1c35..5b328bff6c 100644
--- a/src/library/scala/collection/generic/GenericOrderedCompanion.scala
+++ b/src/library/scala/collection/generic/GenericOrderedCompanion.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
@@ -19,16 +20,16 @@ import scala.language.higherKinds
* @since 2.8
*/
abstract class GenericOrderedCompanion[+CC[X] <: Traversable[X]] {
- type Coll = CC[_]
+ protected[this] type Coll = CC[_]
def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]]
- def empty[A: Ordering]: CC[A] = newBuilder[A].result
+ def empty[A: Ordering]: CC[A] = newBuilder[A].result()
def apply[A](elems: A*)(implicit ord: Ordering[A]): CC[A] = {
val b = newBuilder[A]
b ++= elems
- b.result
+ b.result()
}
}
diff --git a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala
index a624e8ca93..c1a41ce7c4 100644
--- a/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala
+++ b/src/library/scala/collection/generic/GenericOrderedTraversableTemplate.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/GenericParCompanion.scala b/src/library/scala/collection/generic/GenericParCompanion.scala
index bb39461e7e..432b9135f8 100644
--- a/src/library/scala/collection/generic/GenericParCompanion.scala
+++ b/src/library/scala/collection/generic/GenericParCompanion.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection.parallel.Combiner
import scala.collection.parallel.ParIterable
diff --git a/src/library/scala/collection/generic/GenericParTemplate.scala b/src/library/scala/collection/generic/GenericParTemplate.scala
index 94c76630d6..b9b7043270 100644
--- a/src/library/scala/collection/generic/GenericParTemplate.scala
+++ b/src/library/scala/collection/generic/GenericParTemplate.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection.parallel.Combiner
import scala.collection.parallel.ParIterable
diff --git a/src/library/scala/collection/generic/GenericSeqCompanion.scala b/src/library/scala/collection/generic/GenericSeqCompanion.scala
index 8b2f8a0fcb..34b20f23a2 100644
--- a/src/library/scala/collection/generic/GenericSeqCompanion.scala
+++ b/src/library/scala/collection/generic/GenericSeqCompanion.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/GenericSetTemplate.scala b/src/library/scala/collection/generic/GenericSetTemplate.scala
index ecfdcffbc5..2cadd14948 100644
--- a/src/library/scala/collection/generic/GenericSetTemplate.scala
+++ b/src/library/scala/collection/generic/GenericSetTemplate.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
/**
diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala
index f7a8a9aa88..cd48cd23f4 100644
--- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala
+++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
@@ -73,11 +74,20 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
/** Converts this $coll of pairs into two collections of the first and second
* half of each pair.
*
+ * {{{
+ * val xs = $Coll(
+ * (1, "one"),
+ * (2, "two"),
+ * (3, "three")).unzip
+ * // xs == ($Coll(1, 2, 3),
+ * // $Coll(one, two, three))
+ * }}}
+ *
* @tparam A1 the type of the first half of the element pairs
* @tparam A2 the type of the second half of the element pairs
* @param asPair an implicit conversion which asserts that the element type
* of this $coll is a pair.
- * @return a pair ${coll}s, containing the first, respectively second
+ * @return a pair of ${coll}s, containing the first, respectively second
* half of each element pair of this $coll.
*/
def unzip[A1, A2](implicit asPair: A => (A1, A2)): (CC[A1], CC[A2]) = {
@@ -88,18 +98,28 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
b1 += x
b2 += y
}
- (b1.result, b2.result)
+ (b1.result(), b2.result())
}
/** Converts this $coll of triples into three collections of the first, second,
* and third element of each triple.
*
+ * {{{
+ * val xs = $Coll(
+ * (1, "one", '1'),
+ * (2, "two", '2'),
+ * (3, "three", '3')).unzip3
+ * // xs == ($Coll(1, 2, 3),
+ * // $Coll(one, two, three),
+ * // $Coll(1, 2, 3))
+ * }}}
+ *
* @tparam A1 the type of the first member of the element triples
* @tparam A2 the type of the second member of the element triples
* @tparam A3 the type of the third member of the element triples
* @param asTriple an implicit conversion which asserts that the element type
* of this $coll is a triple.
- * @return a triple ${coll}s, containing the first, second, respectively
+ * @return a triple of ${coll}s, containing the first, second, respectively
* third member of each element triple of this $coll.
*/
def unzip3[A1, A2, A3](implicit asTriple: A => (A1, A2, A3)): (CC[A1], CC[A2], CC[A3]) = {
@@ -113,7 +133,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
b2 += y
b3 += z
}
- (b1.result, b2.result, b3.result)
+ (b1.result(), b2.result(), b3.result())
}
/** Converts this $coll of traversable collections into
@@ -133,10 +153,16 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
* static type of $coll. For example:
*
* {{{
- * val xs = List(Set(1, 2, 3), Set(1, 2, 3))
+ * val xs = List(
+ * Set(1, 2, 3),
+ * Set(1, 2, 3)
+ * ).flatten
* // xs == List(1, 2, 3, 1, 2, 3)
*
- * val ys = Set(List(1, 2, 3), List(3, 2, 1))
+ * val ys = Set(
+ * List(1, 2, 3),
+ * List(3, 2, 1)
+ * ).flatten
* // ys == Set(1, 2, 3)
* }}}
*/
@@ -144,12 +170,33 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
val b = genericBuilder[B]
for (xs <- sequential)
b ++= asTraversable(xs).seq
- b.result
+ b.result()
}
/** Transposes this $coll of traversable collections into
* a $coll of ${coll}s.
*
+ * The resulting collection's type will be guided by the
+ * static type of $coll. For example:
+ *
+ * {{{
+ * val xs = List(
+ * Set(1, 2, 3),
+ * Set(4, 5, 6)).transpose
+ * // xs == List(
+ * // List(1, 4),
+ * // List(2, 5),
+ * // List(3, 6))
+ *
+ * val ys = Vector(
+ * List(1, 2, 3),
+ * List(4, 5, 6)).transpose
+ * // ys == Vector(
+ * // Vector(1, 4),
+ * // Vector(2, 5),
+ * // Vector(3, 6))
+ * }}}
+ *
* @tparam B the type of the elements of each traversable collection.
* @param asTraversable an implicit conversion which asserts that the
* element type of this $coll is a `Traversable`.
@@ -161,7 +208,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
@migration("`transpose` throws an `IllegalArgumentException` if collections are not uniformly sized.", "2.9.0")
def transpose[B](implicit asTraversable: A => /*<:<!!!*/ GenTraversableOnce[B]): CC[CC[B] @uncheckedVariance] = {
if (isEmpty)
- return genericBuilder[CC[B]].result
+ return genericBuilder[CC[B]].result()
def fail = throw new IllegalArgumentException("transpose requires all collections have the same size")
@@ -179,7 +226,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew
}
val bb = genericBuilder[CC[B]]
for (b <- bs) bb += b.result
- bb.result
+ bb.result()
}
}
diff --git a/src/library/scala/collection/generic/Growable.scala b/src/library/scala/collection/generic/Growable.scala
index cb75212e3d..254d4566be 100644
--- a/src/library/scala/collection/generic/Growable.scala
+++ b/src/library/scala/collection/generic/Growable.scala
@@ -6,10 +6,12 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
package generic
+import scala.annotation.tailrec
+
/** This trait forms part of collections that can be augmented
* using a `+=` operator and that can be cleared of all elements using
* a `clear` method.
@@ -45,7 +47,19 @@ trait Growable[-A] extends Clearable {
* @param xs the TraversableOnce producing the elements to $add.
* @return the $coll itself.
*/
- def ++=(xs: TraversableOnce[A]): this.type = { xs.seq foreach += ; this }
+ def ++=(xs: TraversableOnce[A]): this.type = {
+ @tailrec def loop(xs: scala.collection.LinearSeq[A]) {
+ if (xs.nonEmpty) {
+ this += xs.head
+ loop(xs.tail)
+ }
+ }
+ xs.seq match {
+ case xs: scala.collection.LinearSeq[_] => loop(xs)
+ case xs => xs foreach +=
+ }
+ this
+ }
/** Clears the $coll's contents. After this operation, the
* $coll is empty.
diff --git a/src/library/scala/collection/generic/HasNewBuilder.scala b/src/library/scala/collection/generic/HasNewBuilder.scala
index 1a981b487f..aa0ce6698d 100755
--- a/src/library/scala/collection/generic/HasNewBuilder.scala
+++ b/src/library/scala/collection/generic/HasNewBuilder.scala
@@ -5,7 +5,8 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/HasNewCombiner.scala b/src/library/scala/collection/generic/HasNewCombiner.scala
index 1ecfba19af..99a0722c3d 100644
--- a/src/library/scala/collection/generic/HasNewCombiner.scala
+++ b/src/library/scala/collection/generic/HasNewCombiner.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection.parallel.Combiner
diff --git a/src/library/scala/collection/generic/ImmutableMapFactory.scala b/src/library/scala/collection/generic/ImmutableMapFactory.scala
index 4ce50a31f9..7d857bf1b4 100644
--- a/src/library/scala/collection/generic/ImmutableMapFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableMapFactory.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/ImmutableSetFactory.scala b/src/library/scala/collection/generic/ImmutableSetFactory.scala
index 2e960e670d..f4d4e061bb 100644
--- a/src/library/scala/collection/generic/ImmutableSetFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableSetFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.{ Builder, SetBuilder }
diff --git a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala
index 7743fc2281..730e58a527 100644
--- a/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableSortedMapFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala
index 9914557b51..1fd4a8c99d 100644
--- a/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala
+++ b/src/library/scala/collection/generic/ImmutableSortedSetFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/ScalaObject.scala b/src/library/scala/collection/generic/IndexedSeqFactory.scala
index f67dc3a6c5..ddc0141aa9 100644
--- a/src/library/scala/ScalaObject.scala
+++ b/src/library/scala/collection/generic/IndexedSeqFactory.scala
@@ -7,10 +7,16 @@
\* */
package scala
+package collection
+package generic
-/** Until scala 2.10.0 this marker trait was added to
- * scala-compiled classes. Now it only exists for backward
- * compatibility.
+import language.higherKinds
+
+/** A template for companion objects of IndexedSeq and subclasses thereof.
+ *
+ * @since 2.11
*/
-@deprecated("ScalaObject will be removed", "2.10.0")
-trait ScalaObject
+abstract class IndexedSeqFactory[CC[X] <: IndexedSeq[X] with GenericTraversableTemplate[X, CC]] extends SeqFactory[CC] {
+ override def ReusableCBF: GenericCanBuildFrom[Nothing] =
+ scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[Nothing]]
+}
diff --git a/src/library/scala/collection/generic/IsSeqLike.scala b/src/library/scala/collection/generic/IsSeqLike.scala
new file mode 100644
index 0000000000..189aea4632
--- /dev/null
+++ b/src/library/scala/collection/generic/IsSeqLike.scala
@@ -0,0 +1,58 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala
+package collection
+package generic
+
+/** Type class witnessing that a collection representation type `Repr` has
+ * elements of type `A` and has a conversion to `SeqLike[A, Repr]`.
+ *
+ * This type enables simple enrichment of `Seq`s with extension methods which
+ * can make full use of the mechanics of the Scala collections framework in
+ * their implementation.
+ *
+ * Example usage:
+ * {{{
+ * class FilterMapImpl[A, Repr](val r: SeqLike[A, Repr]) {
+ * final def filterMap[B, That](f: A => Option[B])(implicit cbf: CanBuildFrom[Repr, B, That]): That =
+ * r.flatMap(f(_))
+ * }
+ * implicit def filterMap[Repr, A](r: Repr)(implicit fr: IsSeqLike[Repr]): FilterMapImpl[fr.A,Repr] =
+ * new FilterMapImpl(fr.conversion(r))
+ *
+ * val l = List(1, 2, 3, 4, 5)
+ * List(1, 2, 3, 4, 5) filterMap (i => if(i % 2 == 0) Some(i) else None)
+ * // == List(2, 4)
+ * }}}
+ *
+ * @see [[scala.collection.Seq]]
+ * @see [[scala.collection.generic.IsTraversableLike]]
+ */
+trait IsSeqLike[Repr] {
+ /** The type of elements we can traverse over. */
+ type A
+ /** A conversion from the representation type `Repr` to a `SeqLike[A,Repr]`. */
+ val conversion: Repr => SeqLike[A, Repr]
+}
+
+object IsSeqLike {
+ import scala.language.higherKinds
+
+ implicit val stringRepr: IsSeqLike[String] { type A = Char } =
+ new IsSeqLike[String] {
+ type A = Char
+ val conversion = implicitly[String => SeqLike[Char, String]]
+ }
+
+ implicit def seqLikeRepr[C[_], A0](implicit conv: C[A0] => SeqLike[A0,C[A0]]): IsSeqLike[C[A0]] { type A = A0 } =
+ new IsSeqLike[C[A0]] {
+ type A = A0
+ val conversion = conv
+ }
+}
diff --git a/src/library/scala/collection/generic/IsTraversableLike.scala b/src/library/scala/collection/generic/IsTraversableLike.scala
index c70772d8f9..22cef555cc 100644
--- a/src/library/scala/collection/generic/IsTraversableLike.scala
+++ b/src/library/scala/collection/generic/IsTraversableLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
/** A trait which can be used to avoid code duplication when defining extension
diff --git a/src/library/scala/collection/generic/IsTraversableOnce.scala b/src/library/scala/collection/generic/IsTraversableOnce.scala
index bb5404c92d..3ee586ae63 100644
--- a/src/library/scala/collection/generic/IsTraversableOnce.scala
+++ b/src/library/scala/collection/generic/IsTraversableOnce.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
/** Type class witnessing that a collection representation type `Repr` has
diff --git a/src/library/scala/collection/generic/IterableForwarder.scala b/src/library/scala/collection/generic/IterableForwarder.scala
index 90ebcace84..5a54ed7f78 100644
--- a/src/library/scala/collection/generic/IterableForwarder.scala
+++ b/src/library/scala/collection/generic/IterableForwarder.scala
@@ -6,13 +6,12 @@
** |/ **
\* */
+package scala
+package collection
+package generic
-
-package scala.collection.generic
import scala.collection._
-import scala.collection.mutable.Buffer
-
/** This trait implements a forwarder for iterable objects. It forwards
* all calls to a different iterable object, except for
*
diff --git a/src/library/scala/collection/generic/MapFactory.scala b/src/library/scala/collection/generic/MapFactory.scala
index 565850bee2..b9f3d4b010 100644
--- a/src/library/scala/collection/generic/MapFactory.scala
+++ b/src/library/scala/collection/generic/MapFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
diff --git a/src/library/scala/collection/generic/MutableMapFactory.scala b/src/library/scala/collection/generic/MutableMapFactory.scala
index ac139cc80c..14c5b6bac3 100644
--- a/src/library/scala/collection/generic/MutableMapFactory.scala
+++ b/src/library/scala/collection/generic/MutableMapFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/MutableSetFactory.scala b/src/library/scala/collection/generic/MutableSetFactory.scala
index 9c69d53608..63944657fc 100644
--- a/src/library/scala/collection/generic/MutableSetFactory.scala
+++ b/src/library/scala/collection/generic/MutableSetFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import mutable.{ Builder, GrowingBuilder }
diff --git a/src/library/scala/collection/generic/MutableSortedSetFactory.scala b/src/library/scala/collection/generic/MutableSortedSetFactory.scala
index b9be83c3c4..0339a523e9 100644
--- a/src/library/scala/collection/generic/MutableSortedSetFactory.scala
+++ b/src/library/scala/collection/generic/MutableSortedSetFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.collection.mutable.{ Builder, GrowingBuilder }
diff --git a/src/library/scala/collection/generic/OrderedTraversableFactory.scala b/src/library/scala/collection/generic/OrderedTraversableFactory.scala
index a2de108721..7657aff2aa 100644
--- a/src/library/scala/collection/generic/OrderedTraversableFactory.scala
+++ b/src/library/scala/collection/generic/OrderedTraversableFactory.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/ParFactory.scala b/src/library/scala/collection/generic/ParFactory.scala
index bb88d26dec..486e2a115e 100644
--- a/src/library/scala/collection/generic/ParFactory.scala
+++ b/src/library/scala/collection/generic/ParFactory.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection.parallel.ParIterable
import scala.collection.parallel.Combiner
diff --git a/src/library/scala/collection/generic/ParMapFactory.scala b/src/library/scala/collection/generic/ParMapFactory.scala
index 0a6b08ae34..70797c83e2 100644
--- a/src/library/scala/collection/generic/ParMapFactory.scala
+++ b/src/library/scala/collection/generic/ParMapFactory.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection.parallel.ParMap
import scala.collection.parallel.ParMapLike
diff --git a/src/library/scala/collection/generic/ParSetFactory.scala b/src/library/scala/collection/generic/ParSetFactory.scala
index 3727ab89f7..4320635ae6 100644
--- a/src/library/scala/collection/generic/ParSetFactory.scala
+++ b/src/library/scala/collection/generic/ParSetFactory.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection.mutable.Builder
import scala.collection.parallel.Combiner
diff --git a/src/library/scala/collection/generic/SeqFactory.scala b/src/library/scala/collection/generic/SeqFactory.scala
index a66074741a..35cce11a79 100644
--- a/src/library/scala/collection/generic/SeqFactory.scala
+++ b/src/library/scala/collection/generic/SeqFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/SeqForwarder.scala b/src/library/scala/collection/generic/SeqForwarder.scala
index e8b15ec450..c23b818c00 100644
--- a/src/library/scala/collection/generic/SeqForwarder.scala
+++ b/src/library/scala/collection/generic/SeqForwarder.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection._
import scala.collection.immutable.Range
@@ -50,7 +52,7 @@ trait SeqForwarder[+A] extends Seq[A] with IterableForwarder[A] {
override def lastIndexOfSlice[B >: A](that: GenSeq[B]): Int = underlying lastIndexOfSlice that
override def lastIndexOfSlice[B >: A](that: GenSeq[B], end: Int): Int = underlying.lastIndexOfSlice(that, end)
override def containsSlice[B](that: GenSeq[B]): Boolean = underlying containsSlice that
- override def contains(elem: Any): Boolean = underlying contains elem
+ override def contains[A1 >: A](elem: A1): Boolean = underlying contains elem
override def corresponds[B](that: GenSeq[B])(p: (A,B) => Boolean): Boolean = underlying.corresponds(that)(p)
override def indices: Range = underlying.indices
}
diff --git a/src/library/scala/collection/generic/SetFactory.scala b/src/library/scala/collection/generic/SetFactory.scala
index e9bbde92f3..fcd8d00c18 100644
--- a/src/library/scala/collection/generic/SetFactory.scala
+++ b/src/library/scala/collection/generic/SetFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.Builder
diff --git a/src/library/scala/collection/generic/Shrinkable.scala b/src/library/scala/collection/generic/Shrinkable.scala
index b00048fd5d..b7412afde0 100644
--- a/src/library/scala/collection/generic/Shrinkable.scala
+++ b/src/library/scala/collection/generic/Shrinkable.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
/** This trait forms part of collections that can be reduced
diff --git a/src/library/scala/collection/generic/Signalling.scala b/src/library/scala/collection/generic/Signalling.scala
index 498db7f8fa..e62eb6ff09 100644
--- a/src/library/scala/collection/generic/Signalling.scala
+++ b/src/library/scala/collection/generic/Signalling.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import java.util.concurrent.atomic.AtomicInteger
@@ -140,7 +142,7 @@ trait AtomicIndexFlag extends Signalling {
val old = intflag.get
if (f <= old) loop = false
else if (intflag.compareAndSet(old, f)) loop = false
- } while (loop);
+ } while (loop)
}
abstract override def setIndexFlagIfLesser(f: Int) = {
var loop = true
@@ -148,7 +150,7 @@ trait AtomicIndexFlag extends Signalling {
val old = intflag.get
if (f >= old) loop = false
else if (intflag.compareAndSet(old, f)) loop = false
- } while (loop);
+ } while (loop)
}
}
@@ -163,7 +165,7 @@ trait DelegatedSignalling extends Signalling {
var signalDelegate: Signalling
def isAborted = signalDelegate.isAborted
- def abort() = signalDelegate.abort
+ def abort() = signalDelegate.abort()
def indexFlag = signalDelegate.indexFlag
def setIndexFlag(f: Int) = signalDelegate.setIndexFlag(f)
diff --git a/src/library/scala/collection/generic/Sizing.scala b/src/library/scala/collection/generic/Sizing.scala
index 1191259b3a..73584ce82e 100644
--- a/src/library/scala/collection/generic/Sizing.scala
+++ b/src/library/scala/collection/generic/Sizing.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
/** A trait for objects which have a size.
*/
diff --git a/src/library/scala/collection/generic/SliceInterval.scala b/src/library/scala/collection/generic/SliceInterval.scala
index 244e960454..82acdd1371 100644
--- a/src/library/scala/collection/generic/SliceInterval.scala
+++ b/src/library/scala/collection/generic/SliceInterval.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
/** A container for the endpoints of a collection slice.
diff --git a/src/library/scala/collection/generic/Sorted.scala b/src/library/scala/collection/generic/Sorted.scala
index f962b26bd3..3876da3275 100644
--- a/src/library/scala/collection/generic/Sorted.scala
+++ b/src/library/scala/collection/generic/Sorted.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package generic
/** Any collection (including maps) whose keys (or elements) are ordered.
@@ -71,28 +72,40 @@ trait Sorted[K, +This <: Sorted[K, This]] {
def to(to: K): This = {
val i = keySet.from(to).iterator
if (i.isEmpty) return repr
- val next = i.next
+ val next = i.next()
if (compare(next, to) == 0)
if (i.isEmpty) repr
- else until(i.next)
+ else until(i.next())
else
until(next)
}
+
+ /**
+ * Creates an iterator over all the keys(or elements) contained in this
+ * collection greater than or equal to `start`
+ * according to the ordering of this collection. x.keysIteratorFrom(y)
+ * is equivalent to but often more efficient than
+ * x.from(y).keysIterator.
+ *
+ * @param start The lower bound (inclusive)
+ * on the keys to be returned
+ */
+ def keysIteratorFrom(start: K): Iterator[K]
protected def hasAll(j: Iterator[K]): Boolean = {
val i = keySet.iterator
if (i.isEmpty) return j.isEmpty
- var in = i.next;
+ var in = i.next()
while (j.hasNext) {
- val jn = j.next;
+ val jn = j.next()
while ({
- val n = compare(jn, in);
- if (n == 0) false;
- else if (n < 0) return false;
- else if (!i.hasNext) return false;
- else true;
- }) in = i.next;
+ val n = compare(jn, in)
+ if (n == 0) false
+ else if (n < 0) return false
+ else if (!i.hasNext) return false
+ else true
+ }) in = i.next()
}
true
}
diff --git a/src/library/scala/collection/generic/SortedMapFactory.scala b/src/library/scala/collection/generic/SortedMapFactory.scala
index 17201b0f7a..afa11e9ab1 100644
--- a/src/library/scala/collection/generic/SortedMapFactory.scala
+++ b/src/library/scala/collection/generic/SortedMapFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.{Builder, MapBuilder}
@@ -24,7 +25,7 @@ abstract class SortedMapFactory[CC[A, B] <: SortedMap[A, B] with SortedMapLike[A
def empty[A, B](implicit ord: Ordering[A]): CC[A, B]
- def apply[A, B](elems: (A, B)*)(implicit ord: Ordering[A]): CC[A, B] = (newBuilder[A, B](ord) ++= elems).result
+ def apply[A, B](elems: (A, B)*)(implicit ord: Ordering[A]): CC[A, B] = (newBuilder[A, B](ord) ++= elems).result()
def newBuilder[A, B](implicit ord: Ordering[A]): Builder[(A, B), CC[A, B]] =
new MapBuilder[A, B, CC[A, B]](empty(ord))
diff --git a/src/library/scala/collection/generic/SortedSetFactory.scala b/src/library/scala/collection/generic/SortedSetFactory.scala
index 08bca04e42..c734830e0b 100644
--- a/src/library/scala/collection/generic/SortedSetFactory.scala
+++ b/src/library/scala/collection/generic/SortedSetFactory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package generic
import mutable.{Builder, SetBuilder}
@@ -23,11 +24,11 @@ abstract class SortedSetFactory[CC[A] <: SortedSet[A] with SortedSetLike[A, CC[A
def empty[A](implicit ord: Ordering[A]): CC[A]
- def apply[A](elems: A*)(implicit ord: Ordering[A]): CC[A] = (newBuilder[A](ord) ++= elems).result
+ def apply[A](elems: A*)(implicit ord: Ordering[A]): CC[A] = (newBuilder[A](ord) ++= elems).result()
def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]] = new SetBuilder[A, CC[A]](empty)
- implicit def newCanBuildFrom[A](implicit ord : Ordering[A]) : CanBuildFrom[Coll, A, CC[A]] = new SortedSetCanBuildFrom()(ord);
+ implicit def newCanBuildFrom[A](implicit ord : Ordering[A]) : CanBuildFrom[Coll, A, CC[A]] = new SortedSetCanBuildFrom()(ord)
class SortedSetCanBuildFrom[A](implicit ord: Ordering[A]) extends CanBuildFrom[Coll, A, CC[A]] {
def apply(from: Coll) = newBuilder[A](ord)
diff --git a/src/library/scala/collection/generic/Subtractable.scala b/src/library/scala/collection/generic/Subtractable.scala
index e0fe07a0a4..32a9000296 100644
--- a/src/library/scala/collection/generic/Subtractable.scala
+++ b/src/library/scala/collection/generic/Subtractable.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
diff --git a/src/library/scala/collection/generic/TraversableFactory.scala b/src/library/scala/collection/generic/TraversableFactory.scala
index 5d1c9d17e2..ad6d8fd198 100644
--- a/src/library/scala/collection/generic/TraversableFactory.scala
+++ b/src/library/scala/collection/generic/TraversableFactory.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package generic
import scala.language.higherKinds
diff --git a/src/library/scala/collection/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala
index 2662018feb..c71368bba0 100644
--- a/src/library/scala/collection/generic/TraversableForwarder.scala
+++ b/src/library/scala/collection/generic/TraversableForwarder.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.collection.generic
+package scala
+package collection
+package generic
import scala.collection._
import mutable.{ Buffer, StringBuilder }
diff --git a/src/library/scala/collection/generic/package.scala b/src/library/scala/collection/generic/package.scala
index dd47b7ace6..1beb4a8599 100644
--- a/src/library/scala/collection/generic/package.scala
+++ b/src/library/scala/collection/generic/package.scala
@@ -1,4 +1,5 @@
-package scala.collection
+package scala
+package collection
import generic.CanBuildFrom
import scala.language.higherKinds
diff --git a/src/library/scala/collection/immutable/BitSet.scala b/src/library/scala/collection/immutable/BitSet.scala
index ed3630edc1..70543aa3a6 100644
--- a/src/library/scala/collection/immutable/BitSet.scala
+++ b/src/library/scala/collection/immutable/BitSet.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -31,9 +32,6 @@ abstract class BitSet extends scala.collection.AbstractSet[Int]
with Serializable {
override def empty = BitSet.empty
- @deprecated("Use BitSet.fromBitMask[NoCopy] instead of fromArray", "2.10.0")
- def fromArray(elems: Array[Long]): BitSet = fromBitMaskNoCopy(elems)
-
protected def fromBitMaskNoCopy(elems: Array[Long]): BitSet = BitSet.fromBitMaskNoCopy(elems)
/** Update word at index `idx`; enlarge set if `idx` outside range of set.
@@ -74,7 +72,7 @@ object BitSet extends BitSetFactory[BitSet] {
def newBuilder: Builder[Int, BitSet] = new Builder[Int, BitSet] {
private[this] val b = new mutable.BitSet
def += (x: Int) = { b += x; this }
- def clear() = b.clear
+ def clear() = b.clear()
def result() = b.toImmutable
}
@@ -82,10 +80,6 @@ object BitSet extends BitSetFactory[BitSet] {
implicit def canBuildFrom: CanBuildFrom[BitSet, Int, BitSet] = bitsetCanBuildFrom
/** A bitset containing all the bits in an array */
- @deprecated("Use fromBitMask[NoCopy] instead of fromArray", "2.10.0")
- def fromArray(elems: Array[Long]): BitSet = fromBitMaskNoCopy(elems)
-
- /** A bitset containing all the bits in an array */
def fromBitMask(elems: Array[Long]): BitSet = {
val len = elems.length
if (len == 0) empty
diff --git a/src/library/scala/collection/immutable/DefaultMap.scala b/src/library/scala/collection/immutable/DefaultMap.scala
index 4a0503adfd..42a03e90ee 100755
--- a/src/library/scala/collection/immutable/DefaultMap.scala
+++ b/src/library/scala/collection/immutable/DefaultMap.scala
@@ -6,13 +6,10 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package immutable
-import generic._
-
/** A default map which implements the `+` and `-`
* methods of maps. It does so using the default builder for
* maps defined in the `Map` object.
@@ -42,7 +39,7 @@ trait DefaultMap[A, +B] extends Map[A, B] { self =>
val b = Map.newBuilder[A, B1]
b ++= this
b += ((kv._1, kv._2))
- b.result
+ b.result()
}
/** A default implementation which creates a new immutable map.
@@ -50,7 +47,7 @@ trait DefaultMap[A, +B] extends Map[A, B] { self =>
override def - (key: A): Map[A, B] = {
val b = newBuilder
for (kv <- this.seq ; if kv._1 != key) b += kv
- b.result
+ b.result()
}
}
diff --git a/src/library/scala/collection/immutable/GenIterable.scala.disabled b/src/library/scala/collection/immutable/GenIterable.scala.disabled
deleted file mode 100644
index d34f7fd856..0000000000
--- a/src/library/scala/collection/immutable/GenIterable.scala.disabled
+++ /dev/null
@@ -1,37 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.collection
-package immutable
-
-
-import generic._
-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]
- with scala.collection.GenIterableLike[A, GenIterable[A]]
-// with GenericTraversableTemplate[A, GenIterable]
-{
- def seq: Iterable[A]
- //override def companion: GenericCompanion[GenIterable] = GenIterable
-}
-
-
-// object GenIterable extends TraversableFactory[GenIterable] {
-// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder
-// }
-
diff --git a/src/library/scala/collection/immutable/GenMap.scala.disabled b/src/library/scala/collection/immutable/GenMap.scala.disabled
deleted file mode 100644
index 73557a4a66..0000000000
--- a/src/library/scala/collection/immutable/GenMap.scala.disabled
+++ /dev/null
@@ -1,36 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.collection
-package immutable
-
-import generic._
-
-
-/** A base trait for maps that can be mutated.
- * $possiblyparinfo
- * $mapNote
- * $mapTags
- * @since 1.0
- * @author Matthias Zenger
- */
-trait GenMap[A, +B]
-extends GenIterable[(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]
-// }
diff --git a/src/library/scala/collection/immutable/GenSeq.scala.disabled b/src/library/scala/collection/immutable/GenSeq.scala.disabled
deleted file mode 100644
index 713529f3db..0000000000
--- a/src/library/scala/collection/immutable/GenSeq.scala.disabled
+++ /dev/null
@@ -1,49 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package immutable
-
-
-import generic._
-import mutable.Builder
-
-
-/** A subtrait of `collection.GenSeq` which represents sequences
- * 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]
- with scala.collection.GenSeqLike[A, GenSeq[A]]
-// with GenericTraversableTemplate[A, GenSeq]
-{
- def seq: Seq[A]
- //override def companion: GenericCompanion[GenSeq] = GenSeq
-}
-
-
-// object GenSeq extends SeqFactory[GenSeq] {
-// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSeq[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder
-// }
-
-
-
-
-
diff --git a/src/library/scala/collection/immutable/GenSet.scala.disabled b/src/library/scala/collection/immutable/GenSet.scala.disabled
deleted file mode 100644
index 56bd2738fd..0000000000
--- a/src/library/scala/collection/immutable/GenSet.scala.disabled
+++ /dev/null
@@ -1,43 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package immutable
-
-
-import generic._
-import mutable.Builder
-
-
-/** A generic trait for mutable sets.
- *
- * $possiblyparinfo
- * $setNote
- * $setTags
- *
- * @since 1.0
- * @author Matthias Zenger
- * @define Coll `mutable.Set`
- * @define coll mutable set
- */
-trait GenSet[A] extends GenIterable[A]
- with scala.collection.GenSet[A]
- with scala.collection.GenSetLike[A, GenSet[A]]
-// with GenericSetTemplate[A, GenSet]
-{
- //override def companion: GenericCompanion[GenSet] = GenSet
- def seq: Set[A]
-}
-
-
-// object GenSet extends TraversableFactory[GenSet] {
-// implicit def canBuildFrom[A] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A] = Set.newBuilder
-// }
diff --git a/src/library/scala/collection/immutable/GenTraversable.scala.disabled b/src/library/scala/collection/immutable/GenTraversable.scala.disabled
deleted file mode 100644
index e5b609f9ed..0000000000
--- a/src/library/scala/collection/immutable/GenTraversable.scala.disabled
+++ /dev/null
@@ -1,41 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package immutable
-
-
-import generic._
-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]
- with scala.collection.GenTraversableLike[A, GenTraversable[A]]
-// with GenericTraversableTemplate[A, GenTraversable]
- with Mutable
-{
- def seq: Traversable[A]
- //override def companion: GenericCompanion[GenTraversable] = GenTraversable
-}
-
-
-// object GenTraversable extends TraversableFactory[GenTraversable] {
-// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenTraversable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A]: Builder[A, GenTraversable[A]] = Traversable.newBuilder
-// }
-
-
diff --git a/src/library/scala/collection/immutable/HashMap.scala b/src/library/scala/collection/immutable/HashMap.scala
index 84416a62d2..44e5304e09 100644
--- a/src/library/scala/collection/immutable/HashMap.scala
+++ b/src/library/scala/collection/immutable/HashMap.scala
@@ -87,9 +87,6 @@ class HashMap[A, +B] extends AbstractMap[A, B]
def split: Seq[HashMap[A, B]] = Seq(this)
- @deprecated("Use the `merged` method instead.", "2.10.0")
- def merge[B1 >: B](that: HashMap[A, B1], mergef: MergeFunction[A, B1] = null): HashMap[A, B1] = merge0(that, 0, liftMerger(mergef))
-
/** Creates a new map which is the merge of this and the argument hash map.
*
* Uses the specified collision resolution function if two keys are the same.
@@ -398,7 +395,7 @@ time { mNew.iterator.foreach( p => ()) }
*/
override def foreach[U](f: ((A, B)) => U): Unit = {
- var i = 0;
+ var i = 0
while (i < elems.length) {
elems(i).foreach(f)
i += 1
@@ -471,9 +468,6 @@ time { mNew.iterator.foreach( p => ()) }
// condition below is due to 2 things:
// 1) no unsigned int compare on JVM
// 2) 0 (no lsb) should always be greater in comparison
- val a = thislsb - 1
- val b = thatlsb - 1
-
if (unsignedCompare(thislsb - 1, thatlsb - 1)) {
val m = thiselems(thisi)
totalelems += m.size
diff --git a/src/library/scala/collection/immutable/HashSet.scala b/src/library/scala/collection/immutable/HashSet.scala
index 87995f705f..e17f07c87b 100644
--- a/src/library/scala/collection/immutable/HashSet.scala
+++ b/src/library/scala/collection/immutable/HashSet.scala
@@ -301,8 +301,8 @@ time { mNew.iterator.foreach( p => ()) }
*/
override def foreach[U](f: A => U): Unit = {
- var i = 0;
- while (i < elems.length) {
+ var i = 0
+ while (i < elems.length) {
elems(i).foreach(f)
i += 1
}
diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala
index 96414c07ef..33170fdd59 100644
--- a/src/library/scala/collection/immutable/IndexedSeq.scala
+++ b/src/library/scala/collection/immutable/IndexedSeq.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -31,14 +32,13 @@ trait IndexedSeq[+A] extends Seq[A]
* @define coll indexed sequence
* @define Coll `IndexedSeq`
*/
-object IndexedSeq extends SeqFactory[IndexedSeq] {
- override lazy val ReusableCBF =
- scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[Nothing]]
+object IndexedSeq extends IndexedSeqFactory[IndexedSeq] {
class Impl[A](buf: ArrayBuffer[A]) extends AbstractSeq[A] with IndexedSeq[A] with Serializable {
def length = buf.length
def apply(idx: Int) = buf.apply(idx)
}
def newBuilder[A]: Builder[A, IndexedSeq[A]] = Vector.newBuilder[A]
+
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] =
ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
}
diff --git a/src/library/scala/collection/immutable/IntMap.scala b/src/library/scala/collection/immutable/IntMap.scala
index ab1faf363e..07e2ddaae2 100644
--- a/src/library/scala/collection/immutable/IntMap.scala
+++ b/src/library/scala/collection/immutable/IntMap.scala
@@ -12,6 +12,7 @@ package immutable
import scala.collection.generic.{ CanBuildFrom, BitOperations }
import scala.collection.mutable.{ Builder, MapBuilder }
+import scala.annotation.tailrec
/** Utility class for integer maps.
* @author David MacIver
@@ -50,8 +51,10 @@ object IntMap {
def apply(): Builder[(Int, B), IntMap[B]] = new MapBuilder[Int, B, IntMap[B]](empty[B])
}
- def empty[T] : IntMap[T] = IntMap.Nil;
- def singleton[T](key: Int, value: T): IntMap[T] = IntMap.Tip(key, value);
+ def empty[T] : IntMap[T] = IntMap.Nil
+
+ def singleton[T](key: Int, value: T): IntMap[T] = IntMap.Tip(key, value)
+
def apply[T](elems: (Int, T)*): IntMap[T] =
elems.foldLeft(empty[T])((x, y) => x.updated(y._1, y._2))
@@ -427,6 +430,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
/**
* The entry with the lowest key value considered in unsigned order.
*/
+ @tailrec
final def firstKey: Int = this match {
case Bin(_, _, l, r) => l.firstKey
case Tip(k, v) => k
@@ -436,6 +440,7 @@ sealed abstract class IntMap[+T] extends AbstractMap[Int, T]
/**
* The entry with the highest key value considered in unsigned order.
*/
+ @tailrec
final def lastKey: Int = this match {
case Bin(_, _, l, r) => r.lastKey
case Tip(k, v) => k
diff --git a/src/library/scala/collection/immutable/Iterable.scala b/src/library/scala/collection/immutable/Iterable.scala
index cc64d8ff3c..6e4eb1e45f 100644
--- a/src/library/scala/collection/immutable/Iterable.scala
+++ b/src/library/scala/collection/immutable/Iterable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/LinearSeq.scala b/src/library/scala/collection/immutable/LinearSeq.scala
index 5ede6d90d0..2109bd5211 100644
--- a/src/library/scala/collection/immutable/LinearSeq.scala
+++ b/src/library/scala/collection/immutable/LinearSeq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala
index 2d6952ff92..c01694960c 100644
--- a/src/library/scala/collection/immutable/List.scala
+++ b/src/library/scala/collection/immutable/List.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -85,7 +86,8 @@ sealed abstract class List[+A] extends AbstractSeq[A]
with LinearSeq[A]
with Product
with GenericTraversableTemplate[A, List]
- with LinearSeqOptimized[A, List[A]] {
+ with LinearSeqOptimized[A, List[A]]
+ with Serializable {
override def companion: GenericCompanion[List] = List
import scala.collection.{Iterable, Traversable, Seq, IndexedSeq}
@@ -158,7 +160,7 @@ sealed abstract class List[+A] extends AbstractSeq[A]
* @usecase def mapConserve(f: A => A): List[A]
* @inheritdoc
*/
- def mapConserve[B >: A <: AnyRef](f: A => B): List[B] = {
+ @inline final def mapConserve[B >: A <: AnyRef](f: A => B): List[B] = {
@tailrec
def loop(mapped: ListBuffer[B], unchanged: List[A], pending: List[A]): List[B] =
if (pending.isEmpty) {
@@ -263,7 +265,7 @@ sealed abstract class List[+A] extends AbstractSeq[A]
(b.toList, these)
}
- override def takeWhile(p: A => Boolean): List[A] = {
+ @inline final override def takeWhile(p: A => Boolean): List[A] = {
val b = new ListBuffer[A]
var these = this
while (!these.isEmpty && p(these.head)) {
@@ -273,7 +275,7 @@ sealed abstract class List[+A] extends AbstractSeq[A]
b.toList
}
- override def dropWhile(p: A => Boolean): List[A] = {
+ @inline final override def dropWhile(p: A => Boolean): List[A] = {
@tailrec
def loop(xs: List[A]): List[A] =
if (xs.isEmpty || !p(xs.head)) xs
@@ -282,7 +284,7 @@ sealed abstract class List[+A] extends AbstractSeq[A]
loop(this)
}
- override def span(p: A => Boolean): (List[A], List[A]) = {
+ @inline final override def span(p: A => Boolean): (List[A], List[A]) = {
val b = new ListBuffer[A]
var these = this
while (!these.isEmpty && p(these.head)) {
@@ -292,6 +294,16 @@ sealed abstract class List[+A] extends AbstractSeq[A]
(b.toList, these)
}
+ // Overridden with an implementation identical to the inherited one (at this time)
+ // solely so it can be finalized and thus inlinable.
+ @inline final override def foreach[U](f: A => U) {
+ var these = this
+ while (!these.isEmpty) {
+ f(these.head)
+ these = these.tail
+ }
+ }
+
override def reverse: List[A] = {
var result: List[A] = Nil
var these = this
@@ -301,7 +313,7 @@ sealed abstract class List[+A] extends AbstractSeq[A]
}
result
}
-
+
override def foldRight[B](z: B)(op: (A, B) => B): B =
reverse.foldLeft(z)((right, left) => op(left, right))
@@ -310,18 +322,6 @@ sealed abstract class List[+A] extends AbstractSeq[A]
override def toStream : Stream[A] =
if (isEmpty) Stream.Empty
else new Stream.Cons(head, tail.toStream)
-
- @inline override final
- def foreach[B](f: A => B) {
- var these = this
- while (!these.isEmpty) {
- f(these.head)
- these = these.tail
- }
- }
-
- @deprecated("use `distinct` instead", "2.8.0")
- def removeDuplicates: List[A] = distinct
}
/** The empty list.
@@ -386,9 +386,6 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend
* @define Coll `List`
*/
object List extends SeqFactory[List] {
-
- import scala.collection.{Iterable, Seq, IndexedSeq}
-
/** $genericCanBuildFromInfo */
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, List[A]] =
ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
@@ -398,255 +395,9 @@ object List extends SeqFactory[List] {
override def empty[A]: List[A] = Nil
override def apply[A](xs: A*): List[A] = xs.toList
-
- /** Create a sorted list with element values `v,,>n+1,, = step(v,,n,,)`
- * where `v,,0,, = start` and elements are in the range between `start`
- * (inclusive) and `end` (exclusive).
- *
- * @param start the start value of the list
- * @param end the end value of the list
- * @param step the increment function of the list, which given `v,,n,,`,
- * computes `v,,n+1,,`. Must be monotonically increasing
- * or decreasing.
- * @return the sorted list of all integers in range `[start;end)`.
- */
- @deprecated("use `iterate` instead", "2.8.0")
- def range(start: Int, end: Int, step: Int => Int): List[Int] = {
- val up = step(start) > start
- val down = step(start) < start
- val b = new ListBuffer[Int]
- var i = start
- while ((!up || i < end) && (!down || i > end)) {
- b += i
- val next = step(i)
- if (i == next)
- throw new IllegalArgumentException("the step function did not make any progress on "+ i)
- i = next
- }
- b.toList
- }
-
- /** Create a list containing several copies of an element.
- *
- * @param n the length of the resulting list
- * @param elem the element composing the resulting list
- * @return a list composed of `n` elements all equal to `elem`
- */
- @deprecated("use `fill` instead", "2.8.0")
- def make[A](n: Int, elem: A): List[A] = {
- val b = new ListBuffer[A]
- var i = 0
- while (i < n) {
- b += elem
- i += 1
- }
- b.toList
- }
-
- /** Concatenate all the elements of a given list of lists.
- *
- * @param xss the list of lists that are to be concatenated
- * @return the concatenation of all the lists
- */
- @deprecated("use `xss.flatten` instead of `List.flatten(xss)`", "2.8.0")
- def flatten[A](xss: List[List[A]]): List[A] = {
- val b = new ListBuffer[A]
- for (xs <- xss) {
- var xc = xs
- while (!xc.isEmpty) {
- b += xc.head
- xc = xc.tail
- }
- }
- b.toList
- }
-
- /** Transforms a list of pairs into a pair of lists.
- *
- * @param xs the list of pairs to unzip
- * @return a pair of lists.
- */
- @deprecated("use `xs.unzip` instead of `List.unzip(xs)`", "2.8.0")
- def unzip[A,B](xs: List[(A,B)]): (List[A], List[B]) = {
- val b1 = new ListBuffer[A]
- val b2 = new ListBuffer[B]
- var xc = xs
- while (!xc.isEmpty) {
- b1 += xc.head._1
- b2 += xc.head._2
- xc = xc.tail
- }
- (b1.toList, b2.toList)
- }
-
- /** Transforms an iterable of pairs into a pair of lists.
- *
- * @param xs the iterable of pairs to unzip
- * @return a pair of lists.
- */
- @deprecated("use `xs.unzip` instead of `List.unzip(xs)`", "2.8.0")
- def unzip[A,B](xs: Iterable[(A,B)]): (List[A], List[B]) =
- xs.foldRight[(List[A], List[B])]((Nil, Nil)) {
- case ((x, y), (xs, ys)) => (x :: xs, y :: ys)
- }
-
- /**
- * Returns the `Left` values in the given `Iterable` of `Either`s.
- */
- @deprecated("use `xs collect { case Left(x: A) => x }` instead of `List.lefts(xs)`", "2.8.0")
- def lefts[A, B](es: Iterable[Either[A, B]]) =
- es.foldRight[List[A]](Nil)((e, as) => e match {
- case Left(a) => a :: as
- case Right(_) => as
- })
-
- /**
- * Returns the `Right` values in the given `Iterable` of `Either`s.
- */
- @deprecated("use `xs collect { case Right(x: B) => x }` instead of `List.rights(xs)`", "2.8.0")
- def rights[A, B](es: Iterable[Either[A, B]]) =
- es.foldRight[List[B]](Nil)((e, bs) => e match {
- case Left(_) => bs
- case Right(b) => b :: bs
- })
-
- /** Transforms an Iterable of Eithers into a pair of lists.
- *
- * @param es the iterable of Eithers to separate
- * @return a pair of lists.
- */
- @deprecated("use `(for (Left(x) <- es) yield x, for (Right(x) <- es) yield x)` instead", "2.8.0")
- def separate[A,B](es: Iterable[Either[A, B]]): (List[A], List[B]) =
- es.foldRight[(List[A], List[B])]((Nil, Nil)) {
- case (Left(a), (lefts, rights)) => (a :: lefts, rights)
- case (Right(b), (lefts, rights)) => (lefts, b :: rights)
- }
-
- /** Converts an iterator to a list.
- *
- * @param it the iterator to convert
- * @return a list that contains the elements returned by successive
- * calls to `it.next`
- */
- @deprecated("use `it.toList` instead of `List.toList(it)`", "2.8.0")
- def fromIterator[A](it: Iterator[A]): List[A] = it.toList
-
- /** Converts an array into a list.
- *
- * @param arr the array to convert
- * @return a list that contains the same elements than `arr`
- * in the same order
- */
- @deprecated("use `array.toList` instead of `List.fromArray(array)`", "2.8.0")
- def fromArray[A](arr: Array[A]): List[A] = fromArray(arr, 0, arr.length)
-
- /** Converts a range of an array into a list.
- *
- * @param arr the array to convert
- * @param start the first index to consider
- * @param len the length of the range to convert
- * @return a list that contains the same elements than `arr`
- * in the same order
- */
- @deprecated("use `array.view(start, end).toList` instead of `List.fromArray(array, start, end)`", "2.8.0")
- def fromArray[A](arr: Array[A], start: Int, len: Int): List[A] = {
- var res: List[A] = Nil
- var i = start + len
- while (i > start) {
- i -= 1
- res = arr(i) :: res
- }
- res
- }
-
- /** Returns the list resulting from applying the given function `f`
- * to corresponding elements of the argument lists.
- *
- * @param f function to apply to each pair of elements.
- * @return `[f(a,,0,,,b,,0,,), ..., f(a,,n,,,b,,n,,)]` if the lists are
- * `[a,,0,,, ..., a,,k,,]`, `[b,,0,,, ..., b,,l,,]` and
- * `n = min(k,l)`
- */
- @deprecated("use `(xs, ys).zipped.map(f)` instead of `List.map2(xs, ys)(f)`", "2.8.0")
- def map2[A,B,C](xs: List[A], ys: List[B])(f: (A, B) => C): List[C] = {
- val b = new ListBuffer[C]
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- b += f(xc.head, yc.head)
- xc = xc.tail
- yc = yc.tail
- }
- b.toList
- }
-
- /** Tests whether the given predicate `p` holds
- * for all corresponding elements of the argument lists.
- *
- * @param f function to apply to each pair of elements.
- * @return `(p(a<sub>0</sub>,b<sub>0</sub>) &amp;&amp;
- * ... &amp;&amp; p(a<sub>n</sub>,b<sub>n</sub>))]`
- * if the lists are `[a<sub>0</sub>, ..., a<sub>k</sub>]`;
- * `[b<sub>0</sub>, ..., b<sub>l</sub>]`
- * and `n = min(k,l)`
- */
- @deprecated("use `(xs, ys).zipped.forall(f)` instead of `List.forall2(xs, ys)(f)`", "2.8.0")
- def forall2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = {
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- if (!f(xc.head, yc.head)) return false
- xc = xc.tail
- yc = yc.tail
- }
- true
- }
-
- /** Tests whether the given predicate `p` holds
- * for some corresponding elements of the argument lists.
- *
- * @param f function to apply to each pair of elements.
- * @return `n != 0 &amp;&amp; (p(a<sub>0</sub>,b<sub>0</sub>) ||
- * ... || p(a<sub>n</sub>,b<sub>n</sub>))]` if the lists are
- * `[a<sub>0</sub>, ..., a<sub>k</sub>]`,
- * `[b<sub>0</sub>, ..., b<sub>l</sub>]` and
- * `n = min(k,l)`
- */
- @deprecated("use `(xs, ys).zipped.exists(f)` instead of `List.exists2(xs, ys)(f)`", "2.8.0")
- def exists2[A,B](xs: List[A], ys: List[B])(f: (A, B) => Boolean): Boolean = {
- var xc = xs
- var yc = ys
- while (!xc.isEmpty && !yc.isEmpty) {
- if (f(xc.head, yc.head)) return true
- xc = xc.tail
- yc = yc.tail
- }
- false
- }
-
- /** Transposes a list of lists.
- * pre: All element lists have the same length.
- *
- * @param xss the list of lists
- * @return the transposed list of lists
- */
- @deprecated("use `xss.transpose` instead of `List.transpose(xss)`", "2.8.0")
- def transpose[A](xss: List[List[A]]): List[List[A]] = {
- val buf = new ListBuffer[List[A]]
- var yss = xss
- while (!yss.head.isEmpty) {
- buf += (yss map (_.head))
- yss = (yss map (_.tail))
- }
- buf.toList
- }
}
/** Only used for list serialization */
-@SerialVersionUID(0L - 8287891243975527522L)
-private[scala] case object ListSerializeStart
-
-/** Only used for list serialization */
@SerialVersionUID(0L - 8476791151975527571L)
private[scala] case object ListSerializeEnd
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 75817350e5..47593a07ab 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/ListSet.scala b/src/library/scala/collection/immutable/ListSet.scala
index 6cf6c4259e..5836321010 100644
--- a/src/library/scala/collection/immutable/ListSet.scala
+++ b/src/library/scala/collection/immutable/ListSet.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -75,7 +76,7 @@ class ListSet[A] extends AbstractSet[A]
* @return number of set elements.
*/
override def size: Int = 0
- override def isEmpty: Boolean = true;
+ override def isEmpty: Boolean = true
/** Checks if this set contains element `elem`.
*
@@ -100,7 +101,7 @@ class ListSet[A] extends AbstractSet[A]
*/
override def ++(xs: GenTraversableOnce[A]): ListSet[A] =
if (xs.isEmpty) this
- else (new ListSet.ListSetBuilder(this) ++= xs.seq).result
+ else (new ListSet.ListSetBuilder(this) ++= xs.seq).result()
private[ListSet] def unchecked_+(e: A): ListSet[A] = new Node(e)
private[ListSet] def unchecked_outer: ListSet[A] =
@@ -120,18 +121,18 @@ class ListSet[A] extends AbstractSet[A]
that = that.tail
res
}
- else Iterator.empty.next
+ else Iterator.empty.next()
}
/**
* @throws Predef.NoSuchElementException
*/
- override def head: A = throw new NoSuchElementException("Set has no elements");
+ override def head: A = throw new NoSuchElementException("Set has no elements")
/**
* @throws Predef.NoSuchElementException
*/
- override def tail: ListSet[A] = throw new NoSuchElementException("Next of an empty set");
+ override def tail: ListSet[A] = throw new NoSuchElementException("Next of an empty set")
override def stringPrefix = "ListSet"
diff --git a/src/library/scala/collection/immutable/LongMap.scala b/src/library/scala/collection/immutable/LongMap.scala
index 2a2910439a..506546c5ba 100644
--- a/src/library/scala/collection/immutable/LongMap.scala
+++ b/src/library/scala/collection/immutable/LongMap.scala
@@ -12,6 +12,7 @@ package immutable
import scala.collection.generic.{ CanBuildFrom, BitOperations }
import scala.collection.mutable.{ Builder, MapBuilder }
+import scala.annotation.tailrec
/** Utility class for long maps.
* @author David MacIver
@@ -77,8 +78,6 @@ object LongMap {
}
}
-import LongMap._
-
// Iterator over a non-empty LongMap.
private[immutable] abstract class LongMapIterator[V, T](it: LongMap[V]) extends AbstractIterator[T] {
@@ -98,7 +97,7 @@ private[immutable] abstract class LongMapIterator[V, T](it: LongMap[V]) extends
buffer(index) = x.asInstanceOf[AnyRef]
index += 1
}
- push(it);
+ push(it)
/**
* What value do we assign to a tip?
@@ -179,7 +178,7 @@ extends AbstractMap[Long, T]
*/
override final def foreach[U](f: ((Long, T)) => U): Unit = this match {
case LongMap.Bin(_, _, left, right) => { left.foreach(f); right.foreach(f) }
- case LongMap.Tip(key, value) => f((key, value));
+ case LongMap.Tip(key, value) => f((key, value))
case LongMap.Nil =>
}
@@ -418,5 +417,20 @@ extends AbstractMap[Long, T]
def ++[S >: T](that: LongMap[S]) =
this.unionWith[S](that, (key, x, y) => y)
+
+ @tailrec
+ final def firstKey: Long = this match {
+ case LongMap.Bin(_, _, l, r) => l.firstKey
+ case LongMap.Tip(k, v) => k
+ case LongMap.Nil => sys.error("Empty set")
+ }
+
+ @tailrec
+ final def lastKey: Long = this match {
+ case LongMap.Bin(_, _, l, r) => r.lastKey
+ case LongMap.Tip(k , v) => k
+ case LongMap.Nil => sys.error("Empty set")
+ }
+
}
diff --git a/src/library/scala/collection/immutable/Map.scala b/src/library/scala/collection/immutable/Map.scala
index 2ebf5035e1..a3f5c85961 100644
--- a/src/library/scala/collection/immutable/Map.scala
+++ b/src/library/scala/collection/immutable/Map.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/MapLike.scala b/src/library/scala/collection/immutable/MapLike.scala
index 7e60f07847..f6041464e7 100644
--- a/src/library/scala/collection/immutable/MapLike.scala
+++ b/src/library/scala/collection/immutable/MapLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -123,7 +124,7 @@ self =>
def transform[C, That](f: (A, B) => C)(implicit bf: CanBuildFrom[This, (A, C), That]): That = {
val b = bf(repr)
for ((key, value) <- this) b += ((key, f(key, value)))
- b.result
+ b.result()
}
}
diff --git a/src/library/scala/collection/immutable/MapProxy.scala b/src/library/scala/collection/immutable/MapProxy.scala
index f3f04ec346..f9f19c021d 100644
--- a/src/library/scala/collection/immutable/MapProxy.scala
+++ b/src/library/scala/collection/immutable/MapProxy.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
/**
diff --git a/src/library/scala/collection/immutable/NumericRange.scala b/src/library/scala/collection/immutable/NumericRange.scala
index d3be299f89..486c2b6c8f 100644
--- a/src/library/scala/collection/immutable/NumericRange.scala
+++ b/src/library/scala/collection/immutable/NumericRange.scala
@@ -6,12 +6,11 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
package immutable
import mutable.{ Builder, ListBuffer }
-import generic._
/** `NumericRange` is a more generic version of the
* `Range` class which works with arbitrary types.
@@ -81,17 +80,6 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
// to guard against any (most likely illusory) performance drop. They should
// be eliminated one way or another.
- // Counts how many elements from the start meet the given test.
- private def skipCount(p: T => Boolean): Int = {
- var current = start
- var counted = 0
-
- while (counted < length && p(current)) {
- counted += 1
- current += step
- }
- counted
- }
// Tests whether a number is within the endpoints, without testing
// whether it is a member of the sequence (i.e. when step > 1.)
private def isWithinBoundaries(elem: T) = !isEmpty && (
@@ -124,21 +112,21 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
if (idx < 0 || idx >= length) throw new IndexOutOfBoundsException(idx.toString)
else locationAfterN(idx)
}
-
+
import NumericRange.defaultOrdering
-
+
override def min[T1 >: T](implicit ord: Ordering[T1]): T =
if (ord eq defaultOrdering(num)) {
if (num.signum(step) > 0) start
else last
} else super.min(ord)
-
- override def max[T1 >: T](implicit ord: Ordering[T1]): T =
+
+ override def max[T1 >: T](implicit ord: Ordering[T1]): T =
if (ord eq defaultOrdering(num)) {
if (num.signum(step) > 0) last
else start
} else super.max(ord)
-
+
// Motivated by the desire for Double ranges with BigDecimal precision,
// we need some way to map a Range and get another Range. This can't be
// done in any fully general way because Ranges are not arbitrary
@@ -182,12 +170,11 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
def containsTyped(x: T): Boolean =
isWithinBoundaries(x) && (((x - start) % step) == zero)
- override def contains(x: Any): Boolean =
+ override def contains[A1 >: T](x: A1): Boolean =
try containsTyped(x.asInstanceOf[T])
catch { case _: ClassCastException => false }
final override def sum[B >: T](implicit num: Numeric[B]): B = {
- import num.Ops
if (isEmpty) this.num fromInt 0
else if (numRangeElements == 1) head
else ((this.num fromInt numRangeElements) * (head + last) / (this.num fromInt 2))
@@ -213,7 +200,7 @@ extends AbstractSeq[T] with IndexedSeq[T] with Serializable {
/** A companion object for numeric ranges.
*/
object NumericRange {
-
+
/** Calculates the number of elements in a range given start, end, step, and
* whether or not it is inclusive. Throws an exception if step == 0 or
* the number of elements exceeds the maximum Int.
@@ -234,10 +221,10 @@ object NumericRange {
if (!isInclusive && zero == remainder) 0 else 1
)
- /** The edge cases keep coming. Since e.g.
- * Long.MaxValue + 1 == Long.MinValue
- * we do some more improbable seeming checks lest
- * overflow turn up as an empty range.
+ /* The edge cases keep coming. Since e.g.
+ * Long.MaxValue + 1 == Long.MinValue
+ * we do some more improbable seeming checks lest
+ * overflow turn up as an empty range.
*/
// The second condition contradicts an empty result.
val isOverflow = longCount == 0 && num.lt(num.plus(start, step), end) == upward
@@ -272,7 +259,7 @@ object NumericRange {
new Exclusive(start, end, step)
def inclusive[T](start: T, end: T, step: T)(implicit num: Integral[T]): Inclusive[T] =
new Inclusive(start, end, step)
-
+
private[collection] val defaultOrdering = Map[Numeric[_], Ordering[_]](
Numeric.BigIntIsIntegral -> Ordering.BigInt,
Numeric.IntIsIntegral -> Ordering.Int,
@@ -284,6 +271,6 @@ object NumericRange {
Numeric.DoubleAsIfIntegral -> Ordering.Double,
Numeric.BigDecimalAsIfIntegral -> Ordering.BigDecimal
)
-
+
}
diff --git a/src/library/scala/collection/immutable/PagedSeq.scala b/src/library/scala/collection/immutable/PagedSeq.scala
index 952107bf78..e190d022d7 100644
--- a/src/library/scala/collection/immutable/PagedSeq.scala
+++ b/src/library/scala/collection/immutable/PagedSeq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import java.io._
@@ -30,7 +31,7 @@ object PagedSeq {
new PagedSeq[T]((data: Array[T], start: Int, len: Int) => {
var i = 0
while (i < len && source.hasNext) {
- data(start + i) = source.next
+ data(start + i) = source.next()
i += 1
}
if (i == 0) -1 else i
@@ -51,7 +52,7 @@ object PagedSeq {
if (cnt == len) cnt
else (more(data, start + cnt, len - cnt) max 0) + cnt
} else if (source.hasNext) {
- current = source.next
+ current = source.next()
more(data, start, len)
} else -1
new PagedSeq(more(_: Array[Char], _: Int, _: Int))
diff --git a/src/library/scala/collection/immutable/Queue.scala b/src/library/scala/collection/immutable/Queue.scala
index 7d2ff95792..c55b46bf05 100644
--- a/src/library/scala/collection/immutable/Queue.scala
+++ b/src/library/scala/collection/immutable/Queue.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala
index 802e16605d..09f8143b55 100644
--- a/src/library/scala/collection/immutable/Range.scala
+++ b/src/library/scala/collection/immutable/Range.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection.immutable
+package scala
+package collection.immutable
import scala.collection.parallel.immutable.ParRange
@@ -77,17 +78,18 @@ extends scala.collection.AbstractSeq[Int]
final val terminalElement = start + numRangeElements * step
override def last = if (isEmpty) Nil.last else lastElement
+ override def head = if (isEmpty) Nil.head else start
override def min[A1 >: Int](implicit ord: Ordering[A1]): Int =
if (ord eq Ordering.Int) {
- if (step > 0) start
+ if (step > 0) head
else last
} else super.min(ord)
override def max[A1 >: Int](implicit ord: Ordering[A1]): Int =
if (ord eq Ordering.Int) {
if (step > 0) last
- else start
+ else head
} else super.max(ord)
protected def copy(start: Int, end: Int, step: Int): Range = new Range(start, end, step)
@@ -111,6 +113,7 @@ extends scala.collection.AbstractSeq[Int]
fail()
}
+ @deprecated("Range.foreach() is now self-contained, making this auxiliary method redundant.", "2.10.1")
def validateRangeBoundaries(f: Int => Any): Boolean = {
validateMaxLength()
@@ -133,14 +136,19 @@ extends scala.collection.AbstractSeq[Int]
}
@inline final override def foreach[@specialized(Unit) U](f: Int => U) {
- if (validateRangeBoundaries(f)) {
- var i = start
- val terminal = terminalElement
- val step = this.step
- while (i != terminal) {
- f(i)
- i += step
- }
+ validateMaxLength()
+ val isCommonCase = (start != Int.MinValue || end != Int.MinValue)
+ var i = start
+ var count = 0
+ val terminal = terminalElement
+ val step = this.step
+ while(
+ if(isCommonCase) { i != terminal }
+ else { count < numRangeElements }
+ ) {
+ f(i)
+ count += 1
+ i += step
}
}
@@ -325,7 +333,7 @@ object Range {
}
}
def count(start: Int, end: Int, step: Int): Int =
- count(start, end, step, false)
+ count(start, end, step, isInclusive = false)
class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) {
// override def par = new ParRange(this)
diff --git a/src/library/scala/collection/immutable/RedBlack.scala b/src/library/scala/collection/immutable/RedBlack.scala
deleted file mode 100644
index 9739e8f3f3..0000000000
--- a/src/library/scala/collection/immutable/RedBlack.scala
+++ /dev/null
@@ -1,293 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2005-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala
-package collection
-package immutable
-
-/** Old base class that was used by previous implementations of `TreeMaps` and `TreeSets`.
- *
- * Deprecated due to various performance bugs (see [[https://issues.scala-lang.org/browse/SI-5331 SI-5331]] for more information).
- *
- * @since 2.3
- */
-@deprecated("use `TreeMap` or `TreeSet` instead", "2.10.0")
-@SerialVersionUID(8691885935445612921L)
-abstract class RedBlack[A] extends Serializable {
-
- def isSmaller(x: A, y: A): Boolean
-
- private def blacken[B](t: Tree[B]): Tree[B] = t match {
- case RedTree(k, v, l, r) => BlackTree(k, v, l, r)
- case t => t
- }
- private def mkTree[B](isBlack: Boolean, k: A, v: B, l: Tree[B], r: Tree[B]) =
- if (isBlack) BlackTree(k, v, l, r) else RedTree(k, v, l, r)
-
- abstract class Tree[+B] extends Serializable {
- def isEmpty: Boolean
- def isBlack: Boolean
- def lookup(x: A): Tree[B]
- def update[B1 >: B](k: A, v: B1): Tree[B1] = blacken(upd(k, v))
- def delete(k: A): Tree[B] = blacken(del(k))
- def range(from: Option[A], until: Option[A]): Tree[B] = blacken(rng(from, until))
- def foreach[U](f: (A, B) => U)
- def toStream: Stream[(A,B)]
- def iterator: Iterator[(A, B)]
- def upd[B1 >: B](k: A, v: B1): Tree[B1]
- def del(k: A): Tree[B]
- def smallest: NonEmpty[B]
- def rng(from: Option[A], until: Option[A]): Tree[B]
- def first : A
- def last : A
- def count : Int
- }
- abstract class NonEmpty[+B] extends Tree[B] with Serializable {
- def isEmpty = false
- def key: A
- def value: B
- def left: Tree[B]
- def right: Tree[B]
- def lookup(k: A): Tree[B] =
- if (isSmaller(k, key)) left.lookup(k)
- else if (isSmaller(key, k)) right.lookup(k)
- else this
- private[this] def balanceLeft[B1 >: B](isBlack: Boolean, z: A, zv: B, l: Tree[B1], d: Tree[B1])/*: NonEmpty[B1]*/ = l match {
- case RedTree(y, yv, RedTree(x, xv, a, b), c) =>
- RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d))
- case RedTree(x, xv, a, RedTree(y, yv, b, c)) =>
- RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d))
- case _ =>
- mkTree(isBlack, z, zv, l, d)
- }
- private[this] def balanceRight[B1 >: B](isBlack: Boolean, x: A, xv: B, a: Tree[B1], r: Tree[B1])/*: NonEmpty[B1]*/ = r match {
- case RedTree(z, zv, RedTree(y, yv, b, c), d) =>
- RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d))
- case RedTree(y, yv, b, RedTree(z, zv, c, d)) =>
- RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d))
- case _ =>
- mkTree(isBlack, x, xv, a, r)
- }
- def upd[B1 >: B](k: A, v: B1): Tree[B1] = {
- if (isSmaller(k, key)) balanceLeft(isBlack, key, value, left.upd(k, v), right)
- else if (isSmaller(key, k)) balanceRight(isBlack, key, value, left, right.upd(k, v))
- else mkTree(isBlack, k, v, left, right)
- }
- // Based on Stefan Kahrs' Haskell version of Okasaki's Red&Black Trees
- // http://www.cse.unsw.edu.au/~dons/data/RedBlackTree.html
- def del(k: A): Tree[B] = {
- def balance(x: A, xv: B, tl: Tree[B], tr: Tree[B]) = (tl, tr) match {
- case (RedTree(y, yv, a, b), RedTree(z, zv, c, d)) =>
- RedTree(x, xv, BlackTree(y, yv, a, b), BlackTree(z, zv, c, d))
- case (RedTree(y, yv, RedTree(z, zv, a, b), c), d) =>
- RedTree(y, yv, BlackTree(z, zv, a, b), BlackTree(x, xv, c, d))
- case (RedTree(y, yv, a, RedTree(z, zv, b, c)), d) =>
- RedTree(z, zv, BlackTree(y, yv, a, b), BlackTree(x, xv, c, d))
- case (a, RedTree(y, yv, b, RedTree(z, zv, c, d))) =>
- RedTree(y, yv, BlackTree(x, xv, a, b), BlackTree(z, zv, c, d))
- case (a, RedTree(y, yv, RedTree(z, zv, b, c), d)) =>
- RedTree(z, zv, BlackTree(x, xv, a, b), BlackTree(y, yv, c, d))
- case (a, b) =>
- BlackTree(x, xv, a, b)
- }
- def subl(t: Tree[B]) = t match {
- case BlackTree(x, xv, a, b) => RedTree(x, xv, a, b)
- case _ => sys.error("Defect: invariance violation; expected black, got "+t)
- }
- def balLeft(x: A, xv: B, tl: Tree[B], tr: Tree[B]) = (tl, tr) match {
- case (RedTree(y, yv, a, b), c) =>
- RedTree(x, xv, BlackTree(y, yv, a, b), c)
- case (bl, BlackTree(y, yv, a, b)) =>
- balance(x, xv, bl, RedTree(y, yv, a, b))
- case (bl, RedTree(y, yv, BlackTree(z, zv, a, b), c)) =>
- RedTree(z, zv, BlackTree(x, xv, bl, a), balance(y, yv, b, subl(c)))
- case _ => sys.error("Defect: invariance violation at "+right)
- }
- def balRight(x: A, xv: B, tl: Tree[B], tr: Tree[B]) = (tl, tr) match {
- case (a, RedTree(y, yv, b, c)) =>
- RedTree(x, xv, a, BlackTree(y, yv, b, c))
- case (BlackTree(y, yv, a, b), bl) =>
- balance(x, xv, RedTree(y, yv, a, b), bl)
- case (RedTree(y, yv, a, BlackTree(z, zv, b, c)), bl) =>
- RedTree(z, zv, balance(y, yv, subl(a), b), BlackTree(x, xv, c, bl))
- case _ => sys.error("Defect: invariance violation at "+left)
- }
- def delLeft = left match {
- case _: BlackTree[_] => balLeft(key, value, left.del(k), right)
- case _ => RedTree(key, value, left.del(k), right)
- }
- def delRight = right match {
- case _: BlackTree[_] => balRight(key, value, left, right.del(k))
- case _ => RedTree(key, value, left, right.del(k))
- }
- def append(tl: Tree[B], tr: Tree[B]): Tree[B] = (tl, tr) match {
- case (Empty, t) => t
- case (t, Empty) => t
- case (RedTree(x, xv, a, b), RedTree(y, yv, c, d)) =>
- append(b, c) match {
- case RedTree(z, zv, bb, cc) => RedTree(z, zv, RedTree(x, xv, a, bb), RedTree(y, yv, cc, d))
- case bc => RedTree(x, xv, a, RedTree(y, yv, bc, d))
- }
- case (BlackTree(x, xv, a, b), BlackTree(y, yv, c, d)) =>
- append(b, c) match {
- case RedTree(z, zv, bb, cc) => RedTree(z, zv, BlackTree(x, xv, a, bb), BlackTree(y, yv, cc, d))
- case bc => balLeft(x, xv, a, BlackTree(y, yv, bc, d))
- }
- case (a, RedTree(x, xv, b, c)) => RedTree(x, xv, append(a, b), c)
- case (RedTree(x, xv, a, b), c) => RedTree(x, xv, a, append(b, c))
- }
- // RedBlack is neither A : Ordering[A], nor A <% Ordered[A]
- k match {
- case _ if isSmaller(k, key) => delLeft
- case _ if isSmaller(key, k) => delRight
- case _ => append(left, right)
- }
- }
-
- def smallest: NonEmpty[B] = if (left.isEmpty) this else left.smallest
-
- def toStream: Stream[(A,B)] =
- left.toStream ++ Stream((key,value)) ++ right.toStream
-
- def iterator: Iterator[(A, B)] =
- left.iterator ++ Iterator.single(Pair(key, value)) ++ right.iterator
-
- def foreach[U](f: (A, B) => U) {
- left foreach f
- f(key, value)
- right foreach f
- }
-
- override def rng(from: Option[A], until: Option[A]): Tree[B] = {
- if (from == None && until == None) return this
- if (from != None && isSmaller(key, from.get)) return right.rng(from, until);
- if (until != None && (isSmaller(until.get,key) || !isSmaller(key,until.get)))
- return left.rng(from, until);
- val newLeft = left.rng(from, None)
- val newRight = right.rng(None, until)
- if ((newLeft eq left) && (newRight eq right)) this
- else if (newLeft eq Empty) newRight.upd(key, value);
- else if (newRight eq Empty) newLeft.upd(key, value);
- else rebalance(newLeft, newRight)
- }
-
- // The zipper returned might have been traversed left-most (always the left child)
- // or right-most (always the right child). Left trees are traversed right-most,
- // and right trees are traversed leftmost.
-
- // Returns the zipper for the side with deepest black nodes depth, a flag
- // indicating whether the trees were unbalanced at all, and a flag indicating
- // whether the zipper was traversed left-most or right-most.
-
- // If the trees were balanced, returns an empty zipper
- private[this] def compareDepth(left: Tree[B], right: Tree[B]): (List[NonEmpty[B]], Boolean, Boolean, Int) = {
- // Once a side is found to be deeper, unzip it to the bottom
- def unzip(zipper: List[NonEmpty[B]], leftMost: Boolean): List[NonEmpty[B]] = {
- val next = if (leftMost) zipper.head.left else zipper.head.right
- next match {
- case node: NonEmpty[_] => unzip(node :: zipper, leftMost)
- case Empty => zipper
- }
- }
-
- // Unzip left tree on the rightmost side and right tree on the leftmost side until one is
- // found to be deeper, or the bottom is reached
- def unzipBoth(left: Tree[B],
- right: Tree[B],
- leftZipper: List[NonEmpty[B]],
- rightZipper: List[NonEmpty[B]],
- smallerDepth: Int): (List[NonEmpty[B]], Boolean, Boolean, Int) = (left, right) match {
- case (l @ BlackTree(_, _, _, _), r @ BlackTree(_, _, _, _)) =>
- unzipBoth(l.right, r.left, l :: leftZipper, r :: rightZipper, smallerDepth + 1)
- case (l @ RedTree(_, _, _, _), r @ RedTree(_, _, _, _)) =>
- unzipBoth(l.right, r.left, l :: leftZipper, r :: rightZipper, smallerDepth)
- case (_, r @ RedTree(_, _, _, _)) =>
- unzipBoth(left, r.left, leftZipper, r :: rightZipper, smallerDepth)
- case (l @ RedTree(_, _, _, _), _) =>
- unzipBoth(l.right, right, l :: leftZipper, rightZipper, smallerDepth)
- case (Empty, Empty) =>
- (Nil, true, false, smallerDepth)
- case (Empty, r @ BlackTree(_, _, _, _)) =>
- val leftMost = true
- (unzip(r :: rightZipper, leftMost), false, leftMost, smallerDepth)
- case (l @ BlackTree(_, _, _, _), Empty) =>
- val leftMost = false
- (unzip(l :: leftZipper, leftMost), false, leftMost, smallerDepth)
- }
- unzipBoth(left, right, Nil, Nil, 0)
- }
-
- private[this] def rebalance(newLeft: Tree[B], newRight: Tree[B]) = {
- // This is like drop(n-1), but only counting black nodes
- def findDepth(zipper: List[NonEmpty[B]], depth: Int): List[NonEmpty[B]] = zipper match {
- case BlackTree(_, _, _, _) :: tail =>
- if (depth == 1) zipper else findDepth(tail, depth - 1)
- case _ :: tail => findDepth(tail, depth)
- case Nil => sys.error("Defect: unexpected empty zipper while computing range")
- }
-
- // Blackening the smaller tree avoids balancing problems on union;
- // this can't be done later, though, or it would change the result of compareDepth
- val blkNewLeft = blacken(newLeft)
- val blkNewRight = blacken(newRight)
- val (zipper, levelled, leftMost, smallerDepth) = compareDepth(blkNewLeft, blkNewRight)
-
- if (levelled) {
- BlackTree(key, value, blkNewLeft, blkNewRight)
- } else {
- val zipFrom = findDepth(zipper, smallerDepth)
- val union = if (leftMost) {
- RedTree(key, value, blkNewLeft, zipFrom.head)
- } else {
- RedTree(key, value, zipFrom.head, blkNewRight)
- }
- val zippedTree = zipFrom.tail.foldLeft(union: Tree[B]) { (tree, node) =>
- if (leftMost)
- balanceLeft(node.isBlack, node.key, node.value, tree, node.right)
- else
- balanceRight(node.isBlack, node.key, node.value, node.left, tree)
- }
- zippedTree
- }
- }
- def first = if (left .isEmpty) key else left.first
- def last = if (right.isEmpty) key else right.last
- def count = 1 + left.count + right.count
- }
- case object Empty extends Tree[Nothing] {
- def isEmpty = true
- def isBlack = true
- def lookup(k: A): Tree[Nothing] = this
- def upd[B](k: A, v: B): Tree[B] = RedTree(k, v, Empty, Empty)
- def del(k: A): Tree[Nothing] = this
- def smallest: NonEmpty[Nothing] = throw new NoSuchElementException("empty map")
- def iterator: Iterator[(A, Nothing)] = Iterator.empty
- def toStream: Stream[(A,Nothing)] = Stream.empty
-
- def foreach[U](f: (A, Nothing) => U) {}
-
- def rng(from: Option[A], until: Option[A]) = this
- def first = throw new NoSuchElementException("empty map")
- def last = throw new NoSuchElementException("empty map")
- def count = 0
- }
- case class RedTree[+B](override val key: A,
- override val value: B,
- override val left: Tree[B],
- override val right: Tree[B]) extends NonEmpty[B] {
- def isBlack = false
- }
- case class BlackTree[+B](override val key: A,
- override val value: B,
- override val left: Tree[B],
- override val right: Tree[B]) extends NonEmpty[B] {
- def isBlack = true
- }
-}
diff --git a/src/library/scala/collection/immutable/RedBlackTree.scala b/src/library/scala/collection/immutable/RedBlackTree.scala
index 0254e9ca3a..48bccde0e8 100644
--- a/src/library/scala/collection/immutable/RedBlackTree.scala
+++ b/src/library/scala/collection/immutable/RedBlackTree.scala
@@ -18,19 +18,19 @@ import scala.annotation.meta.getter
/** An object containing the RedBlack tree implementation used by for `TreeMaps` and `TreeSets`.
*
* Implementation note: since efficiency is important for data structures this implementation
- * uses <code>null</code> to represent empty trees. This also means pattern matching cannot
+ * uses `null` to represent empty trees. This also means pattern matching cannot
* easily be used. The API represented by the RedBlackTree object tries to hide these
* optimizations behind a reasonably clean API.
*
* @since 2.10
*/
-private[immutable]
+private[collection]
object RedBlackTree {
def isEmpty(tree: Tree[_, _]): Boolean = tree eq null
- def contains[A](tree: Tree[A, _], x: A)(implicit ordering: Ordering[A]): Boolean = lookup(tree, x) ne null
- def get[A, B](tree: Tree[A, B], x: A)(implicit ordering: Ordering[A]): Option[B] = lookup(tree, x) match {
+ def contains[A: Ordering](tree: Tree[A, _], x: A): Boolean = lookup(tree, x) ne null
+ def get[A: Ordering, B](tree: Tree[A, B], x: A): Option[B] = lookup(tree, x) match {
case null => None
case tree => Some(tree.value)
}
@@ -44,8 +44,27 @@ object RedBlackTree {
}
def count(tree: Tree[_, _]) = if (tree eq null) 0 else tree.count
- def update[A, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean)(implicit ordering: Ordering[A]): Tree[A, B1] = blacken(upd(tree, k, v, overwrite))
- def delete[A, B](tree: Tree[A, B], k: A)(implicit ordering: Ordering[A]): Tree[A, B] = blacken(del(tree, k))
+ /**
+ * Count all the nodes with keys greater than or equal to the lower bound and less than the upper bound.
+ * The two bounds are optional.
+ */
+ def countInRange[A](tree: Tree[A, _], from: Option[A], to:Option[A])(implicit ordering: Ordering[A]) : Int =
+ if (tree eq null) 0 else
+ (from, to) match {
+ // with no bounds use this node's count
+ case (None, None) => tree.count
+ // if node is less than the lower bound, try the tree on the right, it might be in range
+ case (Some(lb), _) if ordering.lt(tree.key, lb) => countInRange(tree.right, from, to)
+ // if node is greater than or equal to the upper bound, try the tree on the left, it might be in range
+ case (_, Some(ub)) if ordering.gteq(tree.key, ub) => countInRange(tree.left, from, to)
+ // node is in range so the tree on the left will all be less than the upper bound and the tree on the
+ // right will all be greater than or equal to the lower bound. So 1 for this node plus
+ // count the subtrees by stripping off the bounds that we don't need any more
+ case _ => 1 + countInRange(tree.left, from, None) + countInRange(tree.right, None, to)
+
+ }
+ def update[A: Ordering, B, B1 >: B](tree: Tree[A, B], k: A, v: B1, overwrite: Boolean): Tree[A, B1] = blacken(upd(tree, k, v, overwrite))
+ def delete[A: Ordering, B](tree: Tree[A, B], k: A): Tree[A, B] = blacken(del(tree, k))
def rangeImpl[A: Ordering, B](tree: Tree[A, B], from: Option[A], until: Option[A]): Tree[A, B] = (from, until) match {
case (Some(from), Some(until)) => this.range(tree, from, until)
case (Some(from), None) => this.from(tree, from)
@@ -74,20 +93,26 @@ object RedBlackTree {
result
}
- def foreach[A, B, U](tree: Tree[A, B], f: ((A, B)) => U): Unit = if (tree ne null) {
- if (tree.left ne null) foreach(tree.left, f)
+
+ def foreach[A,B,U](tree:Tree[A,B], f:((A,B)) => U):Unit = if (tree ne null) _foreach(tree,f)
+
+ private[this] def _foreach[A, B, U](tree: Tree[A, B], f: ((A, B)) => U) {
+ if (tree.left ne null) _foreach(tree.left, f)
f((tree.key, tree.value))
- if (tree.right ne null) foreach(tree.right, f)
+ if (tree.right ne null) _foreach(tree.right, f)
}
- def foreachKey[A, U](tree: Tree[A, _], f: A => U): Unit = if (tree ne null) {
- if (tree.left ne null) foreachKey(tree.left, f)
- f(tree.key)
- if (tree.right ne null) foreachKey(tree.right, f)
+
+ def foreachKey[A, U](tree:Tree[A,_], f: A => U):Unit = if (tree ne null) _foreachKey(tree,f)
+
+ private[this] def _foreachKey[A, U](tree: Tree[A, _], f: A => U) {
+ if (tree.left ne null) _foreachKey(tree.left, f)
+ f((tree.key))
+ if (tree.right ne null) _foreachKey(tree.right, f)
}
- def iterator[A, B](tree: Tree[A, B]): Iterator[(A, B)] = new EntriesIterator(tree)
- def keysIterator[A, _](tree: Tree[A, _]): Iterator[A] = new KeysIterator(tree)
- def valuesIterator[_, B](tree: Tree[_, B]): Iterator[B] = new ValuesIterator(tree)
+ def iterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None): Iterator[(A, B)] = new EntriesIterator(tree, start)
+ def keysIterator[A: Ordering](tree: Tree[A, _], start: Option[A] = None): Iterator[A] = new KeysIterator(tree, start)
+ def valuesIterator[A: Ordering, B](tree: Tree[A, B], start: Option[A] = None): Iterator[B] = new ValuesIterator(tree, start)
@tailrec
def nth[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = {
@@ -227,7 +252,7 @@ object RedBlackTree {
if (ordering.lt(tree.key, from)) return doFrom(tree.right, from)
val newLeft = doFrom(tree.left, from)
if (newLeft eq tree.left) tree
- else if (newLeft eq null) upd(tree.right, tree.key, tree.value, false)
+ else if (newLeft eq null) upd(tree.right, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, tree.right)
}
private[this] def doTo[A, B](tree: Tree[A, B], to: A)(implicit ordering: Ordering[A]): Tree[A, B] = {
@@ -235,7 +260,7 @@ object RedBlackTree {
if (ordering.lt(to, tree.key)) return doTo(tree.left, to)
val newRight = doTo(tree.right, to)
if (newRight eq tree.right) tree
- else if (newRight eq null) upd(tree.left, tree.key, tree.value, false)
+ else if (newRight eq null) upd(tree.left, tree.key, tree.value, overwrite = false)
else rebalance(tree, tree.left, newRight)
}
private[this] def doUntil[A, B](tree: Tree[A, B], until: A)(implicit ordering: Ordering[A]): Tree[A, B] = {
@@ -243,18 +268,18 @@ object RedBlackTree {
if (ordering.lteq(until, tree.key)) return doUntil(tree.left, until)
val newRight = doUntil(tree.right, until)
if (newRight eq tree.right) tree
- else if (newRight eq null) upd(tree.left, tree.key, tree.value, false)
+ else if (newRight eq null) upd(tree.left, tree.key, tree.value, overwrite = false)
else rebalance(tree, tree.left, newRight)
}
private[this] def doRange[A, B](tree: Tree[A, B], from: A, until: A)(implicit ordering: Ordering[A]): Tree[A, B] = {
if (tree eq null) return null
- if (ordering.lt(tree.key, from)) return doRange(tree.right, from, until);
- if (ordering.lteq(until, tree.key)) return doRange(tree.left, from, until);
+ if (ordering.lt(tree.key, from)) return doRange(tree.right, from, until)
+ if (ordering.lteq(until, tree.key)) return doRange(tree.left, from, until)
val newLeft = doFrom(tree.left, from)
val newRight = doUntil(tree.right, until)
if ((newLeft eq tree.left) && (newRight eq tree.right)) tree
- else if (newLeft eq null) upd(newRight, tree.key, tree.value, false);
- else if (newRight eq null) upd(newLeft, tree.key, tree.value, false);
+ else if (newLeft eq null) upd(newRight, tree.key, tree.value, overwrite = false)
+ else if (newRight eq null) upd(newLeft, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, newRight)
}
@@ -265,7 +290,7 @@ object RedBlackTree {
if (n > count) return doDrop(tree.right, n - count - 1)
val newLeft = doDrop(tree.left, n)
if (newLeft eq tree.left) tree
- else if (newLeft eq null) updNth(tree.right, n - count - 1, tree.key, tree.value, false)
+ else if (newLeft eq null) updNth(tree.right, n - count - 1, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, tree.right)
}
private[this] def doTake[A, B](tree: Tree[A, B], n: Int): Tree[A, B] = {
@@ -275,7 +300,7 @@ object RedBlackTree {
if (n <= count) return doTake(tree.left, n)
val newRight = doTake(tree.right, n - count - 1)
if (newRight eq tree.right) tree
- else if (newRight eq null) updNth(tree.left, n, tree.key, tree.value, false)
+ else if (newRight eq null) updNth(tree.left, n, tree.key, tree.value, overwrite = false)
else rebalance(tree, tree.left, newRight)
}
private[this] def doSlice[A, B](tree: Tree[A, B], from: Int, until: Int): Tree[A, B] = {
@@ -286,8 +311,8 @@ object RedBlackTree {
val newLeft = doDrop(tree.left, from)
val newRight = doTake(tree.right, until - count - 1)
if ((newLeft eq tree.left) && (newRight eq tree.right)) tree
- else if (newLeft eq null) updNth(newRight, from - count - 1, tree.key, tree.value, false)
- else if (newRight eq null) updNth(newLeft, until, tree.key, tree.value, false)
+ else if (newLeft eq null) updNth(newRight, from - count - 1, tree.key, tree.value, overwrite = false)
+ else if (newRight eq null) updNth(newLeft, until, tree.key, tree.value, overwrite = false)
else rebalance(tree, newLeft, newRight)
}
@@ -300,54 +325,56 @@ object RedBlackTree {
// whether the zipper was traversed left-most or right-most.
// If the trees were balanced, returns an empty zipper
- private[this] def compareDepth[A, B](left: Tree[A, B], right: Tree[A, B]): (List[Tree[A, B]], Boolean, Boolean, Int) = {
+ private[this] def compareDepth[A, B](left: Tree[A, B], right: Tree[A, B]): (NList[Tree[A, B]], Boolean, Boolean, Int) = {
+ import NList.cons
// Once a side is found to be deeper, unzip it to the bottom
- def unzip(zipper: List[Tree[A, B]], leftMost: Boolean): List[Tree[A, B]] = {
+ def unzip(zipper: NList[Tree[A, B]], leftMost: Boolean): NList[Tree[A, B]] = {
val next = if (leftMost) zipper.head.left else zipper.head.right
- next match {
- case null => zipper
- case node => unzip(node :: zipper, leftMost)
- }
+ if (next eq null) zipper
+ else unzip(cons(next, zipper), leftMost)
}
// Unzip left tree on the rightmost side and right tree on the leftmost side until one is
// found to be deeper, or the bottom is reached
def unzipBoth(left: Tree[A, B],
right: Tree[A, B],
- leftZipper: List[Tree[A, B]],
- rightZipper: List[Tree[A, B]],
- smallerDepth: Int): (List[Tree[A, B]], Boolean, Boolean, Int) = {
+ leftZipper: NList[Tree[A, B]],
+ rightZipper: NList[Tree[A, B]],
+ smallerDepth: Int): (NList[Tree[A, B]], Boolean, Boolean, Int) = {
if (isBlackTree(left) && isBlackTree(right)) {
- unzipBoth(left.right, right.left, left :: leftZipper, right :: rightZipper, smallerDepth + 1)
+ unzipBoth(left.right, right.left, cons(left, leftZipper), cons(right, rightZipper), smallerDepth + 1)
} else if (isRedTree(left) && isRedTree(right)) {
- unzipBoth(left.right, right.left, left :: leftZipper, right :: rightZipper, smallerDepth)
+ unzipBoth(left.right, right.left, cons(left, leftZipper), cons(right, rightZipper), smallerDepth)
} else if (isRedTree(right)) {
- unzipBoth(left, right.left, leftZipper, right :: rightZipper, smallerDepth)
+ unzipBoth(left, right.left, leftZipper, cons(right, rightZipper), smallerDepth)
} else if (isRedTree(left)) {
- unzipBoth(left.right, right, left :: leftZipper, rightZipper, smallerDepth)
+ unzipBoth(left.right, right, cons(left, leftZipper), rightZipper, smallerDepth)
} else if ((left eq null) && (right eq null)) {
- (Nil, true, false, smallerDepth)
+ (null, true, false, smallerDepth)
} else if ((left eq null) && isBlackTree(right)) {
val leftMost = true
- (unzip(right :: rightZipper, leftMost), false, leftMost, smallerDepth)
+ (unzip(cons(right, rightZipper), leftMost), false, leftMost, smallerDepth)
} else if (isBlackTree(left) && (right eq null)) {
val leftMost = false
- (unzip(left :: leftZipper, leftMost), false, leftMost, smallerDepth)
+ (unzip(cons(left, leftZipper), leftMost), false, leftMost, smallerDepth)
} else {
sys.error("unmatched trees in unzip: " + left + ", " + right)
}
}
- unzipBoth(left, right, Nil, Nil, 0)
+ unzipBoth(left, right, null, null, 0)
}
private[this] def rebalance[A, B](tree: Tree[A, B], newLeft: Tree[A, B], newRight: Tree[A, B]) = {
// This is like drop(n-1), but only counting black nodes
- def findDepth(zipper: List[Tree[A, B]], depth: Int): List[Tree[A, B]] = zipper match {
- case head :: tail if isBlackTree(head) =>
- if (depth == 1) zipper else findDepth(tail, depth - 1)
- case _ :: tail => findDepth(tail, depth)
- case Nil => sys.error("Defect: unexpected empty zipper while computing range")
- }
+ @tailrec
+ def findDepth(zipper: NList[Tree[A, B]], depth: Int): NList[Tree[A, B]] =
+ if (zipper eq null) {
+ sys.error("Defect: unexpected empty zipper while computing range")
+ } else if (isBlackTree(zipper.head)) {
+ if (depth == 1) zipper else findDepth(zipper.tail, depth - 1)
+ } else {
+ findDepth(zipper.tail, depth)
+ }
// Blackening the smaller tree avoids balancing problems on union;
// this can't be done later, though, or it would change the result of compareDepth
@@ -364,7 +391,7 @@ object RedBlackTree {
} else {
RedTree(tree.key, tree.value, zipFrom.head, blkNewRight)
}
- val zippedTree = zipFrom.tail.foldLeft(union: Tree[A, B]) { (tree, node) =>
+ val zippedTree = NList.foldLeft(zipFrom.tail, union: Tree[A, B]) { (tree, node) =>
if (leftMost)
balanceLeft(isBlackTree(node), node.key, node.value, tree, node.right)
else
@@ -373,6 +400,25 @@ object RedBlackTree {
zippedTree
}
}
+
+ // Null optimized list implementation for tree rebalancing. null presents Nil.
+ private[this] final class NList[A](val head: A, val tail: NList[A])
+
+ private[this] final object NList {
+
+ def cons[B](x: B, xs: NList[B]): NList[B] = new NList(x, xs)
+
+ def foldLeft[A, B](xs: NList[A], z: B)(f: (B, A) => B): B = {
+ var acc = z
+ var these = xs
+ while (these ne null) {
+ acc = f(acc, these.head)
+ these = these.tail
+ }
+ acc
+ }
+
+ }
/*
* Forcing direct fields access using the @inline annotation helps speed up
@@ -419,32 +465,28 @@ object RedBlackTree {
def unapply[A, B](t: BlackTree[A, B]) = Some((t.key, t.value, t.left, t.right))
}
- private[this] abstract class TreeIterator[A, B, R](tree: Tree[A, B]) extends Iterator[R] {
+ private[this] abstract class TreeIterator[A, B, R](root: Tree[A, B], start: Option[A])(implicit ordering: Ordering[A]) extends Iterator[R] {
protected[this] def nextResult(tree: Tree[A, B]): R
- override def hasNext: Boolean = next ne null
+ override def hasNext: Boolean = lookahead ne null
- override def next: R = next match {
+ override def next: R = lookahead match {
case null =>
throw new NoSuchElementException("next on empty iterator")
case tree =>
- next = findNext(tree.right)
+ lookahead = findLeftMostOrPopOnEmpty(goRight(tree))
nextResult(tree)
}
@tailrec
- private[this] def findNext(tree: Tree[A, B]): Tree[A, B] = {
- if (tree eq null) popPath()
+ private[this] def findLeftMostOrPopOnEmpty(tree: Tree[A, B]): Tree[A, B] =
+ if (tree eq null) popNext()
else if (tree.left eq null) tree
- else {
- pushPath(tree)
- findNext(tree.left)
- }
- }
+ else findLeftMostOrPopOnEmpty(goLeft(tree))
- private[this] def pushPath(tree: Tree[A, B]) {
+ private[this] def pushNext(tree: Tree[A, B]) {
try {
- path(index) = tree
+ stackOfNexts(index) = tree
index += 1
} catch {
case _: ArrayIndexOutOfBoundsException =>
@@ -456,17 +498,17 @@ object RedBlackTree {
* An exception handler is used instead of an if-condition to optimize the normal path.
* This makes a large difference in iteration speed!
*/
- assert(index >= path.length)
- path :+= null
- pushPath(tree)
+ assert(index >= stackOfNexts.length)
+ stackOfNexts :+= null
+ pushNext(tree)
}
}
- private[this] def popPath(): Tree[A, B] = if (index == 0) null else {
+ private[this] def popNext(): Tree[A, B] = if (index == 0) null else {
index -= 1
- path(index)
+ stackOfNexts(index)
}
- private[this] var path = if (tree eq null) null else {
+ private[this] var stackOfNexts = if (root eq null) null else {
/*
* According to "Ralf Hinze. Constructing red-black trees" [http://www.cs.ox.ac.uk/ralf.hinze/publications/#P5]
* the maximum height of a red-black tree is 2*log_2(n + 2) - 2.
@@ -475,22 +517,45 @@ object RedBlackTree {
*
* We also don't store the deepest nodes in the path so the maximum path length is further reduced by one.
*/
- val maximumHeight = 2 * (32 - Integer.numberOfLeadingZeros(tree.count + 2 - 1)) - 2 - 1
+ val maximumHeight = 2 * (32 - Integer.numberOfLeadingZeros(root.count + 2 - 1)) - 2 - 1
new Array[Tree[A, B]](maximumHeight)
}
private[this] var index = 0
- private[this] var next: Tree[A, B] = findNext(tree)
+ private[this] var lookahead: Tree[A, B] = start map startFrom getOrElse findLeftMostOrPopOnEmpty(root)
+
+ /**
+ * Find the leftmost subtree whose key is equal to the given key, or if no such thing,
+ * the leftmost subtree with the key that would be "next" after it according
+ * to the ordering. Along the way build up the iterator's path stack so that "next"
+ * functionality works.
+ */
+ private[this] def startFrom(key: A) : Tree[A,B] = if (root eq null) null else {
+ @tailrec def find(tree: Tree[A, B]): Tree[A, B] =
+ if (tree eq null) popNext()
+ else find(
+ if (ordering.lteq(key, tree.key)) goLeft(tree)
+ else goRight(tree)
+ )
+ find(root)
+ }
+
+ private[this] def goLeft(tree: Tree[A, B]) = {
+ pushNext(tree)
+ tree.left
+ }
+
+ private[this] def goRight(tree: Tree[A, B]) = tree.right
}
- private[this] class EntriesIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, (A, B)](tree) {
+ private[this] class EntriesIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, (A, B)](tree, focus) {
override def nextResult(tree: Tree[A, B]) = (tree.key, tree.value)
}
- private[this] class KeysIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, A](tree) {
+ private[this] class KeysIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, A](tree, focus) {
override def nextResult(tree: Tree[A, B]) = tree.key
}
- private[this] class ValuesIterator[A, B](tree: Tree[A, B]) extends TreeIterator[A, B, B](tree) {
+ private[this] class ValuesIterator[A: Ordering, B](tree: Tree[A, B], focus: Option[A]) extends TreeIterator[A, B, B](tree, focus) {
override def nextResult(tree: Tree[A, B]) = tree.value
}
}
diff --git a/src/library/scala/collection/immutable/Seq.scala b/src/library/scala/collection/immutable/Seq.scala
index 14610aea33..38855ca6b0 100644
--- a/src/library/scala/collection/immutable/Seq.scala
+++ b/src/library/scala/collection/immutable/Seq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/Set.scala b/src/library/scala/collection/immutable/Set.scala
index 8433c2b002..2c96f4c194 100644
--- a/src/library/scala/collection/immutable/Set.scala
+++ b/src/library/scala/collection/immutable/Set.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/SetProxy.scala b/src/library/scala/collection/immutable/SetProxy.scala
index 06c6843181..9e25678435 100644
--- a/src/library/scala/collection/immutable/SetProxy.scala
+++ b/src/library/scala/collection/immutable/SetProxy.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
/** This is a simple wrapper class for <a href="Set.html"
diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala
index eb04231c55..4b9fa81a8c 100644
--- a/src/library/scala/collection/immutable/SortedMap.scala
+++ b/src/library/scala/collection/immutable/SortedMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -82,11 +83,17 @@ self =>
override def filterKeys(p: A => Boolean): SortedMap[A, B] = new FilteredKeys(p) with SortedMap.Default[A, B] {
implicit def ordering: Ordering[A] = self.ordering
override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, B] = self.rangeImpl(from, until).filterKeys(p)
+ override def iteratorFrom(start: A) = self iteratorFrom start filter {case (k, _) => p(k)}
+ override def keysIteratorFrom(start : A) = self keysIteratorFrom start filter p
+ override def valuesIteratorFrom(start : A) = self iteratorFrom start collect {case (k,v) if p(k) => v}
}
override def mapValues[C](f: B => C): SortedMap[A, C] = new MappedValues(f) with SortedMap.Default[A, C] {
implicit def ordering: Ordering[A] = self.ordering
override def rangeImpl(from : Option[A], until : Option[A]): SortedMap[A, C] = self.rangeImpl(from, until).mapValues(f)
+ override def iteratorFrom(start: A) = self iteratorFrom start map {case (k, v) => (k, f(v))}
+ override def keysIteratorFrom(start : A) = self keysIteratorFrom start
+ override def valuesIteratorFrom(start : A) = self valuesIteratorFrom start map f
}
}
@@ -106,13 +113,13 @@ object SortedMap extends ImmutableSortedMapFactory[SortedMap] {
val b = SortedMap.newBuilder[A, B1]
b ++= this
b += ((kv._1, kv._2))
- b.result
+ b.result()
}
override def - (key: A): SortedMap[A, B] = {
val b = newBuilder
for (kv <- this; if kv._1 != key) b += kv
- b.result
+ b.result()
}
}
}
diff --git a/src/library/scala/collection/immutable/SortedSet.scala b/src/library/scala/collection/immutable/SortedSet.scala
index 3f75d50555..4a8859a7ab 100644
--- a/src/library/scala/collection/immutable/SortedSet.scala
+++ b/src/library/scala/collection/immutable/SortedSet.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/Stack.scala b/src/library/scala/collection/immutable/Stack.scala
index 357e9a123c..65a34e2310 100644
--- a/src/library/scala/collection/immutable/Stack.scala
+++ b/src/library/scala/collection/immutable/Stack.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala
index 5bb4ef5f21..5e1de44749 100644
--- a/src/library/scala/collection/immutable/Stream.scala
+++ b/src/library/scala/collection/immutable/Stream.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -181,11 +182,14 @@ import scala.language.implicitConversions
* @define coll stream
* @define orderDependent
* @define orderDependentFold
+ * @define willTerminateInf Note: lazily evaluated; will terminate for infinite-sized collections.
*/
+@deprecatedInheritance("This class will be sealed.", "2.11.0")
abstract class Stream[+A] extends AbstractSeq[A]
with LinearSeq[A]
with GenericTraversableTemplate[A, Stream]
- with LinearSeqOptimized[A, Stream[A]] {
+ with LinearSeqOptimized[A, Stream[A]]
+ with Serializable {
self =>
override def companion: GenericCompanion[Stream] = Stream
@@ -286,9 +290,8 @@ self =>
len
}
- /** It's an imperfect world, but at least we can bottle up the
- * imperfection in a capsule.
- */
+ // It's an imperfect world, but at least we can bottle up the
+ // imperfection in a capsule.
@inline private def asThat[That](x: AnyRef): That = x.asInstanceOf[That]
@inline private def asStream[B](x: AnyRef): Stream[B] = x.asInstanceOf[Stream[B]]
@inline private def isStreamBuilder[B, That](bf: CanBuildFrom[Stream[A], B, That]) =
@@ -385,12 +388,17 @@ self =>
// 1) stackoverflows (could be achieved with tailrec, too)
// 2) out of memory errors for big streams (`this` reference can be eliminated from the stack)
var rest: Stream[A] = this
- while (rest.nonEmpty && !pf.isDefinedAt(rest.head)) rest = rest.tail
+
+ // Avoids calling both `pf.isDefined` and `pf.apply`.
+ var newHead: B = null.asInstanceOf[B]
+ val runWith = pf.runWith((b: B) => newHead = b)
+
+ while (rest.nonEmpty && !runWith(rest.head)) rest = rest.tail
// without the call to the companion object, a thunk is created for the tail of the new stream,
// and the closure of the thunk will reference `this`
if (rest.isEmpty) Stream.Empty.asInstanceOf[That]
- else Stream.collectedTail(rest, pf, bf).asInstanceOf[That]
+ else Stream.collectedTail(newHead, rest, pf, bf).asInstanceOf[That]
}
}
@@ -725,10 +733,15 @@ self =>
* // produces: "5, 6, 7, 8, 9"
* }}}
*/
- override def take(n: Int): Stream[A] =
+ override def take(n: Int): Stream[A] = (
+ // Note that the n == 1 condition appears redundant but is not.
+ // It prevents "tail" from being referenced (and its head being evaluated)
+ // when obtaining the last element of the result. Such are the challenges
+ // of working with a lazy-but-not-really sequence.
if (n <= 0 || isEmpty) Stream.empty
else if (n == 1) cons(head, Stream.empty)
else cons(head, tail take n-1)
+ )
@tailrec final override def drop(n: Int): Stream[A] =
if (n <= 0 || isEmpty) this
@@ -784,8 +797,23 @@ self =>
these
}
- // there's nothing we can do about dropRight, so we just keep the definition
- // in LinearSeq
+ /**
+ * @inheritdoc
+ * $willTerminateInf
+ */
+ override def dropRight(n: Int): Stream[A] = {
+ // We make dropRight work for possibly infinite streams by carrying
+ // a buffer of the dropped size. As long as the buffer is full and the
+ // rest is non-empty, we can feed elements off the buffer head. When
+ // the rest becomes empty, the full buffer is the dropped elements.
+ def advance(stub0: List[A], stub1: List[A], rest: Stream[A]): Stream[A] = {
+ if (rest.isEmpty) Stream.empty
+ else if (stub0.isEmpty) advance(stub1.reverse, Nil, rest)
+ else cons(stub0.head, advance(stub0.tail, rest.head :: stub1, rest.tail))
+ }
+ if (n <= 0) this
+ else advance((this take n).toList, Nil, this drop n)
+ }
/** Returns the longest prefix of this `Stream` whose elements satisfy the
* predicate `p`.
@@ -973,7 +1001,7 @@ final class StreamIterator[+A] private() extends AbstractIterator[A] with Iterat
def hasNext: Boolean = these.v.nonEmpty
def next(): A =
- if (isEmpty) Iterator.empty.next
+ if (isEmpty) Iterator.empty.next()
else {
val cur = these.v
val result = cur.head
@@ -1023,7 +1051,7 @@ object Stream extends SeqFactory[Stream] {
def result: Stream[A] = parts.toStream flatMap (_.toStream)
}
- object Empty extends Stream[Nothing] with Serializable {
+ object Empty extends Stream[Nothing] {
override def isEmpty = true
override def head = throw new NoSuchElementException("head of empty stream")
override def tail = throw new UnsupportedOperationException("tail of empty stream")
@@ -1074,7 +1102,7 @@ object Stream extends SeqFactory[Stream] {
/** A lazy cons cell, from which streams are built. */
@SerialVersionUID(-602202424901551803L)
- final class Cons[+A](hd: A, tl: => Stream[A]) extends Stream[A] with Serializable {
+ final class Cons[+A](hd: A, tl: => Stream[A]) extends Stream[A] {
override def isEmpty = false
override def head = hd
@volatile private[this] var tlVal: Stream[A] = _
@@ -1149,8 +1177,8 @@ object Stream extends SeqFactory[Stream] {
cons(stream.head, stream.tail filter p)
}
- private[immutable] def collectedTail[A, B, That](stream: Stream[A], pf: PartialFunction[A, B], bf: CanBuildFrom[Stream[A], B, That]) = {
- cons(pf(stream.head), stream.tail.collect(pf)(bf).asInstanceOf[Stream[B]])
+ private[immutable] def collectedTail[A, B, That](head: B, stream: Stream[A], pf: PartialFunction[A, B], bf: CanBuildFrom[Stream[A], B, That]) = {
+ cons(head, stream.tail.collect(pf)(bf).asInstanceOf[Stream[B]])
}
}
diff --git a/src/library/scala/collection/immutable/StreamView.scala b/src/library/scala/collection/immutable/StreamView.scala
index 5a24b77eb3..127ed76eb5 100644
--- a/src/library/scala/collection/immutable/StreamView.scala
+++ b/src/library/scala/collection/immutable/StreamView.scala
@@ -1,4 +1,5 @@
-package scala.collection
+package scala
+package collection
package immutable
trait StreamView[+A, +Coll] extends StreamViewLike[A, Coll, StreamView[A, Coll]] { }
diff --git a/src/library/scala/collection/immutable/StreamViewLike.scala b/src/library/scala/collection/immutable/StreamViewLike.scala
index 236308da2e..ccab032cfd 100644
--- a/src/library/scala/collection/immutable/StreamViewLike.scala
+++ b/src/library/scala/collection/immutable/StreamViewLike.scala
@@ -1,4 +1,5 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/StringLike.scala b/src/library/scala/collection/immutable/StringLike.scala
index edea89b555..4768413e75 100644
--- a/src/library/scala/collection/immutable/StringLike.scala
+++ b/src/library/scala/collection/immutable/StringLike.scala
@@ -6,10 +6,10 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
-import generic._
import mutable.Builder
import scala.util.matching.Regex
import scala.math.ScalaNumber
@@ -19,12 +19,11 @@ import scala.reflect.ClassTag
* @since 2.8
*/
object StringLike {
-
// just statics for companion class.
- private final val LF: Char = 0x0A
- private final val FF: Char = 0x0C
- private final val CR: Char = 0x0D
- private final val SU: Char = 0x1A
+ private final val LF = 0x0A
+ private final val FF = 0x0C
+ private final val CR = 0x0D
+ private final val SU = 0x1A
}
import StringLike._
@@ -60,8 +59,8 @@ self =>
val start = from max 0
val end = until min length
- if (start >= end) newBuilder.result
- else (newBuilder ++= toString.substring(start, end)).result
+ if (start >= end) newBuilder.result()
+ else (newBuilder ++= toString.substring(start, end)).result()
}
/** Return the current string concatenated `n` times.
diff --git a/src/library/scala/collection/immutable/StringOps.scala b/src/library/scala/collection/immutable/StringOps.scala
index a650d98697..6737692fb1 100644
--- a/src/library/scala/collection/immutable/StringOps.scala
+++ b/src/library/scala/collection/immutable/StringOps.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package immutable
import mutable.StringBuilder
diff --git a/src/library/scala/collection/immutable/Traversable.scala b/src/library/scala/collection/immutable/Traversable.scala
index 5188343011..775d635fae 100644
--- a/src/library/scala/collection/immutable/Traversable.scala
+++ b/src/library/scala/collection/immutable/Traversable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/TreeMap.scala b/src/library/scala/collection/immutable/TreeMap.scala
index 5b4db2686a..4d2ec579db 100644
--- a/src/library/scala/collection/immutable/TreeMap.scala
+++ b/src/library/scala/collection/immutable/TreeMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -51,9 +52,6 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
with MapLike[A, B, TreeMap[A, B]]
with Serializable {
- @deprecated("use `ordering.lt` instead", "2.10.0")
- def isSmaller(x: A, y: A) = ordering.lt(x, y)
-
override protected[this] def newBuilder : Builder[(A, B), TreeMap[A, B]] =
TreeMap.newBuilder[A, B]
@@ -111,7 +109,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
private[this] def countWhile(p: ((A, B)) => Boolean): Int = {
var result = 0
val it = iterator
- while (it.hasNext && p(it.next)) result += 1
+ while (it.hasNext && p(it.next())) result += 1
result
}
override def dropWhile(p: ((A, B)) => Boolean) = drop(countWhile(p))
@@ -131,7 +129,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
* @param value the value to be associated with `key`
* @return a new $coll with the updated binding
*/
- override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = new TreeMap(RB.update(tree, key, value, true))
+ override def updated [B1 >: B](key: A, value: B1): TreeMap[A, B1] = new TreeMap(RB.update(tree, key, value, overwrite = true))
/** Add a key/value pair to this map.
* @tparam B1 type of the value of the new binding, a supertype of `B`
@@ -171,7 +169,7 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
*/
def insert [B1 >: B](key: A, value: B1): TreeMap[A, B1] = {
assert(!RB.contains(tree, key))
- new TreeMap(RB.update(tree, key, value, true))
+ new TreeMap(RB.update(tree, key, value, overwrite = true))
}
def - (key:A): TreeMap[A, B] =
@@ -192,9 +190,13 @@ class TreeMap[A, +B] private (tree: RB.Tree[A, B])(implicit val ordering: Orderi
* @return the new iterator
*/
override def iterator: Iterator[(A, B)] = RB.iterator(tree)
+ override def iteratorFrom(start: A): Iterator[(A, B)] = RB.iterator(tree, Some(start))
override def keysIterator: Iterator[A] = RB.keysIterator(tree)
+ override def keysIteratorFrom(start: A): Iterator[A] = RB.keysIterator(tree, Some(start))
+
override def valuesIterator: Iterator[B] = RB.valuesIterator(tree)
+ override def valuesIteratorFrom(start: A): Iterator[B] = RB.valuesIterator(tree, Some(start))
override def contains(key: A): Boolean = RB.contains(tree, key)
override def isDefinedAt(key: A): Boolean = RB.contains(tree, key)
diff --git a/src/library/scala/collection/immutable/TreeSet.scala b/src/library/scala/collection/immutable/TreeSet.scala
index 494776587d..dfe1a833ef 100644
--- a/src/library/scala/collection/immutable/TreeSet.scala
+++ b/src/library/scala/collection/immutable/TreeSet.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
@@ -89,16 +90,13 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
private[this] def countWhile(p: A => Boolean): Int = {
var result = 0
val it = iterator
- while (it.hasNext && p(it.next)) result += 1
+ while (it.hasNext && p(it.next())) result += 1
result
}
override def dropWhile(p: A => Boolean) = drop(countWhile(p))
override def takeWhile(p: A => Boolean) = take(countWhile(p))
override def span(p: A => Boolean) = splitAt(countWhile(p))
- @deprecated("use `ordering.lt` instead", "2.10.0")
- def isSmaller(x: A, y: A) = compare(x,y) < 0
-
def this()(implicit ordering: Ordering[A]) = this(null)(ordering)
private def newSet(t: RB.Tree[A, Unit]) = new TreeSet[A](t)
@@ -112,7 +110,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
* @param elem a new element to add.
* @return a new $coll containing `elem` and all the elements of this $coll.
*/
- def + (elem: A): TreeSet[A] = newSet(RB.update(tree, elem, (), false))
+ def + (elem: A): TreeSet[A] = newSet(RB.update(tree, elem, (), overwrite = false))
/** A new `TreeSet` with the entry added is returned,
* assuming that elem is <em>not</em> in the TreeSet.
@@ -122,7 +120,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
*/
def insert(elem: A): TreeSet[A] = {
assert(!RB.contains(tree, elem))
- newSet(RB.update(tree, elem, (), false))
+ newSet(RB.update(tree, elem, (), overwrite = false))
}
/** Creates a new `TreeSet` with the entry removed.
@@ -147,6 +145,7 @@ class TreeSet[A] private (tree: RB.Tree[A, Unit])(implicit val ordering: Orderin
* @return the new iterator
*/
def iterator: Iterator[A] = RB.keysIterator(tree)
+ override def keysIteratorFrom(start: A): Iterator[A] = RB.keysIterator(tree, Some(start))
override def foreach[U](f: A => U) = RB.foreachKey(tree, f)
diff --git a/src/library/scala/collection/immutable/TrieIterator.scala b/src/library/scala/collection/immutable/TrieIterator.scala
index ae427852d4..d7335e80f1 100644
--- a/src/library/scala/collection/immutable/TrieIterator.scala
+++ b/src/library/scala/collection/immutable/TrieIterator.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package immutable
import HashMap.{ HashTrieMap, HashMapCollision1, HashMap1 }
@@ -46,7 +47,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e
case x: HashSetCollision1[_] => x.ks.map(x => HashSet(x)).toArray
}).asInstanceOf[Array[Iterable[T]]]
- private type SplitIterators = ((Iterator[T], Int), Iterator[T])
+ private[this] type SplitIterators = ((Iterator[T], Int), Iterator[T])
private def isTrie(x: AnyRef) = x match {
case _: HashTrieMap[_,_] | _: HashTrieSet[_] => true
@@ -94,7 +95,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e
def hasNext = (subIter ne null) || depth >= 0
def next(): T = {
if (subIter ne null) {
- val el = subIter.next
+ val el = subIter.next()
if (!subIter.hasNext)
subIter = null
el
@@ -135,7 +136,7 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e
}
else {
subIter = m.iterator
- next
+ next()
}
// The much slower version:
//
@@ -177,7 +178,6 @@ private[collection] abstract class TrieIterator[+T](elems: Array[Iterable[T]]) e
if (depth > 0) {
// 2) topmost comes before (is not) arrayD
// steal a portion of top to create a new iterator
- val topmost = arrayStack(0)
if (posStack(0) == arrayStack(0).length - 1) {
// 2a) only a single entry left on top
// this means we have to modify this iterator - pop topmost
diff --git a/src/library/scala/collection/immutable/Vector.scala b/src/library/scala/collection/immutable/Vector.scala
index bcce4a99bd..571e6775c8 100644
--- a/src/library/scala/collection/immutable/Vector.scala
+++ b/src/library/scala/collection/immutable/Vector.scala
@@ -18,16 +18,7 @@ import scala.collection.parallel.immutable.ParVector
/** Companion object to the Vector class
*/
-object Vector extends SeqFactory[Vector] {
- // left lying around for binary compatibility check
- private[collection] class VectorReusableCBF extends GenericCanBuildFrom[Nothing] {
- override def apply() = newBuilder[Nothing]
- }
- // left lying around for binary compatibility check
- private val VectorReusableCBF: GenericCanBuildFrom[Nothing] = new VectorReusableCBF
-
- override lazy val ReusableCBF =
- scala.collection.IndexedSeq.ReusableCBF.asInstanceOf[GenericCanBuildFrom[Nothing]]
+object Vector extends IndexedSeqFactory[Vector] {
def newBuilder[A]: Builder[A, Vector[A]] = new VectorBuilder[A]
implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Vector[A]] =
ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
@@ -113,7 +104,7 @@ override def companion: GenericCompanion[Vector] = Vector
if (0 < i) {
i -= 1
self(i)
- } else Iterator.empty.next
+ } else Iterator.empty.next()
}
// TODO: reverse
@@ -148,7 +139,7 @@ override def companion: GenericCompanion[Vector] = Vector
if (bf eq IndexedSeq.ReusableCBF) appendFront(elem).asInstanceOf[That] // just ignore bf
else super.+:(elem)(bf)
- override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That =
+ override def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Vector[A], B, That]): That =
if (bf eq IndexedSeq.ReusableCBF) appendBack(elem).asInstanceOf[That] // just ignore bf
else super.:+(elem)(bf)
@@ -251,8 +242,8 @@ override def companion: GenericCompanion[Vector] = Vector
private[immutable] def appendFront[B>:A](value: B): Vector[B] = {
if (endIndex != startIndex) {
- var blockIndex = (startIndex - 1) & ~31
- var lo = (startIndex - 1) & 31
+ val blockIndex = (startIndex - 1) & ~31
+ val lo = (startIndex - 1) & 31
if (startIndex != blockIndex + 32) {
val s = new Vector(startIndex - 1, endIndex, blockIndex)
@@ -270,7 +261,7 @@ override def companion: GenericCompanion[Vector] = Vector
//println("----- appendFront " + value + " at " + (startIndex - 1) + " reached block start")
if (shift != 0) {
// case A: we can shift right on the top level
- debug
+ debug()
//println("shifting right by " + shiftBlocks + " at level " + (depth-1) + " (had "+freeSpace+" free space)")
if (depth > 1) {
@@ -280,7 +271,7 @@ override def companion: GenericCompanion[Vector] = Vector
s.initFrom(this)
s.dirty = dirty
s.shiftTopLevel(0, shiftBlocks) // shift right by n blocks
- s.debug
+ s.debug()
s.gotoFreshPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) // maybe create pos; prepare for writing
s.display0(lo) = value.asInstanceOf[AnyRef]
//assert(depth == s.depth)
@@ -298,7 +289,7 @@ override def companion: GenericCompanion[Vector] = Vector
s.shiftTopLevel(0, shiftBlocks) // shift right by n elements
s.gotoPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) // prepare for writing
s.display0(shift-1) = value.asInstanceOf[AnyRef]
- s.debug
+ s.debug()
s
}
} else if (blockIndex < 0) {
@@ -313,10 +304,10 @@ override def companion: GenericCompanion[Vector] = Vector
val s = new Vector(startIndex - 1 + move, endIndex + move, newBlockIndex)
s.initFrom(this)
s.dirty = dirty
- s.debug
+ s.debug()
s.gotoFreshPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex) // could optimize: we know it will create a whole branch
s.display0(lo) = value.asInstanceOf[AnyRef]
- s.debug
+ s.debug()
//assert(s.depth == depth+1)
s
} else {
@@ -348,8 +339,8 @@ override def companion: GenericCompanion[Vector] = Vector
// //println("------- append " + value)
// debug()
if (endIndex != startIndex) {
- var blockIndex = endIndex & ~31
- var lo = endIndex & 31
+ val blockIndex = endIndex & ~31
+ val lo = endIndex & 31
if (endIndex != blockIndex) {
//println("will make writable block (from "+focus+") at: " + blockIndex)
@@ -366,7 +357,7 @@ override def companion: GenericCompanion[Vector] = Vector
//println("----- appendBack " + value + " at " + endIndex + " reached block end")
if (shift != 0) {
- debug
+ debug()
//println("shifting left by " + shiftBlocks + " at level " + (depth-1) + " (had "+startIndex+" free space)")
if (depth > 1) {
val newBlockIndex = blockIndex - shift
@@ -375,10 +366,10 @@ override def companion: GenericCompanion[Vector] = Vector
s.initFrom(this)
s.dirty = dirty
s.shiftTopLevel(shiftBlocks, 0) // shift left by n blocks
- s.debug
+ s.debug()
s.gotoFreshPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex)
s.display0(lo) = value.asInstanceOf[AnyRef]
- s.debug
+ s.debug()
//assert(depth == s.depth)
s
} else {
@@ -394,7 +385,7 @@ override def companion: GenericCompanion[Vector] = Vector
s.shiftTopLevel(shiftBlocks, 0) // shift right by n elements
s.gotoPosWritable(newFocus, newBlockIndex, newFocus ^ newBlockIndex)
s.display0(32 - shift) = value.asInstanceOf[AnyRef]
- s.debug
+ s.debug()
s
}
} else {
@@ -409,7 +400,7 @@ override def companion: GenericCompanion[Vector] = Vector
//assert(s.depth == depth+1) might or might not create new level!
if (s.depth == depth+1) {
//println("creating new level " + s.depth + " (had "+0+" free space)")
- s.debug
+ s.debug()
}
s
}
@@ -583,9 +574,7 @@ override def companion: GenericCompanion[Vector] = Vector
}
private def dropFront0(cutIndex: Int): Vector[A] = {
- var blockIndex = cutIndex & ~31
- var lo = cutIndex & 31
-
+ val blockIndex = cutIndex & ~31
val xor = cutIndex ^ (endIndex - 1)
val d = requiredDepth(xor)
val shift = (cutIndex & ~((1 << (5*d))-1))
@@ -615,9 +604,7 @@ override def companion: GenericCompanion[Vector] = Vector
}
private def dropBack0(cutIndex: Int): Vector[A] = {
- var blockIndex = (cutIndex - 1) & ~31
- var lo = ((cutIndex - 1) & 31) + 1
-
+ val blockIndex = (cutIndex - 1) & ~31
val xor = startIndex ^ (cutIndex - 1)
val d = requiredDepth(xor)
val shift = (startIndex & ~((1 << (5*d))-1))
@@ -639,14 +626,13 @@ override def companion: GenericCompanion[Vector] = Vector
}
-class VectorIterator[+A](_startIndex: Int, _endIndex: Int)
+class VectorIterator[+A](_startIndex: Int, endIndex: Int)
extends AbstractIterator[A]
with Iterator[A]
with VectorPointer[A @uncheckedVariance] {
private var blockIndex: Int = _startIndex & ~31
private var lo: Int = _startIndex & 31
- private var endIndex: Int = _endIndex
private var endLo = math.min(endIndex - blockIndex, 32)
@@ -676,13 +662,13 @@ extends AbstractIterator[A]
res
}
- private[collection] def remainingElementCount: Int = (_endIndex - (blockIndex + lo)) max 0
+ private[collection] def remainingElementCount: Int = (endIndex - (blockIndex + lo)) max 0
/** Creates a new vector which consists of elements remaining in this iterator.
* Such a vector can then be split into several vectors using methods like `take` and `drop`.
*/
private[collection] def remainingVector: Vector[A] = {
- val v = new Vector(blockIndex + lo, _endIndex, blockIndex + lo)
+ val v = new Vector(blockIndex + lo, endIndex, blockIndex + lo)
v.initFrom(this)
v
}
diff --git a/src/library/scala/collection/immutable/WrappedString.scala b/src/library/scala/collection/immutable/WrappedString.scala
index edcab31f33..d6bebf9ef5 100644
--- a/src/library/scala/collection/immutable/WrappedString.scala
+++ b/src/library/scala/collection/immutable/WrappedString.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package immutable
import generic._
diff --git a/src/library/scala/collection/immutable/package.scala b/src/library/scala/collection/immutable/package.scala
deleted file mode 100644
index ed0c1b3736..0000000000
--- a/src/library/scala/collection/immutable/package.scala
+++ /dev/null
@@ -1,93 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.collection
-
-package immutable {
- /** It looks like once upon a time this was used by ParRange, but
- * since December 2010 in r23721 it is not used by anything. We
- * should not have public API traits with seductive names like
- * "RangeUtils" which are neither documented nor used.
- */
- @deprecated("this class will be removed", "2.10.0")
- trait RangeUtils[+Repr <: RangeUtils[Repr]] {
- def start: Int
- def end: Int
- def step: Int
- def inclusive: Boolean
- def create(_start: Int, _end: Int, _step: Int, _inclusive: Boolean): Repr
-
- private final def inclusiveLast: Int = {
- val size = end.toLong - start.toLong
- (size / step.toLong * step.toLong + start.toLong).toInt
- }
-
- final def _last: Int = (
- if (!inclusive) {
- if (step == 1 || step == -1) end - step
- else {
- val inclast = inclusiveLast
- if ((end.toLong - start.toLong) % step == 0) inclast - step else inclast
- }
- }
- else if (step == 1 || step == -1) end
- else inclusiveLast
- )
-
- final def _foreach[U](f: Int => U) = if (_length > 0) {
- var i = start
- val last = _last
- while (i != last) {
- f(i)
- i += step
- }
- }
-
- final def _length: Int = (
- if (!inclusive) {
- if (end > start == step > 0 && start != end) {
- (_last.toLong - start.toLong) / step.toLong + 1
- } else 0
- }.toInt
- else {
- if (end > start == step > 0 || start == end) {
- (_last.toLong - start.toLong) / step.toLong + 1
- } else 0
- }.toInt
- )
-
- final def _apply(idx: Int): Int = {
- if (idx < 0 || idx >= _length) throw new IndexOutOfBoundsException(idx.toString)
- start + idx * step
- }
-
- private def locationAfterN(n: Int) = (
- if (n > 0) {
- if (step > 0)
- scala.math.min(start.toLong + step.toLong * n.toLong, _last.toLong).toInt
- else
- scala.math.max(start.toLong + step.toLong * n.toLong, _last.toLong).toInt
- }
- else start
- )
-
- final def _take(n: Int) = (
- if (n > 0 && _length > 0)
- create(start, locationAfterN(n), step, true)
- else
- create(start, start, step, false)
- )
-
- final def _drop(n: Int) = create(locationAfterN(n), end, step, inclusive)
- final def _slice(from: Int, until: Int) = _drop(from)._take(until - from)
- }
-}
-
-package object immutable {
- /** Nothing left after I promoted RangeUtils to the package. */
-}
diff --git a/src/library/scala/collection/mutable/AVLTree.scala b/src/library/scala/collection/mutable/AVLTree.scala
index 157e5dae62..d2205f9994 100644
--- a/src/library/scala/collection/mutable/AVLTree.scala
+++ b/src/library/scala/collection/mutable/AVLTree.scala
@@ -10,12 +10,11 @@ package scala
package collection
package mutable
-
/**
* An immutable AVL Tree implementation used by mutable.TreeSet
*
* @author Lucien Pereira
- *
+ * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11")
*/
private[mutable] sealed trait AVLTree[+A] extends Serializable {
def balance: Int
@@ -65,13 +64,19 @@ private[mutable] sealed trait AVLTree[+A] extends Serializable {
def doubleRightRotation[B >: A]: Node[B] = sys.error("Should not happen.")
}
+/**
+ * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11")
+ */
private case object Leaf extends AVLTree[Nothing] {
override val balance: Int = 0
override val depth: Int = -1
}
-private case class Node[A](val data: A, val left: AVLTree[A], val right: AVLTree[A]) extends AVLTree[A] {
+/**
+ * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11")
+ */
+private case class Node[A](data: A, left: AVLTree[A], right: AVLTree[A]) extends AVLTree[A] {
override val balance: Int = right.depth - left.depth
override val depth: Int = math.max(left.depth, right.depth) + 1
@@ -205,6 +210,9 @@ private case class Node[A](val data: A, val left: AVLTree[A], val right: AVLTree
}
}
+/**
+ * @deprecated("AVLTree and its related classes are being removed from the standard library since they're not different enough from RedBlackTree to justify keeping them.", "2.11")
+ */
private class AVLIterator[A](root: Node[A]) extends Iterator[A] {
val stack = mutable.ArrayStack[Node[A]](root)
diveLeft()
@@ -220,11 +228,11 @@ private class AVLIterator[A](root: Node[A]) extends Iterator[A] {
private def engageRight(): Unit = {
if (Leaf != stack.head.right) {
val right: Node[A] = stack.head.right.asInstanceOf[Node[A]]
- stack.pop
+ stack.pop()
stack.push(right)
diveLeft()
} else
- stack.pop
+ stack.pop()
}
override def hasNext: Boolean = !stack.isEmpty
diff --git a/src/library/scala/collection/mutable/ArrayBuffer.scala b/src/library/scala/collection/mutable/ArrayBuffer.scala
index f1cfd2d69a..2d43b352c5 100644
--- a/src/library/scala/collection/mutable/ArrayBuffer.scala
+++ b/src/library/scala/collection/mutable/ArrayBuffer.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala
index 0ce2cda32c..65b4d52a60 100644
--- a/src/library/scala/collection/mutable/ArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/ArrayBuilder.scala
@@ -6,12 +6,10 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime
diff --git a/src/library/scala/collection/mutable/ArrayLike.scala b/src/library/scala/collection/mutable/ArrayLike.scala
index 31f3d2a497..4a6820856d 100644
--- a/src/library/scala/collection/mutable/ArrayLike.scala
+++ b/src/library/scala/collection/mutable/ArrayLike.scala
@@ -6,11 +6,9 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
/** A common supertrait of `ArrayOps` and `WrappedArray` that factors out most
* operations on arrays and wrapped arrays.
diff --git a/src/library/scala/collection/mutable/ArrayOps.scala b/src/library/scala/collection/mutable/ArrayOps.scala
index 25ba7e4ce6..4c996bfb88 100644
--- a/src/library/scala/collection/mutable/ArrayOps.scala
+++ b/src/library/scala/collection/mutable/ArrayOps.scala
@@ -52,6 +52,20 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza
super.toArray[U]
}
+ def :+[B >: T: scala.reflect.ClassTag](elem: B): Array[B] = {
+ val result = Array.ofDim[B](repr.length + 1)
+ Array.copy(repr, 0, result, 0, repr.length)
+ result(repr.length) = elem
+ result
+ }
+
+ def +:[B >: T: scala.reflect.ClassTag](elem: B): Array[B] = {
+ val result = Array.ofDim[B](repr.length + 1)
+ result(0) = elem
+ Array.copy(repr, 0, result, 1, repr.length)
+ result
+ }
+
override def par = ParArray.handoff(repr)
/** Flattens a two-dimensional array by concatenating all its rows
@@ -66,7 +80,7 @@ trait ArrayOps[T] extends Any with ArrayLike[T, Array[T]] with CustomParalleliza
b.sizeHint(map{case is: scala.collection.IndexedSeq[_] => is.size case _ => 0}.sum)
for (xs <- this)
b ++= asTrav(xs)
- b.result
+ b.result()
}
/** Transposes a two dimensional array.
diff --git a/src/library/scala/collection/mutable/ArraySeq.scala b/src/library/scala/collection/mutable/ArraySeq.scala
index 33f6949662..577a838315 100644
--- a/src/library/scala/collection/mutable/ArraySeq.scala
+++ b/src/library/scala/collection/mutable/ArraySeq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -90,7 +91,7 @@ extends AbstractSeq[A]
}
override def clone(): ArraySeq[A] = {
- val cloned = array.clone.asInstanceOf[Array[AnyRef]]
+ val cloned = array.clone().asInstanceOf[Array[AnyRef]]
new ArraySeq[A](length) {
override val array = cloned
}
diff --git a/src/library/scala/collection/mutable/ArrayStack.scala b/src/library/scala/collection/mutable/ArrayStack.scala
index 670558ab06..e05d668519 100644
--- a/src/library/scala/collection/mutable/ArrayStack.scala
+++ b/src/library/scala/collection/mutable/ArrayStack.scala
@@ -150,7 +150,7 @@ extends AbstractSeq[T]
*
* @param f The function to drain to.
*/
- def drain(f: T => Unit) = while (!isEmpty) f(pop)
+ def drain(f: T => Unit) = while (!isEmpty) f(pop())
/** Pushes all the provided elements in the traversable object onto the stack.
*
@@ -190,7 +190,7 @@ extends AbstractSeq[T]
*
* @param f The function to apply to the top two elements.
*/
- def combine(f: (T, T) => T): Unit = push(f(pop, pop))
+ def combine(f: (T, T) => T): Unit = push(f(pop(), pop()))
/** Repeatedly combine the top elements of the stack until the stack contains only
* one element.
diff --git a/src/library/scala/collection/mutable/BitSet.scala b/src/library/scala/collection/mutable/BitSet.scala
index 2a535a799c..f252a0bfeb 100644
--- a/src/library/scala/collection/mutable/BitSet.scala
+++ b/src/library/scala/collection/mutable/BitSet.scala
@@ -8,11 +8,12 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
-import BitSetLike.{LogWL, updateArray}
+import BitSetLike.{LogWL, MaxSize, updateArray}
/** A class for mutable bitsets.
*
@@ -58,14 +59,19 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int]
if (idx < nwords) elems(idx) else 0L
private def updateWord(idx: Int, w: Long) {
+ ensureCapacity(idx)
+ elems(idx) = w
+ }
+
+ private def ensureCapacity(idx: Int) {
+ require(idx < MaxSize)
if (idx >= nwords) {
var newlen = nwords
- while (idx >= newlen) newlen = newlen * 2
+ while (idx >= newlen) newlen = (newlen * 2) min MaxSize
val elems1 = new Array[Long](newlen)
Array.copy(elems, 0, elems1, 0, nwords)
elems = elems1
}
- elems(idx) = w
}
protected def fromBitMaskNoCopy(words: Array[Long]): BitSet = new BitSet(words)
@@ -92,6 +98,51 @@ class BitSet(protected var elems: Array[Long]) extends AbstractSet[Int]
def += (elem: Int): this.type = { add(elem); this }
def -= (elem: Int): this.type = { remove(elem); this }
+ /** Updates this bitset to the union with another bitset by performing a bitwise "or".
+ *
+ * @param other the bitset to form the union with.
+ * @return the bitset itself.
+ */
+ def |= (other: BitSet): this.type = {
+ ensureCapacity(other.nwords)
+ for (i <- 0 until other.nwords)
+ elems(i) = elems(i) | other.word(i)
+ this
+ }
+ /** Updates this bitset to the intersection with another bitset by performing a bitwise "and".
+ *
+ * @param other the bitset to form the intersection with.
+ * @return the bitset itself.
+ */
+ def &= (other: BitSet): this.type = {
+ ensureCapacity(other.nwords)
+ for (i <- 0 until other.nwords)
+ elems(i) = elems(i) & other.word(i)
+ this
+ }
+ /** Updates this bitset to the symmetric difference with another bitset by performing a bitwise "xor".
+ *
+ * @param other the bitset to form the symmetric difference with.
+ * @return the bitset itself.
+ */
+ def ^= (other: BitSet): this.type = {
+ ensureCapacity(other.nwords)
+ for (i <- 0 until other.nwords)
+ elems(i) = elems(i) ^ other.word(i)
+ this
+ }
+ /** Updates this bitset to the difference with another bitset by performing a bitwise "and-not".
+ *
+ * @param other the bitset to form the difference with.
+ * @return the bitset itself.
+ */
+ def &~= (other: BitSet): this.type = {
+ ensureCapacity(other.nwords)
+ for (i <- 0 until other.nwords)
+ elems(i) = elems(i) & ~other.word(i)
+ this
+ }
+
override def clear() {
elems = new Array[Long](elems.length)
}
diff --git a/src/library/scala/collection/mutable/Buffer.scala b/src/library/scala/collection/mutable/Buffer.scala
index 230799c6f3..d2e33badbe 100644
--- a/src/library/scala/collection/mutable/Buffer.scala
+++ b/src/library/scala/collection/mutable/Buffer.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/BufferLike.scala b/src/library/scala/collection/mutable/BufferLike.scala
index 5935a2858a..4b3d3bc1cf 100644
--- a/src/library/scala/collection/mutable/BufferLike.scala
+++ b/src/library/scala/collection/mutable/BufferLike.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -198,7 +199,7 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]]
case Remove(Index(n), x) => if (this(n) == x) remove(n)
case Remove(NoLo, x) => this -= x
- case Reset() => clear
+ case Reset() => clear()
case s: Script[_] => s.iterator foreach <<
case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
}
@@ -260,6 +261,6 @@ trait BufferLike[A, +This <: BufferLike[A, This] with Buffer[A]]
override def clone(): This = {
val bf = newBuilder
bf ++= this
- bf.result.asInstanceOf[This]
+ bf.result().asInstanceOf[This]
}
}
diff --git a/src/library/scala/collection/mutable/BufferProxy.scala b/src/library/scala/collection/mutable/BufferProxy.scala
index 37aa1862fa..14946cdfd8 100644
--- a/src/library/scala/collection/mutable/BufferProxy.scala
+++ b/src/library/scala/collection/mutable/BufferProxy.scala
@@ -6,12 +6,10 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
import script._
/** This is a simple proxy class for <a href="Buffer.html"
@@ -127,7 +125,7 @@ trait BufferProxy[A] extends Buffer[A] with Proxy {
/** Clears the buffer contents.
*/
- def clear() { self.clear }
+ def clear() { self.clear() }
/** Send a message to this scriptable object.
*
diff --git a/src/library/scala/collection/mutable/Builder.scala b/src/library/scala/collection/mutable/Builder.scala
index 5c0681df1d..75560580cc 100644
--- a/src/library/scala/collection/mutable/Builder.scala
+++ b/src/library/scala/collection/mutable/Builder.scala
@@ -121,7 +121,7 @@ trait Builder[-Elem, +To] extends Growable[Elem] {
override def ++=(xs: TraversableOnce[Elem]): this.type = { self ++= xs; this }
override def sizeHint(size: Int) = self.sizeHint(size)
override def sizeHintBounded(size: Int, boundColl: TraversableLike[_, _]) = self.sizeHintBounded(size, boundColl)
- def result: NewTo = f(self.result)
+ def result: NewTo = f(self.result())
}
}
diff --git a/src/library/scala/collection/mutable/Cloneable.scala b/src/library/scala/collection/mutable/Cloneable.scala
index dadcd36257..8b2f3f70de 100644
--- a/src/library/scala/collection/mutable/Cloneable.scala
+++ b/src/library/scala/collection/mutable/Cloneable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
/** A trait for cloneable collections.
diff --git a/src/library/scala/collection/mutable/ConcurrentMap.scala b/src/library/scala/collection/mutable/ConcurrentMap.scala
deleted file mode 100644
index 5b5d738d03..0000000000
--- a/src/library/scala/collection/mutable/ConcurrentMap.scala
+++ /dev/null
@@ -1,90 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2010-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.collection
-package mutable
-
-/** A template trait for mutable maps that allow concurrent access.
- *
- * $concurrentmapinfo
- *
- * @since 2.8
- * @see [[http://docs.scala-lang.org/overviews/collections/concrete-mutable-collection-classes.html#concurrent_maps "Scala's Collection Library overview"]]
- * section on `Concurrent Maps` for more information.
- *
- * @tparam A the key type of the map
- * @tparam B the value type of the map
- *
- * @define Coll `ConcurrentMap`
- * @define coll concurrent map
- * @define concurrentmapinfo
- * This is a base trait for all Scala concurrent map implementations. It
- * provides all of the methods a `Map` does, with the difference that all the
- * changes are atomic. It also describes methods specific to concurrent maps.
- *
- * '''Note''': The concurrent maps do not accept `'''null'''` for keys or values.
- *
- * @define atomicop
- * This is an atomic operation.
- */
-@deprecated("Use `scala.collection.concurrent.Map` instead.", "2.10.0")
-trait ConcurrentMap[A, B] extends Map[A, B] {
-
- /**
- * Associates the given key with a given value, unless the key was already
- * associated with some other value.
- *
- * $atomicop
- *
- * @param k key with which the specified value is to be associated with
- * @param v value to be associated with the specified key
- * @return `Some(oldvalue)` if there was a value `oldvalue` previously
- * associated with the specified key, or `None` if there was no
- * mapping for the specified key
- */
- def putIfAbsent(k: A, v: B): Option[B]
-
- /**
- * Removes the entry for the specified key if its currently mapped to the
- * specified value.
- *
- * $atomicop
- *
- * @param k key for which the entry should be removed
- * @param v value expected to be associated with the specified key if
- * the removal is to take place
- * @return `true` if the removal took place, `false` otherwise
- */
- def remove(k: A, v: B): Boolean
-
- /**
- * Replaces the entry for the given key only if it was previously mapped to
- * a given value.
- *
- * $atomicop
- *
- * @param k key for which the entry should be replaced
- * @param oldvalue value expected to be associated with the specified key
- * if replacing is to happen
- * @param newvalue value to be associated with the specified key
- * @return `true` if the entry was replaced, `false` otherwise
- */
- def replace(k: A, oldvalue: B, newvalue: B): Boolean
-
- /**
- * Replaces the entry for the given key only if it was previously mapped
- * to some value.
- *
- * $atomicop
- *
- * @param k key for which the entry should be replaced
- * @param v value to be associated with the specified key
- * @return `Some(v)` if the given key was previously mapped to some value `v`, or `None` otherwise
- */
- def replace(k: A, v: B): Option[B]
-}
diff --git a/src/library/scala/collection/mutable/DefaultEntry.scala b/src/library/scala/collection/mutable/DefaultEntry.scala
index f14cb4ac2b..66db45866c 100644
--- a/src/library/scala/collection/mutable/DefaultEntry.scala
+++ b/src/library/scala/collection/mutable/DefaultEntry.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** Class used internally for default map model.
diff --git a/src/library/scala/collection/mutable/DefaultMapModel.scala b/src/library/scala/collection/mutable/DefaultMapModel.scala
index 903f117466..4dfae047c3 100644
--- a/src/library/scala/collection/mutable/DefaultMapModel.scala
+++ b/src/library/scala/collection/mutable/DefaultMapModel.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
/** This class is used internally. It implements the mutable `Map`
diff --git a/src/library/scala/collection/mutable/DoubleLinkedList.scala b/src/library/scala/collection/mutable/DoubleLinkedList.scala
index 18a1e234f6..8654a91cf1 100644
--- a/src/library/scala/collection/mutable/DoubleLinkedList.scala
+++ b/src/library/scala/collection/mutable/DoubleLinkedList.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -68,7 +69,7 @@ class DoubleLinkedList[A]() extends AbstractSeq[A]
override def clone(): DoubleLinkedList[A] = {
val builder = newBuilder
builder ++= this
- builder.result
+ builder.result()
}
}
diff --git a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala
index 3f223f30ec..776ac76c45 100644
--- a/src/library/scala/collection/mutable/DoubleLinkedListLike.scala
+++ b/src/library/scala/collection/mutable/DoubleLinkedListLike.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import scala.annotation.migration
diff --git a/src/library/scala/collection/mutable/FlatHashTable.scala b/src/library/scala/collection/mutable/FlatHashTable.scala
index 91e95e039b..1cdf150cb8 100644
--- a/src/library/scala/collection/mutable/FlatHashTable.scala
+++ b/src/library/scala/collection/mutable/FlatHashTable.scala
@@ -6,18 +6,16 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
package mutable
-
/** An implementation class backing a `HashSet`.
*
* This trait is used internally. It can be mixed in with various collections relying on
* hash table as an implementation.
*
* @define coll flat hash table
- * @define cannotStoreNull '''Note''': A $coll cannot store `null` elements.
* @since 2.3
* @tparam A the type of the elements contained in the $coll.
*/
@@ -78,7 +76,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
assert(size >= 0)
table = new Array(capacity(sizeForThreshold(size, _loadFactor)))
- threshold = newThreshold(_loadFactor, table.size)
+ threshold = newThreshold(_loadFactor, table.length)
seedvalue = in.readInt()
@@ -87,9 +85,9 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
var index = 0
while (index < size) {
- val elem = in.readObject().asInstanceOf[A]
+ val elem = entryToElem(in.readObject())
f(elem)
- addEntry(elem)
+ addElem(elem)
index += 1
}
}
@@ -109,61 +107,78 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
}
/** Finds an entry in the hash table if such an element exists. */
- protected def findEntry(elem: A): Option[A] = {
- val entry = findEntryImpl(elem)
- if (null == entry) None else Some(entry.asInstanceOf[A])
- }
+ protected def findEntry(elem: A): Option[A] =
+ findElemImpl(elem) match {
+ case null => None
+ case entry => Some(entryToElem(entry))
+ }
+
/** Checks whether an element is contained in the hash table. */
- protected def containsEntry(elem: A): Boolean = {
- null != findEntryImpl(elem)
+ protected def containsElem(elem: A): Boolean = {
+ null != findElemImpl(elem)
}
- private def findEntryImpl(elem: A): AnyRef = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry && entry != elem) {
+ private def findElemImpl(elem: A): AnyRef = {
+ val searchEntry = elemToEntry(elem)
+ var h = index(searchEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry && curEntry != searchEntry) {
h = (h + 1) % table.length
- entry = table(h)
+ curEntry = table(h)
}
- entry
+ curEntry
}
- /** Add entry if not yet in table.
- * @return Returns `true` if a new entry was added, `false` otherwise.
+ /** Add elem if not yet in table.
+ * @return Returns `true` if a new elem was added, `false` otherwise.
*/
- protected def addEntry(elem: A) : Boolean = {
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) return false
+ protected def addElem(elem: A) : Boolean = {
+ addEntry(elemToEntry(elem))
+ }
+
+ /**
+ * Add an entry (an elem converted to an entry via elemToEntry) if not yet in
+ * table.
+ * @return Returns `true` if a new elem was added, `false` otherwise.
+ */
+ protected def addEntry(newEntry : AnyRef) : Boolean = {
+ var h = index(newEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry) {
+ if (curEntry == newEntry) return false
h = (h + 1) % table.length
- entry = table(h)
+ curEntry = table(h)
//Statistics.collisions += 1
}
- table(h) = elem.asInstanceOf[AnyRef]
+ table(h) = newEntry
tableSize = tableSize + 1
nnSizeMapAdd(h)
if (tableSize >= threshold) growTable()
true
+
}
- /** Removes an entry from the hash table, returning an option value with the element, or `None` if it didn't exist. */
- protected def removeEntry(elem: A) : Option[A] = {
+ /**
+ * Removes an elem from the hash table returning true if the element was found (and thus removed)
+ * or false if it didn't exist.
+ */
+ protected def removeElem(elem: A) : Boolean = {
if (tableDebug) checkConsistent()
def precedes(i: Int, j: Int) = {
val d = table.length >> 1
if (i <= j) j - i < d
else i - j > d
}
- var h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) {
+ val removalEntry = elemToEntry(elem)
+ var h = index(removalEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry) {
+ if (curEntry == removalEntry) {
var h0 = h
var h1 = (h0 + 1) % table.length
while (null != table(h1)) {
- val h2 = index(elemHashCode(table(h1).asInstanceOf[A]))
+ val h2 = index(table(h1).hashCode)
//Console.println("shift at "+h1+":"+table(h1)+" with h2 = "+h2+"? "+(h2 != h1)+precedes(h2, h0)+table.length)
if (h2 != h1 && precedes(h2, h0)) {
//Console.println("shift "+h1+" to "+h0+"!")
@@ -176,12 +191,12 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
tableSize -= 1
nnSizeMapRemove(h0)
if (tableDebug) checkConsistent()
- return Some(entry.asInstanceOf[A])
+ return true
}
h = (h + 1) % table.length
- entry = table(h)
+ curEntry = table(h)
}
- None
+ false
}
protected def iterator: Iterator[A] = new AbstractIterator[A] {
@@ -191,8 +206,8 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
i < table.length
}
def next(): A =
- if (hasNext) { i += 1; table(i - 1).asInstanceOf[A] }
- else Iterator.empty.next
+ if (hasNext) { i += 1; entryToElem(table(i - 1)) }
+ else Iterator.empty.next()
}
private def growTable() {
@@ -205,7 +220,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
var i = 0
while (i < oldtable.length) {
val entry = oldtable(i)
- if (null != entry) addEntry(entry.asInstanceOf[A])
+ if (null != entry) addEntry(entry)
i += 1
}
if (tableDebug) checkConsistent()
@@ -213,9 +228,10 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
private def checkConsistent() {
for (i <- 0 until table.length)
- if (table(i) != null && !containsEntry(table(i).asInstanceOf[A]))
- assert(false, i+" "+table(i)+" "+table.mkString)
+ if (table(i) != null && !containsElem(entryToElem(table(i))))
+ assert(assertion = false, i+" "+table(i)+" "+table.mkString)
}
+
/* Size map handling code */
@@ -265,7 +281,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
val totalbuckets = totalSizeMapBuckets
var bucketidx = 0
var tableidx = 0
- var tbl = table
+ val tbl = table
var tableuntil = sizeMapBucketSize min tbl.length
while (bucketidx < totalbuckets) {
var currbucketsz = 0
@@ -341,7 +357,7 @@ trait FlatHashTable[A] extends FlatHashTable.HashUtils[A] {
seedvalue = c.seedvalue
sizemap = c.sizemap
}
- if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild
+ if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild()
}
}
@@ -358,6 +374,11 @@ private[collection] object FlatHashTable {
final def seedGenerator = new ThreadLocal[scala.util.Random] {
override def initialValue = new scala.util.Random
}
+
+ private object NullSentinel {
+ override def hashCode = 0
+ override def toString = "NullSentinel"
+ }
/** The load factor for the hash table; must be < 500 (0.5)
*/
@@ -386,10 +407,6 @@ private[collection] object FlatHashTable {
// so that:
protected final def sizeMapBucketSize = 1 << sizeMapBucketBitSize
- protected def elemHashCode(elem: A) =
- if (elem == null) throw new IllegalArgumentException("Flat hash tables cannot contain null elements.")
- else elem.hashCode()
-
protected final def improve(hcode: Int, seed: Int) = {
//var h: Int = hcode + ~(hcode << 9)
//h = h ^ (h >>> 14)
@@ -404,6 +421,19 @@ private[collection] object FlatHashTable {
val rotated = (improved >>> rotation) | (improved << (32 - rotation))
rotated
}
+
+ /**
+ * Elems have type A, but we store AnyRef in the table. Plus we need to deal with
+ * null elems, which need to be stored as NullSentinel
+ */
+ protected final def elemToEntry(elem : A) : AnyRef =
+ if (null == elem) NullSentinel else elem.asInstanceOf[AnyRef]
+
+ /**
+ * Does the inverse translation of elemToEntry
+ */
+ protected final def entryToElem(entry : AnyRef) : A =
+ (if (entry.isInstanceOf[NullSentinel.type]) null else entry).asInstanceOf[A]
}
}
diff --git a/src/library/scala/collection/mutable/GenIterable.scala.disabled b/src/library/scala/collection/mutable/GenIterable.scala.disabled
deleted file mode 100644
index 9acfccdae8..0000000000
--- a/src/library/scala/collection/mutable/GenIterable.scala.disabled
+++ /dev/null
@@ -1,37 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.collection
-package mutable
-
-
-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]
- with scala.collection.GenIterableLike[A, GenIterable[A]]
-// with GenericTraversableTemplate[A, GenIterable]
-{
- def seq: Iterable[A]
- //override def companion: GenericCompanion[GenIterable] = GenIterable
-}
-
-
-// object GenIterable extends TraversableFactory[GenIterable] {
-// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenIterable[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A]: Builder[A, GenIterable[A]] = Iterable.newBuilder
-// }
-
-
diff --git a/src/library/scala/collection/mutable/GenMap.scala.disabled b/src/library/scala/collection/mutable/GenMap.scala.disabled
deleted file mode 100644
index e4fd1dad64..0000000000
--- a/src/library/scala/collection/mutable/GenMap.scala.disabled
+++ /dev/null
@@ -1,40 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package mutable
-
-
-import generic._
-
-
-/** A base trait for maps that can be mutated.
- * $possiblyparinfo
- * $mapNote
- * $mapTags
- * @since 1.0
- * @author Matthias Zenger
- */
-trait GenMap[A, B]
-extends GenIterable[(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]
-// }
-
diff --git a/src/library/scala/collection/mutable/GenSeq.scala.disabled b/src/library/scala/collection/mutable/GenSeq.scala.disabled
deleted file mode 100644
index ec904723a5..0000000000
--- a/src/library/scala/collection/mutable/GenSeq.scala.disabled
+++ /dev/null
@@ -1,44 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package mutable
-
-
-import generic._
-
-
-/** A subtrait of `collection.GenSeq` which represents sequences
- * 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]
- with scala.collection.GenSeqLike[A, GenSeq[A]]
-// with GenericTraversableTemplate[A, 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]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A]: Builder[A, GenSeq[A]] = Seq.newBuilder
-// }
-
diff --git a/src/library/scala/collection/mutable/GenSet.scala.disabled b/src/library/scala/collection/mutable/GenSet.scala.disabled
deleted file mode 100644
index dec20e2a46..0000000000
--- a/src/library/scala/collection/mutable/GenSet.scala.disabled
+++ /dev/null
@@ -1,46 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package mutable
-
-
-
-import generic._
-
-
-/** A generic trait for mutable sets.
- *
- * $possiblyparinfo
- * $setNote
- * $setTags
- *
- * @since 1.0
- * @author Matthias Zenger
- * @define Coll `mutable.Set`
- * @define coll mutable set
- */
-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]
-{
- //override def companion: GenericCompanion[GenSet] = GenSet
- def seq: Set[A]
-}
-
-
-// object GenSet extends TraversableFactory[GenSet] {
-// implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, GenSet[A]] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A]: Builder[A, GenSet[A]] = Set.newBuilder
-// }
-
-
diff --git a/src/library/scala/collection/mutable/GenTraversable.scala.disabled b/src/library/scala/collection/mutable/GenTraversable.scala.disabled
deleted file mode 100644
index 2453e2ce87..0000000000
--- a/src/library/scala/collection/mutable/GenTraversable.scala.disabled
+++ /dev/null
@@ -1,38 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.collection
-package mutable
-
-
-import generic._
-
-
-/** A trait for traversable collections that can be mutated.
- *
- * $possiblyparinfo
- *
- * $traversableInfo
- * @define mutability mutable
- */
-trait GenTraversable[A] extends scala.collection.GenTraversable[A]
- with scala.collection.GenTraversableLike[A, GenTraversable[A]]
-// with GenericTraversableTemplate[A, GenTraversable]
- with Mutable
-{
- def seq: Traversable[A]
- //override def companion: GenericCompanion[GenTraversable] = GenTraversable
-}
-
-// object GenTraversable extends TraversableFactory[GenTraversable] {
-// implicit def canBuildFrom[A] = ReusableCBF.asInstanceOf[GenericCanBuildFrom[A]]
-// def newBuilder[A] = Traversable.newBuilder
-// }
-
diff --git a/src/library/scala/collection/mutable/GrowingBuilder.scala b/src/library/scala/collection/mutable/GrowingBuilder.scala
index ba7ea60df1..c4b5e546aa 100644
--- a/src/library/scala/collection/mutable/GrowingBuilder.scala
+++ b/src/library/scala/collection/mutable/GrowingBuilder.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/HashEntry.scala b/src/library/scala/collection/mutable/HashEntry.scala
index 5cd976eb47..4c0f6a93e8 100644
--- a/src/library/scala/collection/mutable/HashEntry.scala
+++ b/src/library/scala/collection/mutable/HashEntry.scala
@@ -5,7 +5,8 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** Class used internally.
diff --git a/src/library/scala/collection/mutable/HashMap.scala b/src/library/scala/collection/mutable/HashMap.scala
index 3cd7f07d83..6fca75ffea 100644
--- a/src/library/scala/collection/mutable/HashMap.scala
+++ b/src/library/scala/collection/mutable/HashMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -93,9 +94,9 @@ extends AbstractMap[A, B]
def -=(key: A): this.type = { removeEntry(key); this }
- def iterator = entriesIterator map {e => (e.key, e.value)}
+ def iterator = entriesIterator map (e => ((e.key, e.value)))
- override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f(e.key, e.value))
+ override def foreach[C](f: ((A, B)) => C): Unit = foreachEntry(e => f((e.key, e.value)))
/* Override to avoid tuple allocation in foreach */
override def keySet: scala.collection.Set[A] = new DefaultKeySet {
@@ -111,21 +112,21 @@ extends AbstractMap[A, B]
override def keysIterator: Iterator[A] = new AbstractIterator[A] {
val iter = entriesIterator
def hasNext = iter.hasNext
- def next() = iter.next.key
+ def next() = iter.next().key
}
/* Override to avoid tuple allocation */
override def valuesIterator: Iterator[B] = new AbstractIterator[B] {
val iter = entriesIterator
def hasNext = iter.hasNext
- def next() = iter.next.value
+ def next() = iter.next().value
}
/** Toggles whether a size map is used to track hash map statistics.
*/
def useSizeMap(t: Boolean) = if (t) {
- if (!isSizeMapDefined) sizeMapInitAndRebuild
- } else sizeMapDisable
+ if (!isSizeMapDefined) sizeMapInitAndRebuild()
+ } else sizeMapDisable()
protected def createNewEntry[B1](key: A, value: B1): Entry = {
new Entry(key, value.asInstanceOf[B])
diff --git a/src/library/scala/collection/mutable/HashSet.scala b/src/library/scala/collection/mutable/HashSet.scala
index c60e363f8f..886fee5a59 100644
--- a/src/library/scala/collection/mutable/HashSet.scala
+++ b/src/library/scala/collection/mutable/HashSet.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -16,8 +17,6 @@ import scala.collection.parallel.mutable.ParHashSet
/** This class implements mutable sets using a hashtable.
*
- * $cannotStoreNull
- *
* @author Matthias Zenger
* @author Martin Odersky
* @version 2.0, 31/12/2006
@@ -55,17 +54,17 @@ extends AbstractSet[A]
override def size: Int = tableSize
- def contains(elem: A): Boolean = containsEntry(elem)
+ def contains(elem: A): Boolean = containsElem(elem)
- def += (elem: A): this.type = { addEntry(elem); this }
+ def += (elem: A): this.type = { addElem(elem); this }
- def -= (elem: A): this.type = { removeEntry(elem); this }
+ def -= (elem: A): this.type = { removeElem(elem); this }
override def par = new ParHashSet(hashTableContents)
- override def add(elem: A): Boolean = addEntry(elem)
+ override def add(elem: A): Boolean = addElem(elem)
- override def remove(elem: A): Boolean = removeEntry(elem).isDefined
+ override def remove(elem: A): Boolean = removeElem(elem)
override def clear() { clearTable() }
@@ -75,8 +74,8 @@ extends AbstractSet[A]
var i = 0
val len = table.length
while (i < len) {
- val elem = table(i)
- if (elem ne null) f(elem.asInstanceOf[A])
+ val curEntry = table(i)
+ if (curEntry ne null) f(entryToElem(curEntry))
i += 1
}
}
@@ -94,8 +93,8 @@ extends AbstractSet[A]
/** Toggles whether a size map is used to track hash map statistics.
*/
def useSizeMap(t: Boolean) = if (t) {
- if (!isSizeMapDefined) sizeMapInitAndRebuild
- } else sizeMapDisable
+ if (!isSizeMapDefined) sizeMapInitAndRebuild()
+ } else sizeMapDisable()
}
diff --git a/src/library/scala/collection/mutable/HashTable.scala b/src/library/scala/collection/mutable/HashTable.scala
index 8fef1be66b..0479b51830 100644
--- a/src/library/scala/collection/mutable/HashTable.scala
+++ b/src/library/scala/collection/mutable/HashTable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
/** This class can be used to construct data structures that are based
@@ -96,7 +97,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU
val smDefined = in.readBoolean()
table = new Array(capacity(sizeForThreshold(_loadFactor, size)))
- threshold = newThreshold(_loadFactor, table.size)
+ threshold = newThreshold(_loadFactor, table.length)
if (smDefined) sizeMapInit(table.length) else sizemap = null
@@ -365,7 +366,7 @@ trait HashTable[A, Entry >: Null <: HashEntry[A, Entry]] extends HashTable.HashU
seedvalue = c.seedvalue
sizemap = c.sizemap
}
- if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild
+ if (alwaysInitSizeMap && sizemap == null) sizeMapInitAndRebuild()
}
private[collection] def hashTableContents = new HashTable.Contents(
@@ -382,7 +383,7 @@ private[collection] object HashTable {
/** The load factor for the hash table (in 0.001 step).
*/
private[collection] final def defaultLoadFactor: Int = 750 // corresponds to 75%
- private[collection] final def loadFactorDenum = 1000;
+ private[collection] final def loadFactorDenum = 1000
private[collection] final def newThreshold(_loadFactor: Int, size: Int) = ((size.toLong * _loadFactor) / loadFactorDenum).toInt
@@ -457,13 +458,13 @@ private[collection] object HashTable {
*/
private[collection] def powerOfTwo(target: Int): Int = {
/* See http://bits.stephan-brumme.com/roundUpToNextPowerOfTwo.html */
- var c = target - 1;
- c |= c >>> 1;
- c |= c >>> 2;
- c |= c >>> 4;
- c |= c >>> 8;
- c |= c >>> 16;
- c + 1;
+ var c = target - 1
+ c |= c >>> 1
+ c |= c >>> 2
+ c |= c >>> 4
+ c |= c >>> 8
+ c |= c >>> 16
+ c + 1
}
class Contents[A, Entry >: Null <: HashEntry[A, Entry]](
diff --git a/src/library/scala/collection/mutable/History.scala b/src/library/scala/collection/mutable/History.scala
index c1d94a904c..19148c0ac2 100644
--- a/src/library/scala/collection/mutable/History.scala
+++ b/src/library/scala/collection/mutable/History.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/tPFL **
+** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/tPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
@@ -41,7 +42,7 @@ extends AbstractIterable[(Pub, Evt)]
*/
def notify(pub: Pub, event: Evt) {
if (log.length >= maxHistory)
- log.dequeue
+ log.dequeue()
log.enqueue((pub, event))
}
@@ -50,7 +51,7 @@ extends AbstractIterable[(Pub, Evt)]
def iterator: Iterator[(Pub, Evt)] = log.iterator
def events: Iterator[Evt] = log.iterator map (_._2)
- def clear() { log.clear }
+ def clear() { log.clear() }
/** Checks if two history objects are structurally identical.
*
@@ -60,5 +61,5 @@ extends AbstractIterable[(Pub, Evt)]
case that: History[_, _] => this.log equals that.log
case _ => false
}
- override def hashCode = log.hashCode
+ override def hashCode = log.hashCode()
}
diff --git a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
index 755eea831f..88e9e9db8f 100644
--- a/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
+++ b/src/library/scala/collection/mutable/ImmutableMapAdaptor.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import scala.annotation.migration
diff --git a/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala b/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
index 42c757d3bf..3e64747832 100644
--- a/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
+++ b/src/library/scala/collection/mutable/ImmutableSetAdaptor.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
diff --git a/src/library/scala/collection/mutable/IndexedSeq.scala b/src/library/scala/collection/mutable/IndexedSeq.scala
index 4d094e697b..3d9630eea7 100644
--- a/src/library/scala/collection/mutable/IndexedSeq.scala
+++ b/src/library/scala/collection/mutable/IndexedSeq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/IndexedSeqLike.scala b/src/library/scala/collection/mutable/IndexedSeqLike.scala
index f0c31ec7fb..4cf794c32f 100644
--- a/src/library/scala/collection/mutable/IndexedSeqLike.scala
+++ b/src/library/scala/collection/mutable/IndexedSeqLike.scala
@@ -6,11 +6,9 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
/** A subtrait of scala.collection.IndexedSeq which represents sequences
* that can be mutated.
diff --git a/src/library/scala/collection/mutable/IndexedSeqOptimized.scala b/src/library/scala/collection/mutable/IndexedSeqOptimized.scala
index cb7e8efdc7..09f0712862 100755
--- a/src/library/scala/collection/mutable/IndexedSeqOptimized.scala
+++ b/src/library/scala/collection/mutable/IndexedSeqOptimized.scala
@@ -6,11 +6,9 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
/** A subtrait of scala.collection.IndexedSeq which represents sequences
* that can be mutated.
diff --git a/src/library/scala/collection/mutable/IndexedSeqView.scala b/src/library/scala/collection/mutable/IndexedSeqView.scala
index cf5166eea8..36c1076b87 100644
--- a/src/library/scala/collection/mutable/IndexedSeqView.scala
+++ b/src/library/scala/collection/mutable/IndexedSeqView.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -82,8 +83,6 @@ self =>
protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new { val pred = p } with AbstractTransformed[A] with TakenWhile
protected override def newReversed: Transformed[A] = new AbstractTransformed[A] with Reversed
- private implicit def asThis(xs: Transformed[A]): This = xs.asInstanceOf[This]
-
override def filter(p: A => Boolean): This = newFiltered(p)
override def init: This = newSliced(SliceInterval(0, self.length - 1))
override def drop(n: Int): This = newSliced(SliceInterval(n, self.length))
diff --git a/src/library/scala/collection/mutable/Iterable.scala b/src/library/scala/collection/mutable/Iterable.scala
index b79453e4e9..f7a794e357 100644
--- a/src/library/scala/collection/mutable/Iterable.scala
+++ b/src/library/scala/collection/mutable/Iterable.scala
@@ -5,7 +5,8 @@
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/LazyBuilder.scala b/src/library/scala/collection/mutable/LazyBuilder.scala
index 0b56c86ac4..ebee38b77f 100644
--- a/src/library/scala/collection/mutable/LazyBuilder.scala
+++ b/src/library/scala/collection/mutable/LazyBuilder.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** A builder that constructs its result lazily. Iterators or iterables to
diff --git a/src/library/scala/collection/mutable/LinearSeq.scala b/src/library/scala/collection/mutable/LinearSeq.scala
index f241a2f6d4..3fa10042ef 100644
--- a/src/library/scala/collection/mutable/LinearSeq.scala
+++ b/src/library/scala/collection/mutable/LinearSeq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/LinkedEntry.scala b/src/library/scala/collection/mutable/LinkedEntry.scala
index e4e29122d8..296e7fde18 100644
--- a/src/library/scala/collection/mutable/LinkedEntry.scala
+++ b/src/library/scala/collection/mutable/LinkedEntry.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
/** Class for the linked hash map entry, used internally.
diff --git a/src/library/scala/collection/mutable/LinkedHashMap.scala b/src/library/scala/collection/mutable/LinkedHashMap.scala
index da2c36ac2d..536f320402 100644
--- a/src/library/scala/collection/mutable/LinkedHashMap.scala
+++ b/src/library/scala/collection/mutable/LinkedHashMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -92,7 +93,7 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B]
def hasNext = cur ne null
def next =
if (hasNext) { val res = (cur.key, cur.value); cur = cur.later; res }
- else Iterator.empty.next
+ else Iterator.empty.next()
}
protected class FilteredKeys(p: A => Boolean) extends super.FilteredKeys(p) {
@@ -118,7 +119,7 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B]
def hasNext = cur ne null
def next =
if (hasNext) { val res = cur.key; cur = cur.later; res }
- else Iterator.empty.next
+ else Iterator.empty.next()
}
override def valuesIterator: Iterator[B] = new AbstractIterator[B] {
@@ -126,7 +127,7 @@ class LinkedHashMap[A, B] extends AbstractMap[A, B]
def hasNext = cur ne null
def next =
if (hasNext) { val res = cur.value; cur = cur.later; res }
- else Iterator.empty.next
+ else Iterator.empty.next()
}
override def foreach[U](f: ((A, B)) => U) {
diff --git a/src/library/scala/collection/mutable/LinkedHashSet.scala b/src/library/scala/collection/mutable/LinkedHashSet.scala
index 1723258433..d89566793f 100644
--- a/src/library/scala/collection/mutable/LinkedHashSet.scala
+++ b/src/library/scala/collection/mutable/LinkedHashSet.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -78,7 +79,7 @@ class LinkedHashSet[A] extends AbstractSet[A]
def hasNext = cur ne null
def next =
if (hasNext) { val res = cur.key; cur = cur.later; res }
- else Iterator.empty.next
+ else Iterator.empty.next()
}
override def foreach[U](f: A => U) {
diff --git a/src/library/scala/collection/mutable/LinkedList.scala b/src/library/scala/collection/mutable/LinkedList.scala
index 29e6fdd375..a772f86d78 100644
--- a/src/library/scala/collection/mutable/LinkedList.scala
+++ b/src/library/scala/collection/mutable/LinkedList.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/LinkedListLike.scala b/src/library/scala/collection/mutable/LinkedListLike.scala
index 4f63ede7ca..6d4565026f 100644
--- a/src/library/scala/collection/mutable/LinkedListLike.scala
+++ b/src/library/scala/collection/mutable/LinkedListLike.scala
@@ -6,12 +6,10 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
import scala.annotation.tailrec
/** This extensible class may be used as a basis for implementing linked
@@ -188,6 +186,6 @@ trait LinkedListLike[A, This <: Seq[A] with LinkedListLike[A, This]] extends Seq
override def clone(): This = {
val bf = newBuilder
bf ++= this
- bf.result
+ bf.result()
}
}
diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala
index 67af4a6bd6..7f54692c8b 100644
--- a/src/library/scala/collection/mutable/ListBuffer.scala
+++ b/src/library/scala/collection/mutable/ListBuffer.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -56,12 +55,18 @@ final class ListBuffer[A]
import scala.collection.Traversable
import scala.collection.immutable.ListSerializeEnd
+ /** Expected invariants:
+ * If start.isEmpty, last0 == null
+ * If start.nonEmpty, last0 != null
+ * If len == 0, start.isEmpty
+ * If len > 0, start.nonEmpty
+ */
private var start: List[A] = Nil
private var last0: ::[A] = _
private var exported: Boolean = false
private var len = 0
- protected def underlying: immutable.Seq[A] = start
+ protected def underlying: List[A] = start
private def writeObject(out: ObjectOutputStream) {
// write start
@@ -133,7 +138,7 @@ final class ListBuffer[A]
if (n < 0 || n >= len) throw new IndexOutOfBoundsException(n.toString)
if (exported) copy()
if (n == 0) {
- val newElem = new :: (x, start.tail);
+ val newElem = new :: (x, start.tail)
if (last0 eq start) {
last0 = newElem
}
@@ -160,7 +165,7 @@ final class ListBuffer[A]
*/
def += (x: A): this.type = {
if (exported) copy()
- if (start.isEmpty) {
+ if (isEmpty) {
last0 = new :: (x, Nil)
start = last0
} else {
@@ -172,8 +177,11 @@ final class ListBuffer[A]
this
}
- override def ++=(xs: TraversableOnce[A]): this.type =
- if (xs.asInstanceOf[AnyRef] eq this) ++= (this take size) else super.++=(xs)
+ override def ++=(xs: TraversableOnce[A]): this.type = xs match {
+ case x: AnyRef if x eq this => this ++= (this take size)
+ case _ => super.++=(xs)
+
+ }
override def ++=:(xs: TraversableOnce[A]): this.type =
if (xs.asInstanceOf[AnyRef] eq this) ++=: (this take size) else super.++=:(xs)
@@ -182,6 +190,7 @@ final class ListBuffer[A]
*/
def clear() {
start = Nil
+ last0 = null
exported = false
len = 0
}
@@ -195,7 +204,7 @@ final class ListBuffer[A]
def +=: (x: A): this.type = {
if (exported) copy()
val newElem = new :: (x, start)
- if (start.isEmpty) last0 = newElem
+ if (isEmpty) last0 = newElem
start = newElem
len += 1
this
@@ -238,13 +247,22 @@ final class ListBuffer[A]
}
}
+ /** Reduce the length of the buffer, and null out last0
+ * if this reduces the length to 0.
+ */
+ private def reduceLengthBy(num: Int) {
+ len -= num
+ if (len <= 0) // obviously shouldn't be < 0, but still better not to leak
+ last0 = null
+ }
+
/** Removes a given number of elements on a given index position. May take
* time linear in the buffer size.
*
* @param n the index which refers to the first element to remove.
* @param count the number of elements to remove.
*/
- @annotation.migration("Invalid input values will be rejected in future releases.", "2.11")
+ @scala.annotation.migration("Invalid input values will be rejected in future releases.", "2.11")
override def remove(n: Int, count: Int) {
if (n >= len)
return
@@ -253,7 +271,6 @@ final class ListBuffer[A]
if (exported) copy()
val n1 = n max 0
val count1 = count min (len - n1)
- var old = start.head
if (n1 == 0) {
var c = count1
while (c > 0) {
@@ -274,7 +291,7 @@ final class ListBuffer[A]
c -= 1
}
}
- len -= count1
+ reduceLengthBy(count1)
}
// Implementation of abstract method in Builder
@@ -285,7 +302,7 @@ final class ListBuffer[A]
* copied lazily, the first time it is mutated.
*/
override def toList: List[A] = {
- exported = !start.isEmpty
+ exported = !isEmpty
start
}
@@ -296,7 +313,7 @@ final class ListBuffer[A]
* @param xs the list to which elements are prepended
*/
def prependToList(xs: List[A]): List[A] = {
- if (start.isEmpty) xs
+ if (isEmpty) xs
else {
if (exported) copy()
last0.tl = xs
@@ -331,7 +348,7 @@ final class ListBuffer[A]
if (last0 eq cursor.tail) last0 = cursor.asInstanceOf[::[A]]
cursor.asInstanceOf[::[A]].tl = cursor.tail.tail
}
- len -= 1
+ reduceLengthBy(1)
old
}
@@ -343,11 +360,12 @@ final class ListBuffer[A]
*/
override def -= (elem: A): this.type = {
if (exported) copy()
- if (start.isEmpty) {}
+ if (isEmpty) {}
else if (start.head == elem) {
start = start.tail
- len -= 1
- } else {
+ reduceLengthBy(1)
+ }
+ else {
var cursor = start
while (!cursor.tail.isEmpty && cursor.tail.head != elem) {
cursor = cursor.tail
@@ -357,7 +375,7 @@ final class ListBuffer[A]
if (z.tl == last0)
last0 = z
z.tl = cursor.tail.tail
- len -= 1
+ reduceLengthBy(1)
}
}
this
@@ -397,6 +415,7 @@ final class ListBuffer[A]
/** Copy contents of this buffer */
private def copy() {
+ if (isEmpty) return
var cursor = start
val limit = last0.tail
clear()
diff --git a/src/library/scala/collection/mutable/ListMap.scala b/src/library/scala/collection/mutable/ListMap.scala
index 7f05deffc8..0b5d34cd81 100644
--- a/src/library/scala/collection/mutable/ListMap.scala
+++ b/src/library/scala/collection/mutable/ListMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/Map.scala b/src/library/scala/collection/mutable/Map.scala
index f72e1fc4e7..7280aaec25 100644
--- a/src/library/scala/collection/mutable/Map.scala
+++ b/src/library/scala/collection/mutable/Map.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -47,7 +48,7 @@ trait Map[A, B]
*/
def withDefaultValue(d: B): mutable.Map[A, B] = new Map.WithDefault[A, B](this, x => d)
- /** Return a read-only projection of this map. !!! or just use an (immutable) MapProxy?
+ /* Return a read-only projection of this map. !!! or just use an (immutable) MapProxy?
def readOnly : scala.collection.Map[A, B] = new scala.collection.Map[A, B] {
override def size = self.size
override def update(key: A, value: B) = self.update(key, value)
diff --git a/src/library/scala/collection/mutable/MapBuilder.scala b/src/library/scala/collection/mutable/MapBuilder.scala
index 8468e09e4d..a5a6b12ea9 100644
--- a/src/library/scala/collection/mutable/MapBuilder.scala
+++ b/src/library/scala/collection/mutable/MapBuilder.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** The canonical builder for immutable maps, working with the map's `+` method
diff --git a/src/library/scala/collection/mutable/MapLike.scala b/src/library/scala/collection/mutable/MapLike.scala
index a53aa3b76a..dbe32fdb79 100644
--- a/src/library/scala/collection/mutable/MapLike.scala
+++ b/src/library/scala/collection/mutable/MapLike.scala
@@ -7,12 +7,13 @@
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
-import scala.annotation.{migration, bridge}
-import parallel.mutable.ParMap
+import scala.annotation.migration
+import scala.collection.parallel.mutable.ParMap
/** A template trait for mutable maps.
* $mapNote
@@ -50,8 +51,6 @@ trait MapLike[A, B, +This <: MapLike[A, B, This] with Map[A, B]]
with Parallelizable[(A, B), ParMap[A, B]]
{ self =>
- import scala.collection.Traversable
-
/** A common implementation of `newBuilder` for all mutable maps
* in terms of `empty`.
*
diff --git a/src/library/scala/collection/mutable/MapProxy.scala b/src/library/scala/collection/mutable/MapProxy.scala
index c730e2b7c8..e4f106731c 100644
--- a/src/library/scala/collection/mutable/MapProxy.scala
+++ b/src/library/scala/collection/mutable/MapProxy.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/**
diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala
index 4635bfbe64..78dfc35268 100644
--- a/src/library/scala/collection/mutable/MultiMap.scala
+++ b/src/library/scala/collection/mutable/MultiMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
diff --git a/src/library/scala/collection/mutable/MutableList.scala b/src/library/scala/collection/mutable/MutableList.scala
index bc6272bfdb..5727b12975 100644
--- a/src/library/scala/collection/mutable/MutableList.scala
+++ b/src/library/scala/collection/mutable/MutableList.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -61,8 +62,7 @@ extends AbstractSeq[A]
tl
}
- // this method must be private for binary compatibility
- private final def tailImpl(tl: MutableList[A]) {
+ protected final def tailImpl(tl: MutableList[A]) {
require(nonEmpty, "tail of empty list")
tl.first0 = first0.tail
tl.len = len - 1
@@ -149,7 +149,7 @@ extends AbstractSeq[A]
override def clone(): MutableList[A] = {
val bf = newBuilder
bf ++= seq
- bf.result
+ bf.result()
}
}
diff --git a/src/library/scala/collection/mutable/ObservableBuffer.scala b/src/library/scala/collection/mutable/ObservableBuffer.scala
index bcaf977727..7fe794caaf 100644
--- a/src/library/scala/collection/mutable/ObservableBuffer.scala
+++ b/src/library/scala/collection/mutable/ObservableBuffer.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import script._
@@ -65,7 +66,7 @@ trait ObservableBuffer[A] extends Buffer[A] with Publisher[Message[A] with Undoa
}
abstract override def clear(): Unit = {
- super.clear
+ super.clear()
publish(new Reset with Undoable {
def undo() { throw new UnsupportedOperationException("cannot undo") }
})
diff --git a/src/library/scala/collection/mutable/ObservableMap.scala b/src/library/scala/collection/mutable/ObservableMap.scala
index d81c90bf4c..0dec6fa516 100644
--- a/src/library/scala/collection/mutable/ObservableMap.scala
+++ b/src/library/scala/collection/mutable/ObservableMap.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import script._
@@ -60,7 +61,7 @@ trait ObservableMap[A, B] extends Map[A, B] with Publisher[Message[(A, B)] with
}
abstract override def clear(): Unit = {
- super.clear
+ super.clear()
publish(new Reset with Undoable {
def undo(): Unit = throw new UnsupportedOperationException("cannot undo")
})
diff --git a/src/library/scala/collection/mutable/ObservableSet.scala b/src/library/scala/collection/mutable/ObservableSet.scala
index 3e79506413..acb6d92c8c 100644
--- a/src/library/scala/collection/mutable/ObservableSet.scala
+++ b/src/library/scala/collection/mutable/ObservableSet.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import script._
@@ -44,7 +45,7 @@ trait ObservableSet[A] extends Set[A] with Publisher[Message[A] with Undoable]
}
abstract override def clear(): Unit = {
- super.clear
+ super.clear()
publish(new Reset with Undoable {
def undo(): Unit = throw new UnsupportedOperationException("cannot undo")
})
diff --git a/src/library/scala/collection/mutable/OpenHashMap.scala b/src/library/scala/collection/mutable/OpenHashMap.scala
index 8b3e52470a..a0aea43121 100644
--- a/src/library/scala/collection/mutable/OpenHashMap.scala
+++ b/src/library/scala/collection/mutable/OpenHashMap.scala
@@ -27,7 +27,7 @@ object OpenHashMap {
var value: Option[Value])
extends HashEntry[Key, OpenEntry[Key, Value]]
- private[mutable] def nextPowerOfTwo(i : Int) = highestOneBit(i) << 1;
+ private[mutable] def nextPowerOfTwo(i : Int) = highestOneBit(i) << 1
}
/** A mutable hash map based on an open hashing scheme. The precise scheme is
@@ -78,8 +78,8 @@ extends AbstractMap[Key, Value]
/** Returns a mangled hash code of the provided key. */
protected def hashOf(key: Key) = {
var h = key.##
- h ^= ((h >>> 20) ^ (h >>> 12));
- h ^ (h >>> 7) ^ (h >>> 4);
+ h ^= ((h >>> 20) ^ (h >>> 12))
+ h ^ (h >>> 7) ^ (h >>> 4)
}
private[this] def growTable() = {
@@ -89,7 +89,7 @@ extends AbstractMap[Key, Value]
table = new Array[Entry](newSize)
mask = newSize - 1
oldTable.foreach( entry =>
- if (entry != null && entry.value != None) addEntry(entry));
+ if (entry != null && entry.value != None) addEntry(entry))
deleted = 0
}
@@ -124,18 +124,18 @@ extends AbstractMap[Key, Value]
put(key, hashOf(key), value)
private def put(key: Key, hash: Int, value: Value): Option[Value] = {
- if (2 * (size + deleted) > mask) growTable
+ if (2 * (size + deleted) > mask) growTable()
val index = findIndex(key, hash)
val entry = table(index)
if (entry == null) {
- table(index) = new OpenEntry(key, hash, Some(value));
+ table(index) = new OpenEntry(key, hash, Some(value))
modCount += 1
size += 1
None
} else {
val res = entry.value
if (entry.value == None) { size += 1; modCount += 1 }
- entry.value = Some(value);
+ entry.value = Some(value)
res
}
}
@@ -161,13 +161,13 @@ extends AbstractMap[Key, Value]
while(entry != null){
if (entry.hash == hash &&
entry.key == key){
- return entry.value;
+ return entry.value
}
- j = 5 * j + 1 + perturb;
- perturb >>= 5;
- index = j & mask;
- entry = table(index);
+ j = 5 * j + 1 + perturb
+ perturb >>= 5
+ index = j & mask
+ entry = table(index)
}
None
}
@@ -182,8 +182,8 @@ extends AbstractMap[Key, Value]
val initialModCount = modCount
private[this] def advance() {
- if (initialModCount != modCount) sys.error("Concurrent modification");
- while((index <= mask) && (table(index) == null || table(index).value == None)) index+=1;
+ if (initialModCount != modCount) sys.error("Concurrent modification")
+ while((index <= mask) && (table(index) == null || table(index).value == None)) index+=1
}
def hasNext = {advance(); index <= mask }
@@ -198,7 +198,7 @@ extends AbstractMap[Key, Value]
override def clone() = {
val it = new OpenHashMap[Key, Value]
- foreachUndeletedEntry(entry => it.put(entry.key, entry.hash, entry.value.get));
+ foreachUndeletedEntry(entry => it.put(entry.key, entry.hash, entry.value.get))
it
}
@@ -213,24 +213,24 @@ extends AbstractMap[Key, Value]
* @param f The function to apply to each key, value mapping.
*/
override def foreach[U](f : ((Key, Value)) => U) {
- val startModCount = modCount;
+ val startModCount = modCount
foreachUndeletedEntry(entry => {
if (modCount != startModCount) sys.error("Concurrent Modification")
f((entry.key, entry.value.get))}
- );
+ )
}
private[this] def foreachUndeletedEntry(f : Entry => Unit){
- table.foreach(entry => if (entry != null && entry.value != None) f(entry));
+ table.foreach(entry => if (entry != null && entry.value != None) f(entry))
}
override def transform(f : (Key, Value) => Value) = {
- foreachUndeletedEntry(entry => entry.value = Some(f(entry.key, entry.value.get)));
+ foreachUndeletedEntry(entry => entry.value = Some(f(entry.key, entry.value.get)))
this
}
override def retain(f : (Key, Value) => Boolean) = {
- foreachUndeletedEntry(entry => if (!f(entry.key, entry.value.get)) {entry.value = None; size -= 1; deleted += 1} );
+ foreachUndeletedEntry(entry => if (!f(entry.key, entry.value.get)) {entry.value = None; size -= 1; deleted += 1} )
this
}
diff --git a/src/library/scala/collection/mutable/PriorityQueue.scala b/src/library/scala/collection/mutable/PriorityQueue.scala
index 84257c6e97..b5b1c1d006 100644
--- a/src/library/scala/collection/mutable/PriorityQueue.scala
+++ b/src/library/scala/collection/mutable/PriorityQueue.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -134,11 +133,11 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
throw new NoSuchElementException("no element to remove from heap")
def dequeueAll[A1 >: A, That](implicit bf: CanBuildFrom[_, A1, That]): That = {
- val b = bf.apply
+ val b = bf.apply()
while (nonEmpty) {
b += dequeue()
}
- b.result
+ b.result()
}
/** Returns the element with the highest priority in the queue,
@@ -146,14 +145,6 @@ class PriorityQueue[A](implicit val ord: Ordering[A])
*
* @return the element with the highest priority.
*/
- @deprecated("Use `head` instead.", "2.9.0")
- def max: A = if (resarr.p_size0 > 1) toA(resarr.p_array(1)) else throw new NoSuchElementException("queue is empty")
-
- /** Returns the element with the highest priority in the queue,
- * or throws an error if there is no element contained in the queue.
- *
- * @return the element with the highest priority.
- */
override def head: A = if (resarr.p_size0 > 1) toA(resarr.p_array(1)) else throw new NoSuchElementException("queue is empty")
/** Removes all elements from the queue. After this operation is completed,
diff --git a/src/library/scala/collection/mutable/PriorityQueueProxy.scala b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
index 3bb5d32cf8..4cb49be9b8 100644
--- a/src/library/scala/collection/mutable/PriorityQueueProxy.scala
+++ b/src/library/scala/collection/mutable/PriorityQueueProxy.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** This class servers as a proxy for priority queues. The
@@ -66,7 +67,7 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority
*
* @return the element with the highest priority.
*/
- override def dequeue(): A = self.dequeue
+ override def dequeue(): A = self.dequeue()
/** Returns the element with the highest priority in the queue,
* or throws an error if there is no element contained in the queue.
@@ -75,18 +76,10 @@ abstract class PriorityQueueProxy[A](implicit ord: Ordering[A]) extends Priority
*/
override def head: A = self.head
- /** Returns the element with the highest priority in the queue,
- * or throws an error if there is no element contained in the queue.
- *
- * @return the element with the highest priority.
- */
- @deprecated("Use `head` instead.", "2.9.0")
- override def max: A = self.max
-
/** Removes all elements from the queue. After this operation is completed,
* the queue will be empty.
*/
- override def clear(): Unit = self.clear
+ override def clear(): Unit = self.clear()
/** Returns a regular queue containing the same elements.
*/
diff --git a/src/library/scala/collection/mutable/Publisher.scala b/src/library/scala/collection/mutable/Publisher.scala
index e31205b477..22bbea16ef 100644
--- a/src/library/scala/collection/mutable/Publisher.scala
+++ b/src/library/scala/collection/mutable/Publisher.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
@@ -45,7 +46,7 @@ trait Publisher[Evt] {
def suspendSubscription(sub: Sub) { suspended += sub }
def activateSubscription(sub: Sub) { suspended -= sub }
def removeSubscription(sub: Sub) { filters -= sub }
- def removeSubscriptions() { filters.clear }
+ def removeSubscriptions() { filters.clear() }
protected def publish(event: Evt) {
filters.keys.foreach(sub =>
diff --git a/src/library/scala/collection/mutable/Queue.scala b/src/library/scala/collection/mutable/Queue.scala
index 8ef5f6aeb7..e80aae2171 100644
--- a/src/library/scala/collection/mutable/Queue.scala
+++ b/src/library/scala/collection/mutable/Queue.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
@@ -167,13 +168,6 @@ extends MutableList[A]
*/
def front: A = head
- // this method (duplicated from MutableList) must be private for binary compatibility
- private final def tailImpl(tl: Queue[A]) {
- require(nonEmpty, "tail of empty list")
- tl.first0 = first0.tail
- tl.len = len - 1
- tl.last0 = if (tl.len == 0) tl.first0 else last0
- }
// TODO - Don't override this just for new to create appropriate type....
override def tail: Queue[A] = {
@@ -185,7 +179,7 @@ extends MutableList[A]
override def clone(): Queue[A] = {
val bf = newBuilder
bf ++= seq
- bf.result
+ bf.result()
}
private[this] def decrementLength() {
diff --git a/src/library/scala/collection/mutable/QueueProxy.scala b/src/library/scala/collection/mutable/QueueProxy.scala
index c286a340e3..bfc5edbeff 100644
--- a/src/library/scala/collection/mutable/QueueProxy.scala
+++ b/src/library/scala/collection/mutable/QueueProxy.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
/** `Queue` objects implement data structures that allow to
@@ -67,7 +68,7 @@ trait QueueProxy[A] extends Queue[A] with Proxy {
*
* @return the first element of the queue.
*/
- override def dequeue(): A = self.dequeue
+ override def dequeue(): A = self.dequeue()
/** Returns the first element in the queue, or throws an error if there
* is no element contained in the queue.
@@ -79,7 +80,7 @@ trait QueueProxy[A] extends Queue[A] with Proxy {
/** Removes all elements from the queue. After this operation is completed,
* the queue will be empty.
*/
- override def clear(): Unit = self.clear
+ override def clear(): Unit = self.clear()
/** Returns an iterator over all elements on the queue.
*
diff --git a/src/library/scala/collection/mutable/RevertibleHistory.scala b/src/library/scala/collection/mutable/RevertibleHistory.scala
index 5544a21a55..725a8113ec 100644
--- a/src/library/scala/collection/mutable/RevertibleHistory.scala
+++ b/src/library/scala/collection/mutable/RevertibleHistory.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
@@ -30,7 +31,7 @@ class RevertibleHistory[Evt <: Undoable, Pub] extends History[Evt, Pub] with Und
*/
def undo(): Unit = {
val old = log.toList.reverse
- clear
- old.foreach { case (sub, event) => event.undo }
+ clear()
+ old.foreach { case (sub, event) => event.undo() }
}
}
diff --git a/src/library/scala/collection/mutable/Seq.scala b/src/library/scala/collection/mutable/Seq.scala
index 9d9399ebb4..11fbdd13f3 100644
--- a/src/library/scala/collection/mutable/Seq.scala
+++ b/src/library/scala/collection/mutable/Seq.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/SeqLike.scala b/src/library/scala/collection/mutable/SeqLike.scala
index 447100cf4c..6987066f2b 100644
--- a/src/library/scala/collection/mutable/SeqLike.scala
+++ b/src/library/scala/collection/mutable/SeqLike.scala
@@ -6,10 +6,10 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
import parallel.mutable.ParSeq
/** A template trait for mutable sequences of type `mutable.Seq[A]`.
diff --git a/src/library/scala/collection/mutable/Set.scala b/src/library/scala/collection/mutable/Set.scala
index 023ff63056..4439880976 100644
--- a/src/library/scala/collection/mutable/Set.scala
+++ b/src/library/scala/collection/mutable/Set.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/SetBuilder.scala b/src/library/scala/collection/mutable/SetBuilder.scala
index 42fd651d41..01bfdc96ed 100644
--- a/src/library/scala/collection/mutable/SetBuilder.scala
+++ b/src/library/scala/collection/mutable/SetBuilder.scala
@@ -6,12 +6,10 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
-
/** The canonical builder for mutable Sets.
*
* @tparam A The type of the elements that will be contained in this set.
diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala
index 01f87447ae..073bc59f61 100644
--- a/src/library/scala/collection/mutable/SetLike.scala
+++ b/src/library/scala/collection/mutable/SetLike.scala
@@ -6,12 +6,13 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
import script._
-import scala.annotation.{ migration, bridge }
+import scala.annotation.migration
import parallel.mutable.ParSet
/** A template trait for mutable sets of type `mutable.Set[A]`.
@@ -210,7 +211,7 @@ trait SetLike[A, +This <: SetLike[A, This] with Set[A]]
def <<(cmd: Message[A]): Unit = cmd match {
case Include(_, x) => this += x
case Remove(_, x) => this -= x
- case Reset() => clear
+ case Reset() => clear()
case s: Script[_] => s.iterator foreach <<
case _ => throw new UnsupportedOperationException("message " + cmd + " not understood")
}
diff --git a/src/library/scala/collection/mutable/SetProxy.scala b/src/library/scala/collection/mutable/SetProxy.scala
index c9f297509f..9568a54276 100644
--- a/src/library/scala/collection/mutable/SetProxy.scala
+++ b/src/library/scala/collection/mutable/SetProxy.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** This is a simple wrapper class for [[scala.collection.mutable.Set]].
diff --git a/src/library/scala/collection/mutable/SortedSet.scala b/src/library/scala/collection/mutable/SortedSet.scala
index 41f2c6e39f..0f2fa75abd 100644
--- a/src/library/scala/collection/mutable/SortedSet.scala
+++ b/src/library/scala/collection/mutable/SortedSet.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/Stack.scala b/src/library/scala/collection/mutable/Stack.scala
index 6eef250f9d..34c6d1fbb9 100644
--- a/src/library/scala/collection/mutable/Stack.scala
+++ b/src/library/scala/collection/mutable/Stack.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/StackProxy.scala b/src/library/scala/collection/mutable/StackProxy.scala
index 16f13ff42c..7d776b99c3 100644
--- a/src/library/scala/collection/mutable/StackProxy.scala
+++ b/src/library/scala/collection/mutable/StackProxy.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** A stack implements a data structure which allows to store and retrieve
@@ -69,13 +70,13 @@ trait StackProxy[A] extends Stack[A] with Proxy {
/** Removes the top element from the stack.
*/
- override def pop(): A = self.pop
+ override def pop(): A = self.pop()
/**
* Removes all elements from the stack. After this operation completed,
* the stack will be empty.
*/
- override def clear(): Unit = self.clear
+ override def clear(): Unit = self.clear()
/** Returns an iterator over all elements on the stack. This iterator
* is stable with respect to state changes in the stack object; i.e.
diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala
index 4d269a95b1..cfabd9171c 100644
--- a/src/library/scala/collection/mutable/StringBuilder.scala
+++ b/src/library/scala/collection/mutable/StringBuilder.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import java.lang.{ StringBuilder => JavaStringBuilder }
diff --git a/src/library/scala/collection/mutable/Subscriber.scala b/src/library/scala/collection/mutable/Subscriber.scala
index 35d31d7316..c2aa9be72d 100644
--- a/src/library/scala/collection/mutable/Subscriber.scala
+++ b/src/library/scala/collection/mutable/Subscriber.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
/** `Subscriber[A, B]` objects may subscribe to events of type `A`
diff --git a/src/library/scala/collection/mutable/SynchronizedBuffer.scala b/src/library/scala/collection/mutable/SynchronizedBuffer.scala
index bf9a70c5b7..b97191137f 100644
--- a/src/library/scala/collection/mutable/SynchronizedBuffer.scala
+++ b/src/library/scala/collection/mutable/SynchronizedBuffer.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import script._
@@ -157,7 +158,7 @@ trait SynchronizedBuffer[A] extends Buffer[A] {
/** Clears the buffer contents.
*/
abstract override def clear(): Unit = synchronized {
- super.clear
+ super.clear()
}
override def <<(cmd: Message[A]): Unit = synchronized {
diff --git a/src/library/scala/collection/mutable/SynchronizedMap.scala b/src/library/scala/collection/mutable/SynchronizedMap.scala
index 5a3562cb22..643701eda9 100644
--- a/src/library/scala/collection/mutable/SynchronizedMap.scala
+++ b/src/library/scala/collection/mutable/SynchronizedMap.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.collection
+package scala
+package collection
package mutable
import scala.annotation.migration
diff --git a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
index 8dfc40b9c8..05676597db 100644
--- a/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedPriorityQueue.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
/** This class implements synchronized priority queues using a binary heap.
@@ -64,7 +65,7 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu
*
* @return the element with the highest priority.
*/
- override def dequeue(): A = synchronized { super.dequeue }
+ override def dequeue(): A = synchronized { super.dequeue() }
/** Returns the element with the highest priority in the queue,
* or throws an error if there is no element contained in the queue.
@@ -73,18 +74,10 @@ class SynchronizedPriorityQueue[A](implicit ord: Ordering[A]) extends PriorityQu
*/
override def head: A = synchronized { super.head }
- /** Returns the element with the highest priority in the queue,
- * or throws an error if there is no element contained in the queue.
- *
- * @return the element with the highest priority.
- */
- @deprecated("Use `head` instead.", "2.9.0")
- override def max: A = synchronized { super.max }
-
/** Removes all elements from the queue. After this operation is completed,
* the queue will be empty.
*/
- override def clear(): Unit = synchronized { super.clear }
+ override def clear(): Unit = synchronized { super.clear() }
/** Returns an iterator which yield all the elements of the priority
* queue in descending priority order.
diff --git a/src/library/scala/collection/mutable/SynchronizedQueue.scala b/src/library/scala/collection/mutable/SynchronizedQueue.scala
index 9559d5eaa5..263c06b439 100644
--- a/src/library/scala/collection/mutable/SynchronizedQueue.scala
+++ b/src/library/scala/collection/mutable/SynchronizedQueue.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
@@ -25,8 +26,6 @@ package mutable
* @define coll synchronized queue
*/
class SynchronizedQueue[A] extends Queue[A] {
- import scala.collection.Traversable
-
/** Checks if the queue is empty.
*
* @return true, iff there is no element in the queue.
@@ -58,7 +57,7 @@ class SynchronizedQueue[A] extends Queue[A] {
*
* @return the first element of the queue.
*/
- override def dequeue(): A = synchronized { super.dequeue }
+ override def dequeue(): A = synchronized { super.dequeue() }
/** Returns the first element in the queue which satisfies the
* given predicate, and removes this element from the queue.
@@ -87,7 +86,7 @@ class SynchronizedQueue[A] extends Queue[A] {
/** Removes all elements from the queue. After this operation is completed,
* the queue will be empty.
*/
- override def clear(): Unit = synchronized { super.clear }
+ override def clear(): Unit = synchronized { super.clear() }
/** Checks if two queues are structurally identical.
*
diff --git a/src/library/scala/collection/mutable/SynchronizedSet.scala b/src/library/scala/collection/mutable/SynchronizedSet.scala
index e4a44993ff..441efea5fb 100644
--- a/src/library/scala/collection/mutable/SynchronizedSet.scala
+++ b/src/library/scala/collection/mutable/SynchronizedSet.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package mutable
import script._
@@ -24,8 +25,6 @@ import script._
* @define coll synchronized set
*/
trait SynchronizedSet[A] extends Set[A] {
- import scala.collection.Traversable
-
abstract override def size: Int = synchronized {
super.size
}
@@ -71,7 +70,7 @@ trait SynchronizedSet[A] extends Set[A] {
}
abstract override def clear(): Unit = synchronized {
- super.clear
+ super.clear()
}
override def subsetOf(that: scala.collection.GenSet[A]) = synchronized {
diff --git a/src/library/scala/collection/mutable/SynchronizedStack.scala b/src/library/scala/collection/mutable/SynchronizedStack.scala
index 5d7c9f6073..c92a68ffde 100644
--- a/src/library/scala/collection/mutable/SynchronizedStack.scala
+++ b/src/library/scala/collection/mutable/SynchronizedStack.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
@@ -67,13 +68,13 @@ class SynchronizedStack[A] extends Stack[A] {
/** Removes the top element from the stack.
*/
- override def pop(): A = synchronized { super.pop }
+ override def pop(): A = synchronized { super.pop() }
/**
* Removes all elements from the stack. After this operation completed,
* the stack will be empty.
*/
- override def clear(): Unit = synchronized { super.clear }
+ override def clear(): Unit = synchronized { super.clear() }
/** Returns an iterator over all elements on the stack. This iterator
* is stable with respect to state changes in the stack object; i.e.
diff --git a/src/library/scala/collection/mutable/Traversable.scala b/src/library/scala/collection/mutable/Traversable.scala
index e36ffc847f..d7ea376d28 100644
--- a/src/library/scala/collection/mutable/Traversable.scala
+++ b/src/library/scala/collection/mutable/Traversable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala
index 5197af1b04..ea5b859367 100644
--- a/src/library/scala/collection/mutable/TreeSet.scala
+++ b/src/library/scala/collection/mutable/TreeSet.scala
@@ -6,10 +6,13 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
+import scala.collection.immutable.{RedBlackTree => RB}
+import scala.runtime.ObjectRef
/**
* @define Coll `mutable.TreeSet`
@@ -29,95 +32,81 @@ object TreeSet extends MutableSortedSetFactory[TreeSet] {
}
/**
- * A mutable SortedSet using an immutable AVL Tree as underlying data structure.
+ * A mutable SortedSet using an immutable RedBlack Tree as underlying data structure.
*
* @author Lucien Pereira
*
*/
-class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with SetLike[A, TreeSet[A]]
+class TreeSet[A] private (treeRef: ObjectRef[RB.Tree[A, Null]], from: Option[A], until: Option[A])(implicit val ordering: Ordering[A])
+ extends SortedSet[A] with SetLike[A, TreeSet[A]]
with SortedSetLike[A, TreeSet[A]] with Set[A] with Serializable {
- // Projection constructor
- private def this(base: Option[TreeSet[A]], from: Option[A], until: Option[A])(implicit ordering: Ordering[A]) {
- this();
- this.base = base
- this.from = from
- this.until = until
- }
-
- private var base: Option[TreeSet[A]] = None
-
- private var from: Option[A] = None
-
- private var until: Option[A] = None
-
- private var avl: AVLTree[A] = Leaf
-
- private var cardinality: Int = 0
+ def this()(implicit ordering: Ordering[A]) = this(new ObjectRef(null), None, None)
- def resolve: TreeSet[A] = base.getOrElse(this)
-
- private def isLeftAcceptable(from: Option[A], ordering: Ordering[A])(a: A): Boolean =
- from.map(x => ordering.gteq(a, x)).getOrElse(true)
-
- private def isRightAcceptable(until: Option[A], ordering: Ordering[A])(a: A): Boolean =
- until.map(x => ordering.lt(a, x)).getOrElse(true)
-
- /**
- * Cardinality store the set size, unfortunately a
- * set view (given by rangeImpl)
- * cannot take advantage of this optimisation
- *
- */
- override def size: Int = base.map(_ => super.size).getOrElse(cardinality)
+ override def size: Int = RB.countInRange(treeRef.elem, from, until)
override def stringPrefix = "TreeSet"
override def empty: TreeSet[A] = TreeSet.empty
- override def rangeImpl(from: Option[A], until: Option[A]): TreeSet[A] = new TreeSet(Some(this), from, until)
+ private def pickBound(comparison: (A, A) => A, oldBound: Option[A], newBound: Option[A]) = (newBound, oldBound) match {
+ case (Some(newB), Some(oldB)) => Some(comparison(newB, oldB))
+ case (None, _) => oldBound
+ case _ => newBound
+ }
+
+ override def rangeImpl(fromArg: Option[A], untilArg: Option[A]): TreeSet[A] = {
+ val newFrom = pickBound(ordering.max, fromArg, from)
+ val newUntil = pickBound(ordering.min, untilArg, until)
+
+ new TreeSet(treeRef, newFrom, newUntil)
+ }
override def -=(elem: A): this.type = {
- try {
- resolve.avl = resolve.avl.remove(elem, ordering)
- resolve.cardinality = resolve.cardinality - 1
- } catch {
- case e: NoSuchElementException => ()
- }
+ treeRef.elem = RB.delete(treeRef.elem, elem)
this
}
override def +=(elem: A): this.type = {
- try {
- resolve.avl = resolve.avl.insert(elem, ordering)
- resolve.cardinality = resolve.cardinality + 1
- } catch {
- case e: IllegalArgumentException => ()
- }
+ treeRef.elem = RB.update(treeRef.elem, elem, null, overwrite = false)
this
}
/**
* Thanks to the immutable nature of the
- * underlying AVL Tree, we can share it with
+ * underlying Tree, we can share it with
* the clone. So clone complexity in time is O(1).
*
*/
- override def clone(): TreeSet[A] = {
- val clone = new TreeSet[A](base, from, until)
- clone.avl = resolve.avl
- clone.cardinality = resolve.cardinality
- clone
- }
+ override def clone(): TreeSet[A] =
+ new TreeSet[A](new ObjectRef(treeRef.elem), from, until)
+
+ private val notProjection = !(from.isDefined || until.isDefined)
override def contains(elem: A): Boolean = {
- isLeftAcceptable(from, ordering)(elem) &&
- isRightAcceptable(until, ordering)(elem) &&
- resolve.avl.contains(elem, ordering)
- }
+ def leftAcceptable: Boolean = from match {
+ case Some(lb) => ordering.gteq(elem, lb)
+ case _ => true
+ }
- override def iterator: Iterator[A] = resolve.avl.iterator
- .dropWhile(e => !isLeftAcceptable(from, ordering)(e))
- .takeWhile(e => isRightAcceptable(until, ordering)(e))
+ def rightAcceptable: Boolean = until match {
+ case Some(ub) => ordering.lt(elem, ub)
+ case _ => true
+ }
+
+ (notProjection || (leftAcceptable && rightAcceptable)) &&
+ RB.contains(treeRef.elem, elem)
+ }
+ override def iterator: Iterator[A] = iteratorFrom(None)
+
+ override def keysIteratorFrom(start: A) = iteratorFrom(Some(start))
+
+ private def iteratorFrom(start: Option[A]) = {
+ val it = RB.keysIterator(treeRef.elem, pickBound(ordering.max, from, start))
+ until match {
+ case None => it
+ case Some(ub) => it takeWhile (k => ordering.lt(k, ub))
+ }
+ }
}
diff --git a/src/library/scala/collection/mutable/Undoable.scala b/src/library/scala/collection/mutable/Undoable.scala
index 0c0e8fed3e..482d618165 100644
--- a/src/library/scala/collection/mutable/Undoable.scala
+++ b/src/library/scala/collection/mutable/Undoable.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
diff --git a/src/library/scala/collection/mutable/UnrolledBuffer.scala b/src/library/scala/collection/mutable/UnrolledBuffer.scala
index 9b48c8f24f..292705c02a 100644
--- a/src/library/scala/collection/mutable/UnrolledBuffer.scala
+++ b/src/library/scala/collection/mutable/UnrolledBuffer.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.mutable
+package scala
+package collection.mutable
import scala.collection.AbstractIterator
import scala.collection.Iterator
@@ -87,7 +88,7 @@ extends scala.collection.mutable.AbstractBuffer[T]
// `that` is no longer usable, so clear it
// here we rely on the fact that `clear` allocates
// new nodes instead of modifying the previous ones
- that.clear
+ that.clear()
// return a reference to this
this
@@ -123,7 +124,7 @@ extends scala.collection.mutable.AbstractBuffer[T]
val r = node.array(pos)
scan()
r
- } else Iterator.empty.next
+ } else Iterator.empty.next()
}
// this should be faster than the iterator
diff --git a/src/library/scala/collection/mutable/WeakHashMap.scala b/src/library/scala/collection/mutable/WeakHashMap.scala
index 70e428c9b6..433d054bfc 100644
--- a/src/library/scala/collection/mutable/WeakHashMap.scala
+++ b/src/library/scala/collection/mutable/WeakHashMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package mutable
import generic._
diff --git a/src/library/scala/collection/mutable/WrappedArray.scala b/src/library/scala/collection/mutable/WrappedArray.scala
index b83724090c..53fca9f779 100644
--- a/src/library/scala/collection/mutable/WrappedArray.scala
+++ b/src/library/scala/collection/mutable/WrappedArray.scala
@@ -8,7 +8,8 @@
-package scala.collection
+package scala
+package collection
package mutable
import scala.reflect.ClassTag
diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
index 7e0210311c..bfe95a11ab 100644
--- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
+++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala
@@ -8,10 +8,10 @@
-package scala.collection
+package scala
+package collection
package mutable
-import generic._
import scala.reflect.ClassTag
import scala.runtime.ScalaRunTime._
diff --git a/src/library/scala/collection/parallel/Combiner.scala b/src/library/scala/collection/parallel/Combiner.scala
index 00993c09ff..68df572517 100644
--- a/src/library/scala/collection/parallel/Combiner.scala
+++ b/src/library/scala/collection/parallel/Combiner.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.Parallel
@@ -33,11 +34,11 @@ import scala.collection.generic.Sizing
* @since 2.9
*/
trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel {
-
+
@transient
@volatile
var _combinerTaskSupport = defaultTaskSupport
-
+
def combinerTaskSupport = {
val cts = _combinerTaskSupport
if (cts eq null) {
@@ -45,9 +46,9 @@ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel {
defaultTaskSupport
} else cts
}
-
+
def combinerTaskSupport_=(cts: TaskSupport) = _combinerTaskSupport = cts
-
+
/** Combines the contents of the receiver builder and the `other` builder,
* producing a new builder containing both their elements.
*
@@ -81,15 +82,15 @@ trait Combiner[-Elem, +To] extends Builder[Elem, To] with Sizing with Parallel {
* By default, this method returns `false`.
*/
def canBeShared: Boolean = false
-
+
/** Constructs the result and sets the appropriate tasksupport object to the resulting collection
* if this is applicable.
*/
def resultWithTaskSupport: To = {
- val res = result
+ val res = result()
setTaskSupport(res, combinerTaskSupport)
}
-
+
}
diff --git a/src/library/scala/collection/parallel/ParIterable.scala b/src/library/scala/collection/parallel/ParIterable.scala
index 2b24c88139..2ceeb18eef 100644
--- a/src/library/scala/collection/parallel/ParIterable.scala
+++ b/src/library/scala/collection/parallel/ParIterable.scala
@@ -6,12 +6,12 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.GenIterable
import scala.collection.generic._
import scala.collection.parallel.mutable.ParArrayCombiner
-import scala.collection.parallel.mutable.ParArray
/** A template trait for parallel iterable collections.
*
diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala
index 0f06ff37af..a0b42f248e 100644
--- a/src/library/scala/collection/parallel/ParIterableLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableLike.scala
@@ -6,11 +6,8 @@
** |/ **
\* */
-
-package scala.collection.parallel
-
-
-
+package scala
+package collection.parallel
import scala.collection.mutable.Builder
import scala.collection.mutable.ArrayBuffer
@@ -171,9 +168,9 @@ self: ParIterableLike[T, Repr, Sequential] =>
/** The task support object which is responsible for scheduling and
* load-balancing tasks to processors.
- *
+ *
* @see [[scala.collection.parallel.TaskSupport]]
- */
+ */
def tasksupport = {
val ts = _tasksupport
if (ts eq null) {
@@ -188,18 +185,18 @@ self: ParIterableLike[T, Repr, Sequential] =>
* A task support object can be changed in a parallel collection after it
* has been created, but only during a quiescent period, i.e. while there
* are no concurrent invocations to parallel collection methods.
- *
- * Here is a way to change the task support of a parallel collection:
- *
- * {{{
- * import scala.collection.parallel._
- * val pc = mutable.ParArray(1, 2, 3)
- * pc.tasksupport = new ForkJoinTaskSupport(
- * new scala.concurrent.forkjoin.ForkJoinPool(2))
- * }}}
+ *
+ * Here is a way to change the task support of a parallel collection:
+ *
+ * {{{
+ * import scala.collection.parallel._
+ * val pc = mutable.ParArray(1, 2, 3)
+ * pc.tasksupport = new ForkJoinTaskSupport(
+ * new scala.concurrent.forkjoin.ForkJoinPool(2))
+ * }}}
*
* @see [[scala.collection.parallel.TaskSupport]]
- */
+ */
def tasksupport_=(ts: TaskSupport) = _tasksupport = ts
def seq: Sequential
@@ -214,7 +211,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
def nonEmpty = size != 0
- def head = iterator.next
+ def head = iterator.next()
def headOption = if (nonEmpty) Some(head) else None
@@ -433,12 +430,13 @@ self: ParIterableLike[T, Repr, Sequential] =>
* @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)
+ * `Nil` for list concatenation or `0` for summation) and may be evaluated
+ * more than once
* @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[S](z: S)(seqop: (S, T) => S, combop: (S, S) => S): S = {
- tasksupport.executeAndWaitResult(new Aggregate(z, seqop, combop, splitter))
+ def aggregate[S](z: =>S)(seqop: (S, T) => S, combop: (S, S) => S): S = {
+ tasksupport.executeAndWaitResult(new Aggregate(() => z, seqop, combop, splitter))
}
def foldLeft[S](z: S)(op: (S, T) => S): S = seq.foldLeft(z)(op)
@@ -453,7 +451,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
def reduceRightOption[U >: T](op: (T, U) => U): Option[U] = seq.reduceRightOption(op)
- /** Applies a function `f` to all the elements of $coll in a undefined order.
+ /** Applies a function `f` to all the elements of $coll in an undefined order.
*
* @tparam U the result type of the function applied to each element, which is always discarded
* @param f function applied to each element
@@ -626,7 +624,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
val b = bf(repr)
this.splitter.copy2builder[U, That, Builder[U, That]](b)
for (elem <- that.seq) b += elem
- setTaskSupport(b.result, tasksupport)
+ setTaskSupport(b.result(), tasksupport)
}
}
@@ -727,7 +725,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
tree => tasksupport.executeAndWaitResult(new FromScanTree(tree, z, op, combinerFactory(() => bf(repr).asCombiner)) mapResult {
cb => cb.resultWithTaskSupport
})
- }) else setTaskSupport((bf(repr) += z).result, tasksupport)
+ }) else setTaskSupport((bf(repr) += z).result(), tasksupport)
} else setTaskSupport(seq.scan(z)(op)(bf2seq(bf)), tasksupport)
} else setTaskSupport(seq.scan(z)(op)(bf2seq(bf)), tasksupport)
@@ -819,10 +817,10 @@ self: ParIterableLike[T, Repr, Sequential] =>
def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) {
val thatseq = that.asParSeq
- tasksupport.executeAndWaitResult(new Zip(combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport });
+ tasksupport.executeAndWaitResult(new Zip(combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult { _.resultWithTaskSupport })
} else setTaskSupport(seq.zip(that)(bf2seq(bf)), tasksupport)
- def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, false)
+ def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[Repr, (U, Int), That]): That = this zip immutable.ParRange(0, size, 1, inclusive = false)
def zipAll[S, U >: T, That](that: GenIterable[S], thisElem: U, thatElem: S)(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) {
val thatseq = that.asParSeq
@@ -830,11 +828,11 @@ self: ParIterableLike[T, Repr, Sequential] =>
new ZipAll(size max thatseq.length, thisElem, thatElem, combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult {
_.resultWithTaskSupport
}
- );
+ )
} else setTaskSupport(seq.zipAll(that, thisElem, thatElem)(bf2seq(bf)), tasksupport)
protected def toParCollection[U >: T, That](cbf: () => Combiner[U, That]): That = {
- tasksupport.executeAndWaitResult(new ToParCollection(combinerFactory(cbf), splitter) mapResult { _.resultWithTaskSupport });
+ tasksupport.executeAndWaitResult(new ToParCollection(combinerFactory(cbf), splitter) mapResult { _.resultWithTaskSupport })
}
protected def toParMap[K, V, That](cbf: () => Combiner[(K, V), That])(implicit ev: T <:< (K, V)): That = {
@@ -877,13 +875,13 @@ self: ParIterableLike[T, Repr, Sequential] =>
override def toSet[U >: T]: immutable.ParSet[U] = toParCollection[U, immutable.ParSet[U]](() => immutable.ParSet.newCombiner[U])
override def toMap[K, V](implicit ev: T <:< (K, V)): immutable.ParMap[K, V] = toParMap[K, V, immutable.ParMap[K, V]](() => immutable.ParMap.newCombiner[K, V])
-
+
override def toVector: Vector[T] = to[Vector]
override def to[Col[_]](implicit cbf: CanBuildFrom[Nothing, T, Col[T @uncheckedVariance]]): Col[T @uncheckedVariance] = if (cbf().isCombiner) {
toParCollection[T, Col[T]](() => cbf().asCombiner)
} else seq.to(cbf)
-
+
/* tasks */
protected trait StrictSplitterCheckTask[R, Tp] extends Task[R, Tp] {
@@ -903,7 +901,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected[this] def newSubtask(p: IterableSplitter[T]): Accessor[R, Tp]
def shouldSplitFurther = pit.shouldSplitFurther(self.repr, tasksupport.parallelismLevel)
def split = pit.splitWithSignalling.map(newSubtask(_)) // default split procedure
- private[parallel] override def signalAbort = pit.abort
+ private[parallel] override def signalAbort = pit.abort()
override def toString = this.getClass.getSimpleName + "(" + pit.toString + ")(" + result + ")(supername: " + super.toString + ")"
}
@@ -920,8 +918,8 @@ self: ParIterableLike[T, Repr, Sequential] =>
def combineResults(fr: FR, sr: SR): R
@volatile var result: R = null.asInstanceOf[R]
private[parallel] override def signalAbort() {
- ft.signalAbort
- st.signalAbort
+ ft.signalAbort()
+ st.signalAbort()
}
protected def mergeSubtasks() {
ft mergeThrowables st
@@ -935,9 +933,9 @@ self: ParIterableLike[T, Repr, Sequential] =>
(f: First, s: Second)
extends Composite[FR, SR, R, First, Second](f, s) {
def leaf(prevr: Option[R]) = {
- tasksupport.executeAndWaitResult(ft)
- tasksupport.executeAndWaitResult(st)
- mergeSubtasks
+ tasksupport.executeAndWaitResult(ft) : Any
+ tasksupport.executeAndWaitResult(st) : Any
+ mergeSubtasks()
}
}
@@ -946,10 +944,10 @@ self: ParIterableLike[T, Repr, Sequential] =>
(f: First, s: Second)
extends Composite[FR, SR, R, First, Second](f, s) {
def leaf(prevr: Option[R]) = {
- val ftfuture = tasksupport.execute(ft)
- tasksupport.executeAndWaitResult(st)
+ val ftfuture: () => Any = tasksupport.execute(ft)
+ tasksupport.executeAndWaitResult(st) : Any
ftfuture()
- mergeSubtasks
+ mergeSubtasks()
}
}
@@ -962,7 +960,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
result = map(initialResult)
}
private[parallel] override def signalAbort() {
- inner.signalAbort
+ inner.signalAbort()
}
override def requiresStrictSplitters = inner.requiresStrictSplitters
}
@@ -1005,10 +1003,10 @@ self: ParIterableLike[T, Repr, Sequential] =>
override def merge(that: Fold[U]) = result = op(result, that.result)
}
- protected[this] class Aggregate[S](z: S, seqop: (S, T) => S, combop: (S, S) => S, protected[this] val pit: IterableSplitter[T])
+ protected[this] class Aggregate[S](z: () => S, seqop: (S, T) => S, combop: (S, S) => S, protected[this] val pit: IterableSplitter[T])
extends Accessor[S, Aggregate[S]] {
@volatile var result: S = null.asInstanceOf[S]
- def leaf(prevr: Option[S]) = result = pit.foldLeft(z)(seqop)
+ def leaf(prevr: Option[S]) = result = pit.foldLeft(z())(seqop)
protected[this] def newSubtask(p: IterableSplitter[T]) = new Aggregate(z, seqop, combop, p)
override def merge(that: Aggregate[S]) = result = combop(result, that.result)
}
@@ -1084,7 +1082,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected[this] class Forall(pred: T => Boolean, protected[this] val pit: IterableSplitter[T])
extends Accessor[Boolean, Forall] {
@volatile var result: Boolean = true
- def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.forall(pred); if (result == false) pit.abort }
+ def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.forall(pred); if (result == false) pit.abort() }
protected[this] def newSubtask(p: IterableSplitter[T]) = new Forall(pred, p)
override def merge(that: Forall) = result = result && that.result
}
@@ -1092,7 +1090,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected[this] class Exists(pred: T => Boolean, protected[this] val pit: IterableSplitter[T])
extends Accessor[Boolean, Exists] {
@volatile var result: Boolean = false
- def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.exists(pred); if (result == true) pit.abort }
+ def leaf(prev: Option[Boolean]) = { if (!pit.isAborted) result = pit.exists(pred); if (result == true) pit.abort() }
protected[this] def newSubtask(p: IterableSplitter[T]) = new Exists(pred, p)
override def merge(that: Exists) = result = result || that.result
}
@@ -1100,7 +1098,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
protected[this] class Find[U >: T](pred: T => Boolean, protected[this] val pit: IterableSplitter[T])
extends Accessor[Option[U], Find[U]] {
@volatile var result: Option[U] = None
- def leaf(prev: Option[Option[U]]) = { if (!pit.isAborted) result = pit.find(pred); if (result != None) pit.abort }
+ def leaf(prev: Option[Option[U]]) = { if (!pit.isAborted) result = pit.find(pred); if (result != None) pit.abort() }
protected[this] def newSubtask(p: IterableSplitter[T]) = new Find(pred, p)
override def merge(that: Find[U]) = if (this.result == None) result = that.result
}
@@ -1152,7 +1150,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
// note: HashMapCombiner doesn't merge same keys until evaluation
val cb = mcf()
while (pit.hasNext) {
- val elem = pit.next
+ val elem = pit.next()
cb += f(elem) -> elem
}
result = cb
@@ -1473,9 +1471,9 @@ self: ParIterableLike[T, Repr, Sequential] =>
/* alias methods */
- def /:[S](z: S)(op: (S, T) => S): S = foldLeft(z)(op);
+ def /:[S](z: S)(op: (S, T) => S): S = foldLeft(z)(op)
- def :\[S](z: S)(op: (T, S) => S): S = foldRight(z)(op);
+ def :\[S](z: S)(op: (T, S) => S): S = foldRight(z)(op)
/* debug information */
@@ -1488,7 +1486,7 @@ self: ParIterableLike[T, Repr, Sequential] =>
def debugBuffer: ArrayBuffer[String] = null
private[parallel] def debugclear() = synchronized {
- debugBuffer.clear
+ debugBuffer.clear()
}
private[parallel] def debuglog(s: String) = synchronized {
@@ -1504,31 +1502,3 @@ self: ParIterableLike[T, Repr, Sequential] =>
})
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/ParIterableView.scala b/src/library/scala/collection/parallel/ParIterableView.scala
index 7644e1bd12..6dce19db19 100644
--- a/src/library/scala/collection/parallel/ParIterableView.scala
+++ b/src/library/scala/collection/parallel/ParIterableView.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.{ Parallel, IterableView, GenIterableView, Iterator }
import scala.collection.generic.CanCombineFrom
diff --git a/src/library/scala/collection/parallel/ParIterableViewLike.scala b/src/library/scala/collection/parallel/ParIterableViewLike.scala
index 0ecd6bd9ec..1ec0ff9c32 100644
--- a/src/library/scala/collection/parallel/ParIterableViewLike.scala
+++ b/src/library/scala/collection/parallel/ParIterableViewLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.Parallel
import scala.collection.{ IterableView, IterableViewLike }
@@ -50,7 +51,8 @@ extends GenIterableView[T, Coll]
self =>
override def foreach[U](f: T => U): Unit = super[ParIterableLike].foreach(f)
- override protected[this] def newCombiner: Combiner[T, This] = throw new UnsupportedOperationException(this + ".newCombiner");
+ override protected[this] def newCombiner: Combiner[T, This] = throw new UnsupportedOperationException(this + ".newCombiner")
+
protected[this] def viewIdentifier: String
protected[this] def viewIdString: String
@@ -130,7 +132,7 @@ self =>
override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedTryParSeq(that).asInstanceOf[That]
override def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[This, (U, Int), That]): That =
- newZipped(ParRange(0, splitter.remaining, 1, false)).asInstanceOf[That]
+ newZipped(ParRange(0, splitter.remaining, 1, inclusive = false)).asInstanceOf[That]
override def zipAll[S, U >: T, That](that: GenIterable[S], thisElem: U, thatElem: S)(implicit bf: CanBuildFrom[This, (U, S), That]): That =
newZippedAllTryParSeq(that, thisElem, thatElem).asInstanceOf[That]
@@ -139,7 +141,7 @@ self =>
} otherwise {
val b = bf(underlying)
b ++= this.iterator
- b.result
+ b.result()
}
/* wrapper virtual ctors */
diff --git a/src/library/scala/collection/parallel/ParMap.scala b/src/library/scala/collection/parallel/ParMap.scala
index 1f27ae830a..9f92e6c1e8 100644
--- a/src/library/scala/collection/parallel/ParMap.scala
+++ b/src/library/scala/collection/parallel/ParMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.Map
import scala.collection.GenMap
diff --git a/src/library/scala/collection/parallel/ParMapLike.scala b/src/library/scala/collection/parallel/ParMapLike.scala
index 56594bec96..ee14324c41 100644
--- a/src/library/scala/collection/parallel/ParMapLike.scala
+++ b/src/library/scala/collection/parallel/ParMapLike.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
@@ -67,7 +68,7 @@ self =>
i =>
val iter = s
def hasNext = iter.hasNext
- def next() = iter.next._1
+ def next() = iter.next()._1
def split = {
val ss = iter.split.map(keysIterator(_))
ss.foreach { _.signalDelegate = i.signalDelegate }
@@ -84,7 +85,7 @@ self =>
i =>
val iter = s
def hasNext = iter.hasNext
- def next() = iter.next._2
+ def next() = iter.next()._2
def split = {
val ss = iter.split.map(valuesIterator(_))
ss.foreach { _.signalDelegate = i.signalDelegate }
diff --git a/src/library/scala/collection/parallel/ParSeq.scala b/src/library/scala/collection/parallel/ParSeq.scala
index b905d1d41f..b4a30e5dc2 100644
--- a/src/library/scala/collection/parallel/ParSeq.scala
+++ b/src/library/scala/collection/parallel/ParSeq.scala
@@ -6,10 +6,8 @@
** |/ **
\* */
-
-package scala.collection.parallel
-
-
+package scala
+package collection.parallel
import scala.collection.generic.GenericCompanion
import scala.collection.generic.GenericParCompanion
@@ -18,9 +16,6 @@ import scala.collection.generic.ParFactory
import scala.collection.generic.CanCombineFrom
import scala.collection.GenSeq
import scala.collection.parallel.mutable.ParArrayCombiner
-import scala.collection.parallel.mutable.ParArray
-
-
/** A template trait for parallel sequences.
*
@@ -56,26 +51,3 @@ object ParSeq extends ParFactory[ParSeq] {
def newCombiner[T]: Combiner[T, ParSeq[T]] = ParArrayCombiner[T]
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/ParSeqLike.scala b/src/library/scala/collection/parallel/ParSeqLike.scala
index 201b624c72..6693e30fcd 100644
--- a/src/library/scala/collection/parallel/ParSeqLike.scala
+++ b/src/library/scala/collection/parallel/ParSeqLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.{ Parallel, SeqLike, GenSeqLike, GenSeq, GenIterable, Iterator }
import scala.collection.generic.DefaultSignalling
@@ -44,8 +45,8 @@ trait ParSeqLike[+T, +Repr <: ParSeq[T], +Sequential <: Seq[T] with SeqLike[T, S
extends scala.collection.GenSeqLike[T, Repr]
with ParIterableLike[T, Repr, Sequential] {
self =>
-
- type SuperParIterator = IterableSplitter[T]
+
+ protected[this] type SuperParIterator = IterableSplitter[T]
/** A more refined version of the iterator found in the `ParallelIterable` trait,
* this iterator can be split into arbitrary subsets of iterators.
@@ -68,7 +69,7 @@ self =>
val x = self(i)
i += 1
x
- } else Iterator.empty.next
+ } else Iterator.empty.next()
def head = self(i)
@@ -228,7 +229,7 @@ self =>
b ++= pits(0)
b ++= patch
b ++= pits(2)
- setTaskSupport(b.result, tasksupport)
+ setTaskSupport(b.result(), tasksupport)
}
def updated[U >: T, That](index: Int, elem: U)(implicit bf: CanBuildFrom[Repr, U, That]): That = if (bf(repr).isCombiner) {
@@ -252,7 +253,7 @@ self =>
def padTo[U >: T, That](len: Int, elem: U)(implicit bf: CanBuildFrom[Repr, U, That]): That = if (length < len) {
patch(length, new immutable.Repetition(elem, len - length), 0)
- } else patch(length, Nil, 0);
+ } else patch(length, Nil, 0)
override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[Repr, (U, S), That]): That = if (bf(repr).isCombiner && that.isParSeq) {
val thatseq = that.asParSeq
@@ -260,7 +261,7 @@ self =>
new Zip(length min thatseq.length, combinerFactory(() => bf(repr).asCombiner), splitter, thatseq.splitter) mapResult {
_.resultWithTaskSupport
}
- );
+ )
} else super.zip(that)(bf)
/** Tests whether every element of this $coll relates to the
@@ -423,7 +424,7 @@ self =>
@volatile var result: Boolean = true
def leaf(prev: Option[Boolean]) = if (!pit.isAborted) {
result = pit.sameElements(otherpit)
- if (!result) pit.abort
+ if (!result) pit.abort()
}
protected[this] def newSubtask(p: SuperParIterator) = unsupported
override def split = {
@@ -471,7 +472,7 @@ self =>
@volatile var result: Boolean = true
def leaf(prev: Option[Boolean]) = if (!pit.isAborted) {
result = pit.corresponds(corr)(otherpit)
- if (!result) pit.abort
+ if (!result) pit.abort()
}
protected[this] def newSubtask(p: SuperParIterator) = unsupported
override def split = {
diff --git a/src/library/scala/collection/parallel/ParSeqView.scala b/src/library/scala/collection/parallel/ParSeqView.scala
index 3e3c497352..b80994514b 100644
--- a/src/library/scala/collection/parallel/ParSeqView.scala
+++ b/src/library/scala/collection/parallel/ParSeqView.scala
@@ -6,10 +6,10 @@
** |/ **
\* */
+package scala
+package collection.parallel
-package scala.collection.parallel
-
-import scala.collection.{ TraversableView, SeqView, Parallel, Iterator }
+import scala.collection.{ SeqView, Parallel, Iterator }
import scala.collection.generic.CanCombineFrom
/** A template view of a non-strict view of a parallel sequence.
diff --git a/src/library/scala/collection/parallel/ParSeqViewLike.scala b/src/library/scala/collection/parallel/ParSeqViewLike.scala
index 04369d8fde..9d30a052de 100644
--- a/src/library/scala/collection/parallel/ParSeqViewLike.scala
+++ b/src/library/scala/collection/parallel/ParSeqViewLike.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.{ Parallel, SeqView, SeqViewLike, GenSeqView, GenSeqViewLike, GenSeq }
import scala.collection.{ GenIterable, GenTraversable, GenTraversableOnce, Iterator }
@@ -125,8 +126,8 @@ self =>
}
protected def newReversed: Transformed[T] = new Reversed { }
protected def newPatched[U >: T](_from: Int, _patch: GenSeq[U], _replaced: Int): Transformed[U] = new {
- val from = _from;
- val patch = _patch;
+ val from = _from
+ val patch = _patch
val replaced = _replaced
} with Patched[U]
@@ -147,7 +148,7 @@ self =>
override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[This, S, That]): That = newMapped(f).asInstanceOf[That]
override def zip[U >: T, S, That](that: GenIterable[S])(implicit bf: CanBuildFrom[This, (U, S), That]): That = newZippedTryParSeq(that).asInstanceOf[That]
override def zipWithIndex[U >: T, That](implicit bf: CanBuildFrom[This, (U, Int), That]): That =
- newZipped(ParRange(0, splitter.remaining, 1, false)).asInstanceOf[That]
+ newZipped(ParRange(0, splitter.remaining, 1, inclusive = false)).asInstanceOf[That]
override def reverse: This = newReversed.asInstanceOf[This]
override def reverseMap[S, That](f: T => S)(implicit bf: CanBuildFrom[This, S, That]): That = reverse.map(f)
@@ -173,7 +174,7 @@ self =>
} otherwise {
val b = bf(underlying)
b ++= this.iterator
- b.result
+ b.result()
}
/* tasks */
diff --git a/src/library/scala/collection/parallel/ParSet.scala b/src/library/scala/collection/parallel/ParSet.scala
index 6e5e9b4387..ba3d23f0e4 100644
--- a/src/library/scala/collection/parallel/ParSet.scala
+++ b/src/library/scala/collection/parallel/ParSet.scala
@@ -6,25 +6,12 @@
** |/ **
\* */
+package scala
+package collection
+package parallel
-package scala.collection.parallel
-
-
-
-
-
-
-
-import scala.collection.Set
-import scala.collection.GenSet
-import scala.collection.mutable.Builder
import scala.collection.generic._
-
-
-
-
-
/** A template trait for parallel sets.
*
* $sideeffects
@@ -35,12 +22,12 @@ import scala.collection.generic._
* @since 2.9
*/
trait ParSet[T]
-extends GenSet[T]
+ extends GenSet[T]
with GenericParTemplate[T, ParSet]
with ParIterable[T]
with ParSetLike[T, ParSet[T], Set[T]]
-{
-self =>
+{ self =>
+
override def empty: ParSet[T] = mutable.ParHashSet[T]()
//protected[this] override def newCombiner: Combiner[T, ParSet[T]] = ParSet.newCombiner[T]
@@ -50,39 +37,8 @@ self =>
override def stringPrefix = "ParSet"
}
-
-
object ParSet extends ParSetFactory[ParSet] {
def newCombiner[T]: Combiner[T, ParSet[T]] = mutable.ParHashSetCombiner[T]
implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParSet[T]] = new GenericCanCombineFrom[T]
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/ParSetLike.scala b/src/library/scala/collection/parallel/ParSetLike.scala
index c80b5ded26..a50d2ae430 100644
--- a/src/library/scala/collection/parallel/ParSetLike.scala
+++ b/src/library/scala/collection/parallel/ParSetLike.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
@@ -15,14 +16,6 @@ import scala.collection.SetLike
import scala.collection.GenSetLike
import scala.collection.GenSet
import scala.collection.Set
-import scala.collection.mutable.Builder
-
-
-
-
-
-
-
/** A template trait for parallel sets. This trait is mixed in with concrete
* parallel sets to override the representation type.
diff --git a/src/library/scala/collection/parallel/PreciseSplitter.scala b/src/library/scala/collection/parallel/PreciseSplitter.scala
index 42563f4dc9..2eb202ce05 100644
--- a/src/library/scala/collection/parallel/PreciseSplitter.scala
+++ b/src/library/scala/collection/parallel/PreciseSplitter.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.Seq
diff --git a/src/library/scala/collection/parallel/RemainsIterator.scala b/src/library/scala/collection/parallel/RemainsIterator.scala
index 3150b0d763..5f2ceac0e0 100644
--- a/src/library/scala/collection/parallel/RemainsIterator.scala
+++ b/src/library/scala/collection/parallel/RemainsIterator.scala
@@ -6,10 +6,8 @@
** |/ **
\* */
-
-package scala.collection.parallel
-
-
+package scala
+package collection.parallel
import scala.collection.Parallel
import scala.collection.generic.Signalling
@@ -21,8 +19,6 @@ import scala.collection.Iterator.empty
import scala.collection.GenTraversableOnce
import scala.collection.parallel.immutable.repetition
-
-
private[collection] trait RemainsIterator[+T] extends Iterator[T] {
/** The number of elements this iterator has yet to iterate.
* This method doesn't change the state of the iterator.
@@ -35,7 +31,6 @@ private[collection] trait RemainsIterator[+T] extends Iterator[T] {
def isRemainingCheap = true
}
-
/** Augments iterators with additional methods, mostly transformers,
* assuming they iterate an iterable collection.
*
@@ -47,47 +42,47 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
override def count(p: T => Boolean): Int = {
var i = 0
- while (hasNext) if (p(next)) i += 1
+ while (hasNext) if (p(next())) i += 1
i
}
override def reduce[U >: T](op: (U, U) => U): U = {
- var r: U = next
- while (hasNext) r = op(r, next)
+ var r: U = next()
+ while (hasNext) r = op(r, next())
r
}
override def fold[U >: T](z: U)(op: (U, U) => U): U = {
var r = z
- while (hasNext) r = op(r, next)
+ while (hasNext) r = op(r, next())
r
}
override def sum[U >: T](implicit num: Numeric[U]): U = {
var r: U = num.zero
- while (hasNext) r = num.plus(r, next)
+ while (hasNext) r = num.plus(r, next())
r
}
override def product[U >: T](implicit num: Numeric[U]): U = {
var r: U = num.one
- while (hasNext) r = num.times(r, next)
+ while (hasNext) r = num.times(r, next())
r
}
override def min[U >: T](implicit ord: Ordering[U]): T = {
- var r = next
+ var r = next()
while (hasNext) {
- val curr = next
+ val curr = next()
if (ord.lteq(curr, r)) r = curr
}
r
}
override def max[U >: T](implicit ord: Ordering[U]): T = {
- var r = next
+ var r = next()
while (hasNext) {
- val curr = next
+ val curr = next()
if (ord.gteq(curr, r)) r = curr
}
r
@@ -97,16 +92,16 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
var i = from
val until = from + len
while (i < until && hasNext) {
- array(i) = next
+ array(i) = next()
i += 1
}
}
def reduceLeft[U >: T](howmany: Int, op: (U, U) => U): U = {
var i = howmany - 1
- var u: U = next
+ var u: U = next()
while (i > 0 && hasNext) {
- u = op(u, next)
+ u = op(u, next())
i -= 1
}
u
@@ -117,15 +112,16 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def map2combiner[S, That](f: T => S, cb: Combiner[S, That]): Combiner[S, That] = {
//val cb = pbf(repr)
if (isRemainingCheap) cb.sizeHint(remaining)
- while (hasNext) cb += f(next)
+ while (hasNext) cb += f(next())
cb
}
def collect2combiner[S, That](pf: PartialFunction[T, S], cb: Combiner[S, That]): Combiner[S, That] = {
//val cb = pbf(repr)
+ val runWith = pf.runWith(cb += _)
while (hasNext) {
- val curr = next
- if (pf.isDefinedAt(curr)) cb += pf(curr)
+ val curr = next()
+ runWith(curr)
}
cb
}
@@ -133,7 +129,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def flatmap2combiner[S, That](f: T => GenTraversableOnce[S], cb: Combiner[S, That]): Combiner[S, That] = {
//val cb = pbf(repr)
while (hasNext) {
- val traversable = f(next).seq
+ val traversable = f(next()).seq
if (traversable.isInstanceOf[Iterable[_]]) cb ++= traversable.asInstanceOf[Iterable[S]].iterator
else cb ++= traversable
}
@@ -148,7 +144,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def filter2combiner[U >: T, This](pred: T => Boolean, cb: Combiner[U, This]): Combiner[U, This] = {
while (hasNext) {
- val curr = next
+ val curr = next()
if (pred(curr)) cb += curr
}
cb
@@ -156,7 +152,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def filterNot2combiner[U >: T, This](pred: T => Boolean, cb: Combiner[U, This]): Combiner[U, This] = {
while (hasNext) {
- val curr = next
+ val curr = next()
if (!pred(curr)) cb += curr
}
cb
@@ -164,7 +160,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def partition2combiners[U >: T, This](pred: T => Boolean, btrue: Combiner[U, This], bfalse: Combiner[U, This]) = {
while (hasNext) {
- val curr = next
+ val curr = next()
if (pred(curr)) btrue += curr
else bfalse += curr
}
@@ -214,7 +210,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def takeWhile2combiner[U >: T, This](p: T => Boolean, cb: Combiner[U, This]) = {
var loop = true
while (hasNext && loop) {
- val curr = next
+ val curr = next()
if (p(curr)) cb += curr
else loop = false
}
@@ -224,7 +220,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def span2combiners[U >: T, This](p: T => Boolean, before: Combiner[U, This], after: Combiner[U, This]) = {
var isBefore = true
while (hasNext && isBefore) {
- val curr = next
+ val curr = next()
if (p(curr)) before += curr
else {
if (isRemainingCheap) after.sizeHint(remaining + 1)
@@ -240,7 +236,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
var last = z
var i = from
while (hasNext) {
- last = op(last, next)
+ last = op(last, next())
array(i) = last
i += 1
}
@@ -249,7 +245,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def scanToCombiner[U >: T, That](startValue: U, op: (U, U) => U, cb: Combiner[U, That]) = {
var curr = startValue
while (hasNext) {
- curr = op(curr, next)
+ curr = op(curr, next())
cb += curr
}
cb
@@ -259,7 +255,7 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
var curr = startValue
var left = howmany
while (left > 0) {
- curr = op(curr, next)
+ curr = op(curr, next())
cb += curr
left -= 1
}
@@ -269,16 +265,16 @@ private[collection] trait AugmentedIterableIterator[+T] extends RemainsIterator[
def zip2combiner[U >: T, S, That](otherpit: RemainsIterator[S], cb: Combiner[(U, S), That]): Combiner[(U, S), That] = {
if (isRemainingCheap && otherpit.isRemainingCheap) cb.sizeHint(remaining min otherpit.remaining)
while (hasNext && otherpit.hasNext) {
- cb += ((next, otherpit.next))
+ cb += ((next(), otherpit.next()))
}
cb
}
def zipAll2combiner[U >: T, S, That](that: RemainsIterator[S], thiselem: U, thatelem: S, cb: Combiner[(U, S), That]): Combiner[(U, S), That] = {
if (isRemainingCheap && that.isRemainingCheap) cb.sizeHint(remaining max that.remaining)
- while (this.hasNext && that.hasNext) cb += ((this.next, that.next))
- while (this.hasNext) cb += ((this.next, thatelem))
- while (that.hasNext) cb += ((thiselem, that.next))
+ while (this.hasNext && that.hasNext) cb += ((this.next(), that.next()))
+ while (this.hasNext) cb += ((this.next(), thatelem))
+ while (that.hasNext) cb += ((thiselem, that.next()))
cb
}
@@ -298,7 +294,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter
var total = 0
var loop = true
while (hasNext && loop) {
- if (pred(next)) total += 1
+ if (pred(next())) total += 1
else loop = false
}
total
@@ -308,7 +304,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter
var i = 0
var loop = true
while (hasNext && loop) {
- if (pred(next)) loop = false
+ if (pred(next())) loop = false
else i += 1
}
if (loop) -1 else i
@@ -318,7 +314,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter
var pos = -1
var i = 0
while (hasNext) {
- if (pred(next)) pos = i
+ if (pred(next())) pos = i
i += 1
}
pos
@@ -326,7 +322,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter
def corresponds[S](corr: (T, S) => Boolean)(that: Iterator[S]): Boolean = {
while (hasNext && that.hasNext) {
- if (!corr(next, that.next)) return false
+ if (!corr(next(), that.next())) return false
}
hasNext == that.hasNext
}
@@ -348,7 +344,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter
//val cb = cbf(repr)
if (isRemainingCheap) cb.sizeHint(remaining)
var lst = List[S]()
- while (hasNext) lst ::= f(next)
+ while (hasNext) lst ::= f(next())
while (lst != Nil) {
cb += lst.head
lst = lst.tail
@@ -363,7 +359,7 @@ private[collection] trait AugmentedSeqIterator[+T] extends AugmentedIterableIter
while (hasNext) {
if (j == index) {
cb += elem
- next
+ next()
} else cb += next
j += 1
}
@@ -438,7 +434,7 @@ self =>
class Taken(taken: Int) extends IterableSplitter[T] {
var remaining = taken min self.remaining
def hasNext = remaining > 0
- def next = { remaining -= 1; self.next }
+ def next = { remaining -= 1; self.next() }
def dup: IterableSplitter[T] = self.dup.take(taken)
def split: Seq[IterableSplitter[T]] = takeSeq(self.split) { (p, n) => p.take(n) }
protected[this] def takeSeq[PI <: IterableSplitter[T]](sq: Seq[PI])(taker: (PI, Int) => PI) = {
@@ -466,7 +462,7 @@ self =>
class Mapped[S](f: T => S) extends IterableSplitter[S] {
signalDelegate = self.signalDelegate
def hasNext = self.hasNext
- def next = f(self.next)
+ def next = f(self.next())
def remaining = self.remaining
def dup: IterableSplitter[S] = self.dup map f
def split: Seq[IterableSplitter[S]] = self.split.map { _ map f }
@@ -483,8 +479,8 @@ self =>
} else false
def next = if (curr eq self) {
hasNext
- curr.next
- } else curr.next
+ curr.next()
+ } else curr.next()
def remaining = if (curr eq self) curr.remaining + that.remaining else curr.remaining
protected def firstNonEmpty = (curr eq self) && curr.hasNext
def dup: IterableSplitter[U] = self.dup.appendParIterable[U, PI](that)
@@ -496,7 +492,7 @@ self =>
class Zipped[S](protected val that: SeqSplitter[S]) extends IterableSplitter[(T, S)] {
signalDelegate = self.signalDelegate
def hasNext = self.hasNext && that.hasNext
- def next = (self.next, that.next)
+ def next = (self.next(), that.next())
def remaining = self.remaining min that.remaining
def dup: IterableSplitter[(T, S)] = self.dup.zipParSeq(that)
def split: Seq[IterableSplitter[(T, S)]] = {
@@ -514,9 +510,10 @@ self =>
signalDelegate = self.signalDelegate
def hasNext = self.hasNext || that.hasNext
def next = if (self.hasNext) {
- if (that.hasNext) (self.next, that.next)
- else (self.next, thatelem)
- } else (thiselem, that.next);
+ if (that.hasNext) (self.next(), that.next())
+ else (self.next(), thatelem)
+ } else (thiselem, that.next())
+
def remaining = self.remaining max that.remaining
def dup: IterableSplitter[(U, S)] = self.dup.zipAllParSeq(that, thiselem, thatelem)
def split: Seq[IterableSplitter[(U, S)]] = {
@@ -530,10 +527,8 @@ self =>
}
def zipAllParSeq[S, U >: T, R >: S](that: SeqSplitter[S], thisElem: U, thatElem: R) = new ZippedAll[U, R](that, thisElem, thatElem)
-
}
-
/** Parallel sequence iterators allow splitting into arbitrary subsets.
*
* @tparam T type of the elements iterated.
@@ -605,7 +600,7 @@ self =>
} else Seq(sz)
}
val (selfszfrom, thatszfrom) = splitsizes.zip(szcum.init).span(_._2 < selfrem)
- val (selfsizes, thatsizes) = (selfszfrom map { _._1 }, thatszfrom map { _._1 });
+ val (selfsizes, thatsizes) = (selfszfrom map { _._1 }, thatszfrom map { _._1 })
// split iterators
val selfs = self.psplit(selfsizes: _*)
@@ -674,37 +669,3 @@ self =>
def patchParSeq[U >: T](from: Int, patchElems: SeqSplitter[U], replaced: Int) = new Patched(from, patchElems, replaced)
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/Splitter.scala b/src/library/scala/collection/parallel/Splitter.scala
index dc49bcf9d7..8329f15d88 100644
--- a/src/library/scala/collection/parallel/Splitter.scala
+++ b/src/library/scala/collection/parallel/Splitter.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.{ Seq, Iterator }
@@ -52,7 +53,7 @@ trait Splitter[+T] extends Iterator[T] {
object Splitter {
def empty[T]: Splitter[T] = new Splitter[T] {
def hasNext = false
- def next = Iterator.empty.next
+ def next = Iterator.empty.next()
def split = Seq(this)
}
}
diff --git a/src/library/scala/collection/parallel/TaskSupport.scala b/src/library/scala/collection/parallel/TaskSupport.scala
index 9bed5be51b..84bb5e425b 100644
--- a/src/library/scala/collection/parallel/TaskSupport.scala
+++ b/src/library/scala/collection/parallel/TaskSupport.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
@@ -17,28 +18,25 @@ import scala.concurrent.ExecutionContext
-/** A trait implementing the scheduling of
- * a parallel collection operation.
+/** A trait implementing the scheduling of a parallel collection operation.
*
* Parallel collections are modular in the way operations are scheduled. Each
* parallel collection is parametrized with a task support object which is
* responsible for scheduling and load-balancing tasks to processors.
- *
+ *
* A task support object can be changed in a parallel collection after it has
* been created, but only during a quiescent period, i.e. while there are no
* concurrent invocations to parallel collection methods.
*
* There are currently a few task support implementations available for
* parallel collections. The [[scala.collection.parallel.ForkJoinTaskSupport]]
- * uses a fork-join pool
- * internally and is used by default on JVM 1.6 or greater. The less efficient
- * [[scala.collection.parallel.ThreadPoolTaskSupport]] is a fallback for JVM
- * 1.5 and JVMs that do not support the fork join pools. The
- * [[scala.collection.parallel.ExecutionContextTaskSupport]] uses the
+ * uses a fork-join pool internally.
+ *
+ * The [[scala.collection.parallel.ExecutionContextTaskSupport]] uses the
* default execution context implementation found in scala.concurrent, and it
- * reuses the thread pool used in scala.concurrent (this is either a fork join
- * pool or a thread pool executor, depending on the JVM version). The
- * execution context task support is set to each parallel collection by
+ * reuses the thread pool used in scala.concurrent.
+ *
+ * The execution context task support is set to each parallel collection by
* default, so parallel collections reuse the same fork-join pool as the
* future API.
*
@@ -68,17 +66,18 @@ extends TaskSupport with AdaptiveWorkStealingForkJoinTasks
*
* @see [[scala.collection.parallel.TaskSupport]] for more information.
*/
+@deprecated("Use `ForkJoinTaskSupport` instead.", "2.11.0")
class ThreadPoolTaskSupport(val environment: ThreadPoolExecutor = ThreadPoolTasks.defaultThreadPool)
extends TaskSupport with AdaptiveWorkStealingThreadPoolTasks
/** A task support that uses an execution context to schedule tasks.
- *
+ *
* It can be used with the default execution context implementation in the
* `scala.concurrent` package. It internally forwards the call to either a
* forkjoin based task support or a thread pool executor one, depending on
* what the execution context uses.
- *
+ *
* By default, parallel collections are parametrized with this task support
* object, so parallel collections share the same execution context backend
* as the rest of the `scala.concurrent` package.
diff --git a/src/library/scala/collection/parallel/Tasks.scala b/src/library/scala/collection/parallel/Tasks.scala
index cec9e294c1..b23131c773 100644
--- a/src/library/scala/collection/parallel/Tasks.scala
+++ b/src/library/scala/collection/parallel/Tasks.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
@@ -54,32 +55,22 @@ trait Task[R, +Tp] {
leaf(lastres)
result = result // ensure that effects of `leaf` are visible to readers of `result`
} catchBreak {
- signalAbort
+ signalAbort()
}
} catch {
case thr: Exception =>
result = result // ensure that effects of `leaf` are visible
throwable = thr
- signalAbort
+ signalAbort()
}
}
private[parallel] def tryMerge(t: Tp @uncheckedVariance) {
val that = t.asInstanceOf[Task[R, Tp]]
- val local = result // ensure that any effects of modifying `result` are detected
- // checkMerge(that)
if (this.throwable == null && that.throwable == null) merge(t)
mergeThrowables(that)
}
- private def checkMerge(that: Task[R, Tp] @uncheckedVariance) {
- if (this.throwable == null && that.throwable == null && (this.result == null || that.result == null)) {
- println("This: " + this + ", thr=" + this.throwable + "; merged with " + that + ", thr=" + that.throwable)
- } else if (this.throwable != null || that.throwable != null) {
- println("merging this: " + this + " with thr: " + this.throwable + " with " + that + ", thr=" + that.throwable)
- }
- }
-
private[parallel] def mergeThrowables(that: Task[_, _]) {
if (this.throwable != null && that.throwable != null) {
// merge exceptions, since there were multiple exceptions
@@ -176,7 +167,6 @@ trait AdaptiveWorkStealingTasks extends Tasks {
while (last.next != null) {
// val lastresult = Option(last.body.result)
- val beforelast = last
last = last.next
if (last.tryCancel()) {
// println("Done with " + beforelast.body + ", next direct is " + last.body)
@@ -202,7 +192,7 @@ trait AdaptiveWorkStealingTasks extends Tasks {
last = t
t.start()
}
- } while (head.body.shouldSplitFurther);
+ } while (head.body.shouldSplitFurther)
head.next = last
head
}
@@ -225,6 +215,7 @@ trait AdaptiveWorkStealingTasks extends Tasks {
/** An implementation of tasks objects based on the Java thread pooling API. */
+@deprecated("Use `ForkJoinTasks` instead.", "2.11.0")
trait ThreadPoolTasks extends Tasks {
import java.util.concurrent._
@@ -313,7 +304,7 @@ trait ThreadPoolTasks extends Tasks {
() => {
t.sync()
- t.body.forwardThrowable
+ t.body.forwardThrowable()
t.body.result
}
}
@@ -325,7 +316,7 @@ trait ThreadPoolTasks extends Tasks {
t.start()
t.sync()
- t.body.forwardThrowable
+ t.body.forwardThrowable()
t.body.result
}
@@ -333,6 +324,7 @@ trait ThreadPoolTasks extends Tasks {
}
+@deprecated("Use `ForkJoinTasks` instead.", "2.11.0")
object ThreadPoolTasks {
import java.util.concurrent._
@@ -357,60 +349,6 @@ object ThreadPoolTasks {
)
}
-
-/** An implementation of tasks objects based on the Java thread pooling API and synchronization using futures. */
-@deprecated("This implementation is not used.", "2.10.0")
-trait FutureThreadPoolTasks extends Tasks {
- import java.util.concurrent._
-
- trait WrappedTask[R, +Tp] extends Runnable with super.WrappedTask[R, Tp] {
- @volatile var future: Future[_] = null
-
- def start() = {
- executor.synchronized {
- future = executor.submit(this)
- }
- }
- def sync() = future.get
- def tryCancel = false
- def run = {
- compute()
- }
- }
-
- protected def newWrappedTask[R, Tp](b: Task[R, Tp]): WrappedTask[R, Tp]
-
- val environment: AnyRef = FutureThreadPoolTasks.defaultThreadPool
- def executor = environment.asInstanceOf[ThreadPoolExecutor]
-
- def execute[R, Tp](task: Task[R, Tp]): () => R = {
- val t = newWrappedTask(task)
-
- // debuglog("-----------> Executing without wait: " + task)
- t.start
-
- () => {
- t.sync
- t.body.forwardThrowable
- t.body.result
- }
- }
-
- def executeAndWaitResult[R, Tp](task: Task[R, Tp]): R = {
- val t = newWrappedTask(task)
-
- // debuglog("-----------> Executing with wait: " + task)
- t.start
-
- t.sync
- t.body.forwardThrowable
- t.body.result
- }
-
- def parallelismLevel = FutureThreadPoolTasks.numCores
-
-}
-
object FutureThreadPoolTasks {
import java.util.concurrent._
@@ -467,8 +405,8 @@ trait ForkJoinTasks extends Tasks with HavingForkJoinPool {
}
() => {
- fjtask.sync
- fjtask.body.forwardThrowable
+ fjtask.sync()
+ fjtask.body.forwardThrowable()
fjtask.body.result
}
}
@@ -489,9 +427,9 @@ trait ForkJoinTasks extends Tasks with HavingForkJoinPool {
forkJoinPool.execute(fjtask)
}
- fjtask.sync
+ fjtask.sync()
// if (fjtask.body.throwable != null) println("throwing: " + fjtask.body.throwable + " at " + fjtask.body)
- fjtask.body.forwardThrowable
+ fjtask.body.forwardThrowable()
fjtask.body.result
}
@@ -520,7 +458,7 @@ trait AdaptiveWorkStealingForkJoinTasks extends ForkJoinTasks with AdaptiveWorkS
}
-
+@deprecated("Use `AdaptiveWorkStealingForkJoinTasks` instead.", "2.11.0")
trait AdaptiveWorkStealingThreadPoolTasks extends ThreadPoolTasks with AdaptiveWorkStealingTasks {
class WrappedTask[R, Tp](val body: Task[R, Tp])
diff --git a/src/library/scala/collection/parallel/immutable/ParHashMap.scala b/src/library/scala/collection/parallel/immutable/ParHashMap.scala
index b25230bbeb..854d0ba918 100644
--- a/src/library/scala/collection/parallel/immutable/ParHashMap.scala
+++ b/src/library/scala/collection/parallel/immutable/ParHashMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.immutable
+package scala
+package collection.parallel.immutable
@@ -109,7 +110,7 @@ self =>
}
def next(): (K, V) = {
i += 1
- val r = triter.next
+ val r = triter.next()
r
}
def hasNext: Boolean = {
diff --git a/src/library/scala/collection/parallel/immutable/ParHashSet.scala b/src/library/scala/collection/parallel/immutable/ParHashSet.scala
index e7e64eb2ad..65a632470e 100644
--- a/src/library/scala/collection/parallel/immutable/ParHashSet.scala
+++ b/src/library/scala/collection/parallel/immutable/ParHashSet.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.immutable
+package scala
+package collection.parallel.immutable
@@ -106,7 +107,7 @@ self =>
}
def next(): T = {
i += 1
- triter.next
+ triter.next()
}
def hasNext: Boolean = {
i < sz
diff --git a/src/library/scala/collection/parallel/immutable/ParIterable.scala b/src/library/scala/collection/parallel/immutable/ParIterable.scala
index 142f07ff26..417622facc 100644
--- a/src/library/scala/collection/parallel/immutable/ParIterable.scala
+++ b/src/library/scala/collection/parallel/immutable/ParIterable.scala
@@ -6,17 +6,13 @@
** |/ **
\* */
-
-package scala.collection
+package scala
+package collection
package parallel.immutable
-
import scala.collection.generic._
-
import scala.collection.parallel.ParIterableLike
import scala.collection.parallel.Combiner
-import scala.collection.GenIterable
-
/** A template trait for immutable parallel iterable collections.
*
@@ -30,22 +26,18 @@ import scala.collection.GenIterable
* @since 2.9
*/
trait ParIterable[+T]
-extends scala.collection/*.immutable*/.GenIterable[T]
+extends scala.collection.GenIterable[T]
with scala.collection.parallel.ParIterable[T]
with GenericParTemplate[T, ParIterable]
with ParIterableLike[T, ParIterable[T], scala.collection.immutable.Iterable[T]]
with Immutable
{
override def companion: GenericCompanion[ParIterable] with GenericParCompanion[ParIterable] = ParIterable
-
// if `immutable.ParIterableLike` is introduced, please move these 4 methods there
override def toIterable: ParIterable[T] = this
-
override def toSeq: ParSeq[T] = toParCollection[T, ParSeq[T]](() => ParSeq.newCombiner[T])
-
}
-
/** $factoryInfo
*/
object ParIterable extends ParFactory[ParIterable] {
@@ -53,21 +45,5 @@ object ParIterable extends ParFactory[ParIterable] {
new GenericCanCombineFrom[T]
def newBuilder[T]: Combiner[T, ParIterable[T]] = ParVector.newBuilder[T]
-
def newCombiner[T]: Combiner[T, ParIterable[T]] = ParVector.newCombiner[T]
-
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/immutable/ParMap.scala b/src/library/scala/collection/parallel/immutable/ParMap.scala
index e904a7616b..4d99006d0f 100644
--- a/src/library/scala/collection/parallel/immutable/ParMap.scala
+++ b/src/library/scala/collection/parallel/immutable/ParMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package parallel.immutable
import scala.collection.generic.ParMapFactory
diff --git a/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled b/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled
deleted file mode 100644
index 5f9c9c3d3d..0000000000
--- a/src/library/scala/collection/parallel/immutable/ParNumericRange.scala.disabled
+++ /dev/null
@@ -1,128 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-package scala.collection.parallel.immutable
-
-
-
-import scala.collection.immutable.NumericRange
-import scala.collection.parallel.Combiner
-import scala.collection.generic.CanCombineFrom
-import scala.collection.parallel.ParIterableIterator
-
-
-
-/** Parallel ranges for numeric types.
- *
- * $paralleliterableinfo
- *
- * $sideeffects
- *
- * @param range the sequential range this parallel range was obtained from
- *
- * @author Aleksandar Prokopec
- * @since 2.9
- *
- * @define Coll `immutable.ParRange`
- * @define coll immutable parallel range
- */
-@SerialVersionUID(1L)
-class ParNumericRange[T](val range: NumericRange[T])(implicit num: Integral[T])
-extends ParSeq[T]
- with Serializable
-{
-self =>
-
- def seq = range
-
- @inline final def length = range.length
-
- @inline final def apply(idx: Int) = range.apply(idx);
-
- def parallelIterator = new ParNumericRangeIterator with SCPI
-
- type SCPI = SignalContextPassingIterator[ParNumericRangeIterator]
-
- class ParNumericRangeIterator(range: NumericRange[T] = self.range, num: Integral[T] = self.num)
- extends ParIterator {
- me: SignalContextPassingIterator[ParNumericRangeIterator] =>
- override def toString = "ParNumericRangeIterator(over: " + range + ")"
- private var ind = 0
- private val len = range.length
-
- final def remaining = len - ind
-
- final def hasNext = ind < len
-
- final def next = if (hasNext) {
- val r = range.apply(ind)
- ind += 1
- r
- } else Iterator.empty.next
-
- private def rangeleft: NumericRange[T] = range.drop(ind)
-
- def dup = new ParNumericRangeIterator(rangeleft) with SCPI
-
- def split = {
- val rleft = rangeleft
- val elemleft = rleft.length
- if (elemleft < 2) Seq(new ParNumericRangeIterator(rleft) with SCPI)
- else Seq(
- new ParNumericRangeIterator(rleft.take(elemleft / 2)) with SCPI,
- new ParNumericRangeIterator(rleft.drop(elemleft / 2)) with SCPI
- )
- }
-
- def psplit(sizes: Int*) = {
- var rleft = rangeleft
- for (sz <- sizes) yield {
- val fronttaken = rleft.take(sz)
- rleft = rleft.drop(sz)
- new ParNumericRangeIterator(fronttaken) with SCPI
- }
- }
-
- /* accessors */
-
- override def foreach[U](f: T => U): Unit = {
- rangeleft.foreach(f)
- ind = len
- }
-
- override def reduce[U >: T](op: (U, U) => U): U = {
- val r = rangeleft.reduceLeft(op)
- ind = len
- r
- }
-
- /* transformers */
-
- override def map2combiner[S, That](f: T => S, cb: Combiner[S, That]): Combiner[S, That] = {
- while (hasNext) {
- cb += f(next)
- }
- cb
- }
- }
-
-}
-
-
-object ParNumericRange {
- def apply[T](start: T, end: T, step: T, inclusive: Boolean)(implicit num: Integral[T]) = new ParNumericRange[T](
- if (inclusive) NumericRange.inclusive(start, end, step)(num)
- else NumericRange.apply(start, end, step)(num)
- )
-}
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/immutable/ParRange.scala b/src/library/scala/collection/parallel/immutable/ParRange.scala
index 0c9f82ba2a..ec90de3a7d 100644
--- a/src/library/scala/collection/parallel/immutable/ParRange.scala
+++ b/src/library/scala/collection/parallel/immutable/ParRange.scala
@@ -6,13 +6,13 @@
** |/ **
\* */
-package scala.collection.parallel.immutable
+package scala
+package collection.parallel.immutable
import scala.collection.immutable.Range
import scala.collection.parallel.Combiner
import scala.collection.parallel.SeqSplitter
import scala.collection.generic.CanCombineFrom
-import scala.collection.parallel.IterableSplitter
import scala.collection.Iterator
/** Parallel ranges.
@@ -42,7 +42,7 @@ self =>
@inline final def length = range.length
- @inline final def apply(idx: Int) = range.apply(idx);
+ @inline final def apply(idx: Int) = range.apply(idx)
def splitter = new ParRangeIterator
@@ -60,7 +60,7 @@ self =>
val r = range.apply(ind)
ind += 1
r
- } else Iterator.empty.next
+ } else Iterator.empty.next()
private def rangeleft = range.drop(ind)
@@ -107,7 +107,7 @@ self =>
cb
}
}
-
+
}
object ParRange {
diff --git a/src/library/scala/collection/parallel/immutable/ParSeq.scala b/src/library/scala/collection/parallel/immutable/ParSeq.scala
index aa19307387..6e98b3102d 100644
--- a/src/library/scala/collection/parallel/immutable/ParSeq.scala
+++ b/src/library/scala/collection/parallel/immutable/ParSeq.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package parallel.immutable
@@ -18,9 +19,6 @@ import scala.collection.generic.CanCombineFrom
import scala.collection.generic.ParFactory
import scala.collection.parallel.ParSeqLike
import scala.collection.parallel.Combiner
-import scala.collection.GenSeq
-
-
/** An immutable variant of `ParSeq`.
*
diff --git a/src/library/scala/collection/parallel/immutable/ParSet.scala b/src/library/scala/collection/parallel/immutable/ParSet.scala
index 3622377a55..7837d6f264 100644
--- a/src/library/scala/collection/parallel/immutable/ParSet.scala
+++ b/src/library/scala/collection/parallel/immutable/ParSet.scala
@@ -6,10 +6,10 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package parallel.immutable
-import scala.collection.GenSet
import scala.collection.generic._
import scala.collection.parallel.ParSetLike
import scala.collection.parallel.Combiner
diff --git a/src/library/scala/collection/parallel/immutable/ParVector.scala b/src/library/scala/collection/parallel/immutable/ParVector.scala
index 1ee7f4ae69..548e7112c7 100644
--- a/src/library/scala/collection/parallel/immutable/ParVector.scala
+++ b/src/library/scala/collection/parallel/immutable/ParVector.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package parallel.immutable
diff --git a/src/library/scala/collection/parallel/immutable/package.scala b/src/library/scala/collection/parallel/immutable/package.scala
index 5ca0724ffc..8fd84eaf4d 100644
--- a/src/library/scala/collection/parallel/immutable/package.scala
+++ b/src/library/scala/collection/parallel/immutable/package.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
package immutable {
/** A (parallel) sequence consisting of `length` elements `elem`. Used in the `padTo` method.
diff --git a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala
index 12b2bc5008..cc25b5b4b2 100644
--- a/src/library/scala/collection/parallel/mutable/LazyCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/LazyCombiner.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.mutable
+package scala
+package collection.parallel.mutable
import scala.collection.generic.Growable
import scala.collection.generic.Sizing
diff --git a/src/library/scala/collection/parallel/mutable/ParArray.scala b/src/library/scala/collection/parallel/mutable/ParArray.scala
index 0a4f30131f..d0d022db4b 100644
--- a/src/library/scala/collection/parallel/mutable/ParArray.scala
+++ b/src/library/scala/collection/parallel/mutable/ParArray.scala
@@ -29,8 +29,6 @@ import scala.collection.mutable.Builder
import scala.collection.GenTraversableOnce
import scala.reflect.ClassTag
-
-
/** Parallel sequence holding elements in a linear array.
*
* `ParArray` is a parallel sequence with a predefined size. The size of the array
@@ -181,10 +179,10 @@ self =>
override def fold[U >: T](z: U)(op: (U, U) => U): U = foldLeft[U](z)(op)
- override def aggregate[S](z: S)(seqop: (S, T) => S, combop: (S, S) => S): S = foldLeft[S](z)(seqop)
+ override def aggregate[S](z: =>S)(seqop: (S, T) => S, combop: (S, S) => S): S = foldLeft[S](z)(seqop)
override def sum[U >: T](implicit num: Numeric[U]): U = {
- var s = sum_quick(num, arr, until, i, num.zero)
+ val s = sum_quick(num, arr, until, i, num.zero)
i = until
s
}
@@ -200,7 +198,7 @@ self =>
}
override def product[U >: T](implicit num: Numeric[U]): U = {
- var p = product_quick(num, arr, until, i, num.one)
+ val p = product_quick(num, arr, until, i, num.one)
i = until
p
}
@@ -226,7 +224,7 @@ self =>
if (all) i = nextuntil
else {
i = until
- abort
+ abort()
}
if (isAborted) return false
@@ -241,7 +239,7 @@ self =>
if (p(a(j).asInstanceOf[T])) j += 1
else return false
}
- return true
+ true
}
override def exists(p: T => Boolean): Boolean = {
@@ -254,7 +252,7 @@ self =>
some = exists_quick(p, array, nextuntil, i)
if (some) {
i = until
- abort
+ abort()
} else i = nextuntil
if (isAborted) return true
@@ -269,7 +267,7 @@ self =>
if (p(a(j).asInstanceOf[T])) return true
else j += 1
}
- return false
+ false
}
override def find(p: T => Boolean): Option[T] = {
@@ -283,7 +281,7 @@ self =>
if (r != None) {
i = until
- abort
+ abort()
} else i = nextuntil
if (isAborted) return r
@@ -298,7 +296,7 @@ self =>
if (p(elem)) return Some(elem)
else j += 1
}
- return None
+ None
}
override def drop(n: Int): ParArrayIterator = {
@@ -405,9 +403,10 @@ self =>
private def collect2combiner_quick[S, That](pf: PartialFunction[T, S], a: Array[Any], cb: Builder[S, That], ntil: Int, from: Int) {
var j = from
+ val runWith = pf.runWith(b => cb += b)
while (j < ntil) {
val curr = a(j).asInstanceOf[T]
- if (pf.isDefinedAt(curr)) cb += pf(curr)
+ runWith(curr)
j += 1
}
}
@@ -432,7 +431,7 @@ self =>
private def filter2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) {
var j = i
while(j < ntil) {
- var curr = a(j).asInstanceOf[T]
+ val curr = a(j).asInstanceOf[T]
if (pred(curr)) cb += curr
j += 1
}
@@ -447,7 +446,7 @@ self =>
private def filterNot2combiner_quick[U >: T, This](pred: T => Boolean, cb: Builder[U, This], a: Array[Any], ntil: Int, from: Int) {
var j = i
while(j < ntil) {
- var curr = a(j).asInstanceOf[T]
+ val curr = a(j).asInstanceOf[T]
if (!pred(curr)) cb += curr
j += 1
}
@@ -576,8 +575,6 @@ self =>
/* operations */
- private def asTask[R, Tp](t: Any) = t.asInstanceOf[Task[R, Tp]]
-
private def buildsArray[S, That](c: Builder[S, That]) = c.isInstanceOf[ParArrayCombiner[_]]
override def map[S, That](f: T => S)(implicit bf: CanBuildFrom[ParArray[T], S, That]) = if (buildsArray(bf(repr))) {
@@ -612,7 +609,8 @@ self =>
class ScanToArray[U >: T](tree: ScanTree[U], z: U, op: (U, U) => U, targetarr: Array[Any])
extends Task[Unit, ScanToArray[U]] {
- var result = ();
+ var result = ()
+
def leaf(prev: Option[Unit]) = iterate(tree)
private def iterate(tree: ScanTree[U]): Unit = tree match {
case ScanNode(left, right) =>
@@ -648,7 +646,8 @@ self =>
}
class Map[S](f: T => S, targetarr: Array[Any], offset: Int, howmany: Int) extends Task[Unit, Map[S]] {
- var result = ();
+ var result = ()
+
def leaf(prev: Option[Unit]) = {
val tarr = targetarr
val sarr = array
@@ -701,7 +700,7 @@ object ParArray extends ParFactory[ParArray] {
private def wrapOrRebuild[T](arr: AnyRef, sz: Int) = arr match {
case arr: Array[AnyRef] => new ParArray[T](new ExposedArraySeq[T](arr, sz))
- case _ => new ParArray[T](new ExposedArraySeq[T](runtime.ScalaRunTime.toObjectArray(arr), sz))
+ case _ => new ParArray[T](new ExposedArraySeq[T](scala.runtime.ScalaRunTime.toObjectArray(arr), sz))
}
def createFromCopy[T <: AnyRef : ClassTag](arr: Array[T]): ParArray[T] = {
@@ -719,27 +718,3 @@ object ParArray extends ParFactory[ParArray] {
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala
index 8bc108a738..afc2d6e987 100644
--- a/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala
+++ b/src/library/scala/collection/parallel/mutable/ParFlatHashTable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package parallel.mutable
import scala.collection.parallel.IterableSplitter
@@ -38,10 +39,6 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] {
}
}
- private def checkbounds() = if (idx >= itertable.length) {
- throw new IndexOutOfBoundsException(idx.toString)
- }
-
def newIterator(index: Int, until: Int, totalsize: Int): IterableSplitter[T]
def remaining = totalsize - traversed
@@ -52,7 +49,7 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] {
idx += 1
if (hasNext) scan()
r
- } else Iterator.empty.next
+ } else Iterator.empty.next()
def dup = newIterator(idx, until, totalsize)
def split = if (remaining > 1) {
val divpt = (until + idx) / 2
@@ -102,11 +99,5 @@ trait ParFlatHashTable[T] extends scala.collection.mutable.FlatHashTable[T] {
}
count
}
-
- private def check() = if (table.slice(idx, until).count(_ != null) != remaining) {
- println("Invariant broken: " + debugInformation)
- assert(false)
- }
}
-
}
diff --git a/src/library/scala/collection/parallel/mutable/ParHashMap.scala b/src/library/scala/collection/parallel/mutable/ParHashMap.scala
index 11588e555b..42a3302c91 100644
--- a/src/library/scala/collection/parallel/mutable/ParHashMap.scala
+++ b/src/library/scala/collection/parallel/mutable/ParHashMap.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
package mutable
@@ -97,7 +98,8 @@ self =>
class ParHashMapIterator(start: Int, untilIdx: Int, totalSize: Int, e: DefaultEntry[K, V])
extends EntryIterator[(K, V), ParHashMapIterator](start, untilIdx, totalSize, e) {
- def entry2item(entry: DefaultEntry[K, V]) = (entry.key, entry.value);
+ def entry2item(entry: DefaultEntry[K, V]) = (entry.key, entry.value)
+
def newIterator(idxFrom: Int, idxUntil: Int, totalSz: Int, es: DefaultEntry[K, V]) =
new ParHashMapIterator(idxFrom, idxUntil, totalSz, es)
}
@@ -166,9 +168,8 @@ private[mutable] abstract class ParHashMapCombiner[K, V](private val tableLoadFa
extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], DefaultEntry[K, V], ParHashMapCombiner[K, V]](ParHashMapCombiner.numblocks)
with scala.collection.mutable.HashTable.HashUtils[K]
{
- private var mask = ParHashMapCombiner.discriminantmask
- private var nonmasklen = ParHashMapCombiner.nonmasklength
- private var seedvalue = 27
+ private val nonmasklen = ParHashMapCombiner.nonmasklength
+ private val seedvalue = 27
def +=(elem: (K, V)) = {
sz += 1
@@ -232,8 +233,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
def setSize(sz: Int) = tableSize = sz
def insertEntry(/*block: Int, */e: DefaultEntry[K, V]) = {
var h = index(elemHashCode(e.key))
- // assertCorrectBlock(h, block)
- var olde = table(h).asInstanceOf[DefaultEntry[K, V]]
+ val olde = table(h).asInstanceOf[DefaultEntry[K, V]]
// check if key already exists
var ce = olde
@@ -252,13 +252,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
true
} else false
}
- private def assertCorrectBlock(h: Int, block: Int) {
- val blocksize = table.length / (1 << ParHashMapCombiner.discriminantbits)
- if (!(h >= block * blocksize && h < (block + 1) * blocksize)) {
- println("trying to put " + h + " into block no.: " + block + ", range: [" + block * blocksize + ", " + (block + 1) * blocksize + ">")
- assert(h >= block * blocksize && h < (block + 1) * blocksize)
- }
- }
protected def createNewEntry[X](key: K, x: X) = ???
}
@@ -288,7 +281,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
val chunksz = unrolled.size
while (i < chunksz) {
val elem = chunkarr(i)
- // assertCorrectBlock(block, elem.key)
if (t.insertEntry(elem)) insertcount += 1
i += 1
}
@@ -297,13 +289,6 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
}
insertcount
}
- private def assertCorrectBlock(block: Int, k: K) {
- val hc = improve(elemHashCode(k), seedvalue)
- if ((hc >>> nonmasklen) != block) {
- println(hc + " goes to " + (hc >>> nonmasklen) + ", while expected block is " + block)
- assert((hc >>> nonmasklen) == block)
- }
- }
def split = {
val fp = howmany / 2
List(new FillBlocks(buckets, table, offset, fp), new FillBlocks(buckets, table, offset + fp, howmany - fp))
@@ -320,7 +305,7 @@ extends scala.collection.parallel.BucketCombiner[(K, V), ParHashMap[K, V], Defau
private[parallel] object ParHashMapCombiner {
private[mutable] val discriminantbits = 5
private[mutable] val numblocks = 1 << discriminantbits
- private[mutable] val discriminantmask = ((1 << discriminantbits) - 1);
+ private[mutable] val discriminantmask = ((1 << discriminantbits) - 1)
private[mutable] val nonmasklength = 32 - discriminantbits
def apply[K, V] = new ParHashMapCombiner[K, V](HashTable.defaultLoadFactor) {} // was: with EnvironmentPassingCombiner[(K, V), ParHashMap[K, V]]
diff --git a/src/library/scala/collection/parallel/mutable/ParHashSet.scala b/src/library/scala/collection/parallel/mutable/ParHashSet.scala
index 57fab57348..1e3d57e0e5 100644
--- a/src/library/scala/collection/parallel/mutable/ParHashSet.scala
+++ b/src/library/scala/collection/parallel/mutable/ParHashSet.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.mutable
+package scala
+package collection.parallel.mutable
@@ -60,18 +61,18 @@ extends ParSet[T]
override def seq = new scala.collection.mutable.HashSet(hashTableContents)
def +=(elem: T) = {
- addEntry(elem)
+ addElem(elem)
this
}
def -=(elem: T) = {
- removeEntry(elem)
+ removeElem(elem)
this
}
override def stringPrefix = "ParHashSet"
- def contains(elem: T) = containsEntry(elem)
+ def contains(elem: T) = containsElem(elem)
def splitter = new ParHashSetIterator(0, table.length, size)
@@ -117,23 +118,23 @@ object ParHashSet extends ParSetFactory[ParHashSet] {
private[mutable] abstract class ParHashSetCombiner[T](private val tableLoadFactor: Int)
-extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], Any, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks)
+extends scala.collection.parallel.BucketCombiner[T, ParHashSet[T], AnyRef, ParHashSetCombiner[T]](ParHashSetCombiner.numblocks)
with scala.collection.mutable.FlatHashTable.HashUtils[T] {
//self: EnvironmentPassingCombiner[T, ParHashSet[T]] =>
- private var mask = ParHashSetCombiner.discriminantmask
- private var nonmasklen = ParHashSetCombiner.nonmasklength
- private var seedvalue = 27
+ private val nonmasklen = ParHashSetCombiner.nonmasklength
+ private val seedvalue = 27
def +=(elem: T) = {
+ val entry = elemToEntry(elem)
sz += 1
- val hc = improve(elemHashCode(elem), seedvalue)
+ val hc = improve(entry.hashCode, seedvalue)
val pos = hc >>> nonmasklen
if (buckets(pos) eq null) {
// initialize bucket
- buckets(pos) = new UnrolledBuffer[Any]
+ buckets(pos) = new UnrolledBuffer[AnyRef]
}
// add to bucket
- buckets(pos) += elem
+ buckets(pos) += entry
this
}
@@ -147,7 +148,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
val table = new AddingFlatHashTable(size, tableLoadFactor, seedvalue)
val (inserted, leftovers) = combinerTaskSupport.executeAndWaitResult(new FillBlocks(buckets, table, 0, buckets.length))
var leftinserts = 0
- for (elem <- leftovers) leftinserts += table.insertEntry(0, table.tableLength, elem.asInstanceOf[T])
+ for (entry <- leftovers) leftinserts += table.insertEntry(0, table.tableLength, entry)
table.setSize(leftinserts + inserted)
table.hashTableContents
}
@@ -159,10 +160,10 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
sizeMapInit(table.length)
seedvalue = ParHashSetCombiner.this.seedvalue
for {
- buffer <- buckets;
- if buffer ne null;
- elem <- buffer
- } addEntry(elem.asInstanceOf[T])
+ buffer <- buckets
+ if buffer ne null
+ entry <- buffer
+ } addEntry(entry)
}
tbl.hashTableContents
}
@@ -189,12 +190,12 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
def setSize(sz: Int) = tableSize = sz
/**
- * The elements are added using the `insertEntry` method. This method accepts three
+ * The elements are added using the `insertElem` method. This method accepts three
* arguments:
*
* @param insertAt where to add the element (set to -1 to use its hashcode)
* @param comesBefore the position before which the element should be added to
- * @param elem the element to be added
+ * @param newEntry the element to be added
*
* If the element is to be inserted at the position corresponding to its hash code,
* the table will try to add the element in such a position if possible. Collisions are resolved
@@ -206,17 +207,17 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
* If the element is already present in the hash table, it is not added, and this method
* returns 0. If the element is added, it returns 1.
*/
- def insertEntry(insertAt: Int, comesBefore: Int, elem: T): Int = {
+ def insertEntry(insertAt: Int, comesBefore: Int, newEntry : AnyRef): Int = {
var h = insertAt
- if (h == -1) h = index(elemHashCode(elem))
- var entry = table(h)
- while (null != entry) {
- if (entry == elem) return 0
+ if (h == -1) h = index(newEntry.hashCode)
+ var curEntry = table(h)
+ while (null != curEntry) {
+ if (curEntry == newEntry) return 0
h = h + 1 // we *do not* do `(h + 1) % table.length` here, because we'll never overflow!!
if (h >= comesBefore) return -1
- entry = table(h)
+ curEntry = table(h)
}
- table(h) = elem.asInstanceOf[AnyRef]
+ table(h) = newEntry
// this is incorrect since we set size afterwards anyway and a counter
// like this would not even work:
@@ -233,13 +234,14 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
/* tasks */
- class FillBlocks(buckets: Array[UnrolledBuffer[Any]], table: AddingFlatHashTable, val offset: Int, val howmany: Int)
- extends Task[(Int, UnrolledBuffer[Any]), FillBlocks] {
- var result = (Int.MinValue, new UnrolledBuffer[Any]);
- def leaf(prev: Option[(Int, UnrolledBuffer[Any])]) {
+ class FillBlocks(buckets: Array[UnrolledBuffer[AnyRef]], table: AddingFlatHashTable, val offset: Int, val howmany: Int)
+ extends Task[(Int, UnrolledBuffer[AnyRef]), FillBlocks] {
+ var result = (Int.MinValue, new UnrolledBuffer[AnyRef])
+
+ def leaf(prev: Option[(Int, UnrolledBuffer[AnyRef])]) {
var i = offset
var totalinserts = 0
- var leftover = new UnrolledBuffer[Any]()
+ var leftover = new UnrolledBuffer[AnyRef]()
while (i < (offset + howmany)) {
val (inserted, intonextblock) = fillBlock(i, buckets(i), leftover)
totalinserts += inserted
@@ -251,11 +253,11 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
private val blocksize = table.tableLength >> ParHashSetCombiner.discriminantbits
private def blockStart(block: Int) = block * blocksize
private def nextBlockStart(block: Int) = (block + 1) * blocksize
- private def fillBlock(block: Int, elems: UnrolledBuffer[Any], leftovers: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = {
+ private def fillBlock(block: Int, elems: UnrolledBuffer[AnyRef], leftovers: UnrolledBuffer[AnyRef]): (Int, UnrolledBuffer[AnyRef]) = {
val beforePos = nextBlockStart(block)
// store the elems
- val (elemsIn, elemsLeft) = if (elems != null) insertAll(-1, beforePos, elems) else (0, UnrolledBuffer[Any]())
+ val (elemsIn, elemsLeft) = if (elems != null) insertAll(-1, beforePos, elems) else (0, UnrolledBuffer[AnyRef]())
// store the leftovers
val (leftoversIn, leftoversLeft) = insertAll(blockStart(block), beforePos, leftovers)
@@ -263,21 +265,21 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
// return the no. of stored elements tupled with leftovers
(elemsIn + leftoversIn, elemsLeft concat leftoversLeft)
}
- private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[Any]): (Int, UnrolledBuffer[Any]) = {
- var leftovers = new UnrolledBuffer[Any]
+ private def insertAll(atPos: Int, beforePos: Int, elems: UnrolledBuffer[AnyRef]): (Int, UnrolledBuffer[AnyRef]) = {
+ val leftovers = new UnrolledBuffer[AnyRef]
var inserted = 0
var unrolled = elems.headPtr
var i = 0
- var t = table
+ val t = table
while (unrolled ne null) {
val chunkarr = unrolled.array
val chunksz = unrolled.size
while (i < chunksz) {
- val elem = chunkarr(i)
- val res = t.insertEntry(atPos, beforePos, elem.asInstanceOf[T])
+ val entry = chunkarr(i)
+ val res = t.insertEntry(atPos, beforePos, entry)
if (res >= 0) inserted += res
- else leftovers += elem
+ else leftovers += entry
i += 1
}
i = 0
@@ -319,7 +321,7 @@ with scala.collection.mutable.FlatHashTable.HashUtils[T] {
private[parallel] object ParHashSetCombiner {
private[mutable] val discriminantbits = 5
private[mutable] val numblocks = 1 << discriminantbits
- private[mutable] val discriminantmask = ((1 << discriminantbits) - 1);
+ private[mutable] val discriminantmask = ((1 << discriminantbits) - 1)
private[mutable] val nonmasklength = 32 - discriminantbits
def apply[T] = new ParHashSetCombiner[T](FlatHashTable.defaultLoadFactor) {} //with EnvironmentPassingCombiner[T, ParHashSet[T]]
diff --git a/src/library/scala/collection/parallel/mutable/ParHashTable.scala b/src/library/scala/collection/parallel/mutable/ParHashTable.scala
index 66ddef6a1e..a6fada3d42 100644
--- a/src/library/scala/collection/parallel/mutable/ParHashTable.scala
+++ b/src/library/scala/collection/parallel/mutable/ParHashTable.scala
@@ -7,7 +7,8 @@
\* */
-package scala.collection
+package scala
+package collection
package parallel.mutable
@@ -110,7 +111,7 @@ trait ParHashTable[K, Entry >: Null <: HashEntry[K, Entry]] extends scala.collec
} else Seq(this.asInstanceOf[IterRepr])
private def convertToArrayBuffer(chainhead: Entry): mutable.ArrayBuffer[T] = {
- var buff = mutable.ArrayBuffer[Entry]()
+ val buff = mutable.ArrayBuffer[Entry]()
var curr = chainhead
while (curr ne null) {
buff += curr
diff --git a/src/library/scala/collection/parallel/mutable/ParIterable.scala b/src/library/scala/collection/parallel/mutable/ParIterable.scala
index 7090c510a0..4659149106 100644
--- a/src/library/scala/collection/parallel/mutable/ParIterable.scala
+++ b/src/library/scala/collection/parallel/mutable/ParIterable.scala
@@ -6,14 +6,12 @@
** |/ **
\* */
-package scala.collection.parallel.mutable
-
+package scala
+package collection
+package parallel.mutable
import scala.collection.generic._
-import scala.collection.parallel.ParIterableLike
-import scala.collection.parallel.Combiner
-import scala.collection.GenIterable
-
+import scala.collection.parallel.{ ParIterableLike, Combiner }
/** A template trait for mutable parallel iterable collections.
*
@@ -26,7 +24,7 @@ import scala.collection.GenIterable
* @author Aleksandar Prokopec
* @since 2.9
*/
-trait ParIterable[T] extends scala.collection/*.mutable*/.GenIterable[T]
+trait ParIterable[T] extends scala.collection.GenIterable[T]
with scala.collection.parallel.ParIterable[T]
with GenericParTemplate[T, ParIterable]
with ParIterableLike[T, ParIterable[T], Iterable[T]]
@@ -45,24 +43,8 @@ trait ParIterable[T] extends scala.collection/*.mutable*/.GenIterable[T]
/** $factoryInfo
*/
object ParIterable extends ParFactory[ParIterable] {
- implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParIterable[T]] =
- new GenericCanCombineFrom[T]
+ implicit def canBuildFrom[T]: CanCombineFrom[Coll, T, ParIterable[T]] = new GenericCanCombineFrom[T]
def newBuilder[T]: Combiner[T, ParIterable[T]] = ParArrayCombiner[T]
-
def newCombiner[T]: Combiner[T, ParIterable[T]] = ParArrayCombiner[T]
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/mutable/ParMap.scala b/src/library/scala/collection/parallel/mutable/ParMap.scala
index 2250a38466..e43e72e559 100644
--- a/src/library/scala/collection/parallel/mutable/ParMap.scala
+++ b/src/library/scala/collection/parallel/mutable/ParMap.scala
@@ -6,17 +6,13 @@
** |/ **
\* */
-
-package scala.collection.parallel.mutable
-
-
-
+package scala
+package collection
+package parallel.mutable
import scala.collection.generic._
import scala.collection.parallel.Combiner
-
-
/** A template trait for mutable parallel maps.
*
* $sideeffects
@@ -28,11 +24,11 @@ import scala.collection.parallel.Combiner
* @since 2.9
*/
trait ParMap[K, V]
-extends scala.collection/*.mutable*/.GenMap[K, V]
- with scala.collection.parallel.ParMap[K, V]
- with /* mutable */ ParIterable[(K, V)]
+extends GenMap[K, V]
+ with parallel.ParMap[K, V]
+ with ParIterable[(K, V)]
with GenericParMapTemplate[K, V, ParMap]
- with /* mutable */ ParMapLike[K, V, ParMap[K, V], scala.collection.mutable.Map[K, V]]
+ with ParMapLike[K, V, ParMap[K, V], mutable.Map[K, V]]
{
protected[this] override def newCombiner: Combiner[(K, V), ParMap[K, V]] = ParMap.newCombiner[K, V]
@@ -63,11 +59,8 @@ extends scala.collection/*.mutable*/.GenMap[K, V]
* @return a wrapper of the map with a default value
*/
def withDefaultValue(d: V): scala.collection.parallel.mutable.ParMap[K, V] = new ParMap.WithDefault[K, V](this, x => d)
-
}
-
-
object ParMap extends ParMapFactory[ParMap] {
def empty[K, V]: ParMap[K, V] = new ParHashMap[K, V]
@@ -94,22 +87,3 @@ object ParMap extends ParMapFactory[ParMap] {
override def withDefaultValue(d: V): ParMap[K, V] = new WithDefault[K, V](underlying, x => d)
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/mutable/ParMapLike.scala b/src/library/scala/collection/parallel/mutable/ParMapLike.scala
index cdcfc59f8f..d96b5482fe 100644
--- a/src/library/scala/collection/parallel/mutable/ParMapLike.scala
+++ b/src/library/scala/collection/parallel/mutable/ParMapLike.scala
@@ -6,19 +6,17 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
package mutable
import scala.collection.generic._
-import scala.collection.mutable.Builder
import scala.collection.mutable.Cloneable
import scala.collection.generic.Growable
import scala.collection.generic.Shrinkable
-
-
/** A template trait for mutable parallel maps. This trait is to be mixed in
* with concrete parallel maps to override the representation type.
*
diff --git a/src/library/scala/collection/parallel/mutable/ParSeq.scala b/src/library/scala/collection/parallel/mutable/ParSeq.scala
index 95a4d4a13a..35be2669f8 100644
--- a/src/library/scala/collection/parallel/mutable/ParSeq.scala
+++ b/src/library/scala/collection/parallel/mutable/ParSeq.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-package scala.collection.parallel.mutable
-
+package scala
+package collection.parallel.mutable
import scala.collection.generic.GenericParTemplate
import scala.collection.generic.GenericCompanion
@@ -17,12 +16,6 @@ import scala.collection.generic.CanCombineFrom
import scala.collection.generic.ParFactory
import scala.collection.parallel.ParSeqLike
import scala.collection.parallel.Combiner
-import scala.collection.GenSeq
-
-
-
-
-
/** A mutable variant of `ParSeq`.
*
@@ -57,18 +50,3 @@ object ParSeq extends ParFactory[ParSeq] {
def newCombiner[T]: Combiner[T, ParSeq[T]] = ParArrayCombiner[T]
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/collection/parallel/mutable/ParSet.scala b/src/library/scala/collection/parallel/mutable/ParSet.scala
index d8f821746c..9367f1424d 100644
--- a/src/library/scala/collection/parallel/mutable/ParSet.scala
+++ b/src/library/scala/collection/parallel/mutable/ParSet.scala
@@ -6,18 +6,11 @@
** |/ **
\* */
-
-package scala.collection.parallel.mutable
-
-
+package scala
+package collection.parallel.mutable
import scala.collection.generic._
import scala.collection.parallel.Combiner
-import scala.collection.GenSet
-
-
-
-
/** A mutable variant of `ParSet`.
*
@@ -51,4 +44,3 @@ object ParSet extends ParSetFactory[ParSet] {
override def newCombiner[T]: Combiner[T, ParSet[T]] = ParHashSet.newCombiner
}
-
diff --git a/src/library/scala/collection/parallel/mutable/ParSetLike.scala b/src/library/scala/collection/parallel/mutable/ParSetLike.scala
index 609888f1a9..1cfc14b094 100644
--- a/src/library/scala/collection/parallel/mutable/ParSetLike.scala
+++ b/src/library/scala/collection/parallel/mutable/ParSetLike.scala
@@ -7,20 +7,15 @@
\* */
-package scala.collection
+package scala
+package collection
package parallel.mutable
-
-
-import scala.collection.mutable.Set
-import scala.collection.mutable.Builder
import scala.collection.mutable.Cloneable
import scala.collection.GenSetLike
import scala.collection.generic.Growable
import scala.collection.generic.Shrinkable
-
-
/** A template trait for mutable parallel sets. This trait is mixed in with concrete
* parallel sets to override the representation type.
*
diff --git a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala
index 61a50a124d..82f2717132 100644
--- a/src/library/scala/collection/parallel/mutable/ParTrieMap.scala
+++ b/src/library/scala/collection/parallel/mutable/ParTrieMap.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.mutable
+package scala
+package collection.parallel.mutable
@@ -136,7 +137,7 @@ extends TrieMapIterator[K, V](lev, ct, mustInit)
}
def dup = {
- val it = newIterator(0, ct, false)
+ val it = newIterator(0, ct, _mustInit = false)
dupTo(it)
it.iterated = this.iterated
it
diff --git a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala
index dc31d1bc25..79322c85b1 100644
--- a/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/ResizableParArrayCombiner.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.mutable
+package scala
+package collection.parallel.mutable
@@ -26,7 +27,7 @@ trait ResizableParArrayCombiner[T] extends LazyCombiner[T, ParArray[T], ExposedA
override def sizeHint(sz: Int) = if (chain.length == 1) chain(0).sizeHint(sz)
// public method with private[mutable] type ExposedArrayBuffer in parameter type; cannot be overridden.
- def newLazyCombiner(c: ArrayBuffer[ExposedArrayBuffer[T]]) = ResizableParArrayCombiner(c)
+ final def newLazyCombiner(c: ArrayBuffer[ExposedArrayBuffer[T]]) = ResizableParArrayCombiner(c)
def allocateAndCopy = if (chain.size > 1) {
val arrayseq = new ArraySeq[T](size)
diff --git a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
index c3a379485d..6b6ea03a6d 100644
--- a/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
+++ b/src/library/scala/collection/parallel/mutable/UnrolledParArrayCombiner.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel.mutable
+package scala
+package collection.parallel.mutable
import scala.collection.generic.Sizing
import scala.collection.mutable.ArraySeq
@@ -47,7 +48,7 @@ extends Combiner[T, ParArray[T]] {
}
def clear() {
- buff.clear
+ buff.clear()
}
override def sizeHint(sz: Int) = {
@@ -69,7 +70,8 @@ extends Combiner[T, ParArray[T]] {
class CopyUnrolledToArray(array: Array[Any], offset: Int, howmany: Int)
extends Task[Unit, CopyUnrolledToArray] {
- var result = ();
+ var result = ()
+
def leaf(prev: Option[Unit]) = if (howmany > 0) {
var totalleft = howmany
val (startnode, startpos) = findStart(offset)
diff --git a/src/library/scala/collection/parallel/mutable/package.scala b/src/library/scala/collection/parallel/mutable/package.scala
index 2494d0907e..81121d9398 100644
--- a/src/library/scala/collection/parallel/mutable/package.scala
+++ b/src/library/scala/collection/parallel/mutable/package.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection.parallel
+package scala
+package collection.parallel
import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable.ArraySeq
diff --git a/src/library/scala/collection/parallel/package.scala b/src/library/scala/collection/parallel/package.scala
index 988886b4ea..66fbad7643 100644
--- a/src/library/scala/collection/parallel/package.scala
+++ b/src/library/scala/collection/parallel/package.scala
@@ -41,9 +41,7 @@ package object parallel {
private[parallel] def outofbounds(idx: Int) = throw new IndexOutOfBoundsException(idx.toString)
- private[parallel] def getTaskSupport: TaskSupport =
- if (scala.util.Properties.isJavaAtLeast("1.6")) new ForkJoinTaskSupport
- else new ThreadPoolTaskSupport
+ private[parallel] def getTaskSupport: TaskSupport = new ForkJoinTaskSupport
val defaultTaskSupport: TaskSupport = getTaskSupport
@@ -136,7 +134,7 @@ package parallel {
/** Composite throwable - thrown when multiple exceptions are thrown at the same time. */
final case class CompositeThrowable(
- val throwables: Set[Throwable]
+ throwables: Set[Throwable]
) extends Exception(
"Multiple exceptions thrown during a parallel computation: " +
throwables.map(t => t + "\n" + t.getStackTrace.take(10).++("...").mkString("\n")).mkString("\n\n")
diff --git a/src/library/scala/collection/script/Location.scala b/src/library/scala/collection/script/Location.scala
index cd64fa2d73..e485737972 100644
--- a/src/library/scala/collection/script/Location.scala
+++ b/src/library/scala/collection/script/Location.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package script
/** Class `Location` describes locations in messages implemented by
diff --git a/src/library/scala/collection/script/Message.scala b/src/library/scala/collection/script/Message.scala
index 2ab7ea726a..dc3e74e170 100644
--- a/src/library/scala/collection/script/Message.scala
+++ b/src/library/scala/collection/script/Message.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package script
import mutable.ArrayBuffer
@@ -69,7 +70,7 @@ class Script[A] extends ArrayBuffer[Message[A]] with Message[A] {
override def toString(): String = {
var res = "Script("
- var it = this.iterator
+ val it = this.iterator
var i = 1
while (it.hasNext) {
if (i > 1)
diff --git a/src/library/scala/collection/script/Scriptable.scala b/src/library/scala/collection/script/Scriptable.scala
index ceaf19a464..110a0f4d82 100644
--- a/src/library/scala/collection/script/Scriptable.scala
+++ b/src/library/scala/collection/script/Scriptable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.collection
+package scala
+package collection
package script
/** Classes that mix in the `Scriptable` class allow messages to be sent to
diff --git a/src/library/scala/compat/Platform.scala b/src/library/scala/compat/Platform.scala
index 88cb1506ae..875d811b9b 100644
--- a/src/library/scala/compat/Platform.scala
+++ b/src/library/scala/compat/Platform.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.compat
+package scala
+package compat
import java.lang.System
diff --git a/src/library/scala/concurrent/BatchingExecutor.scala b/src/library/scala/concurrent/BatchingExecutor.scala
new file mode 100644
index 0000000000..a0d7aaea47
--- /dev/null
+++ b/src/library/scala/concurrent/BatchingExecutor.scala
@@ -0,0 +1,117 @@
+/* __ *\
+** ________ ___ / / ___ Scala API **
+** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
+** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
+** /____/\___/_/ |_/____/_/ | | **
+** |/ **
+\* */
+
+package scala.concurrent
+
+import java.util.concurrent.Executor
+import scala.annotation.tailrec
+
+/**
+ * Mixin trait for an Executor
+ * which groups multiple nested `Runnable.run()` calls
+ * into a single Runnable passed to the original
+ * Executor. This can be a useful optimization
+ * because it bypasses the original context's task
+ * queue and keeps related (nested) code on a single
+ * thread which may improve CPU affinity. However,
+ * if tasks passed to the Executor are blocking
+ * or expensive, this optimization can prevent work-stealing
+ * and make performance worse. Also, some ExecutionContext
+ * may be fast enough natively that this optimization just
+ * adds overhead.
+ * The default ExecutionContext.global is already batching
+ * or fast enough not to benefit from it; while
+ * `fromExecutor` and `fromExecutorService` do NOT add
+ * this optimization since they don't know whether the underlying
+ * executor will benefit from it.
+ * A batching executor can create deadlocks if code does
+ * not use `scala.concurrent.blocking` when it should,
+ * because tasks created within other tasks will block
+ * on the outer task completing.
+ * This executor may run tasks in any order, including LIFO order.
+ * There are no ordering guarantees.
+ *
+ * WARNING: The underlying Executor's execute-method must not execute the submitted Runnable
+ * in the calling thread synchronously. It must enqueue/handoff the Runnable.
+ */
+private[concurrent] trait BatchingExecutor extends Executor {
+
+ // invariant: if "_tasksLocal.get ne null" then we are inside BatchingRunnable.run; if it is null, we are outside
+ private val _tasksLocal = new ThreadLocal[List[Runnable]]()
+
+ private class Batch(val initial: List[Runnable]) extends Runnable with BlockContext {
+ private var parentBlockContext: BlockContext = _
+ // this method runs in the delegate ExecutionContext's thread
+ override def run(): Unit = {
+ require(_tasksLocal.get eq null)
+
+ val prevBlockContext = BlockContext.current
+ BlockContext.withBlockContext(this) {
+ try {
+ parentBlockContext = prevBlockContext
+
+ @tailrec def processBatch(batch: List[Runnable]): Unit = batch match {
+ case Nil => ()
+ case head :: tail =>
+ _tasksLocal set tail
+ try {
+ head.run()
+ } catch {
+ case t: Throwable =>
+ // if one task throws, move the
+ // remaining tasks to another thread
+ // so we can throw the exception
+ // up to the invoking executor
+ val remaining = _tasksLocal.get
+ _tasksLocal set Nil
+ unbatchedExecute(new Batch(remaining)) //TODO what if this submission fails?
+ throw t // rethrow
+ }
+ processBatch(_tasksLocal.get) // since head.run() can add entries, always do _tasksLocal.get here
+ }
+
+ processBatch(initial)
+ } finally {
+ _tasksLocal.remove()
+ parentBlockContext = null
+ }
+ }
+ }
+
+ override def blockOn[T](thunk: => T)(implicit permission: CanAwait): T = {
+ // if we know there will be blocking, we don't want to keep tasks queued up because it could deadlock.
+ {
+ val tasks = _tasksLocal.get
+ _tasksLocal set Nil
+ if ((tasks ne null) && tasks.nonEmpty)
+ unbatchedExecute(new Batch(tasks))
+ }
+
+ // now delegate the blocking to the previous BC
+ require(parentBlockContext ne null)
+ parentBlockContext.blockOn(thunk)
+ }
+ }
+
+ protected def unbatchedExecute(r: Runnable): Unit
+
+ override def execute(runnable: Runnable): Unit = {
+ if (batchable(runnable)) { // If we can batch the runnable
+ _tasksLocal.get match {
+ case null => unbatchedExecute(new Batch(List(runnable))) // If we aren't in batching mode yet, enqueue batch
+ case some => _tasksLocal.set(runnable :: some) // If we are already in batching mode, add to batch
+ }
+ } else unbatchedExecute(runnable) // If not batchable, just delegate to underlying
+ }
+
+ /** Override this to define which runnables will be batched. */
+ def batchable(runnable: Runnable): Boolean = runnable match {
+ case _: OnCompleteRunnable => true
+ case _ => false
+ }
+}
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 6b6ad29074..c444050e3d 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -71,7 +71,7 @@ import scala.reflect.ClassTag
* val g = future { 3 }
* val h = for {
* x: Int <- f // returns Future(5)
- * y: Int <- g // returns Future(5)
+ * y: Int <- g // returns Future(3)
* } yield x + y
* }}}
*
@@ -576,7 +576,7 @@ object Future {
def sequence[A, M[_] <: TraversableOnce[_]](in: M[Future[A]])(implicit cbf: CanBuildFrom[M[Future[A]], A, M[A]], executor: ExecutionContext): Future[M[A]] = {
in.foldLeft(Promise.successful(cbf(in)).future) {
(fr, fa) => for (r <- fr; a <- fa.asInstanceOf[Future[A]]) yield (r += a)
- } map (_.result)
+ } map (_.result())
}
/** Returns a `Future` to the result of the first future in the list that is completed.
@@ -638,7 +638,7 @@ object Future {
* }}}
*/
def reduce[T, R >: T](futures: TraversableOnce[Future[T]])(op: (R, T) => R)(implicit executor: ExecutionContext): Future[R] = {
- if (futures.isEmpty) Promise[R].failure(new NoSuchElementException("reduce attempted on empty collection")).future
+ if (futures.isEmpty) Promise[R]().failure(new NoSuchElementException("reduce attempted on empty collection")).future
else sequence(futures).map(_ reduceLeft op)
}
@@ -654,7 +654,7 @@ object Future {
in.foldLeft(Promise.successful(cbf(in)).future) { (fr, a) =>
val fb = fn(a.asInstanceOf[A])
for (r <- fr; b <- fb) yield (r += b)
- }.map(_.result)
+ }.map(_.result())
// This is used to run callbacks which are internal
// to scala.concurrent; our own callbacks are only
@@ -675,111 +675,11 @@ object Future {
// by just not ever using it itself. scala.concurrent
// doesn't need to create defaultExecutionContext as
// a side effect.
- private[concurrent] object InternalCallbackExecutor extends ExecutionContext with java.util.concurrent.Executor {
+ private[concurrent] object InternalCallbackExecutor extends ExecutionContext with BatchingExecutor {
+ override protected def unbatchedExecute(r: Runnable): Unit =
+ r.run()
override def reportFailure(t: Throwable): Unit =
throw new IllegalStateException("problem in scala.concurrent internal callback", t)
-
- /**
- * The BatchingExecutor trait had to be inlined into InternalCallbackExecutor for binary compatibility.
- *
- * BatchingExecutor is a trait for an Executor
- * which groups multiple nested `Runnable.run()` calls
- * into a single Runnable passed to the original
- * Executor. This can be a useful optimization
- * because it bypasses the original context's task
- * queue and keeps related (nested) code on a single
- * thread which may improve CPU affinity. However,
- * if tasks passed to the Executor are blocking
- * or expensive, this optimization can prevent work-stealing
- * and make performance worse. Also, some ExecutionContext
- * may be fast enough natively that this optimization just
- * adds overhead.
- * The default ExecutionContext.global is already batching
- * or fast enough not to benefit from it; while
- * `fromExecutor` and `fromExecutorService` do NOT add
- * this optimization since they don't know whether the underlying
- * executor will benefit from it.
- * A batching executor can create deadlocks if code does
- * not use `scala.concurrent.blocking` when it should,
- * because tasks created within other tasks will block
- * on the outer task completing.
- * This executor may run tasks in any order, including LIFO order.
- * There are no ordering guarantees.
- *
- * WARNING: The underlying Executor's execute-method must not execute the submitted Runnable
- * in the calling thread synchronously. It must enqueue/handoff the Runnable.
- */
- // invariant: if "_tasksLocal.get ne null" then we are inside BatchingRunnable.run; if it is null, we are outside
- private val _tasksLocal = new ThreadLocal[List[Runnable]]()
-
- private class Batch(val initial: List[Runnable]) extends Runnable with BlockContext {
- private[this] var parentBlockContext: BlockContext = _
- // this method runs in the delegate ExecutionContext's thread
- override def run(): Unit = {
- require(_tasksLocal.get eq null)
-
- val prevBlockContext = BlockContext.current
- BlockContext.withBlockContext(this) {
- try {
- parentBlockContext = prevBlockContext
-
- @tailrec def processBatch(batch: List[Runnable]): Unit = batch match {
- case Nil => ()
- case head :: tail =>
- _tasksLocal set tail
- try {
- head.run()
- } catch {
- case t: Throwable =>
- // if one task throws, move the
- // remaining tasks to another thread
- // so we can throw the exception
- // up to the invoking executor
- val remaining = _tasksLocal.get
- _tasksLocal set Nil
- unbatchedExecute(new Batch(remaining)) //TODO what if this submission fails?
- throw t // rethrow
- }
- processBatch(_tasksLocal.get) // since head.run() can add entries, always do _tasksLocal.get here
- }
-
- processBatch(initial)
- } finally {
- _tasksLocal.remove()
- parentBlockContext = null
- }
- }
- }
-
- override def blockOn[T](thunk: => T)(implicit permission: CanAwait): T = {
- // if we know there will be blocking, we don't want to keep tasks queued up because it could deadlock.
- {
- val tasks = _tasksLocal.get
- _tasksLocal set Nil
- if ((tasks ne null) && tasks.nonEmpty)
- unbatchedExecute(new Batch(tasks))
- }
-
- // now delegate the blocking to the previous BC
- require(parentBlockContext ne null)
- parentBlockContext.blockOn(thunk)
- }
- }
-
- override def execute(runnable: Runnable): Unit = runnable match {
- // If we can batch the runnable
- case _: OnCompleteRunnable =>
- _tasksLocal.get match {
- case null => unbatchedExecute(new Batch(List(runnable))) // If we aren't in batching mode yet, enqueue batch
- case some => _tasksLocal.set(runnable :: some) // If we are already in batching mode, add to batch
- }
-
- // If not batchable, just delegate to underlying
- case _ =>
- unbatchedExecute(runnable)
- }
-
- private def unbatchedExecute(r: Runnable): Unit = r.run()
}
}
diff --git a/src/library/scala/concurrent/FutureTaskRunner.scala b/src/library/scala/concurrent/FutureTaskRunner.scala
index eeadaddb5e..089e67cedd 100644
--- a/src/library/scala/concurrent/FutureTaskRunner.scala
+++ b/src/library/scala/concurrent/FutureTaskRunner.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2009-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2009-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
@@ -10,13 +10,13 @@ package scala.concurrent
import scala.language.{implicitConversions, higherKinds}
-/** The `FutureTaskRunner</code> trait is a base trait of task runners
+/** The `FutureTaskRunner` trait is a base trait of task runners
* that provide some sort of future abstraction.
*
* @author Philipp Haller
*/
@deprecated("Use `ExecutionContext` instead.", "2.10.0")
-trait FutureTaskRunner extends TaskRunner {
+private[scala] trait FutureTaskRunner extends TaskRunner {
/** The type of the futures that the underlying task runner supports.
*/
diff --git a/src/library/scala/concurrent/JavaConversions.scala b/src/library/scala/concurrent/JavaConversions.scala
index d6a7c1f1bb..3d0597ca22 100644
--- a/src/library/scala/concurrent/JavaConversions.scala
+++ b/src/library/scala/concurrent/JavaConversions.scala
@@ -18,38 +18,6 @@ import scala.language.implicitConversions
*/
object JavaConversions {
- @deprecated("Use `asExecutionContext` instead.", "2.10.0")
- implicit def asTaskRunner(exec: ExecutorService): FutureTaskRunner =
- new ThreadPoolRunner {
- override protected def executor =
- exec
-
- def shutdown() =
- exec.shutdown()
- }
-
- @deprecated("Use `asExecutionContext` instead.", "2.10.0")
- implicit def asTaskRunner(exec: Executor): TaskRunner =
- new TaskRunner {
- type Task[T] = Runnable
-
- implicit def functionAsTask[T](fun: () => T): Task[T] = new Runnable {
- def run() { fun() }
- }
-
- def execute[S](task: Task[S]) {
- exec.execute(task)
- }
-
- def managedBlock(blocker: ManagedBlocker) {
- blocker.block()
- }
-
- def shutdown() {
- // do nothing
- }
- }
-
/**
* Creates a new `ExecutionContext` which uses the provided `ExecutorService`.
*/
diff --git a/src/library/scala/concurrent/ManagedBlocker.scala b/src/library/scala/concurrent/ManagedBlocker.scala
index 7b2966c663..b5a6e21893 100644
--- a/src/library/scala/concurrent/ManagedBlocker.scala
+++ b/src/library/scala/concurrent/ManagedBlocker.scala
@@ -13,7 +13,7 @@ package scala.concurrent
* @author Philipp Haller
*/
@deprecated("Use `blocking` instead.", "2.10.0")
-trait ManagedBlocker {
+private[scala] trait ManagedBlocker {
/**
* Possibly blocks the current thread, for example waiting for
diff --git a/src/library/scala/concurrent/SyncVar.scala b/src/library/scala/concurrent/SyncVar.scala
index 9ab7bcc572..d22471ac0f 100644
--- a/src/library/scala/concurrent/SyncVar.scala
+++ b/src/library/scala/concurrent/SyncVar.scala
@@ -41,9 +41,9 @@ class SyncVar[A] {
* @return `None` if variable is undefined after `timeout`, `Some(value)` otherwise
*/
def get(timeout: Long): Option[A] = synchronized {
- /** Defending against the system clock going backward
- * by counting time elapsed directly. Loop required
- * to deal with spurious wakeups.
+ /* Defending against the system clock going backward
+ * by counting time elapsed directly. Loop required
+ * to deal with spurious wakeups.
*/
var rest = timeout
while (!isDefined && rest > 0) {
@@ -79,7 +79,7 @@ class SyncVar[A] {
// whether or not the SyncVar is already defined. So, set has been
// deprecated in order to eventually be able to make "setting" private
@deprecated("Use `put` instead, as `set` is potentionally error-prone", "2.10.0")
- def set(x: A): Unit = setVal(x)
+ private[scala] def set(x: A): Unit = setVal(x)
/** Places a value in the SyncVar. If the SyncVar already has a stored value,
* it waits until another thread takes it */
@@ -98,7 +98,7 @@ class SyncVar[A] {
// whether or not the SyncVar is already defined. So, unset has been
// deprecated in order to eventually be able to make "unsetting" private
@deprecated("Use `take` instead, as `unset` is potentionally error-prone", "2.10.0")
- def unset(): Unit = synchronized {
+ private[scala] def unset(): Unit = synchronized {
isDefined = false
value = None
notifyAll()
diff --git a/src/library/scala/concurrent/TaskRunner.scala b/src/library/scala/concurrent/TaskRunner.scala
index a939a3f070..98c212d9fa 100644
--- a/src/library/scala/concurrent/TaskRunner.scala
+++ b/src/library/scala/concurrent/TaskRunner.scala
@@ -15,7 +15,7 @@ import scala.language.{higherKinds, implicitConversions}
* @author Philipp Haller
*/
@deprecated("Use `ExecutionContext` instead.", "2.10.0")
-trait TaskRunner {
+private[scala] trait TaskRunner {
type Task[T]
diff --git a/src/library/scala/concurrent/TaskRunners.scala b/src/library/scala/concurrent/TaskRunners.scala
deleted file mode 100644
index e109a8abf9..0000000000
--- a/src/library/scala/concurrent/TaskRunners.scala
+++ /dev/null
@@ -1,36 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.concurrent
-
-import java.util.concurrent.{ThreadPoolExecutor, LinkedBlockingQueue, TimeUnit}
-
-/** The `TaskRunners` object...
- *
- * @author Philipp Haller
- */
-@deprecated("Use `ExecutionContext` instead.", "2.10.0")
-object TaskRunners {
-
- implicit val threadRunner: FutureTaskRunner =
- new ThreadRunner
-
- implicit val threadPoolRunner: FutureTaskRunner = {
- val numCores = Runtime.getRuntime().availableProcessors()
- val keepAliveTime = 60000L
- val workQueue = new LinkedBlockingQueue[Runnable]
- val exec = new ThreadPoolExecutor(numCores,
- numCores,
- keepAliveTime,
- TimeUnit.MILLISECONDS,
- workQueue,
- new ThreadPoolExecutor.CallerRunsPolicy)
- JavaConversions.asTaskRunner(exec)
- }
-
-}
diff --git a/src/library/scala/concurrent/ThreadPoolRunner.scala b/src/library/scala/concurrent/ThreadPoolRunner.scala
index afa14ed2fa..7784681f71 100644
--- a/src/library/scala/concurrent/ThreadPoolRunner.scala
+++ b/src/library/scala/concurrent/ThreadPoolRunner.scala
@@ -17,7 +17,7 @@ import scala.language.implicitConversions
* @author Philipp Haller
*/
@deprecated("Use `ExecutionContext` instead.", "2.10.0")
-trait ThreadPoolRunner extends FutureTaskRunner {
+private[scala] trait ThreadPoolRunner extends FutureTaskRunner {
type Task[T] = Callable[T] with Runnable
type Future[T] = java.util.concurrent.Future[T]
diff --git a/src/library/scala/concurrent/ThreadRunner.scala b/src/library/scala/concurrent/ThreadRunner.scala
deleted file mode 100644
index cd92db9486..0000000000
--- a/src/library/scala/concurrent/ThreadRunner.scala
+++ /dev/null
@@ -1,60 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.concurrent
-
-import java.lang.Thread
-import scala.language.implicitConversions
-
-/** The `ThreadRunner` trait...
- *
- * @author Philipp Haller
- */
-@deprecated("Use `ExecutionContext` instead.", "2.10.0")
-class ThreadRunner extends FutureTaskRunner {
-
- type Task[T] = () => T
- type Future[T] = () => T
-
- implicit def functionAsTask[S](fun: () => S): Task[S] = fun
- implicit def futureAsFunction[S](x: Future[S]): () => S = x
-
- /* If expression computed successfully return it in `Right`,
- * otherwise return exception in `Left`.
- */
- private def tryCatch[A](body: => A): Either[Exception, A] =
- try Right(body) catch {
- case ex: Exception => Left(ex)
- }
-
- def execute[S](task: Task[S]) {
- val runnable = new Runnable {
- def run() { tryCatch(task()) }
- }
- (new Thread(runnable)).start()
- }
-
- def submit[S](task: Task[S]): Future[S] = {
- val result = new SyncVar[Either[Exception, S]]
- val runnable = new Runnable {
- def run() { result set tryCatch(task()) }
- }
- (new Thread(runnable)).start()
- () => result.get.fold[S](throw _, identity _)
- }
-
- @deprecated("Use `blocking` instead.", "2.10.0")
- def managedBlock(blocker: ManagedBlocker) {
- blocker.block()
- }
-
- def shutdown() {
- // do nothing
- }
-
-}
diff --git a/src/library/scala/concurrent/duration/Duration.scala b/src/library/scala/concurrent/duration/Duration.scala
index 0353d61b22..a24266bf19 100644
--- a/src/library/scala/concurrent/duration/Duration.scala
+++ b/src/library/scala/concurrent/duration/Duration.scala
@@ -10,6 +10,7 @@ package scala.concurrent.duration
import java.lang.{ Double => JDouble, Long => JLong }
import scala.language.implicitConversions
+import scala.language.postfixOps
object Duration {
@@ -103,7 +104,7 @@ object Duration {
* Extract length and time unit out of a duration, if it is finite.
*/
def unapply(d: Duration): Option[(Long, TimeUnit)] =
- if (d.isFinite) Some((d.length, d.unit)) else None
+ if (d.isFinite()) Some((d.length, d.unit)) else None
/**
* Construct a possibly infinite or undefined Duration from the given number of nanoseconds.
@@ -623,7 +624,7 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio
// if this is made a constant, then scalac will elide the conditional and always return +0.0, SI-6331
private[this] def minusZero = -0d
def /(divisor: Duration): Double =
- if (divisor.isFinite) toNanos.toDouble / divisor.toNanos
+ if (divisor.isFinite()) toNanos.toDouble / divisor.toNanos
else if (divisor eq Undefined) Double.NaN
else if ((length < 0) ^ (divisor > Zero)) 0d
else minusZero
@@ -663,8 +664,8 @@ final class FiniteDuration(val length: Long, val unit: TimeUnit) extends Duratio
* Long.MinValue is not a legal `length` anyway.
*/
private def safeMul(_a: Long, _b: Long): Long = {
- val a = math.abs(_a)
- val b = math.abs(_b)
+ val a = scala.math.abs(_a)
+ val b = scala.math.abs(_b)
import java.lang.Long.{ numberOfLeadingZeros => leading }
if (leading(a) + leading(b) < 64) throw new IllegalArgumentException("multiplication overflow")
val product = a * b
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
index 0aa6b37ffc..ed04293e0d 100644
--- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
+++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -30,7 +30,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
}
// Implement BlockContext on FJP threads
- class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory {
+ class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory {
def wire[T <: Thread](thread: T): T = {
thread.setDaemon(daemonic)
thread.setUncaughtExceptionHandler(uncaughtExceptionHandler)
@@ -72,7 +72,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
getInt("scala.concurrent.context.maxThreads", _.toInt))
val threadFactory = new DefaultThreadFactory(daemonic = true)
-
+
try {
new ForkJoinPool(
desiredParallelism,
@@ -96,12 +96,26 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
}
}
-
def execute(runnable: Runnable): Unit = executor match {
case fj: ForkJoinPool =>
- val fjt = runnable match {
+ val fjt: ForkJoinTask[_] = runnable match {
case t: ForkJoinTask[_] => t
- case runnable => new ForkJoinTask[Unit] {
+ case r => new ExecutionContextImpl.AdaptedForkJoinTask(r)
+ }
+ Thread.currentThread match {
+ case fjw: ForkJoinWorkerThread if fjw.getPool eq fj => fjt.fork()
+ case _ => fj execute fjt
+ }
+ case generic => generic execute runnable
+ }
+
+ def reportFailure(t: Throwable) = reporter(t)
+}
+
+
+private[concurrent] object ExecutionContextImpl {
+
+ final class AdaptedForkJoinTask(runnable: Runnable) extends ForkJoinTask[Unit] {
final override def setRawResult(u: Unit): Unit = ()
final override def getRawResult(): Unit = ()
final override def exec(): Boolean = try { runnable.run(); true } catch {
@@ -114,18 +128,7 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
throw anything
}
}
- }
- Thread.currentThread match {
- case fjw: ForkJoinWorkerThread if fjw.getPool eq fj => fjt.fork()
- case _ => fj execute fjt
- }
- case generic => generic execute runnable
- }
-
- def reportFailure(t: Throwable) = reporter(t)
-}
-private[concurrent] object ExecutionContextImpl {
def fromExecutor(e: Executor, reporter: Throwable => Unit = ExecutionContext.defaultReporter): ExecutionContextImpl = new ExecutionContextImpl(e, reporter)
def fromExecutorService(es: ExecutorService, reporter: Throwable => Unit = ExecutionContext.defaultReporter): ExecutionContextImpl with ExecutionContextExecutorService =
new ExecutionContextImpl(es, reporter) with ExecutionContextExecutorService {
diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala
index 89d10e5c47..042d32c234 100644
--- a/src/library/scala/concurrent/impl/Future.scala
+++ b/src/library/scala/concurrent/impl/Future.scala
@@ -12,7 +12,7 @@ package scala.concurrent.impl
import scala.concurrent.ExecutionContext
import scala.util.control.NonFatal
-import scala.util.{Try, Success, Failure}
+import scala.util.{ Success, Failure }
private[concurrent] object Future {
diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala
index 52f1075137..7af70400ef 100644
--- a/src/library/scala/concurrent/impl/Promise.scala
+++ b/src/library/scala/concurrent/impl/Promise.scala
@@ -83,7 +83,7 @@ private[concurrent] object Promise {
import Duration.Undefined
atMost match {
case u if u eq Undefined => throw new IllegalArgumentException("cannot wait for Undefined period")
- case Duration.Inf => awaitUnbounded
+ case Duration.Inf => awaitUnbounded()
case Duration.MinusInf => isCompleted
case f: FiniteDuration => if (f > Duration.Zero) awaitUnsafe(f.fromNow, f) else isCompleted
}
@@ -135,7 +135,7 @@ private[concurrent] object Promise {
}
def onComplete[U](func: Try[T] => U)(implicit executor: ExecutionContext): Unit = {
- val preparedEC = executor.prepare
+ val preparedEC = executor.prepare()
val runnable = new CallbackRunnable[T](preparedEC, func)
@tailrec //Tries to add the callback, if already completed, it dispatches the callback to be executed
@@ -162,7 +162,7 @@ private[concurrent] object Promise {
def onComplete[U](func: Try[T] => U)(implicit executor: ExecutionContext): Unit = {
val completedAs = value.get
- val preparedEC = executor.prepare
+ val preparedEC = executor.prepare()
(new CallbackRunnable(preparedEC, func)).executeWithValue(completedAs)
}
diff --git a/src/library/scala/concurrent/ops.scala b/src/library/scala/concurrent/ops.scala
deleted file mode 100644
index 4c91e78dc7..0000000000
--- a/src/library/scala/concurrent/ops.scala
+++ /dev/null
@@ -1,73 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.concurrent
-
-import java.lang.Thread
-import scala.util.control.Exception.allCatch
-
-/** The object `ops` ...
- *
- * @author Martin Odersky, Stepan Koltsov, Philipp Haller
- */
-@deprecated("Use `Future` instead.", "2.10.0")
-object ops
-{
- val defaultRunner: FutureTaskRunner = TaskRunners.threadRunner
-
- /**
- * If expression computed successfully return it in `Right`,
- * otherwise return exception in `Left`.
- */
- private def tryCatch[A](body: => A): Either[Throwable, A] =
- allCatch[A] either body
-
- private def getOrThrow[T <: Throwable, A](x: Either[T, A]): A =
- x.fold[A](throw _, identity _)
-
- /** Evaluates an expression asynchronously.
- *
- * @param p the expression to evaluate
- */
- def spawn(p: => Unit)(implicit runner: TaskRunner = defaultRunner): Unit = {
- runner execute runner.functionAsTask(() => p)
- }
-
- /** Evaluates an expression asynchronously, and returns a closure for
- * retrieving the result.
- *
- * @param p the expression to evaluate
- * @return a closure which returns the result once it has been computed
- */
- def future[A](p: => A)(implicit runner: FutureTaskRunner = defaultRunner): () => A = {
- runner.futureAsFunction(runner submit runner.functionAsTask(() => p))
- }
-
- /** Evaluates two expressions in parallel. Invoking `par` blocks the current
- * thread until both expressions have been evaluated.
- *
- * @param xp the first expression to evaluate
- * @param yp the second expression to evaluate
- *
- * @return a pair holding the evaluation results
- */
- def par[A, B](xp: => A, yp: => B)(implicit runner: TaskRunner = defaultRunner): (A, B) = {
- val y = new SyncVar[Either[Throwable, B]]
- spawn { y set tryCatch(yp) }
- (xp, getOrThrow(y.get))
- }
-
-/*
- def parMap[a,b](f: a => b, xs: Array[a]): Array[b] = {
- val results = new Array[b](xs.length);
- replicate(0, xs.length) { i => results(i) = f(xs(i)) }
- results
- }
-*/
-
-}
diff --git a/src/library/scala/deprecatedInheritance.scala b/src/library/scala/deprecatedInheritance.scala
index 70065560b1..7d20219d4d 100644
--- a/src/library/scala/deprecatedInheritance.scala
+++ b/src/library/scala/deprecatedInheritance.scala
@@ -11,7 +11,8 @@ package scala
/** An annotation that designates that inheriting from a class is deprecated.
*
* This is usually done to warn about a non-final class being made final in a future version.
- * Sub-classing such a class then generates a warning.
+ * Sub-classing such a class then generates a warning. No warnings are generated if the
+ * subclass is in the same compilation unit.
*
* @param message the message to print during compilation if the class was sub-classed
* @param since a string identifying the first version in which inheritance was deprecated
diff --git a/src/library/scala/io/AnsiColor.scala b/src/library/scala/io/AnsiColor.scala
new file mode 100644
index 0000000000..6b00eb283f
--- /dev/null
+++ b/src/library/scala/io/AnsiColor.scala
@@ -0,0 +1,53 @@
+package scala
+package io
+
+trait AnsiColor {
+ /** Foreground color for ANSI black */
+ final val BLACK = "\033[30m"
+ /** Foreground color for ANSI red */
+ final val RED = "\033[31m"
+ /** Foreground color for ANSI green */
+ final val GREEN = "\033[32m"
+ /** Foreground color for ANSI yellow */
+ final val YELLOW = "\033[33m"
+ /** Foreground color for ANSI blue */
+ final val BLUE = "\033[34m"
+ /** Foreground color for ANSI magenta */
+ final val MAGENTA = "\033[35m"
+ /** Foreground color for ANSI cyan */
+ final val CYAN = "\033[36m"
+ /** Foreground color for ANSI white */
+ final val WHITE = "\033[37m"
+
+ /** Background color for ANSI black */
+ final val BLACK_B = "\033[40m"
+ /** Background color for ANSI red */
+ final val RED_B = "\033[41m"
+ /** Background color for ANSI green */
+ final val GREEN_B = "\033[42m"
+ /** Background color for ANSI yellow */
+ final val YELLOW_B = "\033[43m"
+ /** Background color for ANSI blue */
+ final val BLUE_B = "\033[44m"
+ /** Background color for ANSI magenta */
+ final val MAGENTA_B = "\033[45m"
+ /** Background color for ANSI cyan */
+ final val CYAN_B = "\033[46m"
+ /** Background color for ANSI white */
+ final val WHITE_B = "\033[47m"
+
+ /** Reset ANSI styles */
+ final val RESET = "\033[0m"
+ /** ANSI bold */
+ final val BOLD = "\033[1m"
+ /** ANSI underlines */
+ final val UNDERLINED = "\033[4m"
+ /** ANSI blink */
+ final val BLINK = "\033[5m"
+ /** ANSI reversed */
+ final val REVERSED = "\033[7m"
+ /** ANSI invisible */
+ final val INVISIBLE = "\033[8m"
+}
+
+object AnsiColor extends AnsiColor { }
diff --git a/src/library/scala/io/BufferedSource.scala b/src/library/scala/io/BufferedSource.scala
index 767f06fd3f..e250da27c3 100644
--- a/src/library/scala/io/BufferedSource.scala
+++ b/src/library/scala/io/BufferedSource.scala
@@ -73,7 +73,7 @@ class BufferedSource(inputStream: InputStream, bufferSize: Int)(implicit val cod
if (nextLine == null) lineReader.readLine
else try nextLine finally nextLine = null
}
- if (result == null) Iterator.empty.next
+ if (result == null) Iterator.empty.next()
else result
}
}
diff --git a/src/library/scala/io/BytePickle.scala b/src/library/scala/io/BytePickle.scala
deleted file mode 100644
index 2c4a0bd2da..0000000000
--- a/src/library/scala/io/BytePickle.scala
+++ /dev/null
@@ -1,318 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.io
-
-import scala.collection.mutable
-
-/**
- * Pickler combinators.
- * Based on a Haskell library by Andrew Kennedy,
- * see <a href="http://research.microsoft.com/~akenn/fun/"
- * target="_top">http://research.microsoft.com/~akenn/fun/</a>.
- *
- * @author Philipp Haller
- * @version 1.1
- */
-@deprecated("This class will be removed.", "2.10.0")
-object BytePickle {
- abstract class SPU[T] {
- def appP(a: T, state: PicklerState): PicklerState
- def appU(state: UnPicklerState): (T, UnPicklerState)
- }
-
- def pickle[T](p: SPU[T], a: T): Array[Byte] =
- p.appP(a, new PicklerState(new Array[Byte](0), new PicklerEnv)).stream
-
- def unpickle[T](p: SPU[T], stream: Array[Byte]): T =
- p.appU(new UnPicklerState(stream, new UnPicklerEnv))._1
-
- abstract class PU[T] {
- def appP(a: T, state: Array[Byte]): Array[Byte]
- def appU(state: Array[Byte]): (T, Array[Byte])
- }
-
- def upickle[T](p: PU[T], a: T): Array[Byte] =
- p.appP(a, new Array[Byte](0))
-
- def uunpickle[T](p: PU[T], stream: Array[Byte]): T =
- p.appU(stream)._1
-
- class PicklerEnv extends mutable.HashMap[Any, Int] {
- private var cnt: Int = 64
- def nextLoc() = { cnt += 1; cnt }
- }
-
- class UnPicklerEnv extends mutable.HashMap[Int, Any] {
- private var cnt: Int = 64
- def nextLoc() = { cnt += 1; cnt }
- }
-
- class PicklerState(val stream: Array[Byte], val dict: PicklerEnv)
- class UnPicklerState(val stream: Array[Byte], val dict: UnPicklerEnv)
-
- abstract class RefDef
- case class Ref() extends RefDef
- case class Def() extends RefDef
-
- def refDef: PU[RefDef] = new PU[RefDef] {
- def appP(b: RefDef, s: Array[Byte]): Array[Byte] =
- b match {
- case Ref() => Array.concat(s, Array[Byte](0))
- case Def() => Array.concat(s, Array[Byte](1))
- };
- def appU(s: Array[Byte]): (RefDef, Array[Byte]) =
- if (s(0) == (0: Byte)) (Ref(), s.slice(1, s.length))
- else (Def(), s.slice(1, s.length));
- }
-
- val REF = 0
- val DEF = 1
-
- def unat: PU[Int] = new PU[Int] {
- def appP(n: Int, s: Array[Byte]): Array[Byte] =
- Array.concat(s, nat2Bytes(n));
- def appU(s: Array[Byte]): (Int, Array[Byte]) = {
- var num = 0
- def readNat: Int = {
- var b = 0;
- var x = 0;
- do {
- b = s(num)
- num += 1
- x = (x << 7) + (b & 0x7f);
- } while ((b & 0x80) != 0);
- x
- }
- (readNat, s.slice(num, s.length))
- }
- }
-
- def share[a](pa: SPU[a]): SPU[a] = new SPU[a] {
- def appP(v: a, state: PicklerState): PicklerState = {
- /*
- - is there some value equal to v associated with a location l in the pickle environment?
- - yes: write REF-tag to outstream together with l
- - no:
- write DEF-tag to outstream
- record current location l of outstream
- --> serialize value
- add entry to pickle environment, mapping v onto l
- */
- val pe = state.dict
- pe.get(v) match {
- case None =>
- val sPrime = refDef.appP(Def(), state.stream)
- val l = pe.nextLoc()
-
- val sPrimePrime = pa.appP(v, new PicklerState(sPrime, pe))
-
- pe.update(v, l)
-
- return sPrimePrime
- case Some(l) =>
- val sPrime = refDef.appP(Ref(), state.stream)
-
- return new PicklerState(unat.appP(l, sPrime), pe)
- }
- }
- def appU(state: UnPicklerState): (a, UnPicklerState) = {
- /*
- - first, read tag (i.e. DEF or REF)
- - if REF:
- read location l
- look up resulting value in unpickler environment
- - if DEF:
- record location l of input stream
- --> deserialize value v with argument deserializer
- add entry to unpickler environment, mapping l onto v
- */
- val upe = state.dict
- val res = refDef.appU(state.stream)
- res._1 match {
- case Def() =>
- val l = upe.nextLoc
- val res2 = pa.appU(new UnPicklerState(res._2, upe))
- upe.update(l, res2._1)
- return res2
- case Ref() =>
- val res2 = unat.appU(res._2) // read location
- upe.get(res2._1) match { // lookup value in unpickler env
- case None => throw new IllegalArgumentException("invalid unpickler environment")
- case Some(v) => return (v.asInstanceOf[a], new UnPicklerState(res2._2, upe))
- }
- }
- }
- }
-
- def ulift[t](x: t): PU[t] = new PU[t] {
- def appP(a: t, state: Array[Byte]): Array[Byte] =
- if (x != a) throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x)
- else state;
- def appU(state: Array[Byte]) = (x, state)
- }
-
- def lift[t](x: t): SPU[t] = new SPU[t] {
- def appP(a: t, state: PicklerState): PicklerState =
- if (x != a) { /*throw new IllegalArgumentException("value to be pickled (" + a + ") != " + x);*/ state }
- else state;
- def appU(state: UnPicklerState) = (x, state)
- }
-
- def usequ[t,u](f: u => t, pa: PU[t], k: t => PU[u]): PU[u] = new PU[u] {
- def appP(b: u, s: Array[Byte]): Array[Byte] = {
- val a = f(b)
- val sPrime = pa.appP(a, s)
- val pb = k(a)
- val sPrimePrime = pb.appP(b, sPrime)
- sPrimePrime
- }
- def appU(s: Array[Byte]): (u, Array[Byte]) = {
- val resPa = pa.appU(s)
- val a = resPa._1
- val sPrime = resPa._2
- val pb = k(a)
- pb.appU(sPrime)
- }
- }
-
- def sequ[t,u](f: u => t, pa: SPU[t], k: t => SPU[u]): SPU[u] = new SPU[u] {
- def appP(b: u, s: PicklerState): PicklerState = {
- val a = f(b)
- val sPrime = pa.appP(a, s)
- val pb = k(a)
- pb.appP(b, sPrime)
- }
- def appU(s: UnPicklerState): (u, UnPicklerState) = {
- val resPa = pa.appU(s)
- val a = resPa._1
- val sPrime = resPa._2
- val pb = k(a)
- pb.appU(sPrime)
- }
- }
-
- def upair[a,b](pa: PU[a], pb: PU[b]): PU[(a,b)] = {
- def fst(p: (a,b)): a = p._1
- def snd(p: (a,b)): b = p._2
- usequ(fst, pa, (x: a) => usequ(snd, pb, (y: b) => ulift((x, y))))
- }
-
- def pair[a,b](pa: SPU[a], pb: SPU[b]): SPU[(a,b)] = {
- def fst(p: (a,b)): a = p._1
- def snd(p: (a,b)): b = p._2
- sequ(fst, pa, (x: a) => sequ(snd, pb, (y: b) => lift((x, y))))
- }
-
- def triple[a,b,c](pa: SPU[a], pb: SPU[b], pc: SPU[c]): SPU[(a,b,c)] = {
- def fst(p: (a,b,c)): a = p._1
- def snd(p: (a,b,c)): b = p._2
- def trd(p: (a,b,c)): c = p._3
-
- sequ(fst, pa,
- (x: a) => sequ(snd, pb,
- (y: b) => sequ(trd, pc,
- (z: c) => lift((x, y, z)))))
- }
-
- def uwrap[a,b](i: a => b, j: b => a, pa: PU[a]): PU[b] =
- usequ(j, pa, (x: a) => ulift(i(x)))
-
- def wrap[a,b](i: a => b, j: b => a, pa: SPU[a]): SPU[b] =
- sequ(j, pa, (x: a) => lift(i(x)))
-
- def appendByte(a: Array[Byte], b: Int): Array[Byte] =
- Array.concat(a, Array(b.toByte))
-
- def nat2Bytes(x: Int): Array[Byte] = {
- val buf = new mutable.ArrayBuffer[Byte]
- def writeNatPrefix(x: Int) {
- val y = x >>> 7;
- if (y != 0) writeNatPrefix(y);
- buf += ((x & 0x7f) | 0x80).asInstanceOf[Byte];
- }
- val y = x >>> 7;
- if (y != 0) writeNatPrefix(y);
- buf += (x & 0x7f).asInstanceOf[Byte];
- buf.toArray
- }
-
- def nat: SPU[Int] = new SPU[Int] {
- def appP(n: Int, s: PicklerState): PicklerState = {
- new PicklerState(Array.concat(s.stream, nat2Bytes(n)), s.dict);
- }
- def appU(s: UnPicklerState): (Int,UnPicklerState) = {
- var num = 0
- def readNat: Int = {
- var b = 0
- var x = 0
- do {
- b = s.stream(num)
- num += 1
- x = (x << 7) + (b & 0x7f);
- } while ((b & 0x80) != 0);
- x
- }
- (readNat, new UnPicklerState(s.stream.slice(num, s.stream.length), s.dict))
- }
- }
-
- def byte: SPU[Byte] = new SPU[Byte] {
- def appP(b: Byte, s: PicklerState): PicklerState =
- new PicklerState(Array.concat(s.stream, Array(b)), s.dict)
- def appU(s: UnPicklerState): (Byte, UnPicklerState) =
- (s.stream(0), new UnPicklerState(s.stream.slice(1, s.stream.length), s.dict));
- }
-
- def string: SPU[String] = share(wrap(
- (a: Array[Byte]) => (Codec fromUTF8 a).mkString,
- (s: String) => Codec toUTF8 s,
- bytearray
- ))
-
- def bytearray: SPU[Array[Byte]] = {
- wrap((l:List[Byte]) => l.toArray, (_.toList), list(byte))
- }
-
- def bool: SPU[Boolean] = {
- def toEnum(b: Boolean) = if (b) 1 else 0
- def fromEnum(n: Int) = if (n == 0) false else true
- wrap(fromEnum, toEnum, nat)
- }
-
- def ufixedList[A](pa: PU[A])(n: Int): PU[List[A]] = {
- def pairToList(p: (A, List[A])): List[A] =
- p._1 :: p._2;
- def listToPair(l: List[A]): (A, List[A]) =
- (l: @unchecked) match { case x :: xs => (x, xs) }
-
- if (n == 0) ulift(Nil)
- else
- uwrap(pairToList, listToPair, upair(pa, ufixedList(pa)(n-1)))
- }
-
- def fixedList[a](pa: SPU[a])(n: Int): SPU[List[a]] = {
- def pairToList(p: (a,List[a])): List[a] =
- p._1 :: p._2;
- def listToPair(l: List[a]): (a,List[a]) =
- (l: @unchecked) match { case x :: xs => (x, xs) }
-
- if (n == 0) lift(Nil)
- else
- wrap(pairToList, listToPair, pair(pa, fixedList(pa)(n-1)))
- }
-
- def list[a](pa: SPU[a]): SPU[List[a]] =
- sequ((l: List[a])=>l.length, nat, fixedList(pa));
-
- def ulist[a](pa: PU[a]): PU[List[a]] =
- usequ((l:List[a]) => l.length, unat, ufixedList(pa));
-
- def data[a](tag: a => Int, ps: List[()=>SPU[a]]): SPU[a] =
- sequ(tag, nat, (x: Int)=> ps.apply(x)());
-}
diff --git a/src/library/scala/io/Codec.scala b/src/library/scala/io/Codec.scala
index 5d046e48b0..60f99199cb 100644
--- a/src/library/scala/io/Codec.scala
+++ b/src/library/scala/io/Codec.scala
@@ -6,8 +6,8 @@
** |/ **
\* */
-
-package scala.io
+package scala
+package io
import java.nio.charset.{ Charset, CharsetDecoder, CharsetEncoder, CharacterCodingException, CodingErrorAction => Action }
import scala.annotation.migration
@@ -43,42 +43,37 @@ class Codec(val charSet: Charset) {
override def toString = name
// these methods can be chained to configure the variables above
- def onMalformedInput(newAction: Action): this.type = { _onMalformedInput = newAction ; this }
- def onUnmappableCharacter(newAction: Action): this.type = { _onUnmappableCharacter = newAction ; this }
- def decodingReplaceWith(newReplacement: String): this.type = { _decodingReplacement = newReplacement ; this }
+ def onMalformedInput(newAction: Action): this.type = { _onMalformedInput = newAction ; this }
+ def onUnmappableCharacter(newAction: Action): this.type = { _onUnmappableCharacter = newAction ; this }
+ def decodingReplaceWith(newReplacement: String): this.type = { _decodingReplacement = newReplacement ; this }
def encodingReplaceWith(newReplacement: Array[Byte]): this.type = { _encodingReplacement = newReplacement ; this }
- def onCodingException(handler: Handler): this.type = { _onCodingException = handler ; this }
+ def onCodingException(handler: Handler): this.type = { _onCodingException = handler ; this }
def name = charSet.name
- def encoder =
- applyFunctions[CharsetEncoder](charSet.newEncoder(),
- (_ onMalformedInput _onMalformedInput, _onMalformedInput != null),
- (_ onUnmappableCharacter _onUnmappableCharacter, _onUnmappableCharacter != null),
- (_ replaceWith _encodingReplacement, _encodingReplacement != null)
- )
-
- def decoder =
- applyFunctions[CharsetDecoder](charSet.newDecoder(),
- (_ onMalformedInput _onMalformedInput, _onMalformedInput != null),
- (_ onUnmappableCharacter _onUnmappableCharacter, _onUnmappableCharacter != null),
- (_ replaceWith _decodingReplacement, _decodingReplacement != null)
- )
+ def encoder: CharsetEncoder = {
+ val enc = charSet.newEncoder()
+ if (_onMalformedInput ne null) enc onMalformedInput _onMalformedInput
+ if (_onUnmappableCharacter ne null) enc onUnmappableCharacter _onUnmappableCharacter
+ if (_encodingReplacement ne null) enc replaceWith _encodingReplacement
+ enc
+ }
+ def decoder: CharsetDecoder = {
+ val dec = charSet.newDecoder()
+ if (_onMalformedInput ne null) dec onMalformedInput _onMalformedInput
+ if (_onUnmappableCharacter ne null) dec onUnmappableCharacter _onUnmappableCharacter
+ if (_decodingReplacement ne null) dec replaceWith _decodingReplacement
+ dec
+ }
def wrap(body: => Int): Int =
try body catch { case e: CharacterCodingException => _onCodingException(e) }
-
- // call a series of side effecting methods on an object, finally returning the object
- private def applyFunctions[T](x: T, fs: Configure[T]*) =
- fs.foldLeft(x)((x, pair) => pair match {
- case (f, cond) => if (cond) f(x) else x
- })
}
trait LowPriorityCodecImplicits {
self: Codec.type =>
/** The Codec of Last Resort. */
- implicit def fallbackSystemCodec: Codec = defaultCharsetCodec
+ implicit lazy val fallbackSystemCodec: Codec = defaultCharsetCodec
}
object Codec extends LowPriorityCodecImplicits {
@@ -90,9 +85,9 @@ object Codec extends LowPriorityCodecImplicits {
* the fact that you can influence anything at all via -Dfile.encoding
* as an accident, with any anomalies considered "not a bug".
*/
- def defaultCharsetCodec = apply(Charset.defaultCharset)
- def fileEncodingCodec = apply(scala.util.Properties.encodingString)
- def default = defaultCharsetCodec
+ def defaultCharsetCodec = apply(Charset.defaultCharset)
+ def fileEncodingCodec = apply(scala.util.Properties.encodingString)
+ def default = defaultCharsetCodec
def apply(encoding: String): Codec = new Codec(Charset forName encoding)
def apply(charSet: Charset): Codec = new Codec(charSet)
@@ -130,7 +125,7 @@ object Codec extends LowPriorityCodecImplicits {
bytes
}
- implicit def string2codec(s: String) = apply(s)
- implicit def charset2codec(c: Charset) = apply(c)
- implicit def decoder2codec(cd: CharsetDecoder) = apply(cd)
+ implicit def string2codec(s: String): Codec = apply(s)
+ implicit def charset2codec(c: Charset): Codec = apply(c)
+ implicit def decoder2codec(cd: CharsetDecoder): Codec = apply(cd)
}
diff --git a/src/library/scala/io/Position.scala b/src/library/scala/io/Position.scala
index daa4e103be..85149223ee 100644
--- a/src/library/scala/io/Position.scala
+++ b/src/library/scala/io/Position.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.io
+package scala
+package io
/** The object Position provides convenience methods to encode
* line and column number in one single integer. The encoded line
@@ -68,14 +69,6 @@ abstract class Position {
}
object Position extends Position {
- /** The undefined position */
- @deprecated("This will be removed", "2.9.0")
- final val NOPOS = 0
-
- /** The first position in a source file */
- @deprecated("This will be removed", "2.9.0")
- final val FIRSTPOS = encode(1, 1)
-
def checkInput(line: Int, column: Int) {
if (line < 0)
throw new IllegalArgumentException(line + " < 0")
diff --git a/src/library/scala/io/ReadStdin.scala b/src/library/scala/io/ReadStdin.scala
new file mode 100644
index 0000000000..e82c26ef7a
--- /dev/null
+++ b/src/library/scala/io/ReadStdin.scala
@@ -0,0 +1,228 @@
+package scala
+package io
+
+import java.text.MessageFormat
+
+/** private[scala] because this is not functionality we should be providing
+ * in the standard library, at least not in this idiosyncractic form.
+ * Factored into trait because it is better code structure regardless.
+ */
+private[scala] trait ReadStdin {
+ import scala.Console._
+
+ /** Read a full line from the default input. Returns `null` if the end of the
+ * input stream has been reached.
+ *
+ * @return the string read from the terminal or null if the end of stream was reached.
+ */
+ def readLine(): String = in.readLine()
+
+ /** Print formatted text to the default output and read a full line from the default input.
+ * Returns `null` if the end of the input stream has been reached.
+ *
+ * @param text the format of the text to print out, as in `printf`.
+ * @param args the parameters used to instantiate the format, as in `printf`.
+ * @return the string read from the default input
+ */
+ def readLine(text: String, args: Any*): String = {
+ printf(text, args: _*)
+ readLine()
+ }
+
+ /** Reads a boolean value from an entire line of the default input.
+ * Has a fairly liberal interpretation of the input.
+ *
+ * @return the boolean value read, or false if it couldn't be converted to a boolean
+ * @throws java.io.EOFException if the end of the input stream has been reached.
+ */
+ def readBoolean(): Boolean = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toLowerCase() match {
+ case "true" => true
+ case "t" => true
+ case "yes" => true
+ case "y" => true
+ case _ => false
+ }
+ }
+
+ /** Reads a byte value from an entire line of the default input.
+ *
+ * @return the Byte that was read
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.NumberFormatException if the value couldn't be converted to a Byte
+ */
+ def readByte(): Byte = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toByte
+ }
+
+ /** Reads a short value from an entire line of the default input.
+ *
+ * @return the short that was read
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.NumberFormatException if the value couldn't be converted to a Short
+ */
+ def readShort(): Short = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toShort
+ }
+
+ /** Reads a char value from an entire line of the default input.
+ *
+ * @return the Char that was read
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.StringIndexOutOfBoundsException if the line read from default input was empty
+ */
+ def readChar(): Char = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s charAt 0
+ }
+
+ /** Reads an int value from an entire line of the default input.
+ *
+ * @return the Int that was read
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.NumberFormatException if the value couldn't be converted to an Int
+ */
+ def readInt(): Int = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toInt
+ }
+
+ /** Reads an long value from an entire line of the default input.
+ *
+ * @return the Long that was read
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.NumberFormatException if the value couldn't be converted to a Long
+ */
+ def readLong(): Long = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toLong
+ }
+
+ /** Reads a float value from an entire line of the default input.
+ * @return the Float that was read.
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float
+ *
+ */
+ def readFloat(): Float = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toFloat
+ }
+
+ /** Reads a double value from an entire line of the default input.
+ *
+ * @return the Double that was read.
+ * @throws java.io.EOFException if the end of the
+ * input stream has been reached.
+ * @throws java.lang.NumberFormatException if the value couldn't be converted to a Float
+ */
+ def readDouble(): Double = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ s.toDouble
+ }
+
+ /** Reads in some structured input (from the default input), specified by
+ * a format specifier. See class `java.text.MessageFormat` for details of
+ * the format specification.
+ *
+ * @param format the format of the input.
+ * @return a list of all extracted values.
+ * @throws java.io.EOFException if the end of the input stream has been
+ * reached.
+ */
+ def readf(format: String): List[Any] = {
+ val s = readLine()
+ if (s == null)
+ throw new java.io.EOFException("Console has reached end of input")
+ else
+ textComponents(new MessageFormat(format).parse(s))
+ }
+
+ /** Reads in some structured input (from the default input), specified by
+ * a format specifier, returning only the first value extracted, according
+ * to the format specification.
+ *
+ * @param format format string, as accepted by `readf`.
+ * @return The first value that was extracted from the input
+ */
+ def readf1(format: String): Any = readf(format).head
+
+ /** Reads in some structured input (from the default input), specified
+ * by a format specifier, returning only the first two values extracted,
+ * according to the format specification.
+ *
+ * @param format format string, as accepted by `readf`.
+ * @return A [[scala.Tuple2]] containing the first two values extracted
+ */
+ def readf2(format: String): (Any, Any) = {
+ val res = readf(format)
+ (res.head, res.tail.head)
+ }
+
+ /** Reads in some structured input (from the default input), specified
+ * by a format specifier, returning only the first three values extracted,
+ * according to the format specification.
+ *
+ * @param format format string, as accepted by `readf`.
+ * @return A [[scala.Tuple3]] containing the first three values extracted
+ */
+ def readf3(format: String): (Any, Any, Any) = {
+ val res = readf(format)
+ (res.head, res.tail.head, res.tail.tail.head)
+ }
+
+ private def textComponents(a: Array[AnyRef]): List[Any] = {
+ var i: Int = a.length - 1
+ var res: List[Any] = Nil
+ while (i >= 0) {
+ res = (a(i) match {
+ case x: java.lang.Boolean => x.booleanValue()
+ case x: java.lang.Byte => x.byteValue()
+ case x: java.lang.Short => x.shortValue()
+ case x: java.lang.Character => x.charValue()
+ case x: java.lang.Integer => x.intValue()
+ case x: java.lang.Long => x.longValue()
+ case x: java.lang.Float => x.floatValue()
+ case x: java.lang.Double => x.doubleValue()
+ case x => x
+ }) :: res
+ i -= 1
+ }
+ res
+ }
+}
+
+object ReadStdin extends ReadStdin { }
diff --git a/src/library/scala/io/Source.scala b/src/library/scala/io/Source.scala
index b13729aefe..74c3e06839 100644
--- a/src/library/scala/io/Source.scala
+++ b/src/library/scala/io/Source.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.io
+package scala
+package io
import scala.collection.AbstractIterator
import java.io.{ FileInputStream, InputStream, PrintStream, File => JFile }
@@ -194,11 +195,11 @@ abstract class Source extends Iterator[Char] {
lazy val iter: BufferedIterator[Char] = Source.this.iter.buffered
def isNewline(ch: Char) = ch == '\r' || ch == '\n'
def getc() = iter.hasNext && {
- val ch = iter.next
+ val ch = iter.next()
if (ch == '\n') false
else if (ch == '\r') {
if (iter.hasNext && iter.head == '\n')
- iter.next
+ iter.next()
false
}
@@ -209,7 +210,7 @@ abstract class Source extends Iterator[Char] {
}
def hasNext = iter.hasNext
def next = {
- sb.clear
+ sb.clear()
while (getc()) { }
sb.toString
}
@@ -227,7 +228,7 @@ abstract class Source extends Iterator[Char] {
/** Returns next character.
*/
- def next(): Char = positioner.next
+ def next(): Char = positioner.next()
class Positioner(encoder: Position) {
def this() = this(RelaxedPosition)
@@ -245,7 +246,7 @@ abstract class Source extends Iterator[Char] {
var tabinc = 4
def next(): Char = {
- ch = iter.next
+ ch = iter.next()
pos = encoder.encode(cline, ccol)
ch match {
case '\n' =>
@@ -267,7 +268,7 @@ abstract class Source extends Iterator[Char] {
}
object RelaxedPositioner extends Positioner(RelaxedPosition) { }
object NoPositioner extends Positioner(Position) {
- override def next(): Char = iter.next
+ override def next(): Char = iter.next()
}
def ch = positioner.ch
def pos = positioner.pos
diff --git a/src/library/scala/io/UTF8Codec.scala b/src/library/scala/io/UTF8Codec.scala
deleted file mode 100644
index e4c2145153..0000000000
--- a/src/library/scala/io/UTF8Codec.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-package scala.io
-
-/**
- * @author Martin Odersky
- * @version 1.0, 04/10/2004
- */
-@deprecated("This class will be removed.", "2.10.0")
-object UTF8Codec {
- final val UNI_REPLACEMENT_CHAR: Int = 0x0000FFFD
- final val UNI_REPLACEMENT_BYTES = Array[Byte](-17, -65, -67)
-
- // Note, from http://unicode.org/faq/utf_bom.html#utf8-5
- //
- // A different issue arises if an unpaired surrogate is encountered when converting
- // ill-formed UTF-16 data. By represented such an unpaired surrogate on its own as a
- // 3-byte sequence, the resulting UTF-8 data stream would become ill-formed.
- // While it faithfully reflects the nature of the input, Unicode conformance
- // requires that encoding form conversion always results in valid data stream.
- // Therefore a converter must treat this as an error.
- //
- // Some useful locations:
- // http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt
-}
diff --git a/src/library/scala/math/BigDecimal.scala b/src/library/scala/math/BigDecimal.scala
index 7c14ed3a9e..f75cfad882 100644
--- a/src/library/scala/math/BigDecimal.scala
+++ b/src/library/scala/math/BigDecimal.scala
@@ -7,7 +7,8 @@
\* */
-package scala.math
+package scala
+package math
import java.{ lang => jl }
import java.math.{ MathContext, BigDecimal => BigDec }
@@ -25,12 +26,6 @@ object BigDecimal {
private val maxCached = 512
val defaultMathContext = MathContext.DECIMAL128
- @deprecated("Use Long.MinValue", "2.9.0")
- val MinLong = new BigDecimal(BigDec valueOf Long.MinValue, defaultMathContext)
-
- @deprecated("Use Long.MaxValue", "2.9.0")
- val MaxLong = new BigDecimal(BigDec valueOf Long.MaxValue, defaultMathContext)
-
/** Cache ony for defaultMathContext using BigDecimals in a small range. */
private lazy val cache = new Array[BigDecimal](maxCached - minCached + 1)
@@ -177,7 +172,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable {
* with unequal hashCodes.
*/
override def hashCode(): Int =
- if (isWhole) unifiedPrimitiveHashcode
+ if (isWhole()) unifiedPrimitiveHashcode()
else doubleValue.##
/** Compares this BigDecimal with the specified value for equality.
@@ -339,21 +334,21 @@ extends ScalaNumber with ScalaNumericConversions with Serializable {
override def byteValue = intValue.toByte
/** Converts this BigDecimal to a Short.
- * If the BigDecimal is too big to fit in a Byte, only the low-order 16 bits are returned.
+ * If the BigDecimal is too big to fit in a Short, only the low-order 16 bits are returned.
* Note that this conversion can lose information about the overall magnitude of the
* BigDecimal value as well as return a result with the opposite sign.
*/
override def shortValue = intValue.toShort
/** Converts this BigDecimal to a Char.
- * If the BigDecimal is too big to fit in a char, only the low-order 16 bits are returned.
+ * If the BigDecimal is too big to fit in a Char, only the low-order 16 bits are returned.
* Note that this conversion can lose information about the overall magnitude of the
* BigDecimal value and that it always returns a positive result.
*/
def charValue = intValue.toChar
/** Converts this BigDecimal to an Int.
- * If the BigDecimal is too big to fit in a char, only the low-order 32 bits
+ * If the BigDecimal is too big to fit in an Int, only the low-order 32 bits
* are returned. Note that this conversion can lose information about the
* overall magnitude of the BigDecimal value as well as return a result with
* the opposite sign.
@@ -361,7 +356,7 @@ extends ScalaNumber with ScalaNumericConversions with Serializable {
def intValue = this.bigDecimal.intValue
/** Converts this BigDecimal to a Long.
- * If the BigDecimal is too big to fit in a char, only the low-order 64 bits
+ * If the BigDecimal is too big to fit in a Long, only the low-order 64 bits
* are returned. Note that this conversion can lose information about the
* overall magnitude of the BigDecimal value as well as return a result with
* the opposite sign.
diff --git a/src/library/scala/math/BigInt.scala b/src/library/scala/math/BigInt.scala
index fdba0ec716..4673aa5d48 100644
--- a/src/library/scala/math/BigInt.scala
+++ b/src/library/scala/math/BigInt.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.math
+package scala
+package math
import java.math.BigInteger
import scala.language.implicitConversions
@@ -23,12 +24,6 @@ object BigInt {
private val cache = new Array[BigInt](maxCached - minCached + 1)
private val minusOne = BigInteger.valueOf(-1)
- @deprecated("Use Long.MinValue", "2.9.0")
- val MinLong = BigInt(Long.MinValue)
-
- @deprecated("Use Long.MaxValue", "2.9.0")
- val MaxLong = BigInt(Long.MaxValue)
-
/** Constructs a `BigInt` whose value is equal to that of the
* specified integer value.
*
@@ -118,7 +113,7 @@ object BigInt {
class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericConversions with Serializable {
/** Returns the hash code for this BigInt. */
override def hashCode(): Int =
- if (isValidLong) unifiedPrimitiveHashcode
+ if (isValidLong) unifiedPrimitiveHashcode()
else bigInteger.##
/** Compares this BigInt with the specified value for equality.
@@ -295,9 +290,6 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo
*/
def signum: Int = this.bigInteger.signum()
- @deprecated("Use ~bigInt (the unary_~ method) instead", "2.10.0")
- def ~ : BigInt = ~this
-
/** Returns the bitwise complement of this BigInt
*/
def unary_~ : BigInt = new BigInt(this.bigInteger.not())
@@ -364,7 +356,7 @@ class BigInt(val bigInteger: BigInteger) extends ScalaNumber with ScalaNumericCo
def charValue = intValue.toChar
/** Converts this BigInt to an <tt>int</tt>.
- * If the BigInt is too big to fit in a int, only the low-order 32 bits
+ * If the BigInt is too big to fit in an int, only the low-order 32 bits
* are returned. Note that this conversion can lose information about the
* overall magnitude of the BigInt value as well as return a result with
* the opposite sign.
diff --git a/src/library/scala/math/Equiv.scala b/src/library/scala/math/Equiv.scala
index 5f5e049941..45b2b3629d 100644
--- a/src/library/scala/math/Equiv.scala
+++ b/src/library/scala/math/Equiv.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.math
+package scala
+package math
import java.util.Comparator
diff --git a/src/library/scala/math/Fractional.scala b/src/library/scala/math/Fractional.scala
index ca33675b0a..b7e0ed5471 100644
--- a/src/library/scala/math/Fractional.scala
+++ b/src/library/scala/math/Fractional.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.math
+package scala
+package math
import scala.language.implicitConversions
diff --git a/src/library/scala/math/Integral.scala b/src/library/scala/math/Integral.scala
index f3684c4e5d..ff1f695f6d 100644
--- a/src/library/scala/math/Integral.scala
+++ b/src/library/scala/math/Integral.scala
@@ -8,7 +8,8 @@
-package scala.math
+package scala
+package math
import scala.language.implicitConversions
diff --git a/src/library/scala/math/Numeric.scala b/src/library/scala/math/Numeric.scala
index 5a76f4f5f2..cb9f9deb70 100644
--- a/src/library/scala/math/Numeric.scala
+++ b/src/library/scala/math/Numeric.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.math
+package scala
+package math
import scala.language.implicitConversions
diff --git a/src/library/scala/math/Ordered.scala b/src/library/scala/math/Ordered.scala
index e8be92eb4a..51f2765a63 100644
--- a/src/library/scala/math/Ordered.scala
+++ b/src/library/scala/math/Ordered.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.math
+package scala
+package math
import scala.language.implicitConversions
diff --git a/src/library/scala/math/Ordering.scala b/src/library/scala/math/Ordering.scala
index 11b12050c9..d1a4e7c35c 100644
--- a/src/library/scala/math/Ordering.scala
+++ b/src/library/scala/math/Ordering.scala
@@ -26,14 +26,14 @@ import scala.language.{implicitConversions, higherKinds}
* val pairs = Array(("a", 5, 2), ("c", 3, 1), ("b", 1, 3))
*
* // sort by 2nd element
- * Sorting.quickSort(pairs)(Ordering.by[(String, Int, Int), Int](_._2))
+ * Sorting.quickSort(pairs)(Ordering.by[(String, Int, Int), Int](_._2)
*
* // sort by the 3rd element, then 1st
* Sorting.quickSort(pairs)(Ordering[(Int, String)].on(x => (x._3, x._1)))
* }}}
*
* An Ordering[T] is implemented by specifying compare(a:T, b:T), which
- * decides how to order to instances a and b. Instances of Ordering[T] can be
+ * decides how to order two instances a and b. Instances of Ordering[T] can be
* used by things like scala.util.Sorting to sort collections like Array[T].
*
* For example:
@@ -173,7 +173,7 @@ object Ordering extends LowPriorityOrderingImplicits {
val ye = y.iterator
while (xe.hasNext && ye.hasNext) {
- val res = ord.compare(xe.next, ye.next)
+ val res = ord.compare(xe.next(), ye.next())
if (res != 0) return res
}
@@ -347,7 +347,7 @@ object Ordering extends LowPriorityOrderingImplicits {
val ye = y.iterator
while (xe.hasNext && ye.hasNext) {
- val res = ord.compare(xe.next, ye.next)
+ val res = ord.compare(xe.next(), ye.next())
if (res != 0) return res
}
diff --git a/src/library/scala/math/PartialOrdering.scala b/src/library/scala/math/PartialOrdering.scala
index a9e317d536..9e35381528 100644
--- a/src/library/scala/math/PartialOrdering.scala
+++ b/src/library/scala/math/PartialOrdering.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.math
+package scala
+package math
/** A trait for representing partial orderings. It is important to
* distinguish between a type that has a partial order and a representation
diff --git a/src/library/scala/math/PartiallyOrdered.scala b/src/library/scala/math/PartiallyOrdered.scala
index 7823e5b396..f58210d6a7 100644
--- a/src/library/scala/math/PartiallyOrdered.scala
+++ b/src/library/scala/math/PartiallyOrdered.scala
@@ -8,7 +8,8 @@
-package scala.math
+package scala
+package math
/** A class for partially ordered data.
*
diff --git a/src/library/scala/math/ScalaNumber.java b/src/library/scala/math/ScalaNumber.java
index 7345147b0d..f03ba7bf08 100644
--- a/src/library/scala/math/ScalaNumber.java
+++ b/src/library/scala/math/ScalaNumber.java
@@ -6,8 +6,6 @@
** |/ **
\* */
-
-
package scala.math;
/** A marker class for Number types introduced by Scala
diff --git a/src/library/scala/math/ScalaNumericConversions.scala b/src/library/scala/math/ScalaNumericConversions.scala
index 6ddf48d03b..336991781e 100644
--- a/src/library/scala/math/ScalaNumericConversions.scala
+++ b/src/library/scala/math/ScalaNumericConversions.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-package scala.math
-
-import java.{ lang => jl }
+package scala
+package math
/** A slightly more specific conversion trait for classes which
* extend ScalaNumber (which excludes value classes.)
@@ -34,37 +33,37 @@ trait ScalaNumericAnyConversions extends Any {
/** Returns the value of this as a [[scala.Char]]. This may involve
* rounding or truncation.
*/
- def toChar = intValue.toChar
+ def toChar = intValue().toChar
/** Returns the value of this as a [[scala.Byte]]. This may involve
* rounding or truncation.
*/
- def toByte = byteValue
+ def toByte = byteValue()
/** Returns the value of this as a [[scala.Short]]. This may involve
* rounding or truncation.
*/
- def toShort = shortValue
+ def toShort = shortValue()
/** Returns the value of this as an [[scala.Int]]. This may involve
* rounding or truncation.
*/
- def toInt = intValue
+ def toInt = intValue()
/** Returns the value of this as a [[scala.Long]]. This may involve
* rounding or truncation.
*/
- def toLong = longValue
+ def toLong = longValue()
/** Returns the value of this as a [[scala.Float]]. This may involve
* rounding or truncation.
*/
- def toFloat = floatValue
+ def toFloat = floatValue()
/** Returns the value of this as a [[scala.Double]]. This may involve
* rounding or truncation.
*/
- def toDouble = doubleValue
+ def toDouble = doubleValue()
/** Returns `true` iff this has a zero fractional part, and is within the
* range of [[scala.Byte]] MinValue and MaxValue; otherwise returns `false`.
diff --git a/src/library/scala/package.scala b/src/library/scala/package.scala
index 84f6f0be9c..224112c11c 100644
--- a/src/library/scala/package.scala
+++ b/src/library/scala/package.scala
@@ -34,12 +34,6 @@ package object scala {
override def toString = "object AnyRef"
}
- @deprecated("instead of `@serializable class C`, use `class C extends Serializable`", "2.9.0")
- type serializable = annotation.serializable
-
- @deprecated("instead of `@cloneable class C`, use `class C extends Cloneable`", "2.10.0")
- type cloneable = annotation.cloneable
-
type TraversableOnce[+A] = scala.collection.TraversableOnce[A]
type Traversable[+A] = scala.collection.Traversable[A]
@@ -95,7 +89,10 @@ package object scala {
val Equiv = scala.math.Equiv
type Fractional[T] = scala.math.Fractional[T]
+ val Fractional = scala.math.Fractional
+
type Integral[T] = scala.math.Integral[T]
+ val Integral = scala.math.Integral
type Numeric[T] = scala.math.Numeric[T]
val Numeric = scala.math.Numeric
@@ -121,14 +118,12 @@ package object scala {
// Annotations which we might move to annotation.*
/*
type SerialVersionUID = annotation.SerialVersionUID
- type cloneable = annotation.cloneable
type deprecated = annotation.deprecated
type deprecatedName = annotation.deprecatedName
type inline = annotation.inline
type native = annotation.native
- type noinline = noannotation.inline
+ type noinline = annotation.noinline
type remote = annotation.remote
- type serializable = annotation.serializable
type specialized = annotation.specialized
type transient = annotation.transient
type throws = annotation.throws
diff --git a/src/library/scala/parallel/Future.scala b/src/library/scala/parallel/Future.scala
deleted file mode 100644
index e255a5772b..0000000000
--- a/src/library/scala/parallel/Future.scala
+++ /dev/null
@@ -1,39 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2005-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.parallel
-
-
-
-/** A future is a function without parameters that will block the caller if
- * the parallel computation associated with the function is not completed.
- *
- * @tparam R the type of the result
- *
- * @since 2.9
- */
-@deprecated("Use `scala.concurrent.Future` instead.", "2.10.0")
-trait Future[@specialized +R] extends (() => R) {
- /** Returns a result once the parallel computation completes. If the
- * computation produced an exception, an exception is forwarded.
- *
- * '''Note:''' creating a circular dependency between futures by calling
- * this method will result in a deadlock.
- *
- * @return the result
- * @throws the exception that was thrown during a parallel computation
- */
- def apply(): R
-
- /** Returns `true` if the parallel computation is completed.
- *
- * @return `true` if the parallel computation is completed, `false` otherwise
- */
- def isDone(): Boolean
-}
-
diff --git a/src/library/scala/parallel/package.scala.disabled b/src/library/scala/parallel/package.scala.disabled
deleted file mode 100644
index 45f5470d03..0000000000
--- a/src/library/scala/parallel/package.scala.disabled
+++ /dev/null
@@ -1,178 +0,0 @@
-package scala
-
-
-
-import scala.concurrent.forkjoin._
-
-
-/** This package object contains various parallel operations.
- *
- * @define invokingPar
- * Invoking a parallel computation creates a future which will
- * hold the result of the computation once it completes. Querying
- * the result of a future before its parallel computation has completed
- * will block the caller. For all practical concerns, the dependency
- * chain obtained by querying results of unfinished futures can have
- * arbitrary lengths. However, care must be taken not to create a
- * circular dependency, as this will result in a deadlock.
- *
- * Additionally, if the parallel computation performs a blocking call
- * (e.g. an I/O operation or waiting for a lock) other than waiting for a future,
- * it should do so by invoking the `block` method. This is another
- * form of waiting that could potentially create a circular dependency,
- * an the user should take care not to do this.
- *
- * Users should be aware that invoking a parallel computation has a
- * certain overhead. Parallel computations should not be invoked for
- * small computations, as this can lead to bad performance. A rule of the
- * thumb is having parallel computations equivalent to a loop
- * with 50000 arithmetic operations (at least). If a parallel computation
- * is invoked within another parallel computation, then it should be
- * computationally equivalent to a loop with 10000 arithmetic operations.
- */
-package object parallel {
-
- private[scala] val forkjoinpool = new ForkJoinPool()
-
- private class Task[T](body: =>T) extends RecursiveTask[T] with Future[T] {
- def compute = body
- def apply() = join()
- }
-
- private final def newTask[T](body: =>T) = new Task[T](body)
-
- private final def executeTask[T](task: RecursiveTask[T]) {
- if (Thread.currentThread().isInstanceOf[ForkJoinWorkerThread]) task.fork
- else forkjoinpool.execute(task)
- }
-
- /* public methods */
-
- /** Performs a call which can potentially block execution.
- *
- * Example:
- * {{{
- * val lock = new ReentrantLock
- *
- * // ... do something ...
- *
- * blocking {
- * if (!lock.hasLock) lock.lock()
- * }
- * }}}
- *
- * '''Note:''' calling methods that wait arbitrary amounts of time
- * (e.g. for I/O operations or locks) may severely decrease performance
- * or even result in deadlocks. This does not include waiting for
- * results of futures.
- */
- def blocking[T](body: =>T): T = {
- if (Thread.currentThread().isInstanceOf[ForkJoinWorkerThread]) {
- val blocker = new ForkJoinPool.ManagedBlocker {
- @volatile var done = false
- @volatile var result: Any = _
- def block() = {
- result = body
- done = true
- true
- }
- def isReleasable() = done
- }
- ForkJoinPool.managedBlock(blocker, true)
- blocker.result.asInstanceOf[T]
- } else body
- }
-
- /** Starts a parallel computation and returns a future.
- *
- * $invokingPar
- *
- * @tparam T the type of the result of the parallel computation
- * @param body the computation to be invoked in parallel
- * @return a future with the result
- */
- def par[T](body: =>T): Future[T] = {
- val task = newTask(body)
- executeTask(task)
- task
- }
-
- /** Starts 2 parallel computations and returns a future.
- *
- * $invokingPar
- *
- * @tparam T1 the type of the result of 1st the parallel computation
- * @tparam T2 the type of the result of 2nd the parallel computation
- * @param b1 the 1st computation to be invoked in parallel
- * @param b2 the 2nd computation to be invoked in parallel
- * @return a tuple of futures corresponding to parallel computations
- */
- def par[T1, T2](b1: =>T1, b2: =>T2): (Future[T1], Future[T2]) = {
- val t1 = newTask(b1)
- executeTask(t1)
- val t2 = newTask(b2)
- executeTask(t2)
- (t1, t2)
- }
-
- /** Starts 3 parallel computations and returns a future.
- *
- * $invokingPar
- *
- * @tparam T1 the type of the result of 1st the parallel computation
- * @tparam T2 the type of the result of 2nd the parallel computation
- * @tparam T3 the type of the result of 3rd the parallel computation
- * @param b1 the 1st computation to be invoked in parallel
- * @param b2 the 2nd computation to be invoked in parallel
- * @param b3 the 3rd computation to be invoked in parallel
- * @return a tuple of futures corresponding to parallel computations
- */
- def par[T1, T2, T3](b1: =>T1, b2: =>T2, b3: =>T3): (Future[T1], Future[T2], Future[T3]) = {
- val t1 = newTask(b1)
- executeTask(t1)
- val t2 = newTask(b2)
- executeTask(t2)
- val t3 = newTask(b3)
- executeTask(t3)
- (t1, t2, t3)
- }
-
- /** Starts 4 parallel computations and returns a future.
- *
- * $invokingPar
- *
- * @tparam T1 the type of the result of 1st the parallel computation
- * @tparam T2 the type of the result of 2nd the parallel computation
- * @tparam T3 the type of the result of 3rd the parallel computation
- * @tparam T4 the type of the result of 4th the parallel computation
- * @param b1 the 1st computation to be invoked in parallel
- * @param b2 the 2nd computation to be invoked in parallel
- * @param b3 the 3rd computation to be invoked in parallel
- * @param b4 the 4th computation to be invoked in parallel
- * @return a tuple of futures corresponding to parallel computations
- */
- def par[T1, T2, T3, T4](b1: =>T1, b2: =>T2, b3: =>T3, b4: =>T4): (Future[T1], Future[T2], Future[T3], Future[T4]) = {
- val t1 = newTask(b1)
- executeTask(t1)
- val t2 = newTask(b2)
- executeTask(t2)
- val t3 = newTask(b3)
- executeTask(t3)
- val t4 = newTask(b4)
- executeTask(t4)
- (t1, t2, t3, t4)
- }
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/library/scala/ref/SoftReference.scala b/src/library/scala/ref/SoftReference.scala
index b414db6e97..e4ce667981 100644
--- a/src/library/scala/ref/SoftReference.scala
+++ b/src/library/scala/ref/SoftReference.scala
@@ -13,7 +13,8 @@ package scala.ref
* @author Sean McDirmid
*/
class SoftReference[+T <: AnyRef](value : T, queue : ReferenceQueue[T]) extends ReferenceWrapper[T] {
- def this(value : T) = this(value, null);
+ def this(value : T) = this(value, null)
+
val underlying: java.lang.ref.SoftReference[_ <: T] =
new SoftReferenceWithWrapper[T](value, queue, this)
}
diff --git a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
index 0a3d818fb9..798746851a 100644
--- a/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
+++ b/src/library/scala/reflect/ClassManifestDeprecatedApis.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.reflect
+package scala
+package reflect
import scala.collection.mutable.{ WrappedArray, ArrayBuilder }
import java.lang.{ Class => jClass }
diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala
index f62d0ecd16..3bc76da295 100644
--- a/src/library/scala/reflect/Manifest.scala
+++ b/src/library/scala/reflect/Manifest.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.reflect
+package scala
+package reflect
import scala.collection.mutable.{ ArrayBuilder, WrappedArray }
diff --git a/src/library/scala/reflect/NameTransformer.scala b/src/library/scala/reflect/NameTransformer.scala
index 384ebc6134..6192971c74 100755
--- a/src/library/scala/reflect/NameTransformer.scala
+++ b/src/library/scala/reflect/NameTransformer.scala
@@ -15,9 +15,12 @@ package reflect
object NameTransformer {
// XXX Short term: providing a way to alter these without having to recompile
// the compiler before recompiling the compiler.
- val MODULE_SUFFIX_STRING = sys.props.getOrElse("SCALA_MODULE_SUFFIX_STRING", "$")
- val NAME_JOIN_STRING = sys.props.getOrElse("SCALA_NAME_JOIN_STRING", "$")
- val MODULE_INSTANCE_NAME = "MODULE$"
+ val MODULE_SUFFIX_STRING = sys.props.getOrElse("SCALA_MODULE_SUFFIX_STRING", "$")
+ val NAME_JOIN_STRING = sys.props.getOrElse("SCALA_NAME_JOIN_STRING", "$")
+ val MODULE_INSTANCE_NAME = "MODULE$"
+ val LOCAL_SUFFIX_STRING = " "
+ val SETTER_SUFFIX_STRING = "_$eq"
+ val TRAIT_SETTER_SEPARATOR_STRING = "$_setter_$"
private val nops = 128
private val ncodes = 26 * 26
@@ -93,8 +96,8 @@ object NameTransformer {
*/
def decode(name0: String): String = {
//System.out.println("decode: " + name);//DEBUG
- val name = if (name0.endsWith("<init>")) name0.substring(0, name0.length() - ("<init>").length()) + "this"
- else name0;
+ val name = if (name0.endsWith("<init>")) name0.stripSuffix("<init>") + "this"
+ else name0
var buf: StringBuilder = null
val len = name.length()
var i = 0
diff --git a/src/library/scala/reflect/NoManifest.scala b/src/library/scala/reflect/NoManifest.scala
index 61bc5e28d3..2ef946c80c 100644
--- a/src/library/scala/reflect/NoManifest.scala
+++ b/src/library/scala/reflect/NoManifest.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.reflect
+package scala
+package reflect
/** One of the branches of an [[scala.reflect.OptManifest]].
*/
diff --git a/src/library/scala/reflect/OptManifest.scala b/src/library/scala/reflect/OptManifest.scala
index 5e373c7318..b69f55483c 100644
--- a/src/library/scala/reflect/OptManifest.scala
+++ b/src/library/scala/reflect/OptManifest.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.reflect
+package scala
+package reflect
/** A `OptManifest[T]` is an optional [[scala.reflect.Manifest]].
*
diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala
index 10e6d7d9a4..97d7da3f2d 100644
--- a/src/library/scala/reflect/package.scala
+++ b/src/library/scala/reflect/package.scala
@@ -1,5 +1,7 @@
package scala
+import java.lang.reflect.{ AccessibleObject => jAccessibleObject }
+
package object reflect {
// in the new scheme of things ClassManifests are aliased to ClassTags
@@ -42,6 +44,18 @@ package object reflect {
def classTag[T](implicit ctag: ClassTag[T]) = ctag
+ /** Make a java reflection object accessible, if it is not already
+ * and it is possible to do so. If a SecurityException is thrown in the
+ * attempt, it is caught and discarded.
+ */
+ def ensureAccessible[T <: jAccessibleObject](m: T): T = {
+ if (!m.isAccessible) {
+ try m setAccessible true
+ catch { case _: SecurityException => } // does nothing
+ }
+ m
+ }
+
// anchor for the class tag materialization macro emitted during tag materialization in Implicits.scala
// implementation is hardwired into `scala.reflect.reify.Taggers`
// using the mechanism implemented in `scala.tools.reflect.FastTrack`
diff --git a/src/library/scala/runtime/AbstractFunction0.scala b/src/library/scala/runtime/AbstractFunction0.scala
index 1b351c62ae..1e677e8008 100644
--- a/src/library/scala/runtime/AbstractFunction0.scala
+++ b/src/library/scala/runtime/AbstractFunction0.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction1.scala b/src/library/scala/runtime/AbstractFunction1.scala
index a68a82e6a2..8d68017a6f 100644
--- a/src/library/scala/runtime/AbstractFunction1.scala
+++ b/src/library/scala/runtime/AbstractFunction1.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction10.scala b/src/library/scala/runtime/AbstractFunction10.scala
index 72c0a2e69d..776f52238d 100644
--- a/src/library/scala/runtime/AbstractFunction10.scala
+++ b/src/library/scala/runtime/AbstractFunction10.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction11.scala b/src/library/scala/runtime/AbstractFunction11.scala
index 031f3044a1..76cd8fbb3c 100644
--- a/src/library/scala/runtime/AbstractFunction11.scala
+++ b/src/library/scala/runtime/AbstractFunction11.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction12.scala b/src/library/scala/runtime/AbstractFunction12.scala
index 9823edbc60..10066ed4b3 100644
--- a/src/library/scala/runtime/AbstractFunction12.scala
+++ b/src/library/scala/runtime/AbstractFunction12.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction13.scala b/src/library/scala/runtime/AbstractFunction13.scala
index 528719b216..6c3a45734c 100644
--- a/src/library/scala/runtime/AbstractFunction13.scala
+++ b/src/library/scala/runtime/AbstractFunction13.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction14.scala b/src/library/scala/runtime/AbstractFunction14.scala
index ecae45a107..bf2b6736f4 100644
--- a/src/library/scala/runtime/AbstractFunction14.scala
+++ b/src/library/scala/runtime/AbstractFunction14.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction15.scala b/src/library/scala/runtime/AbstractFunction15.scala
index 5f5e8afcf7..5136f666c8 100644
--- a/src/library/scala/runtime/AbstractFunction15.scala
+++ b/src/library/scala/runtime/AbstractFunction15.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction16.scala b/src/library/scala/runtime/AbstractFunction16.scala
index c0093c4fbb..dbafab8301 100644
--- a/src/library/scala/runtime/AbstractFunction16.scala
+++ b/src/library/scala/runtime/AbstractFunction16.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction17.scala b/src/library/scala/runtime/AbstractFunction17.scala
index caae343a79..9c36dbf5d8 100644
--- a/src/library/scala/runtime/AbstractFunction17.scala
+++ b/src/library/scala/runtime/AbstractFunction17.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction18.scala b/src/library/scala/runtime/AbstractFunction18.scala
index 9a2bdffee1..30eee9586f 100644
--- a/src/library/scala/runtime/AbstractFunction18.scala
+++ b/src/library/scala/runtime/AbstractFunction18.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction19.scala b/src/library/scala/runtime/AbstractFunction19.scala
index 1dbbd61004..14baf5f1eb 100644
--- a/src/library/scala/runtime/AbstractFunction19.scala
+++ b/src/library/scala/runtime/AbstractFunction19.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction2.scala b/src/library/scala/runtime/AbstractFunction2.scala
index 0905ea178c..223ade9983 100644
--- a/src/library/scala/runtime/AbstractFunction2.scala
+++ b/src/library/scala/runtime/AbstractFunction2.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction20.scala b/src/library/scala/runtime/AbstractFunction20.scala
index eb4c085427..f5c29571bf 100644
--- a/src/library/scala/runtime/AbstractFunction20.scala
+++ b/src/library/scala/runtime/AbstractFunction20.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction21.scala b/src/library/scala/runtime/AbstractFunction21.scala
index 98e32b22f1..15feea3a66 100644
--- a/src/library/scala/runtime/AbstractFunction21.scala
+++ b/src/library/scala/runtime/AbstractFunction21.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction22.scala b/src/library/scala/runtime/AbstractFunction22.scala
index 67b13399d1..d77369ff01 100644
--- a/src/library/scala/runtime/AbstractFunction22.scala
+++ b/src/library/scala/runtime/AbstractFunction22.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction3.scala b/src/library/scala/runtime/AbstractFunction3.scala
index 3a45cdcea5..f863509214 100644
--- a/src/library/scala/runtime/AbstractFunction3.scala
+++ b/src/library/scala/runtime/AbstractFunction3.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction4.scala b/src/library/scala/runtime/AbstractFunction4.scala
index fbf55344f6..5927015ef8 100644
--- a/src/library/scala/runtime/AbstractFunction4.scala
+++ b/src/library/scala/runtime/AbstractFunction4.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction5.scala b/src/library/scala/runtime/AbstractFunction5.scala
index 949bae8ab7..411e1e14bf 100644
--- a/src/library/scala/runtime/AbstractFunction5.scala
+++ b/src/library/scala/runtime/AbstractFunction5.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction6.scala b/src/library/scala/runtime/AbstractFunction6.scala
index 337fd9f3fc..411c30d480 100644
--- a/src/library/scala/runtime/AbstractFunction6.scala
+++ b/src/library/scala/runtime/AbstractFunction6.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction7.scala b/src/library/scala/runtime/AbstractFunction7.scala
index 24458678ad..498f98633a 100644
--- a/src/library/scala/runtime/AbstractFunction7.scala
+++ b/src/library/scala/runtime/AbstractFunction7.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction8.scala b/src/library/scala/runtime/AbstractFunction8.scala
index 6d3dac849e..c6d320b887 100644
--- a/src/library/scala/runtime/AbstractFunction8.scala
+++ b/src/library/scala/runtime/AbstractFunction8.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractFunction9.scala b/src/library/scala/runtime/AbstractFunction9.scala
index 43cf3d2a74..34bd9d7107 100644
--- a/src/library/scala/runtime/AbstractFunction9.scala
+++ b/src/library/scala/runtime/AbstractFunction9.scala
@@ -1,6 +1,6 @@
/* __ *\
** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2011, LAMP/EPFL **
+** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
diff --git a/src/library/scala/runtime/AbstractPartialFunction.scala b/src/library/scala/runtime/AbstractPartialFunction.scala
index 57f8e2603b..e3516bc4d9 100644
--- a/src/library/scala/runtime/AbstractPartialFunction.scala
+++ b/src/library/scala/runtime/AbstractPartialFunction.scala
@@ -6,7 +6,10 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
+import scala.annotation.unspecialized
/** `AbstractPartialFunction` reformulates all operations of its supertrait `PartialFunction`
* in terms of `isDefinedAt` and `applyOrElse`.
diff --git a/src/library/scala/runtime/BooleanRef.java b/src/library/scala/runtime/BooleanRef.java
index 889db31e2a..92e8055351 100644
--- a/src/library/scala/runtime/BooleanRef.java
+++ b/src/library/scala/runtime/BooleanRef.java
@@ -17,4 +17,7 @@ public class BooleanRef implements java.io.Serializable {
public boolean elem;
public BooleanRef(boolean elem) { this.elem = elem; }
public String toString() { return String.valueOf(elem); }
+
+ public static BooleanRef create(boolean e) { return new BooleanRef(e); }
+ public static BooleanRef zero() { return new BooleanRef(false); }
}
diff --git a/src/library/scala/runtime/Boxed.scala b/src/library/scala/runtime/Boxed.scala
index 8b531076ac..855f0ff41a 100644
--- a/src/library/scala/runtime/Boxed.scala
+++ b/src/library/scala/runtime/Boxed.scala
@@ -8,7 +8,9 @@
-package scala.runtime
+package scala
+package runtime
+
trait Boxed {
diff --git a/src/library/scala/runtime/ByteRef.java b/src/library/scala/runtime/ByteRef.java
index cc10611e26..27d3259db3 100644
--- a/src/library/scala/runtime/ByteRef.java
+++ b/src/library/scala/runtime/ByteRef.java
@@ -17,4 +17,7 @@ public class ByteRef implements java.io.Serializable {
public byte elem;
public ByteRef(byte elem) { this.elem = elem; }
public String toString() { return java.lang.Byte.toString(elem); }
+
+ public static ByteRef create(byte e) { return new ByteRef(e); }
+ public static ByteRef zero() { return new ByteRef((byte)0); }
}
diff --git a/src/library/scala/runtime/CharRef.java b/src/library/scala/runtime/CharRef.java
index 03d3337b3d..31956f5b55 100644
--- a/src/library/scala/runtime/CharRef.java
+++ b/src/library/scala/runtime/CharRef.java
@@ -17,4 +17,7 @@ public class CharRef implements java.io.Serializable {
public char elem;
public CharRef(char elem) { this.elem = elem; }
public String toString() { return java.lang.Character.toString(elem); }
+
+ public static CharRef create(char e) { return new CharRef(e); }
+ public static CharRef zero() { return new CharRef((char)0); }
}
diff --git a/src/library/scala/runtime/DoubleRef.java b/src/library/scala/runtime/DoubleRef.java
index 317198ee48..0c7d9156d6 100644
--- a/src/library/scala/runtime/DoubleRef.java
+++ b/src/library/scala/runtime/DoubleRef.java
@@ -17,4 +17,7 @@ public class DoubleRef implements java.io.Serializable {
public double elem;
public DoubleRef(double elem) { this.elem = elem; }
public String toString() { return java.lang.Double.toString(elem); }
+
+ public static DoubleRef create(double e) { return new DoubleRef(e); }
+ public static DoubleRef zero() { return new DoubleRef(0); }
}
diff --git a/src/library/scala/runtime/FloatRef.java b/src/library/scala/runtime/FloatRef.java
index e26b89be60..f0e1d5f8f3 100644
--- a/src/library/scala/runtime/FloatRef.java
+++ b/src/library/scala/runtime/FloatRef.java
@@ -17,4 +17,7 @@ public class FloatRef implements java.io.Serializable {
public float elem;
public FloatRef(float elem) { this.elem = elem; }
public String toString() { return java.lang.Float.toString(elem); }
+
+ public static FloatRef create(float e) { return new FloatRef(e); }
+ public static FloatRef zero() { return new FloatRef(0); }
}
diff --git a/src/library/scala/runtime/IntRef.java b/src/library/scala/runtime/IntRef.java
index edb6fafe94..adcf474aae 100644
--- a/src/library/scala/runtime/IntRef.java
+++ b/src/library/scala/runtime/IntRef.java
@@ -17,4 +17,7 @@ public class IntRef implements java.io.Serializable {
public int elem;
public IntRef(int elem) { this.elem = elem; }
public String toString() { return java.lang.Integer.toString(elem); }
+
+ public static IntRef create(int e) { return new IntRef(e); }
+ public static IntRef zero() { return new IntRef(0); }
}
diff --git a/src/library/scala/runtime/LongRef.java b/src/library/scala/runtime/LongRef.java
index 12004b5bb5..51426ab8f6 100644
--- a/src/library/scala/runtime/LongRef.java
+++ b/src/library/scala/runtime/LongRef.java
@@ -17,4 +17,7 @@ public class LongRef implements java.io.Serializable {
public long elem;
public LongRef(long elem) { this.elem = elem; }
public String toString() { return java.lang.Long.toString(elem); }
+
+ public static LongRef create(long e) { return new LongRef(e); }
+ public static LongRef zero() { return new LongRef(0); }
}
diff --git a/src/library/scala/runtime/MethodCache.scala b/src/library/scala/runtime/MethodCache.scala
index 217b51893b..bbf80593db 100644
--- a/src/library/scala/runtime/MethodCache.scala
+++ b/src/library/scala/runtime/MethodCache.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
import java.lang.reflect.{ Method => JMethod }
import java.lang.{ Class => JClass }
diff --git a/src/library/scala/runtime/NonLocalReturnControl.scala b/src/library/scala/runtime/NonLocalReturnControl.scala
index b9525ef419..16b2fec6d7 100644
--- a/src/library/scala/runtime/NonLocalReturnControl.scala
+++ b/src/library/scala/runtime/NonLocalReturnControl.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
import scala.util.control.ControlThrowable
diff --git a/src/library/scala/runtime/Nothing$.scala b/src/library/scala/runtime/Nothing$.scala
index 04fcc55a1c..4ecc536223 100644
--- a/src/library/scala/runtime/Nothing$.scala
+++ b/src/library/scala/runtime/Nothing$.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
/**
* Dummy class which exist only to satisfy the JVM. It corresponds
diff --git a/src/library/scala/runtime/Null$.scala b/src/library/scala/runtime/Null$.scala
index 797b31583d..1b7685c507 100644
--- a/src/library/scala/runtime/Null$.scala
+++ b/src/library/scala/runtime/Null$.scala
@@ -6,11 +6,14 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
/**
* Dummy class which exist only to satisfy the JVM. It corresponds to
* `scala.Null`. If such type appears in method signatures, it is erased
- * to this one.
+ * to this one. A private constructor ensures that Java code can't create
+ * subclasses. The only value of type Null$ should be null
*/
-sealed abstract class Null$
+sealed abstract class Null$ private ()
diff --git a/src/library/scala/runtime/ObjectRef.java b/src/library/scala/runtime/ObjectRef.java
index c8298b8b21..c553c780a8 100644
--- a/src/library/scala/runtime/ObjectRef.java
+++ b/src/library/scala/runtime/ObjectRef.java
@@ -17,4 +17,7 @@ public class ObjectRef<T> implements java.io.Serializable {
public T elem;
public ObjectRef(T elem) { this.elem = elem; }
public String toString() { return String.valueOf(elem); }
+
+ public static <U> ObjectRef create(U e) { return new ObjectRef(e); }
+ public static ObjectRef zero() { return new ObjectRef(null); }
}
diff --git a/src/library/scala/runtime/RichBoolean.scala b/src/library/scala/runtime/RichBoolean.scala
index 97e2b77f96..4f867960a0 100644
--- a/src/library/scala/runtime/RichBoolean.scala
+++ b/src/library/scala/runtime/RichBoolean.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
final class RichBoolean(val self: Boolean) extends AnyVal with OrderedProxy[Boolean] {
protected def ord = scala.math.Ordering.Boolean
diff --git a/src/library/scala/runtime/RichByte.scala b/src/library/scala/runtime/RichByte.scala
index ca578620cf..ea23cb8867 100644
--- a/src/library/scala/runtime/RichByte.scala
+++ b/src/library/scala/runtime/RichByte.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
final class RichByte(val self: Byte) extends AnyVal with ScalaWholeNumberProxy[Byte] {
protected def num = scala.math.Numeric.ByteIsIntegral
diff --git a/src/library/scala/runtime/RichChar.scala b/src/library/scala/runtime/RichChar.scala
index 5124ca00de..c069fd1fef 100644
--- a/src/library/scala/runtime/RichChar.scala
+++ b/src/library/scala/runtime/RichChar.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
import java.lang.Character
diff --git a/src/library/scala/runtime/RichException.scala b/src/library/scala/runtime/RichException.scala
index 94c4137674..f01788a4e9 100644
--- a/src/library/scala/runtime/RichException.scala
+++ b/src/library/scala/runtime/RichException.scala
@@ -6,10 +6,12 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
import scala.compat.Platform.EOL
+@deprecated("Use Throwable#getStackTrace", "2.11.0")
final class RichException(exc: Throwable) {
def getStackTraceString = exc.getStackTrace().mkString("", EOL, EOL)
}
diff --git a/src/library/scala/runtime/RichInt.scala b/src/library/scala/runtime/RichInt.scala
index 192f94f939..a39710b146 100644
--- a/src/library/scala/runtime/RichInt.scala
+++ b/src/library/scala/runtime/RichInt.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
import scala.collection.immutable.Range
diff --git a/src/library/scala/runtime/RichLong.scala b/src/library/scala/runtime/RichLong.scala
index ce2d1fdcbd..e5b39b1c09 100644
--- a/src/library/scala/runtime/RichLong.scala
+++ b/src/library/scala/runtime/RichLong.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
final class RichLong(val self: Long) extends AnyVal with IntegralProxy[Long] {
protected def num = scala.math.Numeric.LongIsIntegral
diff --git a/src/library/scala/runtime/RichShort.scala b/src/library/scala/runtime/RichShort.scala
index aa24dd2ba6..3e5d8781ff 100644
--- a/src/library/scala/runtime/RichShort.scala
+++ b/src/library/scala/runtime/RichShort.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
final class RichShort(val self: Short) extends AnyVal with ScalaWholeNumberProxy[Short] {
protected def num = scala.math.Numeric.ShortIsIntegral
diff --git a/src/library/scala/runtime/ScalaNumberProxy.scala b/src/library/scala/runtime/ScalaNumberProxy.scala
index 76fc38b267..6ea6448b1a 100644
--- a/src/library/scala/runtime/ScalaNumberProxy.scala
+++ b/src/library/scala/runtime/ScalaNumberProxy.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
import scala.collection.{ mutable, immutable }
import scala.math.{ ScalaNumericConversions, ScalaNumericAnyConversions }
@@ -28,8 +29,8 @@ trait ScalaNumberProxy[T] extends Any with ScalaNumericAnyConversions with Typed
def floatValue() = num.toFloat(self)
def longValue() = num.toLong(self)
def intValue() = num.toInt(self)
- def byteValue() = intValue.toByte
- def shortValue() = intValue.toShort
+ def byteValue() = intValue().toByte
+ def shortValue() = intValue().toShort
def min(that: T): T = num.min(self, that)
def max(that: T): T = num.max(self, that)
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala
index 1d8fe5e9ad..ea1f392e2b 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -26,8 +26,7 @@ import java.lang.reflect.{ Modifier, Method => JMethod }
* outside the API and subject to change or removal without notice.
*/
object ScalaRunTime {
- def isArray(x: AnyRef): Boolean = isArray(x, 1)
- def isArray(x: Any, atLevel: Int): Boolean =
+ def isArray(x: Any, atLevel: Int = 1): Boolean =
x != null && isArrayClass(x.getClass, atLevel)
private def isArrayClass(clazz: jClass[_], atLevel: Int): Boolean =
@@ -159,13 +158,7 @@ object ScalaRunTime {
// Java bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4071957
// More background at ticket #2318.
- def ensureAccessible(m: JMethod): JMethod = {
- if (!m.isAccessible) {
- try m setAccessible true
- catch { case _: SecurityException => () }
- }
- m
- }
+ def ensureAccessible(m: JMethod): JMethod = scala.reflect.ensureAccessible(m)
def checkInitialized[T <: AnyRef](x: T): T =
if (x == null) throw new UninitializedError else x
@@ -228,7 +221,7 @@ object ScalaRunTime {
if (iv == fv) return iv
val lv = fv.toLong
- if (lv == fv) return hash(lv)
+ if (lv == fv) hash(lv)
else fv.hashCode
}
def hash(lv: Long): Int = {
diff --git a/src/library/scala/runtime/SeqCharSequence.scala b/src/library/scala/runtime/SeqCharSequence.scala
index d2084a6598..ce7d7afc9e 100644
--- a/src/library/scala/runtime/SeqCharSequence.scala
+++ b/src/library/scala/runtime/SeqCharSequence.scala
@@ -11,6 +11,7 @@ package runtime
import java.util.Arrays.copyOfRange
+@deprecated("Use Predef.SeqCharSequence", "2.11.0")
final class SeqCharSequence(val xs: scala.collection.IndexedSeq[Char]) extends CharSequence {
def length: Int = xs.length
def charAt(index: Int): Char = xs(index)
@@ -18,6 +19,8 @@ final class SeqCharSequence(val xs: scala.collection.IndexedSeq[Char]) extends C
override def toString = xs.mkString("")
}
+// Still need this one since the implicit class ArrayCharSequence only converts
+// a single argument.
final class ArrayCharSequence(val xs: Array[Char], start: Int, end: Int) extends CharSequence {
// yikes
// java.lang.VerifyError: (class: scala/runtime/ArrayCharSequence, method: <init> signature: ([C)V)
diff --git a/src/library/scala/runtime/ShortRef.java b/src/library/scala/runtime/ShortRef.java
index 461b521e5f..e5e8de3d8b 100644
--- a/src/library/scala/runtime/ShortRef.java
+++ b/src/library/scala/runtime/ShortRef.java
@@ -17,4 +17,7 @@ public class ShortRef implements java.io.Serializable {
public short elem;
public ShortRef(short elem) { this.elem = elem; }
public String toString() { return java.lang.Short.toString(elem); }
+
+ public static ShortRef create(short e) { return new ShortRef(e); }
+ public static ShortRef zero() { return new ShortRef((short)0); }
}
diff --git a/src/library/scala/runtime/StringAdd.scala b/src/library/scala/runtime/StringAdd.scala
index 9d848f0ba7..d5b51a6e92 100644
--- a/src/library/scala/runtime/StringAdd.scala
+++ b/src/library/scala/runtime/StringAdd.scala
@@ -6,9 +6,12 @@
** **
\* */
-package scala.runtime
+package scala
+package runtime
+
/** A wrapper class that adds string concatenation `+` to any value */
+@deprecated("Use Predef.StringAdd", "2.11.0")
final class StringAdd(val self: Any) extends AnyVal {
def +(other: String) = String.valueOf(self) + other
}
diff --git a/src/library/scala/runtime/StringFormat.scala b/src/library/scala/runtime/StringFormat.scala
index 983ae2fc54..de32ac7e86 100644
--- a/src/library/scala/runtime/StringFormat.scala
+++ b/src/library/scala/runtime/StringFormat.scala
@@ -6,10 +6,13 @@
** **
\* */
-package scala.runtime
+package scala
+package runtime
+
/** A wrapper class that adds a `formatted` operation to any value
*/
+@deprecated("Use Predef.StringFormat", "2.11.0")
final class StringFormat(val self: Any) extends AnyVal {
/** Returns string formatted according to given `format` string.
* Format strings are as for `String.format`
diff --git a/src/library/scala/runtime/Tuple2Zipped.scala b/src/library/scala/runtime/Tuple2Zipped.scala
index ef29075ac3..b28f6d4269 100644
--- a/src/library/scala/runtime/Tuple2Zipped.scala
+++ b/src/library/scala/runtime/Tuple2Zipped.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
import scala.collection.{ TraversableLike, IterableLike }
import scala.collection.generic.{ CanBuildFrom => CBF }
@@ -37,12 +39,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
for (el1 <- colls._1) {
if (elems2.hasNext)
- b += f(el1, elems2.next)
+ b += f(el1, elems2.next())
else
- return b.result
+ return b.result()
}
- b.result
+ b.result()
}
def flatMap[B, To](f: (El1, El2) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
@@ -51,12 +53,12 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
for (el1 <- colls._1) {
if (elems2.hasNext)
- b ++= f(el1, elems2.next)
+ b ++= f(el1, elems2.next())
else
- return b.result
+ return b.result()
}
- b.result
+ b.result()
}
def filter[To1, To2](f: (El1, El2) => Boolean)(implicit cbf1: CBF[Repr1, El1, To1], cbf2: CBF[Repr2, El2, To2]): (To1, To2) = {
@@ -66,16 +68,16 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
for (el1 <- colls._1) {
if (elems2.hasNext) {
- val el2 = elems2.next
+ val el2 = elems2.next()
if (f(el1, el2)) {
b1 += el1
b2 += el2
}
}
- else return (b1.result, b2.result)
+ else return (b1.result(), b2.result())
}
- (b1.result, b2.result)
+ (b1.result(), b2.result())
}
def exists(f: (El1, El2) => Boolean): Boolean = {
@@ -83,7 +85,7 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
for (el1 <- colls._1) {
if (elems2.hasNext) {
- if (f(el1, elems2.next))
+ if (f(el1, elems2.next()))
return true
}
else return false
@@ -99,7 +101,7 @@ final class Tuple2Zipped[El1, Repr1, El2, Repr2](val colls: (TraversableLike[El1
for (el1 <- colls._1) {
if (elems2.hasNext)
- f(el1, elems2.next)
+ f(el1, elems2.next())
else
return
}
@@ -117,9 +119,9 @@ object Tuple2Zipped {
val it1 = x._1.toIterator
val it2 = x._2.toIterator
while (it1.hasNext && it2.hasNext)
- buf += ((it1.next, it2.next))
+ buf += ((it1.next(), it2.next()))
- buf.result
+ buf.result()
}
def zipped[El1, Repr1, El2, Repr2]
diff --git a/src/library/scala/runtime/Tuple3Zipped.scala b/src/library/scala/runtime/Tuple3Zipped.scala
index 3f2afaf772..7c501380a3 100644
--- a/src/library/scala/runtime/Tuple3Zipped.scala
+++ b/src/library/scala/runtime/Tuple3Zipped.scala
@@ -6,7 +6,9 @@
** |/ **
\* */
-package scala.runtime
+package scala
+package runtime
+
import scala.collection.{ TraversableLike, IterableLike }
import scala.collection.generic.{ CanBuildFrom => CBF }
@@ -34,11 +36,11 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext)
- b += f(el1, elems2.next, elems3.next)
+ b += f(el1, elems2.next(), elems3.next())
else
- return b.result
+ return b.result()
}
- b.result
+ b.result()
}
def flatMap[B, To](f: (El1, El2, El3) => TraversableOnce[B])(implicit cbf: CBF[Repr1, B, To]): To = {
@@ -48,11 +50,11 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext)
- b ++= f(el1, elems2.next, elems3.next)
+ b ++= f(el1, elems2.next(), elems3.next())
else
- return b.result
+ return b.result()
}
- b.result
+ b.result()
}
def filter[To1, To2, To3](f: (El1, El2, El3) => Boolean)(
@@ -64,12 +66,12 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
val b3 = cbf3(colls._3.repr)
val elems2 = colls._2.iterator
val elems3 = colls._3.iterator
- def result = (b1.result, b2.result, b3.result)
+ def result = (b1.result(), b2.result(), b3.result())
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
- val el2 = elems2.next
- val el3 = elems3.next
+ val el2 = elems2.next()
+ val el3 = elems3.next()
if (f(el1, el2, el3)) {
b1 += el1
@@ -89,7 +91,7 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext) {
- if (f(el1, elems2.next, elems3.next))
+ if (f(el1, elems2.next(), elems3.next()))
return true
}
else return false
@@ -106,7 +108,7 @@ final class Tuple3Zipped[El1, Repr1, El2, Repr2, El3, Repr3](val colls: (Travers
for (el1 <- colls._1) {
if (elems2.hasNext && elems3.hasNext)
- f(el1, elems2.next, elems3.next)
+ f(el1, elems2.next(), elems3.next())
else
return
}
@@ -126,9 +128,9 @@ object Tuple3Zipped {
val it2 = x._2.toIterator
val it3 = x._3.toIterator
while (it1.hasNext && it2.hasNext && it3.hasNext)
- buf += ((it1.next, it2.next, it3.next))
+ buf += ((it1.next(), it2.next(), it3.next()))
- buf.result
+ buf.result()
}
def zipped[El1, Repr1, El2, Repr2, El3, Repr3]
diff --git a/src/library/scala/runtime/VolatileBooleanRef.java b/src/library/scala/runtime/VolatileBooleanRef.java
index e3bd182345..ef5b691118 100755
--- a/src/library/scala/runtime/VolatileBooleanRef.java
+++ b/src/library/scala/runtime/VolatileBooleanRef.java
@@ -17,4 +17,7 @@ public class VolatileBooleanRef implements java.io.Serializable {
volatile public boolean elem;
public VolatileBooleanRef(boolean elem) { this.elem = elem; }
public String toString() { return String.valueOf(elem); }
+
+ public static VolatileBooleanRef create(boolean e) { return new VolatileBooleanRef(e); }
+ public static VolatileBooleanRef zero() { return new VolatileBooleanRef(false); }
}
diff --git a/src/library/scala/runtime/VolatileByteRef.java b/src/library/scala/runtime/VolatileByteRef.java
index 034b003017..d792b0a386 100755
--- a/src/library/scala/runtime/VolatileByteRef.java
+++ b/src/library/scala/runtime/VolatileByteRef.java
@@ -17,4 +17,7 @@ public class VolatileByteRef implements java.io.Serializable {
volatile public byte elem;
public VolatileByteRef(byte elem) { this.elem = elem; }
public String toString() { return java.lang.Byte.toString(elem); }
+
+ public static VolatileByteRef create(byte e) { return new VolatileByteRef(e); }
+ public static VolatileByteRef zero() { return new VolatileByteRef((byte)0); }
}
diff --git a/src/library/scala/runtime/VolatileCharRef.java b/src/library/scala/runtime/VolatileCharRef.java
index f90648c5e9..555b171283 100755
--- a/src/library/scala/runtime/VolatileCharRef.java
+++ b/src/library/scala/runtime/VolatileCharRef.java
@@ -17,4 +17,7 @@ public class VolatileCharRef implements java.io.Serializable {
volatile public char elem;
public VolatileCharRef(char elem) { this.elem = elem; }
public String toString() { return java.lang.Character.toString(elem); }
+
+ public static VolatileCharRef create(char e) { return new VolatileCharRef(e); }
+ public static VolatileCharRef zero() { return new VolatileCharRef((char)0); }
}
diff --git a/src/library/scala/runtime/VolatileDoubleRef.java b/src/library/scala/runtime/VolatileDoubleRef.java
index d47c9578c6..1932055c6a 100755
--- a/src/library/scala/runtime/VolatileDoubleRef.java
+++ b/src/library/scala/runtime/VolatileDoubleRef.java
@@ -16,4 +16,7 @@ public class VolatileDoubleRef implements java.io.Serializable {
volatile public double elem;
public VolatileDoubleRef(double elem) { this.elem = elem; }
public String toString() { return java.lang.Double.toString(elem); }
+
+ public static VolatileDoubleRef create(double e) { return new VolatileDoubleRef(e); }
+ public static VolatileDoubleRef zero() { return new VolatileDoubleRef(0); }
}
diff --git a/src/library/scala/runtime/VolatileFloatRef.java b/src/library/scala/runtime/VolatileFloatRef.java
index 97da95f7cc..3a81be1146 100755
--- a/src/library/scala/runtime/VolatileFloatRef.java
+++ b/src/library/scala/runtime/VolatileFloatRef.java
@@ -17,4 +17,7 @@ public class VolatileFloatRef implements java.io.Serializable {
volatile public float elem;
public VolatileFloatRef(float elem) { this.elem = elem; }
public String toString() { return java.lang.Float.toString(elem); }
+
+ public static VolatileFloatRef create(float e) { return new VolatileFloatRef(e); }
+ public static VolatileFloatRef zero() { return new VolatileFloatRef(0); }
}
diff --git a/src/library/scala/runtime/VolatileIntRef.java b/src/library/scala/runtime/VolatileIntRef.java
index e8a68a1a9a..ae015bc8b1 100755
--- a/src/library/scala/runtime/VolatileIntRef.java
+++ b/src/library/scala/runtime/VolatileIntRef.java
@@ -16,4 +16,7 @@ public class VolatileIntRef implements java.io.Serializable {
volatile public int elem;
public VolatileIntRef(int elem) { this.elem = elem; }
public String toString() { return java.lang.Integer.toString(elem); }
+
+ public static VolatileIntRef create(int e) { return new VolatileIntRef(e); }
+ public static VolatileIntRef zero() { return new VolatileIntRef(0); }
}
diff --git a/src/library/scala/runtime/VolatileLongRef.java b/src/library/scala/runtime/VolatileLongRef.java
index 80e627cd4b..e596f5aa69 100755
--- a/src/library/scala/runtime/VolatileLongRef.java
+++ b/src/library/scala/runtime/VolatileLongRef.java
@@ -17,4 +17,7 @@ public class VolatileLongRef implements java.io.Serializable {
volatile public long elem;
public VolatileLongRef(long elem) { this.elem = elem; }
public String toString() { return java.lang.Long.toString(elem); }
+
+ public static VolatileLongRef create(long e) { return new VolatileLongRef(e); }
+ public static VolatileLongRef zero() { return new VolatileLongRef(0); }
}
diff --git a/src/library/scala/runtime/VolatileObjectRef.java b/src/library/scala/runtime/VolatileObjectRef.java
index 848b0632ea..9f1f3ac0cf 100755
--- a/src/library/scala/runtime/VolatileObjectRef.java
+++ b/src/library/scala/runtime/VolatileObjectRef.java
@@ -17,4 +17,7 @@ public class VolatileObjectRef<T> implements java.io.Serializable {
volatile public T elem;
public VolatileObjectRef(T elem) { this.elem = elem; }
public String toString() { return String.valueOf(elem); }
+
+ public static <U> VolatileObjectRef create(U e) { return new VolatileObjectRef(e); }
+ public static VolatileObjectRef zero() { return new VolatileObjectRef(null); }
}
diff --git a/src/library/scala/runtime/VolatileShortRef.java b/src/library/scala/runtime/VolatileShortRef.java
index 4e91d0dc70..0a2825941f 100755
--- a/src/library/scala/runtime/VolatileShortRef.java
+++ b/src/library/scala/runtime/VolatileShortRef.java
@@ -17,4 +17,7 @@ public class VolatileShortRef implements java.io.Serializable {
volatile public short elem;
public VolatileShortRef(short elem) { this.elem = elem; }
public String toString() { return java.lang.Short.toString(elem); }
+
+ public static VolatileShortRef create(short e) { return new VolatileShortRef(e); }
+ public static VolatileShortRef zero() { return new VolatileShortRef((short)0); }
}
diff --git a/src/library/scala/sys/BooleanProp.scala b/src/library/scala/sys/BooleanProp.scala
index e3c25bbd11..74b0a9077b 100644
--- a/src/library/scala/sys/BooleanProp.scala
+++ b/src/library/scala/sys/BooleanProp.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
import scala.language.implicitConversions
diff --git a/src/library/scala/sys/PropImpl.scala b/src/library/scala/sys/PropImpl.scala
index b50e0e18a7..3b451ab1d9 100644
--- a/src/library/scala/sys/PropImpl.scala
+++ b/src/library/scala/sys/PropImpl.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
import scala.collection.mutable
diff --git a/src/library/scala/sys/ShutdownHookThread.scala b/src/library/scala/sys/ShutdownHookThread.scala
index a8f4871870..6018ac852b 100644
--- a/src/library/scala/sys/ShutdownHookThread.scala
+++ b/src/library/scala/sys/ShutdownHookThread.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
/** A minimal Thread wrapper to enhance shutdown hooks. It knows
* how to unregister itself.
diff --git a/src/library/scala/sys/SystemProperties.scala b/src/library/scala/sys/SystemProperties.scala
index da9adb3dc2..39f66f5030 100644
--- a/src/library/scala/sys/SystemProperties.scala
+++ b/src/library/scala/sys/SystemProperties.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
import scala.collection.{ mutable, Iterator }
import scala.collection.JavaConverters._
@@ -64,7 +65,6 @@ object SystemProperties {
propertyHelp(p.key) = helpText
p
}
- private def str(key: String, helpText: String) = addHelp(Prop[String](key), helpText)
private def bool(key: String, helpText: String): BooleanProp = addHelp[BooleanProp](
if (key startsWith "java.") BooleanProp.valueIsTrue(key) else BooleanProp.keyExists(key),
helpText
diff --git a/src/library/scala/sys/process/BasicIO.scala b/src/library/scala/sys/process/BasicIO.scala
index 0003df6c52..58517de402 100644
--- a/src/library/scala/sys/process/BasicIO.scala
+++ b/src/library/scala/sys/process/BasicIO.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import processInternal._
@@ -46,7 +47,7 @@ object BasicIO {
def next(): Stream[T] = q.take match {
case Left(0) => Stream.empty
case Left(code) => if (nonzeroException) scala.sys.error("Nonzero exit code: " + code) else Stream.empty
- case Right(s) => Stream.cons(s, next)
+ case Right(s) => Stream.cons(s, next())
}
new Streamed((s: T) => q put Right(s), code => q put Left(code), () => next())
}
diff --git a/src/library/scala/sys/process/Process.scala b/src/library/scala/sys/process/Process.scala
index 715b364e08..402183a1f0 100644
--- a/src/library/scala/sys/process/Process.scala
+++ b/src/library/scala/sys/process/Process.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import processInternal._
diff --git a/src/library/scala/sys/process/ProcessBuilder.scala b/src/library/scala/sys/process/ProcessBuilder.scala
index d0b2ecfe73..c8e548c76b 100644
--- a/src/library/scala/sys/process/ProcessBuilder.scala
+++ b/src/library/scala/sys/process/ProcessBuilder.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import processInternal._
@@ -23,7 +24,7 @@ import ProcessBuilder._
* based on these factories made available in the package object
* [[scala.sys.process]]. Here are some examples:
* {{{
- * import.scala.sys.process._
+ * import scala.sys.process._
*
* // Executes "ls" and sends output to stdout
* "ls".!
@@ -46,14 +47,14 @@ import ProcessBuilder._
*
* Two existing `ProcessBuilder` can be combined in the following ways:
*
- * * They can be executed in parallel, with the output of the first being fed
- * as input to the second, like Unix pipes. This is achieved with the `#|`
- * method.
- * * They can be executed in sequence, with the second starting as soon as
- * the first ends. This is done by the `###` method.
- * * The execution of the second one can be conditioned by the return code
- * (exit status) of the first, either only when it's zero, or only when it's
- * not zero. The methods `#&&` and `#||` accomplish these tasks.
+ * - They can be executed in parallel, with the output of the first being fed
+ * as input to the second, like Unix pipes. This is achieved with the `#|`
+ * method.
+ * - They can be executed in sequence, with the second starting as soon as
+ * the first ends. This is done by the `###` method.
+ * - The execution of the second one can be conditioned by the return code
+ * (exit status) of the first, either only when it's zero, or only when it's
+ * not zero. The methods `#&&` and `#||` accomplish these tasks.
*
* ==Redirecting Input/Output==
*
@@ -74,18 +75,18 @@ import ProcessBuilder._
* overloads and variations to enable further control over the I/O. These
* methods are:
*
- * * `run`: the most general method, it returns a
- * [[scala.sys.process.Process]] immediately, and the external command
- * executes concurrently.
- * * `!`: blocks until all external commands exit, and returns the exit code
- * of the last one in the chain of execution.
- * * `!!`: blocks until all external commands exit, and returns a `String`
- * with the output generated.
- * * `lines`: returns immediately like `run`, and the output being generared
- * is provided through a `Stream[String]`. Getting the next element of that
- * `Stream` may block until it becomes available. This method will throw an
- * exception if the return code is different than zero -- if this is not
- * desired, use the `lines_!` method.
+ * - `run`: the most general method, it returns a
+ * [[scala.sys.process.Process]] immediately, and the external command
+ * executes concurrently.
+ * - `!`: blocks until all external commands exit, and returns the exit code
+ * of the last one in the chain of execution.
+ * - `!!`: blocks until all external commands exit, and returns a `String`
+ * with the output generated.
+ * - `lines`: returns immediately like `run`, and the output being generared
+ * is provided through a `Stream[String]`. Getting the next element of that
+ * `Stream` may block until it becomes available. This method will throw an
+ * exception if the return code is different than zero -- if this is not
+ * desired, use the `lines_!` method.
*
* ==Handling Input and Output==
*
@@ -305,10 +306,10 @@ object ProcessBuilder extends ProcessBuilderImpl {
protected def toSource: ProcessBuilder
/** Writes the output stream of this process to the given file. */
- def #> (f: File): ProcessBuilder = toFile(f, false)
+ def #> (f: File): ProcessBuilder = toFile(f, append = false)
/** Appends the output stream of this process to the given file. */
- def #>> (f: File): ProcessBuilder = toFile(f, true)
+ def #>> (f: File): ProcessBuilder = toFile(f, append = true)
/** Writes the output stream of this process to the given OutputStream. The
* argument is call-by-name, so the stream is recreated, written, and closed each
diff --git a/src/library/scala/sys/process/ProcessBuilderImpl.scala b/src/library/scala/sys/process/ProcessBuilderImpl.scala
index 49fea6f464..adf6d1e724 100644
--- a/src/library/scala/sys/process/ProcessBuilderImpl.scala
+++ b/src/library/scala/sys/process/ProcessBuilderImpl.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import processInternal._
@@ -69,7 +70,7 @@ private[process] trait ProcessBuilderImpl {
import io._
// spawn threads that process the input, output, and error streams using the functions defined in `io`
- val inThread = Spawn(writeInput(process.getOutputStream), true)
+ val inThread = Spawn(writeInput(process.getOutputStream), daemon = true)
val outThread = Spawn(processOutput(process.getInputStream), daemonizeThreads)
val errorThread =
if (p.redirectErrorStream) Nil
@@ -93,26 +94,26 @@ private[process] trait ProcessBuilderImpl {
def #&&(other: ProcessBuilder): ProcessBuilder = new AndBuilder(this, other)
def ###(other: ProcessBuilder): ProcessBuilder = new SequenceBuilder(this, other)
- def run(): Process = run(false)
+ def run(): Process = run(connectInput = false)
def run(connectInput: Boolean): Process = run(BasicIO.standard(connectInput))
- def run(log: ProcessLogger): Process = run(log, false)
+ def run(log: ProcessLogger): Process = run(log, connectInput = false)
def run(log: ProcessLogger, connectInput: Boolean): Process = run(BasicIO(connectInput, log))
- def !! = slurp(None, false)
- def !!(log: ProcessLogger) = slurp(Some(log), false)
- def !!< = slurp(None, true)
- def !!<(log: ProcessLogger) = slurp(Some(log), true)
+ def !! = slurp(None, withIn = false)
+ def !!(log: ProcessLogger) = slurp(Some(log), withIn = false)
+ def !!< = slurp(None, withIn = true)
+ def !!<(log: ProcessLogger) = slurp(Some(log), withIn = true)
- def lines: Stream[String] = lines(false, true, None)
- def lines(log: ProcessLogger): Stream[String] = lines(false, true, Some(log))
- def lines_! : Stream[String] = lines(false, false, None)
- def lines_!(log: ProcessLogger): Stream[String] = lines(false, false, Some(log))
+ def lines: Stream[String] = lines(withInput = false, nonZeroException = true, None)
+ def lines(log: ProcessLogger): Stream[String] = lines(withInput = false, nonZeroException = true, Some(log))
+ def lines_! : Stream[String] = lines(withInput = false, nonZeroException = false, None)
+ def lines_!(log: ProcessLogger): Stream[String] = lines(withInput = false, nonZeroException = false, Some(log))
- def ! = run(false).exitValue()
+ def ! = run(connectInput = false).exitValue()
def !(io: ProcessIO) = run(io).exitValue()
- def !(log: ProcessLogger) = runBuffered(log, false)
- def !< = run(true).exitValue()
- def !<(log: ProcessLogger) = runBuffered(log, true)
+ def !(log: ProcessLogger) = runBuffered(log, connectInput = false)
+ def !< = run(connectInput = true).exitValue()
+ def !<(log: ProcessLogger) = runBuffered(log, connectInput = true)
/** Constructs a new builder which runs this command with all input/output threads marked
* as daemon threads. This allows the creation of a long running process while still
diff --git a/src/library/scala/sys/process/ProcessIO.scala b/src/library/scala/sys/process/ProcessIO.scala
index f5b26680d9..eedf667c88 100644
--- a/src/library/scala/sys/process/ProcessIO.scala
+++ b/src/library/scala/sys/process/ProcessIO.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import processInternal._
diff --git a/src/library/scala/sys/process/ProcessImpl.scala b/src/library/scala/sys/process/ProcessImpl.scala
index c21c0daa5e..7a5fc4ef9b 100644
--- a/src/library/scala/sys/process/ProcessImpl.scala
+++ b/src/library/scala/sys/process/ProcessImpl.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import processInternal._
@@ -17,7 +18,7 @@ private[process] trait ProcessImpl {
/** Runs provided code in a new Thread and returns the Thread instance. */
private[process] object Spawn {
- def apply(f: => Unit): Thread = apply(f, false)
+ def apply(f: => Unit): Thread = apply(f, daemon = false)
def apply(f: => Unit, daemon: Boolean): Thread = {
val thread = new Thread() { override def run() = { f } }
thread.setDaemon(daemon)
@@ -32,7 +33,7 @@ private[process] trait ProcessImpl {
try result set Right(f)
catch { case e: Exception => result set Left(e) }
- Spawn(run)
+ Spawn(run())
() => result.get match {
case Right(value) => value
@@ -68,10 +69,10 @@ private[process] trait ProcessImpl {
protected[this] override def runAndExitValue() = {
val first = a.run(io)
- runInterruptible(first.exitValue)(first.destroy()) flatMap { codeA =>
+ runInterruptible(first.exitValue())(first.destroy()) flatMap { codeA =>
if (evaluateSecondProcess(codeA)) {
val second = b.run(io)
- runInterruptible(second.exitValue)(second.destroy())
+ runInterruptible(second.exitValue())(second.destroy())
}
else Some(codeA)
}
@@ -132,10 +133,10 @@ private[process] trait ProcessImpl {
val first = a.run(firstIO)
try {
runInterruptible {
- val exit1 = first.exitValue
+ val exit1 = first.exitValue()
currentSource put None
currentSink put None
- val exit2 = second.exitValue
+ val exit2 = second.exitValue()
// Since file redirection (e.g. #>) is implemented as a piped process,
// we ignore its exit value so cmd #> file doesn't always return 0.
if (b.hasExitValue) exit2 else exit1
diff --git a/src/library/scala/sys/process/ProcessLogger.scala b/src/library/scala/sys/process/ProcessLogger.scala
index a4acb065d0..ae347221ef 100644
--- a/src/library/scala/sys/process/ProcessLogger.scala
+++ b/src/library/scala/sys/process/ProcessLogger.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.sys
+package scala
+package sys
package process
import java.io._
diff --git a/src/library/scala/sys/process/package.scala b/src/library/scala/sys/process/package.scala
index ed436febc0..902543665f 100644
--- a/src/library/scala/sys/process/package.scala
+++ b/src/library/scala/sys/process/package.scala
@@ -25,7 +25,7 @@ package scala.sys {
*
* {{{
* import scala.sys.process._
- * "ls" #| "grep .scala" #&& "scalac *.scala" #|| "echo nothing found" lines
+ * "ls" #| "grep .scala" #&& Seq("sh", "-c", "scalac *.scala") #|| "echo nothing found" lines
* }}}
*
* We describe below the general concepts and architecture of the package,
diff --git a/src/library/scala/testing/Benchmark.scala b/src/library/scala/testing/Benchmark.scala
deleted file mode 100644
index 66d7d448eb..0000000000
--- a/src/library/scala/testing/Benchmark.scala
+++ /dev/null
@@ -1,114 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.testing
-
-import scala.compat.Platform
-
-/** `Benchmark` can be used to quickly turn an existing class into a
- * benchmark. Here is a short example:
- * {{{
- * object sort1 extends Sorter with Benchmark {
- * def run = sort(List.range(1, 1000))
- * }
- * }}}
- * The `run` method has to be defined by the user, who will perform the
- * timed operation there. Run the benchmark as follows:
- * {{{
- * > scala sort1 5
- * }}}
- * This will run the benchmark 5 times, forcing a garbage collection
- * between runs, and printing the execution times to stdout.
- *
- * It is also possible to add a multiplier, so
- * {{{
- * > scala sort1 5 10
- * }}}
- * will run the entire benchmark 10 times, each time for 5 runs.
- *
- * @author Iulian Dragos, Burak Emir
- */
-@deprecated("This class will be removed.", "2.10.0")
-trait Benchmark {
-
- /** this method should be implemented by the concrete benchmark.
- * This method is called by the benchmarking code for a number of times.
- * The GC is called between "multiplier" calls to run, right after tear
- * down.
- *
- * @see setUp
- * @see tearDown
- */
- def run()
-
- var multiplier = 1
-
- /** Run the benchmark the specified number of times and return a list with
- * the execution times in milliseconds in reverse order of the execution.
- */
- def runBenchmark(noTimes: Int): List[Long] =
- for (i <- List.range(1, noTimes + 1)) yield {
- setUp
- val startTime = Platform.currentTime
- var i = 0; while (i < multiplier) {
- run()
- i += 1
- }
- val stopTime = Platform.currentTime
- tearDown
- Platform.collectGarbage
-
- stopTime - startTime
- }
-
- /** Prepare any data needed by the benchmark, but whose execution time
- * should not be measured. This method is run before each call to the
- * benchmark payload, 'run'.
- */
- def setUp() {}
-
- /** Perform cleanup operations after each 'run'. For micro benchmarks,
- * think about using the result of 'run' in a way that prevents the JVM
- * to dead-code eliminate the whole 'run' method. For instance, print or
- * write the results to a file. The execution time of this method is not
- * measured.
- */
- def tearDown() {}
-
- /** a string that is written at the beginning of the output line
- * that contains the timings. By default, this is the class name.
- */
- def prefix: String = getClass().getName()
-
- /**
- * The entry point. It takes two arguments:
- * - argument `n` is the number of consecutive runs
- * - optional argument `mult` specifies that the `n` runs are repeated
- * `mult` times.
- */
- def main(args: Array[String]) {
- if (args.length > 0) {
- val logFile = new java.io.OutputStreamWriter(System.out)
- if (args.length > 1) multiplier = args(1).toInt
- logFile.write(prefix)
- for (t <- runBenchmark(args(0).toInt))
- logFile.write("\t" + t)
-
- logFile.write(Platform.EOL)
- logFile.flush()
- } else {
- println("Usage: scala benchmarks.program <runs> ")
- println(" or: scala benchmarks.program <runs> <multiplier>")
- println("""
- The benchmark is run <runs> times, forcing a garbage collection between runs. The optional
- <multiplier> causes the benchmark to be repeated <multiplier> times, each time for <runs>
- executions.
- """)
- }
- }
-}
diff --git a/src/library/scala/testing/Show.scala b/src/library/scala/testing/Show.scala
deleted file mode 100644
index 9376e26db4..0000000000
--- a/src/library/scala/testing/Show.scala
+++ /dev/null
@@ -1,75 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.testing
-
-/** Classes inheriting trait `Show` can test their member methods using the
- * notation `meth(arg,,1,,, ..., arg,,n,,)`, where `meth` is the name of
- * the method and `arg,,1,,,...,arg,,n,,` are the arguments.
- *
- * The only difference to a normal method call is the leading quote
- * character (`'`). A quoted method call like the one above will produces
- * a legible diagnostic to be printed on [[scala.Console]].
- *
- * It is of the form
- *
- * `meth(arg,,1,,, ..., arg,,n,,)` gives `&lt;result&gt;`
- *
- * where `&lt;result&gt;` is the result of evaluating the call.
- *
- */
-@deprecated("This class will be removed.", "2.10.0")
-trait Show {
-
- /** An implicit definition that adds an apply method to Symbol which forwards to `test`.
- * Prints out diagnostics of method applications.
- */
- implicit class SymApply(f: Symbol) {
- def apply[A](args: A*) {
- println(test(f, args: _*))
- }
- }
-
- @deprecated("use SymApply instead", "2.10.0")
- def symApply(sym: Symbol): SymApply = new SymApply(sym)
-
- /** Apply method with name of given symbol `f` to given arguments and return
- * a result diagnostics.
- */
- def test[A](f: Symbol, args: A*): String = {
- val args1 = args map (_.asInstanceOf[AnyRef])
- def testMethod(meth: java.lang.reflect.Method): String =
- f.name+"("+(args mkString ",")+") gives "+
- {
- try {
- meth.invoke(this, args1: _*)
- } catch {
- case ex: IllegalAccessException => ex
- case ex: IllegalArgumentException => ex
- case ex: java.lang.reflect.InvocationTargetException => ex
- }
- }
- getClass.getMethods.toList filter (_.getName == f.name) match {
- case List() =>
- f.name+" is not defined"
- case List(m) =>
- testMethod(m)
- case ms => // multiple methods, disambiguate by number of arguments
- ms filter (_.getParameterTypes.length == args.length) match {
- case List() =>
- testMethod(ms.head) // go ahead anyway, to get an exception
- case List(m) =>
- testMethod(m)
- case ms =>
- "cannot disambiguate between multiple implementations of "+f.name
- }
- }
- }
-}
diff --git a/src/library/scala/text/Document.scala b/src/library/scala/text/Document.scala
index b74fd152b5..59d5b1bf93 100644
--- a/src/library/scala/text/Document.scala
+++ b/src/library/scala/text/Document.scala
@@ -80,7 +80,7 @@ abstract class Document {
fmt(k, (i + ii, b, d) :: z)
case (i, true, DocBreak) :: z =>
writer write "\n"
- spaces(i);
+ spaces(i)
fmt(i, z)
case (i, false, DocBreak) :: z =>
writer write " "
diff --git a/src/library/scala/throws.scala b/src/library/scala/throws.scala
index 159f1f02f4..5a5dd9a1f5 100644
--- a/src/library/scala/throws.scala
+++ b/src/library/scala/throws.scala
@@ -24,5 +24,5 @@ package scala
* @since 2.1
*/
class throws[T <: Throwable](cause: String = "") extends scala.annotation.StaticAnnotation {
- def this(clazz: Class[T]) = this()
+ def this(clazz: Class[T]) = this("")
}
diff --git a/src/library/scala/util/DynamicVariable.scala b/src/library/scala/util/DynamicVariable.scala
index 52cba6850d..963fe1c497 100644
--- a/src/library/scala/util/DynamicVariable.scala
+++ b/src/library/scala/util/DynamicVariable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util
+package scala
+package util
import java.lang.InheritableThreadLocal
diff --git a/src/library/scala/util/Either.scala b/src/library/scala/util/Either.scala
index dba11ed73c..1ed3f4becb 100644
--- a/src/library/scala/util/Either.scala
+++ b/src/library/scala/util/Either.scala
@@ -8,7 +8,8 @@
-package scala.util
+package scala
+package util
import scala.language.implicitConversions
@@ -21,7 +22,7 @@ import scala.language.implicitConversions
* [[scala.util.Right]] takes the place of [[scala.Some]]. Convention dictates
* that Left is used for failure and Right is used for success.
*
- * For example, you could use ``Either[String, Int]`` to detect whether a
+ * For example, you could use `Either[String, Int]` to detect whether a
* received input is a String or an Int.
*
* {{{
@@ -205,7 +206,7 @@ final case class Right[+A, +B](b: B) extends Either[A, B] {
object Either {
/**
- * Allows use of a ``merge`` method to extract values from Either instances
+ * Allows use of a `merge` method to extract values from Either instances
* regardless of whether they are Left or Right.
*
* {{{
@@ -221,8 +222,6 @@ object Either {
case Right(a) => a
}
}
- @deprecated("use MergeableEither instead", "2.10.0")
- def either2mergeable[A](x: Either[A, A]): MergeableEither[A] = new MergeableEither(x)
/**
* Projects an `Either` into a `Left`.
diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala
deleted file mode 100644
index b78ed2140e..0000000000
--- a/src/library/scala/util/Marshal.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2008-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.util
-
-/**
- * Marshalling of Scala objects using Scala tags.
- *
- * @author Stephane Micheloud
- * @version 1.0
- */
-@deprecated("This class will be removed", "2.10.0")
-object Marshal {
- import java.io._
- import scala.reflect.ClassTag
-
- def dump[A](o: A)(implicit t: ClassTag[A]): Array[Byte] = {
- val ba = new ByteArrayOutputStream(512)
- val out = new ObjectOutputStream(ba)
- out.writeObject(t)
- out.writeObject(o)
- out.close()
- ba.toByteArray()
- }
-
- @throws(classOf[IOException])
- @throws(classOf[ClassCastException])
- @throws(classOf[ClassNotFoundException])
- def load[A](buffer: Array[Byte])(implicit expected: ClassTag[A]): A = {
- val in = new ObjectInputStream(new ByteArrayInputStream(buffer))
- val found = in.readObject.asInstanceOf[ClassTag[_]]
- try {
- found.runtimeClass.asSubclass(expected.runtimeClass)
- in.readObject.asInstanceOf[A]
- } catch {
- case _: ClassCastException =>
- in.close()
- throw new ClassCastException("type mismatch;"+
- "\n found : "+found+
- "\n required: "+expected)
- }
- }
-}
diff --git a/src/library/scala/util/MurmurHash.scala b/src/library/scala/util/MurmurHash.scala
deleted file mode 100644
index a5bc8faf8d..0000000000
--- a/src/library/scala/util/MurmurHash.scala
+++ /dev/null
@@ -1,197 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util
-
-/** An implementation of Austin Appleby's MurmurHash 3.0 algorithm
- * (32 bit version); reference: http://code.google.com/p/smhasher
- *
- * This is the hash used by collections and case classes (including
- * tuples).
- *
- * @author Rex Kerr
- * @version 2.9
- * @since 2.9
- */
-
-import java.lang.Integer.{ rotateLeft => rotl }
-import scala.collection.Iterator
-
-/** A class designed to generate well-distributed non-cryptographic
- * hashes. It is designed to be passed to a collection's foreach method,
- * or can take individual hash values with append. Its own hash code is
- * set equal to the hash code of whatever it is hashing.
- */
-@deprecated("Use the object MurmurHash3 instead.", "2.10.0")
-class MurmurHash[@specialized(Int,Long,Float,Double) T](seed: Int) extends (T => Unit) {
- import MurmurHash._
-
- private var h = startHash(seed)
- private var c = hiddenMagicA
- private var k = hiddenMagicB
- private var hashed = false
- private var hashvalue = h
-
- /** Begin a new hash using the same seed. */
- def reset() {
- h = startHash(seed)
- c = hiddenMagicA
- k = hiddenMagicB
- hashed = false
- }
-
- /** Incorporate the hash value of one item. */
- def apply(t: T) {
- h = extendHash(h,t.##,c,k)
- c = nextMagicA(c)
- k = nextMagicB(k)
- hashed = false
- }
-
- /** Incorporate a known hash value. */
- def append(i: Int) {
- h = extendHash(h,i,c,k)
- c = nextMagicA(c)
- k = nextMagicB(k)
- hashed = false
- }
-
- /** Retrieve the hash value */
- def hash = {
- if (!hashed) {
- hashvalue = finalizeHash(h)
- hashed = true
- }
- hashvalue
- }
- override def hashCode = hash
-}
-
-/** An object designed to generate well-distributed non-cryptographic
- * hashes. It is designed to hash a collection of integers; along with
- * the integers to hash, it generates two magic streams of integers to
- * increase the distribution of repetitive input sequences. Thus,
- * three methods need to be called at each step (to start and to
- * incorporate a new integer) to update the values. Only one method
- * needs to be called to finalize the hash.
- */
-@deprecated("Use the object MurmurHash3 instead.", "2.10.0")
-object MurmurHash {
- // Magic values used for MurmurHash's 32 bit hash.
- // Don't change these without consulting a hashing expert!
- final private val visibleMagic = 0x971e137b
- final private val hiddenMagicA = 0x95543787
- final private val hiddenMagicB = 0x2ad7eb25
- final private val visibleMixer = 0x52dce729
- final private val hiddenMixerA = 0x7b7d159c
- final private val hiddenMixerB = 0x6bce6396
- final private val finalMixer1 = 0x85ebca6b
- final private val finalMixer2 = 0xc2b2ae35
-
- // Arbitrary values used for hashing certain classes
- final private val seedString = 0xf7ca7fd2
- final private val seedArray = 0x3c074a61
-
- /** The first 23 magic integers from the first stream are stored here */
- val storedMagicA =
- Iterator.iterate(hiddenMagicA)(nextMagicA).take(23).toArray
-
- /** The first 23 magic integers from the second stream are stored here */
- val storedMagicB =
- Iterator.iterate(hiddenMagicB)(nextMagicB).take(23).toArray
-
- /** Begin a new hash with a seed value. */
- def startHash(seed: Int) = seed ^ visibleMagic
-
- /** The initial magic integers in the first stream. */
- def startMagicA = hiddenMagicA
-
- /** The initial magic integer in the second stream. */
- def startMagicB = hiddenMagicB
-
- /** Incorporates a new value into an existing hash.
- *
- * @param hash the prior hash value
- * @param value the new value to incorporate
- * @param magicA a magic integer from the stream
- * @param magicB a magic integer from a different stream
- * @return the updated hash value
- */
- def extendHash(hash: Int, value: Int, magicA: Int, magicB: Int) = {
- (hash ^ rotl(value*magicA,11)*magicB)*3 + visibleMixer
- }
-
- /** Given a magic integer from the first stream, compute the next */
- def nextMagicA(magicA: Int) = magicA*5 + hiddenMixerA
-
- /** Given a magic integer from the second stream, compute the next */
- def nextMagicB(magicB: Int) = magicB*5 + hiddenMixerB
-
- /** Once all hashes have been incorporated, this performs a final mixing */
- def finalizeHash(hash: Int) = {
- var i = (hash ^ (hash>>>16))
- i *= finalMixer1
- i ^= (i >>> 13)
- i *= finalMixer2
- i ^= (i >>> 16)
- i
- }
-
- /** Compute a high-quality hash of an array */
- def arrayHash[@specialized T](a: Array[T]) = {
- var h = startHash(a.length * seedArray)
- var c = hiddenMagicA
- var k = hiddenMagicB
- var j = 0
- while (j < a.length) {
- h = extendHash(h, a(j).##, c, k)
- c = nextMagicA(c)
- k = nextMagicB(k)
- j += 1
- }
- finalizeHash(h)
- }
-
- /** Compute a high-quality hash of a string */
- def stringHash(s: String) = {
- var h = startHash(s.length * seedString)
- var c = hiddenMagicA
- var k = hiddenMagicB
- var j = 0
- while (j+1 < s.length) {
- val i = (s.charAt(j)<<16) + s.charAt(j+1);
- h = extendHash(h,i,c,k)
- c = nextMagicA(c)
- k = nextMagicB(k)
- j += 2
- }
- if (j < s.length) h = extendHash(h,s.charAt(j),c,k)
- finalizeHash(h)
- }
-
- /** Compute a hash that is symmetric in its arguments--that is,
- * where the order of appearance of elements does not matter.
- * This is useful for hashing sets, for example.
- */
- def symmetricHash[T](xs: scala.collection.TraversableOnce[T], seed: Int) = {
- var a,b,n = 0
- var c = 1
- xs.seq.foreach(i => {
- val h = i.##
- a += h
- b ^= h
- if (h != 0) c *= h
- n += 1
- })
- var h = startHash(seed * n)
- h = extendHash(h, a, storedMagicA(0), storedMagicB(0))
- h = extendHash(h, b, storedMagicA(1), storedMagicB(1))
- h = extendHash(h, c, storedMagicA(2), storedMagicB(2))
- finalizeHash(h)
- }
-}
diff --git a/src/library/scala/util/Properties.scala b/src/library/scala/util/Properties.scala
index cc145134c4..d2d473bf98 100644
--- a/src/library/scala/util/Properties.scala
+++ b/src/library/scala/util/Properties.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util
+package scala
+package util
import java.io.{ IOException, PrintWriter }
import java.util.jar.Attributes.{ Name => AttributeName }
@@ -72,7 +73,7 @@ private[scala] trait PropertiesTrait {
* it is an RC, Beta, etc. or was built from source, or if the version
* cannot be read.
*/
- val releaseVersion =
+ val releaseVersion =
for {
v <- scalaPropOrNone("maven.version.number")
if !(v endsWith "-SNAPSHOT")
@@ -86,7 +87,7 @@ private[scala] trait PropertiesTrait {
* @return Some(version) if this is a non-final version, None if this
* is a final release or the version cannot be read.
*/
- val developmentVersion =
+ val developmentVersion =
for {
v <- scalaPropOrNone("maven.version.number")
if v endsWith "-SNAPSHOT"
diff --git a/src/library/scala/util/Random.scala b/src/library/scala/util/Random.scala
index 24c4cd7a32..8d68c5be38 100644
--- a/src/library/scala/util/Random.scala
+++ b/src/library/scala/util/Random.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util
+package scala
+package util
import scala.collection.mutable.ArrayBuffer
import scala.collection.generic.CanBuildFrom
@@ -17,7 +18,7 @@ import scala.language.{implicitConversions, higherKinds}
* @author Stephane Micheloud
*
*/
-class Random(val self: java.util.Random) {
+class Random(val self: java.util.Random) extends AnyRef with Serializable {
/** Creates a new random number generator using a single long seed. */
def this(seed: Long) = this(new java.util.Random(seed))
@@ -117,7 +118,7 @@ class Random(val self: java.util.Random) {
swap(n - 1, k)
}
- (bf(xs) ++= buf).result
+ (bf(xs) ++= buf).result()
}
/** Returns a Stream of pseudorandomly chosen alphanumeric characters,
diff --git a/src/library/scala/util/Try.scala b/src/library/scala/util/Try.scala
index 7749543caa..89db57a55e 100644
--- a/src/library/scala/util/Try.scala
+++ b/src/library/scala/util/Try.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util
+package scala
+package util
import scala.collection.Seq
import scala.util.control.NonFatal
@@ -164,7 +165,7 @@ object Try {
}
-final case class Failure[+T](val exception: Throwable) extends Try[T] {
+final case class Failure[+T](exception: Throwable) extends Try[T] {
def isFailure: Boolean = true
def isSuccess: Boolean = false
def recoverWith[U >: T](f: PartialFunction[Throwable, Try[U]]): Try[U] =
diff --git a/src/library/scala/util/control/Breaks.scala b/src/library/scala/util/control/Breaks.scala
index 89e1b58d95..5524b10afa 100644
--- a/src/library/scala/util/control/Breaks.scala
+++ b/src/library/scala/util/control/Breaks.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.control
+package scala
+package util.control
/** A class that can be instantiated for the break control abstraction.
* Example usage:
diff --git a/src/library/scala/util/control/ControlThrowable.scala b/src/library/scala/util/control/ControlThrowable.scala
index 33c90c5815..7ed3d95cd3 100644
--- a/src/library/scala/util/control/ControlThrowable.scala
+++ b/src/library/scala/util/control/ControlThrowable.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.control
+package scala
+package util.control
/** A marker trait indicating that the `Throwable` it is mixed into is
* intended for flow control.
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala
index b97914c4b1..be6d03a145 100644
--- a/src/library/scala/util/control/Exception.scala
+++ b/src/library/scala/util/control/Exception.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util
+package scala
+package util
package control
import scala.collection.immutable.List
diff --git a/src/library/scala/util/control/NonFatal.scala b/src/library/scala/util/control/NonFatal.scala
index 0d8cdfbace..11fb988e8e 100644
--- a/src/library/scala/util/control/NonFatal.scala
+++ b/src/library/scala/util/control/NonFatal.scala
@@ -6,12 +6,13 @@
** |/ **
\* */
-package scala.util.control
+package scala
+package util.control
/**
* Extractor of non-fatal Throwables. Will not match fatal errors like `VirtualMachineError`
* (for example, `OutOfMemoryError`, a subclass of `VirtualMachineError`), `ThreadDeath`,
- * `LinkageError`, `InterruptedException`, `ControlThrowable`, or `NotImplementedError`.
+ * `LinkageError`, `InterruptedException`, `ControlThrowable`.
* However, `StackOverflowError` is matched, i.e. considered non-fatal.
*
* Note that [[scala.util.control.ControlThrowable]], an internal Throwable, is not matched by
@@ -35,7 +36,7 @@ object NonFatal {
def apply(t: Throwable): Boolean = t match {
case _: StackOverflowError => true // StackOverflowError ok even though it is a VirtualMachineError
// VirtualMachineError includes OutOfMemoryError and other fatal errors
- case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable | _: NotImplementedError => false
+ case _: VirtualMachineError | _: ThreadDeath | _: InterruptedException | _: LinkageError | _: ControlThrowable => false
case _ => true
}
/**
diff --git a/src/library/scala/util/control/TailCalls.scala b/src/library/scala/util/control/TailCalls.scala
index 955cee7657..ba3044c718 100644
--- a/src/library/scala/util/control/TailCalls.scala
+++ b/src/library/scala/util/control/TailCalls.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.control
+package scala
+package util.control
/** Methods exported by this object implement tail calls via trampolining.
* Tail calling methods have to return their result using `done` or call the
diff --git a/src/library/scala/util/grammar/HedgeRHS.scala b/src/library/scala/util/grammar/HedgeRHS.scala
deleted file mode 100644
index d1c11a2f99..0000000000
--- a/src/library/scala/util/grammar/HedgeRHS.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.util.grammar
-
-@deprecated("This class will be removed", "2.10.0")
-abstract class HedgeRHS
-
-/** Right hand side of a hedge production, deriving a single tree. */
-@deprecated("This class will be removed", "2.10.0")
-case class ConsRHS(tnt: Int, hnt: Int) extends HedgeRHS
-
-/** Right hand side of a hedge production, deriving any hedge. */
-@deprecated("This class will be removed", "2.10.0")
-case object AnyHedgeRHS extends HedgeRHS
-
-/** Right hand side of a hedge production, deriving the empty hedge. */
-@deprecated("This class will be removed", "2.10.0")
-case object EmptyHedgeRHS extends HedgeRHS
diff --git a/src/library/scala/util/grammar/TreeRHS.scala b/src/library/scala/util/grammar/TreeRHS.scala
deleted file mode 100644
index ee72ea982d..0000000000
--- a/src/library/scala/util/grammar/TreeRHS.scala
+++ /dev/null
@@ -1,22 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.util.grammar
-
-/** Right hand side of a tree production. */
-@deprecated("This class will be removed", "2.10.0")
-abstract class TreeRHS
-
-/** Right hand side of a tree production, labelled with a letter from an alphabet. */
-@deprecated("This class will be removed", "2.10.0")
-case class LabelledRHS[A](label: A, hnt: Int) extends TreeRHS
-
-@deprecated("This class will be removed", "2.10.0")
-case object AnyTreeRHS extends TreeRHS
diff --git a/src/library/scala/util/hashing/ByteswapHashing.scala b/src/library/scala/util/hashing/ByteswapHashing.scala
index a96945788c..470479725b 100644
--- a/src/library/scala/util/hashing/ByteswapHashing.scala
+++ b/src/library/scala/util/hashing/ByteswapHashing.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.hashing
+package scala
+package util.hashing
@@ -16,20 +17,20 @@ package scala.util.hashing
/** A fast multiplicative hash by Phil Bagwell.
*/
final class ByteswapHashing[T] extends Hashing[T] {
-
+
def hash(v: T) = byteswap32(v.##)
-
+
}
object ByteswapHashing {
-
+
private class Chained[T](h: Hashing[T]) extends Hashing[T] {
def hash(v: T) = byteswap32(h.hash(v))
}
-
+
/** Composes another `Hashing` with the Byteswap hash.
*/
def chain[T](h: Hashing[T]): Hashing[T] = new Chained(h)
-
+
}
diff --git a/src/library/scala/util/hashing/Hashing.scala b/src/library/scala/util/hashing/Hashing.scala
index b57f858bed..2b72c1dbe3 100644
--- a/src/library/scala/util/hashing/Hashing.scala
+++ b/src/library/scala/util/hashing/Hashing.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.hashing
+package scala
+package util.hashing
import scala.annotation.implicitNotFound
diff --git a/src/library/scala/util/hashing/MurmurHash3.scala b/src/library/scala/util/hashing/MurmurHash3.scala
index 0aa7e6f1cb..c38d0f4da5 100644
--- a/src/library/scala/util/hashing/MurmurHash3.scala
+++ b/src/library/scala/util/hashing/MurmurHash3.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.hashing
+package scala
+package util.hashing
import java.lang.Integer.{ rotateLeft => rotl }
@@ -274,12 +275,4 @@ object MurmurHash3 extends MurmurHash3 {
finalizeHash(h, n)
}
*/
-
- @deprecated("Use unorderedHash", "2.10.0")
- final def symmetricHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = symmetricSeed): Int =
- unorderedHash(xs.seq, seed)
-
- @deprecated("Use orderedHash", "2.10.0")
- final def traversableHash[T](xs: scala.collection.GenTraversableOnce[T], seed: Int = traversableSeed): Int =
- orderedHash(xs.seq, seed)
}
diff --git a/src/library/scala/util/hashing/package.scala b/src/library/scala/util/hashing/package.scala
index 7d38f151f9..2c8e0154fc 100644
--- a/src/library/scala/util/hashing/package.scala
+++ b/src/library/scala/util/hashing/package.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util
+package scala
+package util
@@ -14,7 +15,7 @@ package scala.util
package object hashing {
-
+
/** Fast multiplicative hash with a nice distribution.
*/
def byteswap32(v: Int): Int = {
@@ -22,7 +23,7 @@ package object hashing {
hc = java.lang.Integer.reverseBytes(hc)
hc * 0x9e3775cd
}
-
+
/** Fast multiplicative hash with a nice distribution
* for 64-bit values.
*/
@@ -31,5 +32,5 @@ package object hashing {
hc = java.lang.Long.reverseBytes(hc)
hc * 0x9e3775cd9e3775cdL
}
-
+
}
diff --git a/src/library/scala/util/logging/ConsoleLogger.scala b/src/library/scala/util/logging/ConsoleLogger.scala
deleted file mode 100644
index 74f058b4ec..0000000000
--- a/src/library/scala/util/logging/ConsoleLogger.scala
+++ /dev/null
@@ -1,26 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-
-package scala.util.logging
-
-/**
- * The trait `ConsoleLogger` is mixed into a concrete class who
- * has class `Logged` among its base classes.
- *
- * @author Burak Emir
- * @version 1.0
- */
-@deprecated("This class will be removed.", "2.10.0")
-trait ConsoleLogger extends Logged {
-
- /** logs argument to Console using [[scala.Console.println]]
- */
- override def log(msg: String): Unit = Console.println(msg)
-}
diff --git a/src/library/scala/util/logging/Logged.scala b/src/library/scala/util/logging/Logged.scala
deleted file mode 100644
index f2661d3206..0000000000
--- a/src/library/scala/util/logging/Logged.scala
+++ /dev/null
@@ -1,33 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.logging
-
-/** Mixing in Logged indicates that a class provides support for logging.
- *
- * For instance:
- * {{{
- * // The developer of the library writes:
- * class MyClass extends Logged {
- * // do stuff, call log
- * }
- *
- * // The user of the library instantiates:
- * val x = new MyClass() with ConsoleLogger
- * }}}
- * and the logging is sent to the [[scala.util.logging.ConsoleLogger]] object.
- */
-@deprecated("This class will be removed.", "2.10.0")
-trait Logged {
- /** This method should log the message given as argument somewhere
- * as a side-effect.
- *
- * @param msg message to be logged
- */
- def log(msg: String): Unit = {}
-}
diff --git a/src/library/scala/util/matching/Regex.scala b/src/library/scala/util/matching/Regex.scala
index 716d746552..8eac0a2520 100644
--- a/src/library/scala/util/matching/Regex.scala
+++ b/src/library/scala/util/matching/Regex.scala
@@ -28,7 +28,8 @@
* into a [[java.lang.String]].
*
*/
-package scala.util.matching
+package scala
+package util.matching
import scala.collection.AbstractIterator
import java.util.regex.{ Pattern, Matcher }
@@ -131,7 +132,7 @@ import java.util.regex.{ Pattern, Matcher }
* @author Martin Odersky
* @version 1.1, 29/01/2008
*
- * @param regex A string representing a regular expression
+ * @param pattern The compiled pattern
* @param groupNames A mapping from names to indices in capture groups
*
* @define replacementString
@@ -144,49 +145,81 @@ import java.util.regex.{ Pattern, Matcher }
* to automatically escape these characters.
*/
@SerialVersionUID(-2094783597747625537L)
-class Regex(regex: String, groupNames: String*) extends Serializable {
+class Regex private[matching](val pattern: Pattern, groupNames: String*) extends Serializable {
outer =>
import Regex._
- /** The compiled pattern */
- val pattern = Pattern.compile(regex)
+ /**
+ * @param regex A string representing a regular expression
+ * @param groupNames A mapping from names to indices in capture groups
+ */
+ def this(regex: String, groupNames: String*) = this(Pattern.compile(regex), groupNames: _*)
- /** Tries to match target (whole match) and returns the matching subgroups.
- * if the pattern has no subgroups, then it returns an empty list on a
- * successful match.
- *
- * Note, however, that if some subgroup has not been matched, a `null` will
- * be returned for that subgroup.
+ /** Tries to match a [[java.lang.CharSequence]].
+ * If the match succeeds, the result is a list of the matching
+ * groups (or a `null` element if a group did not match any input).
+ * If the pattern specifies no groups, then the result will be an empty list
+ * on a successful match.
*
+ * This method attempts to match the entire input by default; to find the next
+ * matching subsequence, use an unanchored Regex.
+
* For example:
*
* {{{
* val p1 = "ab*c".r
- * val p2 = "a(b*)c".r
- *
* val p1Matches = "abbbc" match {
* case p1() => true
* case _ => false
* }
- *
+ * val p2 = "a(b*)c".r
* val numberOfB = "abbbc" match {
* case p2(b) => Some(b.length)
* case _ => None
* }
+ * val p3 = "b*".r.unanchored
+ * val p3Matches = "abbbc" match {
+ * case p3() => true
+ * case _ => false
+ * }
* }}}
*
+ * @param s The string to match
+ * @return The matches
+ */
+ def unapplySeq(s: CharSequence): Option[Seq[String]] = {
+ val m = pattern matcher s
+ if (runMatcher(m)) Some(1 to m.groupCount map m.group)
+ else None
+ }
+
+ /** Tries to match on a [[scala.util.matching.Regex.Match]].
+ * A previously failed match results in None.
+ * If a successful match was made against the current pattern, then that result is used.
+ * Otherwise, this Regex is applied to the previously matched input,
+ * and the result of that match is used.
+ */
+ def unapplySeq(m: Match): Option[Seq[String]] =
+ if (m.matched == null) None
+ else if (m.matcher.pattern == this.pattern) Some(1 to m.groupCount map m.group)
+ else unapplySeq(m.matched)
+
+ /** Tries to match target.
* @param target The string to match
* @return The matches
*/
+ @deprecated("Extracting a match result from anything but a CharSequence or Match is deprecated", "2.11.0")
def unapplySeq(target: Any): Option[List[String]] = target match {
case s: CharSequence =>
val m = pattern matcher s
if (runMatcher(m)) Some((1 to m.groupCount).toList map m.group)
else None
- case m: Match => unapplySeq(m.matched)
- case _ => None
+ case m: Match => unapplySeq(m.matched)
+ case _ => None
}
+
+ // @see UnanchoredRegex
protected def runMatcher(m: Matcher) = m.matches()
/** Return all matches of this regexp in given character sequence as a [[scala.util.matching.Regex.MatchIterator]],
@@ -200,7 +233,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return A [[scala.util.matching.Regex.MatchIterator]] of all matches.
* @example {{{for (words <- """\w+""".r findAllIn "A simple example.") yield words}}}
*/
- def findAllIn(source: java.lang.CharSequence) = new Regex.MatchIterator(source, this, groupNames)
+ def findAllIn(source: CharSequence) = new Regex.MatchIterator(source, this, groupNames)
/** Return all matches of this regexp in given character sequence as a
@@ -210,12 +243,12 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return A [[scala.collection.Iterator]] of [[scala.util.matching.Regex.Match]] for all matches.
* @example {{{for (words <- """\w+""".r findAllMatchIn "A simple example.") yield words.start}}}
*/
- def findAllMatchIn(source: java.lang.CharSequence): Iterator[Match] = {
+ def findAllMatchIn(source: CharSequence): Iterator[Match] = {
val matchIterator = findAllIn(source)
new Iterator[Match] {
def hasNext = matchIterator.hasNext
def next: Match = {
- matchIterator.next;
+ matchIterator.next()
new Match(matchIterator.source, matchIterator.matcher, matchIterator.groupNames).force
}
}
@@ -228,7 +261,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return An [[scala.Option]] of the first matching string in the text.
* @example {{{"""\w+""".r findFirstIn "A simple example." foreach println // prints "A"}}}
*/
- def findFirstIn(source: java.lang.CharSequence): Option[String] = {
+ def findFirstIn(source: CharSequence): Option[String] = {
val m = pattern.matcher(source)
if (m.find) Some(m.group) else None
}
@@ -245,7 +278,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return A [[scala.Option]] of [[scala.util.matching.Regex.Match]] of the first matching string in the text.
* @example {{{("""[a-z]""".r findFirstMatchIn "A simple example.") map (_.start) // returns Some(2), the index of the first match in the text}}}
*/
- def findFirstMatchIn(source: java.lang.CharSequence): Option[Match] = {
+ def findFirstMatchIn(source: CharSequence): Option[Match] = {
val m = pattern.matcher(source)
if (m.find) Some(new Match(source, m, groupNames)) else None
}
@@ -262,7 +295,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return A [[scala.Option]] of the matched prefix.
* @example {{{"""[a-z]""".r findPrefixOf "A simple example." // returns None, since the text does not begin with a lowercase letter}}}
*/
- def findPrefixOf(source: java.lang.CharSequence): Option[String] = {
+ def findPrefixOf(source: CharSequence): Option[String] = {
val m = pattern.matcher(source)
if (m.lookingAt) Some(m.group) else None
}
@@ -279,7 +312,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return A [[scala.Option]] of the [[scala.util.matching.Regex.Match]] of the matched string.
* @example {{{"""\w+""".r findPrefixMatchOf "A simple example." map (_.after) // returns Some(" simple example.")}}}
*/
- def findPrefixMatchOf(source: java.lang.CharSequence): Option[Match] = {
+ def findPrefixMatchOf(source: CharSequence): Option[Match] = {
val m = pattern.matcher(source)
if (m.lookingAt) Some(new Match(source, m, groupNames)) else None
}
@@ -293,7 +326,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return The resulting string
* @example {{{"""\d+""".r replaceAllIn ("July 15", "<NUMBER>") // returns "July <NUMBER>"}}}
*/
- def replaceAllIn(target: java.lang.CharSequence, replacement: String): String = {
+ def replaceAllIn(target: CharSequence, replacement: String): String = {
val m = pattern.matcher(target)
m.replaceAll(replacement)
}
@@ -316,7 +349,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @param replacer The function which maps a match to another string.
* @return The target string after replacements.
*/
- def replaceAllIn(target: java.lang.CharSequence, replacer: Match => String): String = {
+ def replaceAllIn(target: CharSequence, replacer: Match => String): String = {
val it = new Regex.MatchIterator(target, this, groupNames).replacementData
it foreach (md => it replace replacer(md))
it.replaced
@@ -343,7 +376,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @param replacer The function which optionally maps a match to another string.
* @return The target string after replacements.
*/
- def replaceSomeIn(target: java.lang.CharSequence, replacer: Match => Option[String]): String = {
+ def replaceSomeIn(target: CharSequence, replacer: Match => Option[String]): String = {
val it = new Regex.MatchIterator(target, this, groupNames).replacementData
for (matchdata <- it ; replacement <- replacer(matchdata))
it replace replacement
@@ -359,7 +392,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @param replacement The string that will replace the match
* @return The resulting string
*/
- def replaceFirstIn(target: java.lang.CharSequence, replacement: String): String = {
+ def replaceFirstIn(target: CharSequence, replacement: String): String = {
val m = pattern.matcher(target)
m.replaceFirst(replacement)
}
@@ -370,7 +403,7 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
* @return The array of strings computed by splitting the
* input around matches of this regexp
*/
- def split(toSplit: java.lang.CharSequence): Array[String] =
+ def split(toSplit: CharSequence): Array[String] =
pattern.split(toSplit)
/** Create a new Regex with the same pattern, but no requirement that
@@ -390,9 +423,11 @@ class Regex(regex: String, groupNames: String*) extends Serializable {
*
* @return The new unanchored regex
*/
- def unanchored: UnanchoredRegex = new Regex(regex, groupNames: _*) with UnanchoredRegex { override def anchored = outer }
+ def unanchored: UnanchoredRegex = new Regex(pattern, groupNames: _*) with UnanchoredRegex { override def anchored = outer }
def anchored: Regex = this
+ def regex: String = pattern.pattern
+
/** The string defining the regular expression */
override def toString = regex
}
@@ -421,7 +456,7 @@ object Regex {
trait MatchData {
/** The source from where the match originated */
- val source: java.lang.CharSequence
+ val source: CharSequence
/** The names of the groups, or some empty sequence if one defined */
val groupNames: Seq[String]
@@ -459,25 +494,25 @@ object Regex {
/** The char sequence before first character of match,
* or `null` if nothing was matched */
- def before: java.lang.CharSequence =
+ def before: CharSequence =
if (start >= 0) source.subSequence(0, start)
else null
/** The char sequence before first character of match in group `i`,
* or `null` if nothing was matched for that group */
- def before(i: Int): java.lang.CharSequence =
+ def before(i: Int): CharSequence =
if (start(i) >= 0) source.subSequence(0, start(i))
else null
/** Returns char sequence after last character of match,
* or `null` if nothing was matched */
- def after: java.lang.CharSequence =
+ def after: CharSequence =
if (end >= 0) source.subSequence(end, source.length)
else null
/** The char sequence after last character of match in group `i`,
* or `null` if nothing was matched for that group */
- def after(i: Int): java.lang.CharSequence =
+ def after(i: Int): CharSequence =
if (end(i) >= 0) source.subSequence(end(i), source.length)
else null
@@ -501,8 +536,8 @@ object Regex {
/** Provides information about a succesful match.
*/
- class Match(val source: java.lang.CharSequence,
- matcher: Matcher,
+ class Match(val source: CharSequence,
+ private[matching] val matcher: Matcher,
val groupNames: Seq[String]) extends MatchData {
/** The index of the first matched character */
@@ -563,7 +598,7 @@ object Regex {
/** A class to step through a sequence of regex matches
*/
- class MatchIterator(val source: java.lang.CharSequence, val regex: Regex, val groupNames: Seq[String])
+ class MatchIterator(val source: CharSequence, val regex: Regex, val groupNames: Seq[String])
extends AbstractIterator[String] with Iterator[String] with MatchData { self =>
protected[Regex] val matcher = regex.pattern.matcher(source)
@@ -602,14 +637,14 @@ object Regex {
/** Convert to an iterator that yields MatchData elements instead of Strings */
def matchData: Iterator[Match] = new AbstractIterator[Match] {
def hasNext = self.hasNext
- def next = { self.next; new Match(source, matcher, groupNames).force }
+ def next = { self.next(); new Match(source, matcher, groupNames).force }
}
/** Convert to an iterator that yields MatchData elements instead of Strings and has replacement support */
private[matching] def replacementData = new AbstractIterator[Match] with Replacement {
def matcher = self.matcher
def hasNext = self.hasNext
- def next = { self.next; new Match(source, matcher, groupNames).force }
+ def next = { self.next(); new Match(source, matcher, groupNames).force }
}
}
@@ -620,7 +655,7 @@ object Regex {
private[matching] trait Replacement {
protected def matcher: Matcher
- private var sb = new java.lang.StringBuffer
+ private val sb = new java.lang.StringBuffer
def replaced = {
val newsb = new java.lang.StringBuffer(sb)
diff --git a/src/library/scala/util/parsing/ast/AbstractSyntax.scala b/src/library/scala/util/parsing/ast/AbstractSyntax.scala
deleted file mode 100644
index 30b20d71c6..0000000000
--- a/src/library/scala/util/parsing/ast/AbstractSyntax.scala
+++ /dev/null
@@ -1,32 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.parsing.ast
-
-import scala.util.parsing.input.Positional
-
-/** This component provides the core abstractions for representing an Abstract Syntax Tree
- *
- * @author Adriaan Moors
- */
-@deprecated("This class will be removed", "2.10.0")
-trait AbstractSyntax {
- /** The base class for elements of the abstract syntax tree.
- */
- trait Element extends Positional
-
- /** The base class for elements in the AST that represent names [[scala.util.parsing.ast.Binders]].
- */
- trait NameElement extends Element {
- def name: String
- override def equals(that: Any): Boolean = that match {
- case n: NameElement => n.name == name
- case _ => false
- }
- }
-}
diff --git a/src/library/scala/util/parsing/ast/Binders.scala b/src/library/scala/util/parsing/ast/Binders.scala
deleted file mode 100644
index a6ad1907c2..0000000000
--- a/src/library/scala/util/parsing/ast/Binders.scala
+++ /dev/null
@@ -1,347 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.parsing.ast
-
-import scala.collection.AbstractIterable
-import scala.collection.mutable
-import scala.language.implicitConversions
-
-//DISCLAIMER: this code is highly experimental!
-
- // TODO: avoid clashes when substituting
- // TODO: check binders in the same scope are distinct
-
-/** This trait provides the core ''Scrap-Your-Boilerplate'' abstractions as
- * well as implementations for common datatypes.
- *
- * (Based on Ralf Lämmel's [[http://homepages.cwi.nl/~ralf/syb3/ SYB papers]].)
- *
- * @author Adriaan Moors
- */
-@deprecated("This class will be removed", "2.10.0")
-trait Mappable {
- trait Mapper { def apply[T <% Mappable[T]](x: T): T } /* TODO: having type `Forall T. T => T` is too strict:
- sometimes we want to allow `Forall T >: precision. T => T` for some type `precision`, so that,
- beneath a certain threshold, we have some leeway.
- concretely: to use gmap for substitution, we simply require that ast nodes are mapped to ast nodes,
- we can't require that the type is preserved precisely: a Name may map to e.g., a MethodCall
- */
-
- trait Mappable[T] {
- // one-layer traversal
- def gmap(f: Mapper): T
- // everywhere f x = f (gmapT (everywhere f) x)
- def everywhere(f: Mapper)(implicit c: T => Mappable[T]): T =
- f(gmap(new Mapper { def apply[T <% Mappable[T]](x: T): T = x.everywhere(f)}))
- }
-
- implicit def StringIsMappable(s: String): Mappable[String] =
- new Mappable[String] {
- def gmap(f: Mapper): String = f(s)
- }
-
- implicit def ListIsMappable[t <% Mappable[t]](xs: List[t]): Mappable[List[t]] =
- new Mappable[List[t]] {
- def gmap(f: Mapper): List[t] = (for (x <- xs) yield f(x)).toList
- }
-
- implicit def OptionIsMappable[t <% Mappable[t]](xs: Option[t]): Mappable[Option[t]] =
- new Mappable[Option[t]] {
- def gmap(f: Mapper): Option[t] = (for (x <- xs) yield f(x))
- }
-}
-
-/** This component provides functionality for enforcing variable binding
- * during parse-time.
- *
- * When parsing simple languages, like Featherweight Scala, these parser
- * combinators will fully enforce the binding discipline. When names are
- * allowed to be left unqualified, these mechanisms would have to be
- * complemented by an extra phase that resolves names that couldn't be
- * resolved using the naive binding rules. (Maybe some machinery to
- * model `implicit` binders (e.g., `this` and imported qualifiers)
- * and selection on a binder will suffice?)
- *
- * @author Adriaan Moors
- */
-trait Binders extends AbstractSyntax with Mappable {
- /** A `Scope` keeps track of one or more syntactic elements that represent bound names.
- * The elements it contains share the same scope and must all be distinct, as determined by `==`.
- *
- * A `NameElement` `n` in the AST that is conceptually bound by a `Scope` `s`, is replaced by a
- * `BoundElement(n, s)`. (For example, in `val x:Int=x+1`, the first `x` is modelled by a
- * Scope `s` that contains `x` and the second `x` is represented by a `BoundElement(x, s)`)
- * The term (`x+1`) in scope of the Scope becomes an `UnderBinder(s, x+1)`.
- *
- * A `NameElement` `n` is bound by a `Scope` `s` if it is wrapped as a `BoundElement(n, s)`, and
- * `s` has a binder element that is semantically equal (`equals` or `==`) to `n`.
- *
- * A `Scope` is represented textually by its list of binder elements, followed by the scope's `id`.
- * For example: `[x, y]!1` represents the scope with `id` `1` and binder elements `x` and `y`.
- * (`id` is solely used for this textual representation.)
- */
- class Scope[binderType <: NameElement] extends AbstractIterable[binderType] with Iterable[binderType] {
- private val substitution: mutable.Map[binderType, Element] =
- new mutable.LinkedHashMap[binderType, Element] // a LinkedHashMap is ordered by insertion order -- important!
-
- /** Returns a unique number identifying this Scope (only used for representation purposes). */
- val id: Int = _Binder.genId
-
- /** Returns the binders in this scope.
- * For a typical let-binding, this is just the variable name. For an argument list to a method body,
- * there is one binder per formal argument.
- */
- def iterator = substitution.keysIterator
-
- /** Return the `i`th binder in this scope. */
- def apply(i: Int): binderType = this.iterator.toList(i)
-
- /** Returns true if this container has a binder equal (as determined by `==`) to `b`. */
- def binds(b: binderType): Boolean = substitution.contains(b)
-
- def indexFor(b: binderType): Option[Int] = {
- val iter = this.iterator.zipWithIndex
- for ((that, count) <- iter) {
- if (that.name == b.name) // TODO: why do name equals and structural equals differ?
- return Some(count + 1)
- else
- Console.println(that+"!="+b)
- }
-
- None
- }
-
- /** Adds a new binder, for example the variable name in a local variable declaration.
- *
- * @param b a new binder that is distinct from the existing binders in this scope,
- * and shares their conceptual scope. `canAddBinder(b)` must hold.
- * @return `binds(b)` and `getElementFor(b) eq b` will hold.
- */
- def addBinder(b: binderType) { substitution += Pair(b, b) }
-
- // TODO: strengthen this condition so that no binders may be added after this scope has been
- // linked to its `UnderBinder` (i.e., while parsing, BoundElements may be added to the Scope
- // associated to the UnderBinder, but after that, no changes are allowed, except for substitution)?
- /** `canAddElement` indicates whether `b` may be added to this scope.
- *
- *
- * @return true if `b` had not been added yet
- */
- def canAddBinder(b: binderType): Boolean = !binds(b)
-
- /** ''Replaces'' the bound occurrences of a contained binder by their new value.
- * The bound occurrences of `b` are not actually replaced; the scope keeps track
- * of a substitution that maps every binder to its current value. Since a `BoundElement` is
- * a proxy for the element it is bound to by its binder, `substitute` may thus be thought of
- * as replacing all the bound occurrences of the given binder `b` by their new value `value`.
- *
- * @param b the binder whose bound occurrences should be given a new value. `binds(b)` must hold.
- * @param value the new value for the bound occurrences of `b`
- * @return `getElementFor(b) eq value` will hold.
- */
- def substitute(b: binderType, value: Element): Unit = substitution(b) = value
-
- /** Returns the current value for the bound occurrences of `b`.
- *
- * @param b the contained binder whose current value should be returned `binds(b)` must hold.
- */
- def getElementFor(b: binderType): Element = substitution(b)
-
- override def toString: String = this.iterator.toList.mkString("[",", ","]")+"!"+id // TODO show substitution?
-
- /** Returns a list of strings that represent the binder elements, each tagged with this scope's id. */
- def bindersToString: List[String] = (for(b <- this.iterator) yield b+"!"+id).toList
-
- /** Return a new inheriting scope that won't check whether binding is respected until the scope is left (so as to support forward references). */
- def allowForwardRef: Scope[binderType] = this // TODO
-
- /** Return a nested scope -- binders entered into it won't be visible in this scope, but if this scope allows forward references,
- * the binding in the returned scope also does, and thus the check that all variables are bound is deferred until this scope is left.
- */
- def nested: Scope[binderType] = this // TODO
-
- def onEnter() {}
- def onLeft() {}
- }
-
-
- trait BindingSensitive {
- // would like to specify this as one method:
- // def alpha_==[t <: NameElement](other: BoundElement[t]): Boolean
- // def alpha_==[bt <: binderType, st <: elementT](other: UnderBinder[bt, st]): Boolean
- }
-
- /** A `BoundElement` is bound in a certain scope `scope`, which keeps track of the actual element that
- * `el` stands for.
- *
- * A `BoundElement` is represented textually by its bound element, followed by its scope's `id`.
- * For example: `x@1` represents the variable `x` that is bound in the scope with `id` `1`.
- *
- * @note `scope.binds(el)` holds before and after.
- */
- case class BoundElement[boundElement <: NameElement](el: boundElement, scope: Scope[boundElement]) extends NameElement with Proxy with BindingSensitive {
- /** Returns the element this `BoundElement` stands for.
- * The `Proxy` trait ensures `equals`, `hashCode` and `toString` are forwarded to
- * the result of this method.
- */
- def self: Element = scope.getElementFor(el)
-
- def name = self.asInstanceOf[NameElement].name // TODO: this is only safe when substituted to a NameElement, which certainly isn't required -- I want dynamic inheritance! :)
-
- // decorate element's representation with the id of the scope it's bound in
- override def toString: String = super.toString+"@"+scope.id
-
- def alpha_==[t <: NameElement](other: BoundElement[t]): Boolean = scope.indexFor(el) == other.scope.indexFor(other.el)
- }
-
- /** A variable that escaped its scope (i.e., a free variable) -- we don't deal very well with these yet. */
- class UnboundElement[N <: NameElement](private val el: N) extends NameElement {
- def name = el.name+"@??"
- }
-
- // this is useless, as Element is a supertype of BoundElement --> the coercion will never be inferred
- // if we knew a more specific type for the element that the bound element represents, this could make sense
- // implicit def BoundElementProxy[t <: NameElement](e: BoundElement[t]): Element = e.self
-
- /** Represents an element with variables that are bound in a certain scope. */
- class UnderBinder[binderType <: NameElement, elementT <% Mappable[elementT]](val scope: Scope[binderType], private[Binders] val element: elementT) extends Element with BindingSensitive {
- override def toString: String = "(" + scope.toString + ") in { "+element.toString+" }"
-
- /** Alpha-equivalence -- TODO
- * Returns true if the `element` of the `other` `UnderBinder` is equal to this `element` up to alpha-conversion.
- *
- * That is, regular equality is used for all elements but `BoundElement`s: such an element is
- * equal to a `BoundElement` in `other` if their binders are equal. Binders are equal if they
- * are at the same index in their respective scope.
- *
- * Example:
- * {{{
- * UnderBinder([x, y]!1, x@1) alpha_== UnderBinder([a, b]!2, a@2)
- * ! (UnderBinder([x, y]!1, y@1) alpha_== UnderBinder([a, b]!2, a@2))
- * }}}
- */
- /*def alpha_==[bt <: binderType, st <: elementT](other: UnderBinder[bt, st]): Boolean = {
- var result = true
-
- // TODO: generic zip or gmap2
- element.gmap2(other.element, new Mapper2 {
- def apply[s <% Mappable[s], t <% Mappable[t]](x :{s, t}): {s, t} = x match {
- case {be1: BoundElement[_], be2: BoundElement[_]} => result == result && be1.alpha_==(be2) // monadic gmap (cheating using state directly)
- case {ub1: UnderBinder[_, _], ub2: UnderBinder[_, _]} => result == result && be1.alpha_==(be2)
- case {a, b} => result == result && a.equals(b)
- }; x
- })
- }*/
-
- def cloneElementWithSubst(subst: Map[NameElement, NameElement]) = element.gmap(new Mapper { def apply[t <% Mappable[t]](x :t): t = x match{
- case substable: NameElement if subst.contains(substable) => subst.get(substable).asInstanceOf[t] // TODO: wrong... substitution is not (necessarily) the identity function
- //Console.println("substed: "+substable+"-> "+subst.get(substable)+")");
- case x => x // Console.println("subst: "+x+"(keys: "+subst.keys+")");x
- }})
-
- // TODO
- def cloneElementNoBoundElements = element.gmap(new Mapper { def apply[t <% Mappable[t]](x :t): t = x match{
- case BoundElement(el, _) => new UnboundElement(el).asInstanceOf[t] // TODO: precision stuff
- case x => x
- }})
-
- def extract: elementT = cloneElementNoBoundElements
- def extract(subst: Map[NameElement, NameElement]): elementT = cloneElementWithSubst(subst)
-
- /** Get a string representation of element, normally we don't allow direct access to element, but just getting a string representation is ok. */
- def elementToString: String = element.toString
- }
-
- //SYB type class instances
- implicit def UnderBinderIsMappable[bt <: NameElement <% Mappable[bt], st <% Mappable[st]](ub: UnderBinder[bt, st]): Mappable[UnderBinder[bt, st]] =
- new Mappable[UnderBinder[bt, st]] {
- def gmap(f: Mapper): UnderBinder[bt, st] = UnderBinder(f(ub.scope), f(ub.element))
- }
-
- implicit def ScopeIsMappable[bt <: NameElement <% Mappable[bt]](scope: Scope[bt]): Mappable[Scope[bt]] =
- new Mappable[Scope[bt]] {
- def gmap(f: Mapper): Scope[bt] = { val newScope = new Scope[bt]()
- for(b <- scope) newScope.addBinder(f(b))
- newScope
- }
- }
-
- implicit def NameElementIsMappable(self: NameElement): Mappable[NameElement] = new Mappable[NameElement] {
- def gmap(f: Mapper): NameElement = self match {
- case BoundElement(el, scope) => BoundElement(f(el), f(scope))
- case _ => UserNameElementIsMappable(self).gmap(f)
- }
- }
-
- def UserNameElementIsMappable[t <: NameElement](self: t): Mappable[t]
-
- object UnderBinder {
- def apply[binderType <: NameElement, elementT <% Mappable[elementT]](scope: Scope[binderType], element: elementT) = new UnderBinder(scope, element)
- def unit[bt <: NameElement, elementT <% Mappable[elementT]](x: elementT) = UnderBinder(new Scope[bt](), x)
- }
-
- /** If a list of `UnderBinder`s all have the same scope, they can be turned in to an `UnderBinder`
- * containing a list of the elements in the original `UnderBinder`.
- *
- * The name `sequence` comes from the fact that this method's type is equal to the type of monadic sequence.
- *
- * @note `!orig.isEmpty` implies `orig.forall(ub => ub.scope eq orig(0).scope)`
- *
- */
- def sequence[bt <: NameElement, st <% Mappable[st]](orig: List[UnderBinder[bt, st]]): UnderBinder[bt, List[st]] =
- if(orig.isEmpty) UnderBinder.unit(Nil)
- else UnderBinder(orig(0).scope, orig.map(_.element))
-
- // couldn't come up with a better name...
- def unsequence[bt <: NameElement, st <% Mappable[st]](orig: UnderBinder[bt, List[st]]): List[UnderBinder[bt, st]] =
- orig.element.map(sc => UnderBinder(orig.scope, sc))
-
- //TODO: more documentation
- /** An environment that maps a `NameElement` to the scope in which it is bound.
- * This can be used to model scoping during parsing.
- *
- * @note This class uses similar techniques as described by ''Burak Emir'' in
- * [[http://library.epfl.ch/theses/?nr=3899 Object-oriented pattern matching]],
- * but uses `==` instead of `eq`, thus types can't be unified in general.
- */
- abstract class BinderEnv {
- def apply[A <: NameElement](v: A): Option[Scope[A]]
- def extend[a <: NameElement](v : a, x : Scope[a]) = new BinderEnv {
- def apply[b <: NameElement](w : b): Option[Scope[b]] =
- if(w == v) Some(x.asInstanceOf[Scope[b]])
- else BinderEnv.this.apply(w)
- }
- }
-
- object EmptyBinderEnv extends BinderEnv {
- def apply[A <: NameElement](v: A): Option[Scope[A]] = None
- }
-
- // TODO: move this to some utility object higher in the scala hierarchy?
- /** Returns a given result, but executes the supplied closure before returning.
- * (The effect of this closure does not influence the returned value.)
- */
- trait ReturnAndDo[T]{
- /**
- * @param block code to be executed, purely for its side-effects
- */
- def andDo(block: => Unit): T
- }
-
- def return_[T](result: T): ReturnAndDo[T] =
- new ReturnAndDo[T] {
- val r = result
- def andDo(block: => Unit): T = {block; r}
- }
-
- private object _Binder {
- private var currentId = 0
- private[Binders] def genId = return_(currentId) andDo {currentId=currentId+1}
- }
-}
diff --git a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala
index ad06749c0d..0683ea927d 100644
--- a/src/library/scala/util/parsing/combinator/ImplicitConversions.scala
+++ b/src/library/scala/util/parsing/combinator/ImplicitConversions.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing.combinator
+package scala
+package util.parsing.combinator
import scala.language.implicitConversions
diff --git a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala
index 89832d3fb2..01288a182e 100644
--- a/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala
+++ b/src/library/scala/util/parsing/combinator/JavaTokenParsers.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing.combinator
+package scala
+package util.parsing.combinator
import scala.annotation.migration
diff --git a/src/library/scala/util/parsing/combinator/PackratParsers.scala b/src/library/scala/util/parsing/combinator/PackratParsers.scala
index 16705d45f9..a11dd18e62 100644
--- a/src/library/scala/util/parsing/combinator/PackratParsers.scala
+++ b/src/library/scala/util/parsing/combinator/PackratParsers.scala
@@ -6,9 +6,9 @@
** |/ **
\* */
-package scala.util.parsing.combinator
+package scala
+package util.parsing.combinator
-import scala.util.parsing.combinator._
import scala.util.parsing.input.{ Reader, Position }
import scala.collection.mutable
import scala.language.implicitConversions
diff --git a/src/library/scala/util/parsing/combinator/Parsers.scala b/src/library/scala/util/parsing/combinator/Parsers.scala
index ead444653e..4602c3cc53 100644
--- a/src/library/scala/util/parsing/combinator/Parsers.scala
+++ b/src/library/scala/util/parsing/combinator/Parsers.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing.combinator
+package scala
+package util.parsing.combinator
import scala.util.parsing.input._
import scala.collection.mutable.ListBuffer
@@ -157,12 +158,6 @@ trait Parsers {
private lazy val lastNoSuccessVar = new DynamicVariable[Option[NoSuccess]](None)
- @deprecated("lastNoSuccess was not thread-safe and will be removed in 2.11.0", "2.10.0")
- def lastNoSuccess: NoSuccess = lastNoSuccessVar.value.orNull
-
- @deprecated("lastNoSuccess was not thread-safe and will be removed in 2.11.0", "2.10.0")
- def lastNoSuccess_=(x: NoSuccess): Unit = lastNoSuccessVar.value = Option(x)
-
/** A common super-class for unsuccessful parse results. */
sealed abstract class NoSuccess(val msg: String, override val next: Input) extends ParseResult[Nothing] { // when we don't care about the difference between Failure and Error
val successful = false
@@ -758,7 +753,7 @@ trait Parsers {
if (elems.length == num) Success(elems.toList, in0)
else p0(in0) match {
case Success(x, rest) => elems += x ; applyp(rest)
- case ns: NoSuccess => return ns
+ case ns: NoSuccess => ns
}
applyp(in)
diff --git a/src/library/scala/util/parsing/combinator/RegexParsers.scala b/src/library/scala/util/parsing/combinator/RegexParsers.scala
index d17d0cac8d..8ebbc573ad 100644
--- a/src/library/scala/util/parsing/combinator/RegexParsers.scala
+++ b/src/library/scala/util/parsing/combinator/RegexParsers.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing.combinator
+package scala
+package util.parsing.combinator
import java.util.regex.Pattern
import scala.util.matching.Regex
diff --git a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala
index c25c97278f..d8029d068f 100644
--- a/src/library/scala/util/parsing/combinator/lexical/Lexical.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/Lexical.scala
@@ -8,7 +8,8 @@
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package lexical
diff --git a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala
index 5c23ad70cd..2e12915bb8 100644
--- a/src/library/scala/util/parsing/combinator/lexical/Scanners.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/Scanners.scala
@@ -6,13 +6,11 @@
** |/ **
\* */
-
-
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package lexical
-import token._
import input._
/** This component provides core functionality for lexical parsers.
diff --git a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
index f3491c096f..32d7502cda 100644
--- a/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
+++ b/src/library/scala/util/parsing/combinator/lexical/StdLexical.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package lexical
@@ -50,7 +51,7 @@ class StdLexical extends Lexical with StdTokens {
def identChar = letter | elem('_')
// see `whitespace in `Scanners`
- def whitespace: Parser[Any] = rep(
+ def whitespace: Parser[Any] = rep[Any](
whitespaceChar
| '/' ~ '*' ~ comment
| '/' ~ '/' ~ rep( chrExcept(EofCh, '\n') )
diff --git a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala
index d3ae0ea54a..5b9d14c9a7 100644
--- a/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala
+++ b/src/library/scala/util/parsing/combinator/syntactical/StandardTokenParsers.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package syntactical
diff --git a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala
index 7283b01da4..adcf85da7a 100644
--- a/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala
+++ b/src/library/scala/util/parsing/combinator/syntactical/StdTokenParsers.scala
@@ -8,7 +8,8 @@
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package syntactical
diff --git a/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala b/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala
index 1c4b25b999..b06babcd7e 100644
--- a/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala
+++ b/src/library/scala/util/parsing/combinator/syntactical/TokenParsers.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package syntactical
diff --git a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala b/src/library/scala/util/parsing/combinator/testing/RegexTest.scala
deleted file mode 100644
index 80e9b0df39..0000000000
--- a/src/library/scala/util/parsing/combinator/testing/RegexTest.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-
-package scala.util.parsing.combinator.testing
-
-import scala.util.parsing.combinator._
-import scala.util.parsing.input._
-import scala.language.postfixOps
-
-@deprecated("This class will be removed", "2.10.0")
-case class Ident(s: String)
-@deprecated("This class will be removed", "2.10.0")
-case class Number(n: Int)
-@deprecated("This class will be removed", "2.10.0")
-case class Str(s: String)
-
-@deprecated("This class will be removed", "2.10.0")
-object RegexTest extends RegexParsers {
- val ident: Parser[Any] = """[a-zA-Z_]\w*""".r ^^ (s => Ident(s))
- val number: Parser[Any] = """\d\d*""".r ^^ (s => Number(s.toInt))
- val string: Parser[Any] = "\".*\"".r ^^ (s => Str(s.substring(1, s.length - 1)))
- val parser = (ident | number | string)*
-
- def main(args: Array[String]) = {
- val in = args mkString " "
- println("\nin : "+in)
- println(phrase[Any](parser)(new CharSequenceReader(in)))
- }
-}
diff --git a/src/library/scala/util/parsing/combinator/testing/Tester.scala b/src/library/scala/util/parsing/combinator/testing/Tester.scala
deleted file mode 100644
index 95730ee292..0000000000
--- a/src/library/scala/util/parsing/combinator/testing/Tester.scala
+++ /dev/null
@@ -1,45 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2006-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-package scala.util.parsing.combinator.testing
-import scala.util.parsing.combinator._
-
-import scala.util.parsing.combinator.lexical.Lexical
-import scala.util.parsing.combinator.syntactical.TokenParsers
-
-/** Facilitates testing a given parser on various input strings.
- *
- * Example use:
- * {{{
- * val syntactic = new MyParsers
- * }}}
- * and
- * {{{
- * val parser = syntactic.term
- * }}}
- * (If `MyParsers` extends [[scala.util.parsing.combinator.syntactical.TokenParsers]]
- * with a parser called `term`.)
- *
- * @author Martin Odersky
- * @author Adriaan Moors
- */
-@deprecated("This class will be removed", "2.10.0")
-abstract class Tester {
-
- val syntactic: TokenParsers { val lexical: Lexical }
- val parser: syntactic.Parser[Any]
-
- /** Scans a String (using a `syntactic.lexical.Scanner`), parses it using
- * `phrase(parser)`, and prints the input and the parsed result to the
- * console.
- */
- def test(in: String) {
- Console.println("\nin : "+in)
- Console.println(syntactic.phrase[Any](parser)(new syntactic.lexical.Scanner(in)))
- }
-}
diff --git a/src/library/scala/util/parsing/combinator/token/StdTokens.scala b/src/library/scala/util/parsing/combinator/token/StdTokens.scala
index 605f53bf1d..a102d1541e 100644
--- a/src/library/scala/util/parsing/combinator/token/StdTokens.scala
+++ b/src/library/scala/util/parsing/combinator/token/StdTokens.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package token
diff --git a/src/library/scala/util/parsing/combinator/token/Tokens.scala b/src/library/scala/util/parsing/combinator/token/Tokens.scala
index ff92802d77..5c3f1f95b5 100644
--- a/src/library/scala/util/parsing/combinator/token/Tokens.scala
+++ b/src/library/scala/util/parsing/combinator/token/Tokens.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing
+package scala
+package util.parsing
package combinator
package token
diff --git a/src/library/scala/util/parsing/input/CharArrayReader.scala b/src/library/scala/util/parsing/input/CharArrayReader.scala
index 3ba69b229b..22530cb9aa 100644
--- a/src/library/scala/util/parsing/input/CharArrayReader.scala
+++ b/src/library/scala/util/parsing/input/CharArrayReader.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
/** An object encapsulating basic character constants.
*
diff --git a/src/library/scala/util/parsing/input/CharSequenceReader.scala b/src/library/scala/util/parsing/input/CharSequenceReader.scala
index 02aa2ab7b8..8e7751cc82 100644
--- a/src/library/scala/util/parsing/input/CharSequenceReader.scala
+++ b/src/library/scala/util/parsing/input/CharSequenceReader.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
/** An object encapsulating basic character constants.
*
diff --git a/src/library/scala/util/parsing/input/NoPosition.scala b/src/library/scala/util/parsing/input/NoPosition.scala
index 40584b3293..4a32264b79 100644
--- a/src/library/scala/util/parsing/input/NoPosition.scala
+++ b/src/library/scala/util/parsing/input/NoPosition.scala
@@ -8,7 +8,8 @@
-package scala.util.parsing.input
+package scala
+package util.parsing.input
/** Undefined position.
*
diff --git a/src/library/scala/util/parsing/input/OffsetPosition.scala b/src/library/scala/util/parsing/input/OffsetPosition.scala
index 01d9ea5cb8..23f79c74d1 100644
--- a/src/library/scala/util/parsing/input/OffsetPosition.scala
+++ b/src/library/scala/util/parsing/input/OffsetPosition.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
import scala.collection.mutable.ArrayBuffer
@@ -22,7 +23,7 @@ case class OffsetPosition(source: java.lang.CharSequence, offset: Int) extends P
/** An index that contains all line starts, including first line, and eof. */
private lazy val index: Array[Int] = {
- var lineStarts = new ArrayBuffer[Int]
+ val lineStarts = new ArrayBuffer[Int]
lineStarts += 0
for (i <- 0 until source.length)
if (source.charAt(i) == '\n') lineStarts += (i + 1)
diff --git a/src/library/scala/util/parsing/input/PagedSeqReader.scala b/src/library/scala/util/parsing/input/PagedSeqReader.scala
index 9140bf2a4f..468f1f9a5f 100644
--- a/src/library/scala/util/parsing/input/PagedSeqReader.scala
+++ b/src/library/scala/util/parsing/input/PagedSeqReader.scala
@@ -7,7 +7,8 @@
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
import scala.collection.immutable.PagedSeq
diff --git a/src/library/scala/util/parsing/input/Position.scala b/src/library/scala/util/parsing/input/Position.scala
index 31715bd8da..b7995a6471 100644
--- a/src/library/scala/util/parsing/input/Position.scala
+++ b/src/library/scala/util/parsing/input/Position.scala
@@ -6,15 +6,16 @@
** |/ **
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
-/** `Position` is the base trait for objects describing a position in a ``document''.
+/** `Position` is the base trait for objects describing a position in a `document`.
*
* It provides functionality for:
* - generating a visual representation of this position (`longString`);
* - comparing two positions (`<`).
*
- * To use this class for a concrete kind of ``document'', implement the `lineContents` method.
+ * To use this class for a concrete kind of `document`, implement the `lineContents` method.
*
* @author Martin Odersky
* @author Adriaan Moors
diff --git a/src/library/scala/util/parsing/input/Positional.scala b/src/library/scala/util/parsing/input/Positional.scala
index 87cb16eac5..cfde67cadd 100644
--- a/src/library/scala/util/parsing/input/Positional.scala
+++ b/src/library/scala/util/parsing/input/Positional.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
/** A trait for objects that have a source position.
*
diff --git a/src/library/scala/util/parsing/input/Reader.scala b/src/library/scala/util/parsing/input/Reader.scala
index bded57bee1..9dbf08a7ca 100644
--- a/src/library/scala/util/parsing/input/Reader.scala
+++ b/src/library/scala/util/parsing/input/Reader.scala
@@ -8,7 +8,8 @@
-package scala.util.parsing.input
+package scala
+package util.parsing.input
/** An interface for streams of values that have positions.
diff --git a/src/library/scala/util/parsing/input/StreamReader.scala b/src/library/scala/util/parsing/input/StreamReader.scala
index ba7ab65845..30eb097fd7 100644
--- a/src/library/scala/util/parsing/input/StreamReader.scala
+++ b/src/library/scala/util/parsing/input/StreamReader.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.parsing.input
+package scala
+package util.parsing.input
import java.io.BufferedReader
import scala.collection.immutable.PagedSeq
@@ -22,7 +23,7 @@ object StreamReader {
*
* @param in the `java.io.Reader` that provides the underlying
* stream of characters for this Reader.
- */
+ */
def apply(in: java.io.Reader): StreamReader = {
new StreamReader(PagedSeq.fromReader(in), 0, 1)
}
diff --git a/src/library/scala/util/parsing/json/JSON.scala b/src/library/scala/util/parsing/json/JSON.scala
index 2f450ed864..6eaa47473f 100644
--- a/src/library/scala/util/parsing/json/JSON.scala
+++ b/src/library/scala/util/parsing/json/JSON.scala
@@ -6,10 +6,8 @@
** |/ **
\* */
-package scala.util.parsing.json
-import scala.util.parsing.combinator._
-import scala.util.parsing.combinator.syntactical._
-import scala.util.parsing.combinator.lexical._
+package scala
+package util.parsing.json
/**
* This object provides a simple interface to the JSON parser class.
diff --git a/src/library/scala/util/parsing/json/Lexer.scala b/src/library/scala/util/parsing/json/Lexer.scala
index 991b5d5c6c..63df9c28eb 100644
--- a/src/library/scala/util/parsing/json/Lexer.scala
+++ b/src/library/scala/util/parsing/json/Lexer.scala
@@ -8,10 +8,10 @@
-package scala.util.parsing.json
+package scala
+package util.parsing.json
import scala.util.parsing.combinator._
-import scala.util.parsing.combinator.syntactical._
import scala.util.parsing.combinator.lexical._
import scala.util.parsing.input.CharArrayReader.EofCh
diff --git a/src/library/scala/util/parsing/json/Parser.scala b/src/library/scala/util/parsing/json/Parser.scala
index cb87866f07..c61e3df181 100644
--- a/src/library/scala/util/parsing/json/Parser.scala
+++ b/src/library/scala/util/parsing/json/Parser.scala
@@ -8,11 +8,11 @@
-package scala.util.parsing.json
+package scala
+package util.parsing.json
import scala.util.parsing.combinator._
import scala.util.parsing.combinator.syntactical._
-import scala.util.parsing.combinator.lexical._
/**
* A marker class for the JSON result types.
diff --git a/src/library/scala/xml/Atom.scala b/src/library/scala/xml/Atom.scala
index cba0b96875..33e58ba7e7 100644
--- a/src/library/scala/xml/Atom.scala
+++ b/src/library/scala/xml/Atom.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** The class `Atom` provides an XML node for text (`PCDATA`).
* It is used in both non-bound and bound XML representations.
diff --git a/src/library/scala/xml/Attribute.scala b/src/library/scala/xml/Attribute.scala
index 0224913cf6..e4b2b69fc6 100644
--- a/src/library/scala/xml/Attribute.scala
+++ b/src/library/scala/xml/Attribute.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** This singleton object contains the `apply` and `unapply` methods for
* convenient construction and deconstruction.
@@ -94,7 +95,7 @@ abstract trait Attribute extends MetaData {
sb append key append '='
val sb2 = new StringBuilder()
- Utility.sequenceToXML(value, TopScope, sb2, true)
+ Utility.sequenceToXML(value, TopScope, sb2, stripComments = true)
Utility.appendQuoted(sb2.toString, sb)
}
}
diff --git a/src/library/scala/xml/Comment.scala b/src/library/scala/xml/Comment.scala
index ff4280d691..b8dccdcb16 100644
--- a/src/library/scala/xml/Comment.scala
+++ b/src/library/scala/xml/Comment.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** The class `Comment` implements an XML node for comments.
*
diff --git a/src/library/scala/xml/Document.scala b/src/library/scala/xml/Document.scala
index a064c4d8e8..9a725014fc 100644
--- a/src/library/scala/xml/Document.scala
+++ b/src/library/scala/xml/Document.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** A document information item (according to InfoSet spec). The comments
* are copied from the Infoset spec, only augmented with some information
diff --git a/src/library/scala/xml/Elem.scala b/src/library/scala/xml/Elem.scala
index b9e665e292..4200b7046a 100755
--- a/src/library/scala/xml/Elem.scala
+++ b/src/library/scala/xml/Elem.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** This singleton object contains the `apply` and `unapplySeq` methods for
* convenient construction and deconstruction. It is possible to deconstruct
@@ -17,7 +18,7 @@ package scala.xml
* @author Burak Emir <bqe@google.com>
*/
object Elem {
- /** Build an Elem, setting its minimizeEmpty property to <code>true</code> if it has no children. Note that this
+ /** Build an Elem, setting its minimizeEmpty property to `true` if it has no children. Note that this
* default may not be exactly what you want, as some XML dialects don't permit some elements to be minimized.
*
* @deprecated This factory method is retained for backward compatibility; please use the other one, with which you
diff --git a/src/library/scala/xml/EntityRef.scala b/src/library/scala/xml/EntityRef.scala
index a7b9835a7e..7a58831075 100644
--- a/src/library/scala/xml/EntityRef.scala
+++ b/src/library/scala/xml/EntityRef.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** The class `EntityRef` implements an XML node for entity references.
*
diff --git a/src/library/scala/xml/Equality.scala b/src/library/scala/xml/Equality.scala
index 02db22a78a..021d185812 100644
--- a/src/library/scala/xml/Equality.scala
+++ b/src/library/scala/xml/Equality.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** In an attempt to contain the damage being inflicted on consistency by the
* ad hoc `equals` methods spread around `xml`, the logic is centralized and
@@ -86,8 +87,8 @@ trait Equality extends scala.Equals {
* to maintain a semblance of order.
*/
override def hashCode() = basisForHashCode.##
- override def equals(other: Any) = doComparison(other, false)
- final def xml_==(other: Any) = doComparison(other, true)
+ override def equals(other: Any) = doComparison(other, blithe = false)
+ final def xml_==(other: Any) = doComparison(other, blithe = true)
final def xml_!=(other: Any) = !xml_==(other)
/** The "blithe" parameter expresses the caller's unconcerned attitude
diff --git a/src/library/scala/xml/Group.scala b/src/library/scala/xml/Group.scala
index 92da2f993f..e3af615008 100644
--- a/src/library/scala/xml/Group.scala
+++ b/src/library/scala/xml/Group.scala
@@ -6,14 +6,15 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** A hack to group XML nodes in one node for output.
*
* @author Burak Emir
* @version 1.0
*/
-final case class Group(val nodes: Seq[Node]) extends Node {
+final case class Group(nodes: Seq[Node]) extends Node {
override def theSeq = nodes
override def canEqual(other: Any) = other match {
diff --git a/src/library/scala/xml/MalformedAttributeException.scala b/src/library/scala/xml/MalformedAttributeException.scala
index 3431cb6765..d499ad3e10 100644
--- a/src/library/scala/xml/MalformedAttributeException.scala
+++ b/src/library/scala/xml/MalformedAttributeException.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
case class MalformedAttributeException(msg: String) extends RuntimeException(msg)
diff --git a/src/library/scala/xml/MetaData.scala b/src/library/scala/xml/MetaData.scala
index 3bf3ebb1c0..8b5ea187cb 100644
--- a/src/library/scala/xml/MetaData.scala
+++ b/src/library/scala/xml/MetaData.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import Utility.sbToString
import scala.annotation.tailrec
diff --git a/src/library/scala/xml/NamespaceBinding.scala b/src/library/scala/xml/NamespaceBinding.scala
index c7cd9e6b6c..b320466976 100644
--- a/src/library/scala/xml/NamespaceBinding.scala
+++ b/src/library/scala/xml/NamespaceBinding.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import Utility.sbToString
@@ -38,6 +39,20 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin
override def toString(): String = sbToString(buildString(_, TopScope))
+ private def shadowRedefined(stop: NamespaceBinding): NamespaceBinding = {
+ def prefixList(x: NamespaceBinding): List[String] =
+ if ((x == null) || (x eq stop)) Nil
+ else x.prefix :: prefixList(x.parent)
+ def fromPrefixList(l: List[String]): NamespaceBinding = l match {
+ case Nil => stop
+ case x :: xs => new NamespaceBinding(x, this.getURI(x), fromPrefixList(xs))
+ }
+ val ps0 = prefixList(this).reverse
+ val ps = ps0.distinct
+ if (ps.size == ps0.size) this
+ else fromPrefixList(ps)
+ }
+
override def canEqual(other: Any) = other match {
case _: NamespaceBinding => true
case _ => false
@@ -53,12 +68,16 @@ case class NamespaceBinding(prefix: String, uri: String, parent: NamespaceBindin
def buildString(stop: NamespaceBinding): String = sbToString(buildString(_, stop))
def buildString(sb: StringBuilder, stop: NamespaceBinding) {
- if (this eq stop) return // contains?
+ shadowRedefined(stop).doBuildString(sb, stop)
+ }
+
+ private def doBuildString(sb: StringBuilder, stop: NamespaceBinding) {
+ if ((this == null) || (this eq stop)) return // contains?
val s = " xmlns%s=\"%s\"".format(
(if (prefix != null) ":" + prefix else ""),
(if (uri != null) uri else "")
)
- parent.buildString(sb append s, stop) // copy(ignore)
+ parent.doBuildString(sb append s, stop) // copy(ignore)
}
}
diff --git a/src/library/scala/xml/Node.scala b/src/library/scala/xml/Node.scala
index 6b6c962692..e121284252 100755
--- a/src/library/scala/xml/Node.scala
+++ b/src/library/scala/xml/Node.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** This singleton object contains the `unapplySeq` method for
* convenient deconstruction.
@@ -55,7 +56,7 @@ abstract class Node extends NodeSeq {
def scope: NamespaceBinding = TopScope
/**
- * convenience, same as <code>getNamespace(this.prefix)</code>
+ * convenience, same as `getNamespace(this.prefix)`
*/
def namespace = getNamespace(this.prefix)
@@ -64,8 +65,8 @@ abstract class Node extends NodeSeq {
* checks if scope is `'''null'''`.
*
* @param pre the prefix whose namespace name we would like to obtain
- * @return the namespace if <code>scope != null</code> and prefix was
- * found, else <code>null</code>
+ * @return the namespace if `scope != null` and prefix was
+ * found, else `null`
*/
def getNamespace(pre: String): String = if (scope eq null) null else scope.getURI(pre)
@@ -74,8 +75,8 @@ abstract class Node extends NodeSeq {
* Same as `attributes.getValue(key)`
*
* @param key of queried attribute.
- * @return value of <code>UnprefixedAttribute</code> with given key
- * in attributes, if it exists, otherwise <code>null</code>.
+ * @return value of `UnprefixedAttribute` with given key
+ * in attributes, if it exists, otherwise `null`.
*/
final def attribute(key: String): Option[Seq[Node]] = attributes.get(key)
@@ -163,7 +164,7 @@ abstract class Node extends NodeSeq {
/**
* Same as `toString('''false''')`.
*/
- override def toString(): String = buildString(false)
+ override def toString(): String = buildString(stripComments = false)
/**
* Appends qualified name of this node to `StringBuilder`.
diff --git a/src/library/scala/xml/NodeBuffer.scala b/src/library/scala/xml/NodeBuffer.scala
index 2db4338fb2..ae7c7b2bf8 100644
--- a/src/library/scala/xml/NodeBuffer.scala
+++ b/src/library/scala/xml/NodeBuffer.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/**
* This class acts as a Buffer for nodes. If it is used as a sequence of
diff --git a/src/library/scala/xml/NodeSeq.scala b/src/library/scala/xml/NodeSeq.scala
index decf60dad7..b8022472fb 100644
--- a/src/library/scala/xml/NodeSeq.scala
+++ b/src/library/scala/xml/NodeSeq.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import scala.collection.{ mutable, immutable, generic, SeqLike, AbstractSeq }
import mutable.{ Builder, ListBuffer }
@@ -145,6 +146,11 @@ abstract class NodeSeq extends AbstractSeq[Node] with immutable.Seq[Node] with S
}
}
+ /** Convenience method which returns string text of the named attribute. Use:
+ * - `that \@ "foo"` to get the string text of attribute `"foo"`;
+ */
+ def \@(attributeName: String): String = (this \ ("@" + attributeName)).text
+
override def toString(): String = theSeq.mkString
def text: String = (this map (_.text)).mkString
diff --git a/src/library/scala/xml/Null.scala b/src/library/scala/xml/Null.scala
index b39ef5dc67..f763c023c4 100644
--- a/src/library/scala/xml/Null.scala
+++ b/src/library/scala/xml/Null.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import Utility.isNameStart
import scala.collection.Iterator
diff --git a/src/library/scala/xml/PCData.scala b/src/library/scala/xml/PCData.scala
index 64818a9c00..31eea2b6d7 100644
--- a/src/library/scala/xml/PCData.scala
+++ b/src/library/scala/xml/PCData.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** This class (which is not used by all XML parsers, but always used by the
* XHTML one) represents parseable character data, which appeared as CDATA
diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala
index 429cd682d6..4ab79c8677 100644
--- a/src/library/scala/xml/PrefixedAttribute.scala
+++ b/src/library/scala/xml/PrefixedAttribute.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
/** prefixed attributes always have a non-null namespace.
*
diff --git a/src/library/scala/xml/PrettyPrinter.scala b/src/library/scala/xml/PrettyPrinter.scala
index 39ff8c35ec..9e01905357 100755
--- a/src/library/scala/xml/PrettyPrinter.scala
+++ b/src/library/scala/xml/PrettyPrinter.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import Utility.sbToString
@@ -47,7 +48,6 @@ class PrettyPrinter(width: Int, step: Int) {
val tmp = width - cur
if (s.length <= tmp)
return List(Box(ind, s))
- val sb = new StringBuilder()
var i = s indexOf ' '
if (i > tmp || i == -1) throw new BrokenException() // cannot break
@@ -142,13 +142,13 @@ class PrettyPrinter(width: Int, step: Int) {
case Text(s) if s.trim() == "" =>
;
case _:Atom[_] | _:Comment | _:EntityRef | _:ProcInstr =>
- makeBox( ind, node.toString.trim() )
+ makeBox( ind, node.toString().trim() )
case g @ Group(xs) =>
traverse(xs.iterator, pscope, ind)
case _ =>
val test = {
val sb = new StringBuilder()
- Utility.serialize(node, pscope, sb, false)
+ Utility.serialize(node, pscope, sb, stripComments = false)
if (doPreserve(node)) sb.toString
else TextBuffer.fromString(sb.toString).toText(0).data
}
diff --git a/src/library/scala/xml/ProcInstr.scala b/src/library/scala/xml/ProcInstr.scala
index 64a9dd5ca3..189c1c6878 100644
--- a/src/library/scala/xml/ProcInstr.scala
+++ b/src/library/scala/xml/ProcInstr.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
/** an XML node for processing instructions (PI)
*
diff --git a/src/library/scala/xml/QNode.scala b/src/library/scala/xml/QNode.scala
index d4d3872181..f9e3f1854b 100644
--- a/src/library/scala/xml/QNode.scala
+++ b/src/library/scala/xml/QNode.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** This object provides an extractor method to match a qualified node with
* its namespace URI
diff --git a/src/library/scala/xml/SpecialNode.scala b/src/library/scala/xml/SpecialNode.scala
index 4c1b81c7ff..5fef8ef66c 100644
--- a/src/library/scala/xml/SpecialNode.scala
+++ b/src/library/scala/xml/SpecialNode.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** `SpecialNode` is a special XML node which represents either text
* `(PCDATA)`, a comment, a `PI`, or an entity ref.
diff --git a/src/library/scala/xml/Text.scala b/src/library/scala/xml/Text.scala
index 782c80f100..debea0c025 100644
--- a/src/library/scala/xml/Text.scala
+++ b/src/library/scala/xml/Text.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** The class `Text` implements an XML node for text (PCDATA).
* It is used in both non-bound and bound XML representations.
diff --git a/src/library/scala/xml/TextBuffer.scala b/src/library/scala/xml/TextBuffer.scala
index 0b96379d85..514b1701af 100644
--- a/src/library/scala/xml/TextBuffer.scala
+++ b/src/library/scala/xml/TextBuffer.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
import Utility.isSpace
diff --git a/src/library/scala/xml/TopScope.scala b/src/library/scala/xml/TopScope.scala
index 1ed1d50e10..474fbbbdb5 100644
--- a/src/library/scala/xml/TopScope.scala
+++ b/src/library/scala/xml/TopScope.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
/** top level namespace scope. only contains the predefined binding
* for the &quot;xml&quot; prefix which is bound to
diff --git a/src/library/scala/xml/TypeSymbol.scala b/src/library/scala/xml/TypeSymbol.scala
index f02c0263c0..fb371ee340 100644
--- a/src/library/scala/xml/TypeSymbol.scala
+++ b/src/library/scala/xml/TypeSymbol.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
abstract class TypeSymbol
diff --git a/src/library/scala/xml/Unparsed.scala b/src/library/scala/xml/Unparsed.scala
index ef80823611..bc190eb724 100644
--- a/src/library/scala/xml/Unparsed.scala
+++ b/src/library/scala/xml/Unparsed.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
/** An XML node for unparsed content. It will be output verbatim, all bets
* are off regarding wellformedness etc.
diff --git a/src/library/scala/xml/UnprefixedAttribute.scala b/src/library/scala/xml/UnprefixedAttribute.scala
index 2985591c95..6fa827da5f 100644
--- a/src/library/scala/xml/UnprefixedAttribute.scala
+++ b/src/library/scala/xml/UnprefixedAttribute.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
/** Unprefixed attributes have the null namespace, and no prefix field
*
diff --git a/src/library/scala/xml/Utility.scala b/src/library/scala/xml/Utility.scala
index 030a89773e..9134476401 100755
--- a/src/library/scala/xml/Utility.scala
+++ b/src/library/scala/xml/Utility.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import scala.collection.mutable
import parsing.XhtmlEntities
@@ -245,10 +246,10 @@ object Utility extends AnyRef with parsing.TokenTests {
if (children.isEmpty) return
else if (children forall isAtomAndNotText) { // add space
val it = children.iterator
- val f = it.next
+ val f = it.next()
serialize(f, pscope, sb, stripComments, decodeEntities, preserveWhitespace, minimizeTags)
while (it.hasNext) {
- val x = it.next
+ val x = it.next()
sb.append(' ')
serialize(x, pscope, sb, stripComments, decodeEntities, preserveWhitespace, minimizeTags)
}
@@ -311,14 +312,14 @@ object Utility extends AnyRef with parsing.TokenTests {
while (i < value.length) {
value.charAt(i) match {
case '<' =>
- return "< not allowed in attribute value";
+ return "< not allowed in attribute value"
case '&' =>
val n = getName(value, i+1)
if (n eq null)
- return "malformed entity reference in attribute value ["+value+"]";
+ return "malformed entity reference in attribute value ["+value+"]"
i = i + n.length + 1
if (i >= value.length || value.charAt(i) != ';')
- return "malformed entity reference in attribute value ["+value+"]";
+ return "malformed entity reference in attribute value ["+value+"]"
case _ =>
}
i = i + 1
@@ -333,22 +334,22 @@ object Utility extends AnyRef with parsing.TokenTests {
val it = value.iterator
while (it.hasNext) {
- var c = it.next
+ var c = it.next()
// entity! flush buffer into text node
if (c == '&') {
- c = it.next
+ c = it.next()
if (c == '#') {
- c = it.next
- val theChar = parseCharRef ({ ()=> c },{ () => c = it.next },{s => throw new RuntimeException(s)}, {s => throw new RuntimeException(s)})
+ c = it.next()
+ val theChar = parseCharRef ({ ()=> c },{ () => c = it.next() },{s => throw new RuntimeException(s)}, {s => throw new RuntimeException(s)})
sb.append(theChar)
}
else {
if (rfb eq null) rfb = new StringBuilder()
rfb append c
- c = it.next
+ c = it.next()
while (c != ';') {
rfb.append(c)
- c = it.next
+ c = it.next()
}
val ref = rfb.toString()
rfb.clear()
diff --git a/src/library/scala/xml/XML.scala b/src/library/scala/xml/XML.scala
index d101684459..020264e509 100755
--- a/src/library/scala/xml/XML.scala
+++ b/src/library/scala/xml/XML.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
import parsing.NoBindingFactoryAdapter
import factory.XMLLoader
@@ -45,8 +46,6 @@ object MinimizeMode extends Enumeration {
val Never = Value
}
-import Source._
-
/** The object `XML` provides constants, and functions to load
* and save XML elements. Use this when data binding is not desired, i.e.
* when XML is handled using `Symbol` nodes.
diff --git a/src/library/scala/xml/Xhtml.scala b/src/library/scala/xml/Xhtml.scala
index 6730548b73..6a12c1a89a 100644
--- a/src/library/scala/xml/Xhtml.scala
+++ b/src/library/scala/xml/Xhtml.scala
@@ -1,5 +1,6 @@
-package scala.xml
+package scala
+package xml
import parsing.XhtmlEntities
import Utility.{ sbToString, isAtomAndNotText }
diff --git a/src/library/scala/xml/dtd/ContentModel.scala b/src/library/scala/xml/dtd/ContentModel.scala
index abc71f55bd..4007985dce 100644
--- a/src/library/scala/xml/dtd/ContentModel.scala
+++ b/src/library/scala/xml/dtd/ContentModel.scala
@@ -6,13 +6,11 @@
** |/ **
\* */
-
-
-package scala.xml
+package scala
+package xml
package dtd
-import scala.util.regexp.WordExp
-import scala.util.automata._
+import scala.xml.dtd.impl._
import scala.xml.Utility.sbToString
import PartialFunction._
diff --git a/src/library/scala/xml/dtd/ContentModelParser.scala b/src/library/scala/xml/dtd/ContentModelParser.scala
index ace02193da..71b391c422 100644
--- a/src/library/scala/xml/dtd/ContentModelParser.scala
+++ b/src/library/scala/xml/dtd/ContentModelParser.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package dtd
/** Parser for regexps (content models in DTD element declarations) */
@@ -21,19 +22,19 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning #
if (token != tok) {
if ((tok == STAR) && (token == END)) // common mistake
scala.sys.error("in DTDs, \n"+
- "mixed content models must be like (#PCDATA|Name|Name|...)*");
+ "mixed content models must be like (#PCDATA|Name|Name|...)*")
else
scala.sys.error("expected "+token2string(tok)+
- ", got unexpected token:"+token2string(token));
+ ", got unexpected token:"+token2string(token))
}
- nextToken
+ nextToken()
}
// s [ '+' | '*' | '?' ]
def maybeSuffix(s: RegExp) = token match {
- case STAR => nextToken; Star(s)
- case PLUS => nextToken; Sequ(s, Star(s))
- case OPT => nextToken; Alt(Eps, s)
+ case STAR => nextToken(); Star(s)
+ case PLUS => nextToken(); Sequ(s, Star(s))
+ case OPT => nextToken(); Alt(Eps, s)
case _ => s
}
@@ -44,45 +45,45 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning #
case NAME => value match {
case "ANY" => ANY
case "EMPTY" => EMPTY
- case _ => scala.sys.error("expected ANY, EMPTY or '(' instead of " + value );
+ case _ => scala.sys.error("expected ANY, EMPTY or '(' instead of " + value )
}
case LPAREN =>
- nextToken;
- sOpt;
+ nextToken()
+ sOpt()
if (token != TOKEN_PCDATA)
- ELEMENTS(regexp);
+ ELEMENTS(regexp)
else {
- nextToken;
+ nextToken()
token match {
case RPAREN =>
PCDATA
case CHOICE =>
- val res = MIXED(choiceRest(Eps));
- sOpt;
- accept( RPAREN );
- accept( STAR );
+ val res = MIXED(choiceRest(Eps))
+ sOpt()
+ accept( RPAREN )
+ accept( STAR )
res
case _ =>
- scala.sys.error("unexpected token:" + token2string(token) );
+ scala.sys.error("unexpected token:" + token2string(token) )
}
}
case _ =>
- scala.sys.error("unexpected token:" + token2string(token) );
- }
+ scala.sys.error("unexpected token:" + token2string(token) )
+ }
// sopt ::= S?
- def sOpt() = if( token == S ) nextToken;
+ def sOpt() = if( token == S ) nextToken()
// (' S? mixed ::= '#PCDATA' S? ')'
// | '#PCDATA' (S? '|' S? atom)* S? ')*'
// '(' S? regexp ::= cp S? [seqRest|choiceRest] ')' [ '+' | '*' | '?' ]
def regexp: RegExp = {
- val p = particle;
- sOpt;
+ val p = particle
+ sOpt()
maybeSuffix(token match {
- case RPAREN => nextToken; p
+ case RPAREN => nextToken(); p
case CHOICE => val q = choiceRest( p );accept( RPAREN ); q
case COMMA => val q = seqRest( p ); accept( RPAREN ); q
})
@@ -90,24 +91,24 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning #
// seqRest ::= (',' S? cp S?)+
def seqRest(p: RegExp) = {
- var k = List(p);
+ var k = List(p)
while( token == COMMA ) {
- nextToken;
- sOpt;
- k = particle::k;
- sOpt;
+ nextToken()
+ sOpt()
+ k = particle::k
+ sOpt()
}
Sequ( k.reverse:_* )
}
// choiceRest ::= ('|' S? cp S?)+
def choiceRest( p:RegExp ) = {
- var k = List( p );
+ var k = List( p )
while( token == CHOICE ) {
- nextToken;
- sOpt;
- k = particle::k;
- sOpt;
+ nextToken()
+ sOpt()
+ k = particle::k
+ sOpt()
}
Alt( k.reverse:_* )
}
@@ -115,14 +116,14 @@ object ContentModelParser extends Scanner { // a bit too permissive concerning #
// particle ::= '(' S? regexp
// | name [ '+' | '*' | '?' ]
def particle = token match {
- case LPAREN => nextToken; sOpt; regexp;
- case NAME => val a = Letter(ElemName(value)); nextToken; maybeSuffix(a)
- case _ => scala.sys.error("expected '(' or Name, got:"+token2string(token));
+ case LPAREN => nextToken(); sOpt(); regexp
+ case NAME => val a = Letter(ElemName(value)); nextToken(); maybeSuffix(a)
+ case _ => scala.sys.error("expected '(' or Name, got:"+token2string(token))
}
// atom ::= name
def atom = token match {
- case NAME => val a = Letter(ElemName(value)); nextToken; a
- case _ => scala.sys.error("expected Name, got:"+token2string(token));
+ case NAME => val a = Letter(ElemName(value)); nextToken(); a
+ case _ => scala.sys.error("expected Name, got:"+token2string(token))
}
}
diff --git a/src/library/scala/xml/dtd/DTD.scala b/src/library/scala/xml/dtd/DTD.scala
index 1f8af3b59e..16a824fe2c 100644
--- a/src/library/scala/xml/dtd/DTD.scala
+++ b/src/library/scala/xml/dtd/DTD.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
package dtd
import scala.collection.mutable
diff --git a/src/library/scala/xml/dtd/Decl.scala b/src/library/scala/xml/dtd/Decl.scala
index dc4cb93ddf..e6804478bd 100644
--- a/src/library/scala/xml/dtd/Decl.scala
+++ b/src/library/scala/xml/dtd/Decl.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package dtd
import Utility.sbToString
@@ -123,7 +124,7 @@ case class ExtDef(extID:ExternalID) extends EntityDef {
/** a parsed entity reference */
case class PEReference(ent:String) extends MarkupDecl {
if( !Utility.isName( ent ))
- throw new IllegalArgumentException("ent must be an XML Name");
+ throw new IllegalArgumentException("ent must be an XML Name")
override def buildString(sb: StringBuilder): StringBuilder =
sb append '%' append ent append ';'
diff --git a/src/library/scala/xml/dtd/DocType.scala b/src/library/scala/xml/dtd/DocType.scala
index 79f8f9fe8b..849d560cc9 100644
--- a/src/library/scala/xml/dtd/DocType.scala
+++ b/src/library/scala/xml/dtd/DocType.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
package dtd
/** An XML node for document type declaration.
@@ -15,11 +16,10 @@ package dtd
* @author Burak Emir
*
* @param name name of this DOCTYPE
- * @param extID None, or Some(external ID of this doctype)
+ * @param extID NoExternalID or the external ID of this doctype
* @param intSubset sequence of internal subset declarations
*/
-case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl])
-{
+case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl]) {
if (!Utility.isName(name))
throw new IllegalArgumentException(name+" must be an XML Name")
@@ -29,6 +29,11 @@ case class DocType(name: String, extID: ExternalID, intSubset: Seq[dtd.Decl])
if (intSubset.isEmpty) ""
else intSubset.mkString("[", "", "]")
- """<!DOCTYPE %s %s%s>""".format(name, extID.toString, intString)
+ """<!DOCTYPE %s %s%s>""".format(name, extID.toString(), intString)
}
}
+
+object DocType {
+ /** Creates a doctype with no external id, nor internal subset declarations. */
+ def apply(name: String): DocType = apply(name, NoExternalID, Nil)
+}
diff --git a/src/library/scala/xml/dtd/ElementValidator.scala b/src/library/scala/xml/dtd/ElementValidator.scala
index bfc85f48a9..4830769a7d 100644
--- a/src/library/scala/xml/dtd/ElementValidator.scala
+++ b/src/library/scala/xml/dtd/ElementValidator.scala
@@ -8,14 +8,17 @@
-package scala.xml
+package scala
+package xml
package dtd
import PartialFunction._
+import scala.collection.mutable
+
import ContentModel.ElemName
import MakeValidationException._ // @todo other exceptions
-import scala.util.automata._
-import scala.collection.mutable
+
+import impl._
/** validate children and/or attributes of an element
* exceptions are created but not thrown.
@@ -61,7 +64,7 @@ class ElementValidator() extends Function1[Node,Boolean] {
*/
def check(md: MetaData): Boolean = {
val len: Int = exc.length
- var ok = new mutable.BitSet(adecls.length)
+ val ok = new mutable.BitSet(adecls.length)
for (attr <- md) {
def attrStr = attr.value.toString
@@ -97,21 +100,21 @@ class ElementValidator() extends Function1[Node,Boolean] {
*/
def check(nodes: Seq[Node]): Boolean = contentModel match {
case ANY => true
- case EMPTY => getIterable(nodes, false).isEmpty
- case PCDATA => getIterable(nodes, true).isEmpty
+ case EMPTY => getIterable(nodes, skipPCDATA = false).isEmpty
+ case PCDATA => getIterable(nodes, skipPCDATA = true).isEmpty
case MIXED(ContentModel.Alt(branches @ _*)) => // @todo
val j = exc.length
def find(Key: String): Boolean =
branches exists { case ContentModel.Letter(ElemName(Key)) => true ; case _ => false }
- getIterable(nodes, true) map (_.name) filterNot find foreach {
+ getIterable(nodes, skipPCDATA = true) map (_.name) filterNot find foreach {
exc ::= MakeValidationException fromUndefinedElement _
}
(exc.length == j) // - true if no new exception
case _: ELEMENTS =>
dfa isFinal {
- getIterable(nodes, false).foldLeft(0) { (q, e) =>
+ getIterable(nodes, skipPCDATA = false).foldLeft(0) { (q, e) =>
(dfa delta q).getOrElse(e, throw ValidationException("element %s not allowed here" format e))
}
}
diff --git a/src/library/scala/xml/dtd/ExternalID.scala b/src/library/scala/xml/dtd/ExternalID.scala
index 7a7463569e..5a1b5d1a19 100644
--- a/src/library/scala/xml/dtd/ExternalID.scala
+++ b/src/library/scala/xml/dtd/ExternalID.scala
@@ -7,15 +7,15 @@
\* */
-package scala.xml
+package scala
+package xml
package dtd
/** an ExternalIDs - either PublicID or SystemID
*
* @author Burak Emir
*/
-abstract class ExternalID extends parsing.TokenTests
-{
+abstract class ExternalID extends parsing.TokenTests {
def quoted(s: String) = {
val c = if (s contains '"') '\'' else '"'
c + s + c
@@ -73,3 +73,14 @@ case class PublicID(publicId: String, systemId: String) extends ExternalID {
/** always empty */
def child = Nil
}
+
+/** A marker used when a `DocType` contains no external id.
+ *
+ * @author Michael Bayne
+ */
+object NoExternalID extends ExternalID {
+ val publicId = null
+ val systemId = null
+
+ override def toString = ""
+}
diff --git a/src/library/scala/xml/dtd/Scanner.scala b/src/library/scala/xml/dtd/Scanner.scala
index 9b64cc61e2..5f9d1ccaed 100644
--- a/src/library/scala/xml/dtd/Scanner.scala
+++ b/src/library/scala/xml/dtd/Scanner.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
package dtd
/** Scanner for regexps (content models in DTD element declarations)
@@ -28,8 +29,8 @@ class Scanner extends Tokens with parsing.TokenTests {
value = ""
it = (s).iterator
token = 1+END
- next
- nextToken
+ next()
+ nextToken()
}
/** scans the next token */
@@ -39,29 +40,29 @@ class Scanner extends Tokens with parsing.TokenTests {
// todo: see XML specification... probably isLetter,isDigit is fine
final def isIdentChar = ( ('a' <= c && c <= 'z')
- || ('A' <= c && c <= 'Z'));
+ || ('A' <= c && c <= 'Z'))
- final def next() = if (it.hasNext) c = it.next else c = ENDCH
+ final def next() = if (it.hasNext) c = it.next() else c = ENDCH
final def acc(d: Char) {
- if (c == d) next else scala.sys.error("expected '"+d+"' found '"+c+"' !");
+ if (c == d) next() else scala.sys.error("expected '"+d+"' found '"+c+"' !")
}
final def accS(ds: Seq[Char]) { ds foreach acc }
final def readToken: Int =
if (isSpace(c)) {
- while (isSpace(c)) c = it.next
+ while (isSpace(c)) c = it.next()
S
} else c match {
- case '(' => next; LPAREN
- case ')' => next; RPAREN
- case ',' => next; COMMA
- case '*' => next; STAR
- case '+' => next; PLUS
- case '?' => next; OPT
- case '|' => next; CHOICE
- case '#' => next; accS( "PCDATA" ); TOKEN_PCDATA
+ case '(' => next(); LPAREN
+ case ')' => next(); RPAREN
+ case ',' => next(); COMMA
+ case '*' => next(); STAR
+ case '+' => next(); PLUS
+ case '?' => next(); OPT
+ case '|' => next(); CHOICE
+ case '#' => next(); accS( "PCDATA" ); TOKEN_PCDATA
case ENDCH => END
case _ =>
if (isNameStart(c)) name; // NAME
@@ -70,7 +71,7 @@ class Scanner extends Tokens with parsing.TokenTests {
final def name = {
val sb = new StringBuilder()
- do { sb.append(c); next } while (isNameChar(c));
+ do { sb.append(c); next() } while (isNameChar(c))
value = sb.toString()
NAME
}
diff --git a/src/library/scala/xml/dtd/Tokens.scala b/src/library/scala/xml/dtd/Tokens.scala
index eaffba99a4..07e888e77a 100644
--- a/src/library/scala/xml/dtd/Tokens.scala
+++ b/src/library/scala/xml/dtd/Tokens.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package dtd
diff --git a/src/library/scala/xml/dtd/ValidationException.scala b/src/library/scala/xml/dtd/ValidationException.scala
index 243db69ab7..1bfae55286 100644
--- a/src/library/scala/xml/dtd/ValidationException.scala
+++ b/src/library/scala/xml/dtd/ValidationException.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package dtd
@@ -33,7 +34,7 @@ object MakeValidationException {
def fromMissingAttribute(allKeys: Set[String]) = {
val sb = new StringBuilder("missing value for REQUIRED attribute")
- if (allKeys.size > 1) sb.append('s');
+ if (allKeys.size > 1) sb.append('s')
allKeys foreach (k => sb append "'%s'".format(k))
new ValidationException(sb.toString())
}
diff --git a/src/library/scala/util/regexp/Base.scala b/src/library/scala/xml/dtd/impl/Base.scala
index 7dbe60a34e..91ff03a93a 100644
--- a/src/library/scala/util/regexp/Base.scala
+++ b/src/library/scala/xml/dtd/impl/Base.scala
@@ -8,7 +8,8 @@
-package scala.util.regexp
+package scala
+package xml.dtd.impl
/** Basic regular expressions.
*
@@ -17,7 +18,7 @@ package scala.util.regexp
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class Base {
+private[dtd] abstract class Base {
type _regexpT <: RegExp
abstract class RegExp {
diff --git a/src/library/scala/util/automata/BaseBerrySethi.scala b/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala
index 3f6f4507a9..f30309b037 100644
--- a/src/library/scala/util/automata/BaseBerrySethi.scala
+++ b/src/library/scala/xml/dtd/impl/BaseBerrySethi.scala
@@ -6,9 +6,9 @@
** |/ **
\* */
-package scala.util.automata
+package scala
+package xml.dtd.impl
-import scala.util.regexp.{ Base }
import scala.collection.{ mutable, immutable }
// todo: replace global variable pos with acc
@@ -18,7 +18,7 @@ import scala.collection.{ mutable, immutable }
* position automata construction (also called ''Berry-Sethi'' or ''Glushkov'').
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class BaseBerrySethi {
+private[dtd] abstract class BaseBerrySethi {
val lang: Base
import lang.{ Alt, Eps, Meta, RegExp, Sequ, Star }
diff --git a/src/library/scala/util/automata/DetWordAutom.scala b/src/library/scala/xml/dtd/impl/DetWordAutom.scala
index 5d709106f8..6f8ba4de72 100644
--- a/src/library/scala/util/automata/DetWordAutom.scala
+++ b/src/library/scala/xml/dtd/impl/DetWordAutom.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.automata
+package scala
+package xml.dtd.impl
import scala.collection.{ mutable, immutable }
@@ -21,7 +22,7 @@ import scala.collection.{ mutable, immutable }
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class DetWordAutom[T <: AnyRef] {
+private[dtd] abstract class DetWordAutom[T <: AnyRef] {
val nstates: Int
val finals: Array[Int]
val delta: Array[mutable.Map[T, Int]]
diff --git a/src/library/scala/util/automata/Inclusion.scala b/src/library/scala/xml/dtd/impl/Inclusion.scala
index 91441bd3a8..07b6afaeba 100644
--- a/src/library/scala/util/automata/Inclusion.scala
+++ b/src/library/scala/xml/dtd/impl/Inclusion.scala
@@ -8,7 +8,8 @@
-package scala.util.automata
+package scala
+package xml.dtd.impl
/** A fast test of language inclusion between minimal automata.
@@ -18,7 +19,7 @@ package scala.util.automata
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
-trait Inclusion[A <: AnyRef] {
+private[dtd] trait Inclusion[A <: AnyRef] {
val labels: Seq[A]
diff --git a/src/library/scala/util/automata/NondetWordAutom.scala b/src/library/scala/xml/dtd/impl/NondetWordAutom.scala
index 24c6612d0f..0bb19a7e3e 100644
--- a/src/library/scala/util/automata/NondetWordAutom.scala
+++ b/src/library/scala/xml/dtd/impl/NondetWordAutom.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.util.automata
+package scala
+package xml.dtd.impl
import scala.collection.{ immutable, mutable }
@@ -18,7 +19,7 @@ import scala.collection.{ immutable, mutable }
* the partial function `finals` is defined.
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class NondetWordAutom[T <: AnyRef] {
+private[dtd] abstract class NondetWordAutom[T <: AnyRef] {
val nstates: Int
val labels: Seq[T]
val finals: Array[Int] // 0 means not final
@@ -37,10 +38,10 @@ abstract class NondetWordAutom[T <: AnyRef] {
/** @return true if there are no accepting states */
final def isEmpty = (0 until nstates) forall (x => !isFinal(x))
- /** @return a immutable.BitSet with the next states for given state and label */
+ /** @return an immutable.BitSet with the next states for given state and label */
def next(q: Int, a: T): immutable.BitSet = delta(q).getOrElse(a, default(q))
- /** @return a immutable.BitSet with the next states for given state and label */
+ /** @return an immutable.BitSet with the next states for given state and label */
def next(Q: immutable.BitSet, a: T): immutable.BitSet = next(Q, next(_, a))
def nextDefault(Q: immutable.BitSet): immutable.BitSet = next(Q, default)
@@ -51,7 +52,7 @@ abstract class NondetWordAutom[T <: AnyRef] {
override def toString = {
val finalString = Map(finalStates map (j => j -> finals(j)) : _*).toString
- val deltaString = (0 until nstates)
+ val deltaString = (0 until nstates)
.map(i => " %d->%s\n _>%s\n".format(i, delta(i), default(i))).mkString
"[NondetWordAutom nstates=%d finals=%s delta=\n%s".format(nstates, finalString, deltaString)
diff --git a/src/library/scala/util/regexp/PointedHedgeExp.scala b/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala
index 5c0379b6f8..1720604132 100644
--- a/src/library/scala/util/regexp/PointedHedgeExp.scala
+++ b/src/library/scala/xml/dtd/impl/PointedHedgeExp.scala
@@ -8,7 +8,8 @@
-package scala.util.regexp
+package scala
+package xml.dtd.impl
/** Pointed regular hedge expressions, a useful subclass of regular hedge expressions.
*
@@ -16,7 +17,7 @@ package scala.util.regexp
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class PointedHedgeExp extends Base {
+private[dtd] abstract class PointedHedgeExp extends Base {
type _regexpT <: RegExp
type _labelT
diff --git a/src/library/scala/util/automata/SubsetConstruction.scala b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala
index 0ee768587c..632ca1eb18 100644
--- a/src/library/scala/util/automata/SubsetConstruction.scala
+++ b/src/library/scala/xml/dtd/impl/SubsetConstruction.scala
@@ -6,12 +6,13 @@
** |/ **
\* */
-package scala.util.automata
+package scala
+package xml.dtd.impl
import scala.collection.{ mutable, immutable }
@deprecated("This class will be removed", "2.10.0")
-class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) {
+private[dtd] class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) {
import nfa.labels
def selectTag(Q: immutable.BitSet, finals: Array[Int]) =
@@ -50,7 +51,7 @@ class SubsetConstruction[T <: AnyRef](val nfa: NondetWordAutom[T]) {
addFinal(q0) // initial state may also be a final state
while (!rest.isEmpty) {
- val P = rest.pop
+ val P = rest.pop()
// assign a number to this bitset
indexMap = indexMap.updated(P, ix)
invIndexMap = invIndexMap.updated(ix, P)
diff --git a/src/library/scala/util/regexp/SyntaxError.scala b/src/library/scala/xml/dtd/impl/SyntaxError.scala
index 1788fdfb84..a5b8a5aba0 100644
--- a/src/library/scala/util/regexp/SyntaxError.scala
+++ b/src/library/scala/xml/dtd/impl/SyntaxError.scala
@@ -8,7 +8,8 @@
-package scala.util.regexp
+package scala
+package xml.dtd.impl
/** This runtime exception is thrown if an attempt to instantiate a
* syntactically incorrect expression is detected.
@@ -17,4 +18,4 @@ package scala.util.regexp
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
-class SyntaxError(e: String) extends RuntimeException(e)
+private[dtd] class SyntaxError(e: String) extends RuntimeException(e)
diff --git a/src/library/scala/util/automata/WordBerrySethi.scala b/src/library/scala/xml/dtd/impl/WordBerrySethi.scala
index 12448f595d..9bf3fa518b 100644
--- a/src/library/scala/util/automata/WordBerrySethi.scala
+++ b/src/library/scala/xml/dtd/impl/WordBerrySethi.scala
@@ -6,10 +6,10 @@
** |/ **
\* */
-package scala.util.automata
+package scala
+package xml.dtd.impl
import scala.collection.{ immutable, mutable }
-import scala.util.regexp.WordExp
/** This class turns a regular expression into a [[scala.util.automata.NondetWordAutom]]
* celebrated position automata construction (also called ''Berry-Sethi'' or ''Glushkov'').
@@ -18,10 +18,10 @@ import scala.util.regexp.WordExp
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class WordBerrySethi extends BaseBerrySethi {
+private[dtd] abstract class WordBerrySethi extends BaseBerrySethi {
override val lang: WordExp
- import lang.{ Alt, Eps, Letter, Meta, RegExp, Sequ, Star, _labelT }
+ import lang.{ Alt, Eps, Letter, RegExp, Sequ, Star, _labelT }
protected var labels: mutable.HashSet[_labelT] = _
// don't let this fool you, only labelAt is a real, surjective mapping
@@ -140,7 +140,6 @@ abstract class WordBerrySethi extends BaseBerrySethi {
val delta1 = immutable.Map(deltaq.zipWithIndex map (_.swap): _*)
val finalsArr = (0 until pos map (k => finals.getOrElse(k, 0))).toArray // 0 == not final
- val initialsArr = initials.toArray
val deltaArr: Array[mutable.Map[_labelT, immutable.BitSet]] =
(0 until pos map { x =>
@@ -152,7 +151,6 @@ abstract class WordBerrySethi extends BaseBerrySethi {
new NondetWordAutom[_labelT] {
val nstates = pos
val labels = WordBerrySethi.this.labels.toList
- val initials = initialsArr
val finals = finalsArr
val delta = deltaArr
val default = defaultArr
diff --git a/src/library/scala/util/regexp/WordExp.scala b/src/library/scala/xml/dtd/impl/WordExp.scala
index 3c0c2ec156..a4bb54c1ea 100644
--- a/src/library/scala/util/regexp/WordExp.scala
+++ b/src/library/scala/xml/dtd/impl/WordExp.scala
@@ -8,7 +8,8 @@
-package scala.util.regexp
+package scala
+package xml.dtd.impl
/**
* The class `WordExp` provides regular word expressions.
@@ -39,7 +40,7 @@ package scala.util.regexp
* @version 1.0
*/
@deprecated("This class will be removed", "2.10.0")
-abstract class WordExp extends Base {
+private[dtd] abstract class WordExp extends Base {
abstract class Label
diff --git a/src/library/scala/xml/factory/Binder.scala b/src/library/scala/xml/factory/Binder.scala
index bad4a4ea09..947f99e6a4 100755
--- a/src/library/scala/xml/factory/Binder.scala
+++ b/src/library/scala/xml/factory/Binder.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package factory
import parsing.ValidatingMarkupHandler
@@ -48,7 +49,7 @@ abstract class Binder(val preserveWS: Boolean) extends ValidatingMarkupHandler {
val old = result
result = new NodeBuffer()
for (m <- x.child) traverse(m)
- result = old &+ elem(0, x.prefix, x.label, x.attributes, x.scope, x.minimizeEmpty, NodeSeq.fromSeq(result)).toList;
+ result = old &+ elem(0, x.prefix, x.label, x.attributes, x.scope, x.minimizeEmpty, NodeSeq.fromSeq(result)).toList
elemEnd(0, x.prefix, x.label)
}
diff --git a/src/library/scala/xml/factory/LoggedNodeFactory.scala b/src/library/scala/xml/factory/LoggedNodeFactory.scala
index cac61acc39..bc074bfc83 100644
--- a/src/library/scala/xml/factory/LoggedNodeFactory.scala
+++ b/src/library/scala/xml/factory/LoggedNodeFactory.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package factory
/** This class logs what the nodefactory is actually doing.
@@ -14,8 +15,9 @@ package factory
{{{
object testLogged extends App {
val x = new scala.xml.parsing.NoBindingFactoryAdapter
- with scala.xml.factory.LoggedNodeFactory[scala.xml.Elem]
- with scala.util.logging.ConsoleLogger
+ with scala.xml.factory.LoggedNodeFactory[scala.xml.Elem] {
+ override def log(s: String) = println(s)
+ }
Console.println("Start")
val doc = x.load(new java.net.URL("http://example.com/file.xml"))
@@ -27,7 +29,8 @@ object testLogged extends App {
* @author Burak Emir
* @version 1.0
*/
-trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.logging.Logged {
+@deprecated("This trait will be removed.", "2.11")
+trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] {
// configuration values
val logNode = true
val logText = false
@@ -46,7 +49,7 @@ trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.loggin
override def makeNode(pre: String, label: String, attrSeq: MetaData,
scope: NamespaceBinding, children: Seq[Node]): A = {
if (logNode)
- log("[makeNode for "+label+"]");
+ log("[makeNode for "+label+"]")
val hash = Utility.hashCode(pre, label, attrSeq.##, scope.##, children)
@@ -59,27 +62,29 @@ trait LoggedNodeFactory[A <: Node] extends NodeFactory[A] with scala.util.loggin
}
*/
if (!cache.get( hash ).isEmpty && (logCompressLevel >= CACHE))
- log("[cache hit !]");
+ log("[cache hit !]")
super.makeNode(pre, label, attrSeq, scope, children)
}
override def makeText(s: String) = {
if (logText)
- log("[makeText:\""+s+"\"]");
+ log("[makeText:\""+s+"\"]")
super.makeText(s)
}
override def makeComment(s: String): Seq[Comment] = {
if (logComment)
- log("[makeComment:\""+s+"\"]");
+ log("[makeComment:\""+s+"\"]")
super.makeComment(s)
}
override def makeProcInstr(t: String, s: String): Seq[ProcInstr] = {
if (logProcInstr)
- log("[makeProcInstr:\""+t+" "+ s+"\"]");
+ log("[makeProcInstr:\""+t+" "+ s+"\"]")
super.makeProcInstr(t, s)
}
+ @deprecated("This method and its usages will be removed. Use a debugger to debug code.", "2.11")
+ def log(msg: String): Unit = {}
}
diff --git a/src/library/scala/xml/factory/NodeFactory.scala b/src/library/scala/xml/factory/NodeFactory.scala
index 28a1b6fff4..94801bb554 100644
--- a/src/library/scala/xml/factory/NodeFactory.scala
+++ b/src/library/scala/xml/factory/NodeFactory.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
package factory
import parsing.{ FactoryAdapter, NoBindingFactoryAdapter }
diff --git a/src/library/scala/xml/factory/XMLLoader.scala b/src/library/scala/xml/factory/XMLLoader.scala
index 72e4c51b11..b69f187039 100644
--- a/src/library/scala/xml/factory/XMLLoader.scala
+++ b/src/library/scala/xml/factory/XMLLoader.scala
@@ -7,12 +7,13 @@
\* */
-package scala.xml
+package scala
+package xml
package factory
import javax.xml.parsers.SAXParserFactory
import parsing.{ FactoryAdapter, NoBindingFactoryAdapter }
-import java.io.{ InputStream, Reader, StringReader, File, FileDescriptor, FileInputStream }
+import java.io.{ InputStream, Reader, File, FileDescriptor }
import java.net.URL
/** Presents collection of XML loading methods which use the parser
@@ -38,7 +39,7 @@ trait XMLLoader[T <: Node]
newAdapter.scopeStack push TopScope
parser.parse(source, newAdapter)
- newAdapter.scopeStack.pop
+ newAdapter.scopeStack.pop()
newAdapter.rootElem.asInstanceOf[T]
}
diff --git a/src/library/scala/xml/include/CircularIncludeException.scala b/src/library/scala/xml/include/CircularIncludeException.scala
index 5e74967d54..351f403008 100644
--- a/src/library/scala/xml/include/CircularIncludeException.scala
+++ b/src/library/scala/xml/include/CircularIncludeException.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package include
/**
diff --git a/src/library/scala/xml/include/UnavailableResourceException.scala b/src/library/scala/xml/include/UnavailableResourceException.scala
index f00cc58699..47b176e0f3 100644
--- a/src/library/scala/xml/include/UnavailableResourceException.scala
+++ b/src/library/scala/xml/include/UnavailableResourceException.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package include
/**
diff --git a/src/library/scala/xml/include/XIncludeException.scala b/src/library/scala/xml/include/XIncludeException.scala
index 84033f853f..11e1644d83 100644
--- a/src/library/scala/xml/include/XIncludeException.scala
+++ b/src/library/scala/xml/include/XIncludeException.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package include
/**
diff --git a/src/library/scala/xml/include/sax/EncodingHeuristics.scala b/src/library/scala/xml/include/sax/EncodingHeuristics.scala
index 1340689cae..57ab5ed91c 100644
--- a/src/library/scala/xml/include/sax/EncodingHeuristics.scala
+++ b/src/library/scala/xml/include/sax/EncodingHeuristics.scala
@@ -6,10 +6,9 @@
** |/ **
\* */
-
-package scala.xml
+package scala
+package xml
package include.sax
-import scala.xml.include._
import java.io.InputStream
import scala.util.matching.Regex
diff --git a/src/library/scala/xml/include/sax/Main.scala b/src/library/scala/xml/include/sax/Main.scala
deleted file mode 100644
index 92d4d6ea73..0000000000
--- a/src/library/scala/xml/include/sax/Main.scala
+++ /dev/null
@@ -1,82 +0,0 @@
-/* __ *\
-** ________ ___ / / ___ Scala API **
-** / __/ __// _ | / / / _ | (c) 2002-2013, LAMP/EPFL **
-** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
-** /____/\___/_/ |_/____/_/ | | **
-** |/ **
-\* */
-
-
-package scala.xml
-package include.sax
-
-import scala.util.control.Exception.{ catching, ignoring }
-import org.xml.sax.XMLReader
-import org.xml.sax.helpers.XMLReaderFactory
-
-@deprecated("Code example will be moved to documentation.", "2.10.0")
-object Main {
- private val namespacePrefixes = "http://xml.org/sax/features/namespace-prefixes"
- private val lexicalHandler = "http://xml.org/sax/properties/lexical-handler"
-
- /**
- * The driver method for xinc
- * Output is written to System.out via Conolse
- * </p>
- *
- * @param args contains the URLs and/or filenames
- * of the documents to be processed.
- */
- def main(args: Array[String]) {
- def saxe[T](body: => T) = catching[T](classOf[SAXException]) opt body
- def fail(msg: String) = System.err.println(msg)
-
- val parser: XMLReader =
- saxe[XMLReader](XMLReaderFactory.createXMLReader()) getOrElse (
- saxe[XMLReader](XMLReaderFactory.createXMLReader(XercesClassName)) getOrElse (
- return fail("Could not find an XML parser")
- )
- )
-
- // Need better namespace handling
- try parser.setFeature(namespacePrefixes, true)
- catch { case e: SAXException => return System.err.println(e) }
-
- if (args.isEmpty)
- return
-
- def dashR = args.size >= 2 && args(0) == "-r"
- val args2 = if (dashR) args drop 2 else args
- val resolver: Option[EntityResolver] =
- if (dashR) None
- else catching(classOf[Exception]) opt {
- val r = Class.forName(args(1)).newInstance().asInstanceOf[EntityResolver]
- parser setEntityResolver r
- r
- } orElse (return fail("Could not load requested EntityResolver"))
-
- for (arg <- args2) {
- try {
- val includer = new XIncludeFilter()
- includer setParent parser
- val s = new XIncluder(System.out, "UTF-8")
- includer setContentHandler s
-
- resolver map (includer setEntityResolver _)
- // SAXException here means will not support comments
- ignoring(classOf[SAXException]) {
- includer.setProperty(lexicalHandler, s)
- s setFilter includer
- }
- includer parse arg
- }
- catch {
- case e: SAXParseException =>
- fail(e.toString)
- fail("Problem in %s at line %d".format(e.getSystemId, e.getLineNumber))
- case e: SAXException =>
- fail(e.toString)
- }
- }
- }
-}
diff --git a/src/library/scala/xml/include/sax/XIncludeFilter.scala b/src/library/scala/xml/include/sax/XIncludeFilter.scala
index 729769366e..3fa3beefb0 100644
--- a/src/library/scala/xml/include/sax/XIncludeFilter.scala
+++ b/src/library/scala/xml/include/sax/XIncludeFilter.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package include.sax
import scala.xml.include._
@@ -147,10 +148,10 @@ class XIncludeFilter extends XMLFilterImpl {
if (parse equals "text") {
val encoding = atts getValue "encoding"
- includeTextDocument(href, encoding);
+ includeTextDocument(href, encoding)
}
else if (parse equals "xml") {
- includeXMLDocument(href);
+ includeXMLDocument(href)
}
// Need to check this also in DOM and JDOM????
else {
@@ -184,7 +185,7 @@ class XIncludeFilter extends XMLFilterImpl {
}
}
- private var depth = 0;
+ private var depth = 0
override def startDocument() {
level = 0
@@ -240,7 +241,7 @@ class XIncludeFilter extends XMLFilterImpl {
}
locationString = (" in document included from " + publicID
+ " at " + systemID
- + " at line " + line + ", column " + column);
+ + " at line " + line + ", column " + column)
locationString
}
@@ -258,7 +259,7 @@ class XIncludeFilter extends XMLFilterImpl {
*/
private def includeTextDocument(url: String, encoding1: String) {
var encoding = encoding1
- if (encoding == null || encoding.trim().equals("")) encoding = "UTF-8";
+ if (encoding == null || encoding.trim().equals("")) encoding = "UTF-8"
var source: URL = null
try {
val base = bases.peek().asInstanceOf[URL]
@@ -275,7 +276,7 @@ class XIncludeFilter extends XMLFilterImpl {
try {
val uc = source.openConnection()
val in = new BufferedInputStream(uc.getInputStream())
- var encodingFromHeader = uc.getContentEncoding()
+ val encodingFromHeader = uc.getContentEncoding()
var contentType = uc.getContentType()
if (encodingFromHeader != null)
encoding = encodingFromHeader
@@ -284,13 +285,13 @@ class XIncludeFilter extends XMLFilterImpl {
// MIME types are case-insensitive
// Java may be picking this up from file URL
if (contentType != null) {
- contentType = contentType.toLowerCase();
+ contentType = contentType.toLowerCase()
if (contentType.equals("text/xml")
|| contentType.equals("application/xml")
|| (contentType.startsWith("text/") && contentType.endsWith("+xml") )
|| (contentType.startsWith("application/") && contentType.endsWith("+xml"))) {
- encoding = EncodingHeuristics.readEncodingFromStream(in);
- }
+ encoding = EncodingHeuristics.readEncodingFromStream(in)
+ }
}
}
val reader = new InputStreamReader(in, encoding)
diff --git a/src/library/scala/xml/include/sax/XIncluder.scala b/src/library/scala/xml/include/sax/XIncluder.scala
index 5064d6b3d8..531b7196f2 100644
--- a/src/library/scala/xml/include/sax/XIncluder.scala
+++ b/src/library/scala/xml/include/sax/XIncluder.scala
@@ -6,11 +6,10 @@
** |/ **
\* */
-
-package scala.xml
+package scala
+package xml
package include.sax
-import scala.xml.include._
import scala.collection.mutable
import org.xml.sax.{ ContentHandler, XMLReader, Locator, Attributes }
import org.xml.sax.ext.LexicalHandler
@@ -30,7 +29,7 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit
def startDocument() {
try {
out.write("<?xml version='1.0' encoding='"
- + encoding + "'?>\r\n");
+ + encoding + "'?>\r\n")
}
catch {
case e:IOException =>
@@ -54,16 +53,16 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit
def startElement(namespaceURI: String, localName: String, qualifiedName: String, atts: Attributes) = {
try {
- out.write("<" + qualifiedName);
+ out.write("<" + qualifiedName)
var i = 0; while (i < atts.getLength()) {
- out.write(" ");
- out.write(atts.getQName(i));
- out.write("='");
- val value = atts.getValue(i);
+ out.write(" ")
+ out.write(atts.getQName(i))
+ out.write("='")
+ val value = atts.getValue(i)
// @todo Need to use character references if the encoding
// can't support the character
out.write(scala.xml.Utility.escape(value))
- out.write("'");
+ out.write("'")
i += 1
}
out.write(">")
@@ -89,20 +88,20 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit
def characters(ch: Array[Char], start: Int, length: Int) {
try {
var i = 0; while (i < length) {
- val c = ch(start+i);
- if (c == '&') out.write("&amp;");
- else if (c == '<') out.write("&lt;");
+ val c = ch(start+i)
+ if (c == '&') out.write("&amp;")
+ else if (c == '<') out.write("&lt;")
// This next fix is normally not necessary.
// However, it is required if text contains ]]>
// (The end CDATA section delimiter)
- else if (c == '>') out.write("&gt;");
- else out.write(c);
+ else if (c == '>') out.write("&gt;")
+ else out.write(c)
i += 1
}
}
catch {
case e: IOException =>
- throw new SAXException("Write failed", e);
+ throw new SAXException("Write failed", e)
}
}
@@ -140,8 +139,8 @@ class XIncluder(outs: OutputStream, encoding: String) extends ContentHandler wit
// if this is the source document, output a DOCTYPE declaration
if (entities.isEmpty) {
var id = ""
- if (publicID != null) id = " PUBLIC \"" + publicID + "\" \"" + systemID + '"';
- else if (systemID != null) id = " SYSTEM \"" + systemID + '"';
+ if (publicID != null) id = " PUBLIC \"" + publicID + "\" \"" + systemID + '"'
+ else if (systemID != null) id = " SYSTEM \"" + systemID + '"'
try {
out.write("<!DOCTYPE " + name + id + ">\r\n")
}
diff --git a/src/library/scala/xml/parsing/ConstructingHandler.scala b/src/library/scala/xml/parsing/ConstructingHandler.scala
index 6fda4dabfb..ba416e4301 100755
--- a/src/library/scala/xml/parsing/ConstructingHandler.scala
+++ b/src/library/scala/xml/parsing/ConstructingHandler.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package parsing
/** Implementation of MarkupHandler that constructs nodes.
diff --git a/src/library/scala/xml/parsing/ConstructingParser.scala b/src/library/scala/xml/parsing/ConstructingParser.scala
index 404411812e..3caeddabf4 100644
--- a/src/library/scala/xml/parsing/ConstructingParser.scala
+++ b/src/library/scala/xml/parsing/ConstructingParser.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package parsing
import java.io.File
diff --git a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala
index 0152e44cda..6ec7474843 100755
--- a/src/library/scala/xml/parsing/DefaultMarkupHandler.scala
+++ b/src/library/scala/xml/parsing/DefaultMarkupHandler.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package parsing
diff --git a/src/library/scala/xml/parsing/ExternalSources.scala b/src/library/scala/xml/parsing/ExternalSources.scala
index aaac588092..bb939bca95 100644
--- a/src/library/scala/xml/parsing/ExternalSources.scala
+++ b/src/library/scala/xml/parsing/ExternalSources.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package parsing
import java.net.URL
diff --git a/src/library/scala/xml/parsing/FactoryAdapter.scala b/src/library/scala/xml/parsing/FactoryAdapter.scala
index 5f776f5299..2154bdf5ba 100644
--- a/src/library/scala/xml/parsing/FactoryAdapter.scala
+++ b/src/library/scala/xml/parsing/FactoryAdapter.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package parsing
import java.io.{ InputStream, Reader, File, FileDescriptor, FileInputStream }
@@ -26,7 +27,7 @@ trait ConsoleErrorHandler extends DefaultHandler {
val s = "[%s]:%d:%d: %s".format(
errtype, ex.getLineNumber, ex.getColumnNumber, ex.getMessage)
Console.println(s)
- Console.flush
+ Console.flush()
}
}
@@ -91,7 +92,7 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
else {
var it = ch.slice(offset, offset + length).iterator
while (it.hasNext) {
- val c = it.next
+ val c = it.next()
val isSpace = c.isWhitespace
buffer append (if (isSpace) ' ' else c)
if (isSpace)
@@ -164,17 +165,17 @@ abstract class FactoryAdapter extends DefaultHandler with factory.XMLLoader[Node
*/
override def endElement(uri: String , _localName: String, qname: String): Unit = {
captureText()
- val metaData = attribStack.pop
+ val metaData = attribStack.pop()
// reverse order to get it right
val v = (Iterator continually hStack.pop takeWhile (_ != null)).toList.reverse
val (pre, localName) = splitName(qname)
- val scp = scopeStack.pop
+ val scp = scopeStack.pop()
// create element
rootElem = createNode(pre, localName, metaData, scp, v)
hStack push rootElem
- curTag = tagStack.pop
+ curTag = tagStack.pop()
capture = curTag != null && nodeContainsText(curTag) // root level
}
diff --git a/src/library/scala/xml/parsing/FatalError.scala b/src/library/scala/xml/parsing/FatalError.scala
index a8b4f8f8cf..ab3cb2a74d 100644
--- a/src/library/scala/xml/parsing/FatalError.scala
+++ b/src/library/scala/xml/parsing/FatalError.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package parsing
/** !!! This is poorly named, but I guess it's in the API.
diff --git a/src/library/scala/xml/parsing/MarkupHandler.scala b/src/library/scala/xml/parsing/MarkupHandler.scala
index 7028161821..1ebffb9c90 100755
--- a/src/library/scala/xml/parsing/MarkupHandler.scala
+++ b/src/library/scala/xml/parsing/MarkupHandler.scala
@@ -8,12 +8,12 @@
-package scala.xml
+package scala
+package xml
package parsing
import scala.collection.mutable
import scala.io.Source
-import scala.util.logging.Logged
import scala.xml.dtd._
/** class that handles markup - provides callback methods to MarkupParser.
@@ -25,8 +25,8 @@ import scala.xml.dtd._
* @todo can we ignore more entity declarations (i.e. those with extIDs)?
* @todo expanding entity references
*/
-abstract class MarkupHandler extends Logged
-{
+abstract class MarkupHandler {
+
/** returns true is this markup handler is validating */
val isValidating: Boolean = false
@@ -121,4 +121,7 @@ abstract class MarkupHandler extends Logged
def unparsedEntityDecl(name: String, extID: ExternalID, notat: String): Unit = ()
def notationDecl(notat: String, extID: ExternalID): Unit = ()
def reportSyntaxError(pos: Int, str: String): Unit
+
+ @deprecated("This method and its usages will be removed. Use a debugger to debug code.", "2.11")
+ def log(msg: String): Unit = {}
}
diff --git a/src/library/scala/xml/parsing/MarkupParser.scala b/src/library/scala/xml/parsing/MarkupParser.scala
index f9ff54d054..3bbd136b67 100755
--- a/src/library/scala/xml/parsing/MarkupParser.scala
+++ b/src/library/scala/xml/parsing/MarkupParser.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package parsing
import scala.io.Source
@@ -102,13 +103,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
def ch: Char = {
if (nextChNeeded) {
if (curInput.hasNext) {
- lastChRead = curInput.next
+ lastChRead = curInput.next()
pos = curInput.pos
} else {
- val ilen = inpStack.length;
+ val ilen = inpStack.length
//Console.println(" ilen = "+ilen+ " extIndex = "+extIndex);
if ((ilen != extIndex) && (ilen > 0)) {
- /** for external source, inpStack == Nil ! need notify of eof! */
+ /* for external source, inpStack == Nil ! need notify of eof! */
pop()
} else {
reachedEof = true
@@ -138,10 +139,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* }}} */
def xmlProcInstr(): MetaData = {
xToken("xml")
- xSpace
+ xSpace()
val (md,scp) = xAttributes(TopScope)
if (scp != TopScope)
- reportSyntaxError("no xmlns definitions here, please.");
+ reportSyntaxError("no xmlns definitions here, please.")
xToken('?')
xToken('>')
md
@@ -154,11 +155,11 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
var info_enc: Option[String] = None
var info_stdl: Option[Boolean] = None
- var m = xmlProcInstr()
+ val m = xmlProcInstr()
var n = 0
if (isProlog)
- xSpaceOpt
+ xSpaceOpt()
m("version") match {
case null =>
@@ -199,11 +200,11 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* // this is a bit more lenient than necessary...
* }}} */
def prolog(): (Option[String], Option[String], Option[Boolean]) =
- prologOrTextDecl(true)
+ prologOrTextDecl(isProlog = true)
/** prolog, but without standalone */
def textDecl(): (Option[String], Option[String]) =
- prologOrTextDecl(false) match { case (x1, x2, _) => (x1, x2) }
+ prologOrTextDecl(isProlog = false) match { case (x1, x2, _) => (x1, x2) }
/** {{{
* [22] prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
@@ -223,10 +224,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
return null
}
- nextch // is prolog ?
+ nextch() // is prolog ?
var children: NodeSeq = null
if ('?' == ch) {
- nextch
+ nextch()
info_prolog = prolog()
doc.version = info_prolog._1
doc.encoding = info_prolog._2
@@ -247,7 +248,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
case _:ProcInstr =>
case _:Comment =>
case _:EntityRef => // todo: fix entities, shouldn't be "special"
- reportSyntaxError("no entity references allowed here");
+ reportSyntaxError("no entity references allowed here")
case s:SpecialNode =>
if (s.toString.trim().length > 0) //non-empty text nodes not allowed
elemCount += 2
@@ -272,7 +273,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* after construction, this method formalizes that suboptimal reality.
*/
def initialize: this.type = {
- nextch
+ nextch()
this
}
@@ -303,10 +304,8 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
var scope: NamespaceBinding = pscope
var aMap: MetaData = Null
while (isNameStart(ch)) {
- val pos = this.pos
-
val qname = xName
- val _ = xEQ
+ xEQ() // side effect
val value = xAttributeValue()
Utility.prefix(qname) match {
@@ -326,11 +325,11 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
}
if ((ch != '/') && (ch != '>') && ('?' != ch))
- xSpace
+ xSpace()
}
if(!aMap.wellformed(scope))
- reportSyntaxError( "double attribute");
+ reportSyntaxError( "double attribute")
(aMap,scope)
}
@@ -343,12 +342,12 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
*/
def xEntityValue(): String = {
val endch = ch
- nextch
+ nextch()
while (ch != endch && !eof) {
putChar(ch)
- nextch
+ nextch()
}
- nextch
+ nextch()
val str = cbuf.toString()
cbuf.length = 0
str
@@ -377,13 +376,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
val sb: StringBuilder = new StringBuilder()
xToken("--")
while (true) {
- if (ch == '-' && { sb.append(ch); nextch; ch == '-' }) {
+ if (ch == '-' && { sb.append(ch); nextch(); ch == '-' }) {
sb.length = sb.length - 1
- nextch
+ nextch()
xToken('>')
return handle.comment(pos, sb.toString())
} else sb.append(ch)
- nextch
+ nextch()
}
throw FatalError("this cannot happen")
}
@@ -391,10 +390,10 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
/* todo: move this into the NodeBuilder class */
def appendText(pos: Int, ts: NodeBuffer, txt: String): Unit = {
if (preserveWS)
- ts &+ handle.text(pos, txt);
+ ts &+ handle.text(pos, txt)
else
for (t <- TextBuffer.fromString(txt).toText) {
- ts &+ handle.text(pos, t.text);
+ ts &+ handle.text(pos, t.text)
}
}
@@ -404,7 +403,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
def content1(pscope: NamespaceBinding, ts: NodeBuffer) {
ch match {
case '!' =>
- nextch
+ nextch()
if ('[' == ch) // CDATA
ts &+ xCharData
else if ('D' == ch) // doctypedecl, parse DTD // @todo REMOVE HACK
@@ -412,7 +411,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
else // comment
ts &+ xComment
case '?' => // PI
- nextch
+ nextch()
ts &+ xProcInstr
case _ =>
ts &+ element1(pscope) // child
@@ -423,7 +422,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* content1 ::= '<' content1 | '&' charref ...
* }}} */
def content(pscope: NamespaceBinding): NodeSeq = {
- var ts = new NodeBuffer
+ val ts = new NodeBuffer
var exit = eof
// todo: optimize seq repr.
def done = new NodeSeq { val theSeq = ts.toList }
@@ -437,18 +436,18 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
ch match {
case '<' => // another tag
- nextch; ch match {
+ nextch(); ch match {
case '/' => exit = true // end tag
case _ => content1(pscope, ts)
}
// postcond: xEmbeddedBlock == false!
case '&' => // EntityRef or CharRef
- nextch; ch match {
+ nextch(); ch match {
case '#' => // CharacterRef
- nextch
- val theChar = handle.text(tmppos, xCharRef(() => ch, () => nextch))
- xToken(';');
+ nextch()
+ val theChar = handle.text(tmppos, xCharRef(() => ch, () => nextch()))
+ xToken(';')
ts &+ theChar
case _ => // EntityRef
val n = xName
@@ -472,16 +471,16 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* }}} */
def externalID(): ExternalID = ch match {
case 'S' =>
- nextch
+ nextch()
xToken("YSTEM")
- xSpace
+ xSpace()
val sysID = systemLiteral()
new SystemID(sysID)
case 'P' =>
- nextch; xToken("UBLIC")
- xSpace
+ nextch(); xToken("UBLIC")
+ xSpace()
val pubID = pubidLiteral()
- xSpace
+ xSpace()
val sysID = systemLiteral()
new PublicID(pubID, sysID)
}
@@ -497,13 +496,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
if (this.dtd ne null)
reportSyntaxError("unexpected character (DOCTYPE already defined")
xToken("DOCTYPE")
- xSpace
+ xSpace()
val n = xName
- xSpace
+ xSpace()
//external ID
if ('S' == ch || 'P' == ch) {
extID = externalID()
- xSpaceOpt
+ xSpaceOpt()
}
/* parse external subset of DTD
@@ -520,12 +519,12 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
}
if ('[' == ch) { // internal subset
- nextch
+ nextch()
/* TODO */
intSubset()
// TODO: do the DTD parsing?? ?!?!?!?!!
xToken(']')
- xSpaceOpt
+ xSpaceOpt()
}
xToken('>')
this.dtd = new DTD {
@@ -582,8 +581,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
var exit = false
while (! exit) {
putChar(ch)
- val opos = pos
- nextch
+ nextch()
exit = eof || ( ch == '<' ) || ( ch == '&' )
}
@@ -600,13 +598,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
def systemLiteral(): String = {
val endch = ch
if (ch != '\'' && ch != '"')
- reportSyntaxError("quote ' or \" expected");
- nextch
+ reportSyntaxError("quote ' or \" expected")
+ nextch()
while (ch != endch && !eof) {
putChar(ch)
- nextch
+ nextch()
}
- nextch
+ nextch()
val str = cbuf.toString()
cbuf.length = 0
str
@@ -618,16 +616,16 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
def pubidLiteral(): String = {
val endch = ch
if (ch!='\'' && ch != '"')
- reportSyntaxError("quote ' or \" expected");
- nextch
+ reportSyntaxError("quote ' or \" expected")
+ nextch()
while (ch != endch && !eof) {
putChar(ch)
//println("hello '"+ch+"'"+isPubIDChar(ch))
if (!isPubIDChar(ch))
reportSyntaxError("char '"+ch+"' is not allowed in public id")
- nextch
+ nextch()
}
- nextch
+ nextch()
val str = cbuf.toString
cbuf.length = 0
str
@@ -640,9 +638,9 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
def extSubset(): Unit = {
var textdecl: (Option[String],Option[String]) = null
if (ch == '<') {
- nextch
+ nextch()
if (ch == '?') {
- nextch
+ nextch()
textdecl = textDecl()
} else
markupDecl1()
@@ -653,13 +651,13 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
def markupDecl1() = {
def doInclude() = {
- xToken('['); while(']' != ch) markupDecl(); nextch // ']'
+ xToken('['); while(']' != ch) markupDecl(); nextch() // ']'
}
def doIgnore() = {
- xToken('['); while(']' != ch) nextch; nextch // ']'
+ xToken('['); while(']' != ch) nextch(); nextch() // ']'
}
if ('?' == ch) {
- nextch
+ nextch()
xProcInstr // simply ignore processing instructions!
} else {
xToken('!')
@@ -668,35 +666,35 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
xComment // ignore comments
case 'E' =>
- nextch
+ nextch()
if ('L' == ch) {
- nextch
+ nextch()
elementDecl()
} else
entityDecl()
case 'A' =>
- nextch
+ nextch()
attrDecl()
case 'N' =>
- nextch
+ nextch()
notationDecl()
case '[' if inpStack.length >= extIndex =>
- nextch
- xSpaceOpt
+ nextch()
+ xSpaceOpt()
ch match {
case '%' =>
- nextch
+ nextch()
val ent = xName
xToken(';')
- xSpaceOpt
+ xSpaceOpt()
push(ent)
- xSpaceOpt
+ xSpaceOpt()
val stmt = xName
- xSpaceOpt
+ xSpaceOpt()
stmt match {
// parameter entity
@@ -704,15 +702,15 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
case "IGNORE" => doIgnore()
}
case 'I' =>
- nextch
+ nextch()
ch match {
case 'G' =>
- nextch
+ nextch()
xToken("NORE")
- xSpaceOpt
+ xSpaceOpt()
doIgnore()
case 'N' =>
- nextch
+ nextch()
xToken("NCLUDE")
doInclude()
}
@@ -723,14 +721,14 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
case _ =>
curInput.reportError(pos, "unexpected character '"+ch+"', expected some markupdecl")
while (ch!='>')
- nextch
+ nextch()
}
}
}
def markupDecl(): Unit = ch match {
case '%' => // parameter entity reference
- nextch
+ nextch()
val ent = xName
xToken(';')
if (!isValidating)
@@ -740,20 +738,20 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
//peReference
case '<' =>
- nextch
+ nextch()
markupDecl1()
case _ if isSpace(ch) =>
- xSpace
+ xSpace()
case _ =>
reportSyntaxError("markupdecl: unexpected character '"+ch+"' #" + ch.toInt)
- nextch
+ nextch()
}
/** "rec-xml/#ExtSubset" pe references may not occur within markup declarations
*/
def intSubset() {
//Console.println("(DEBUG) intSubset()")
- xSpace
+ xSpace()
while (']' != ch)
markupDecl()
}
@@ -762,16 +760,16 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
*/
def elementDecl() {
xToken("EMENT")
- xSpace
+ xSpace()
val n = xName
- xSpace
+ xSpace()
while ('>' != ch) {
//Console.println("["+ch+"]")
putChar(ch)
- nextch
+ nextch()
}
//Console.println("END["+ch+"]")
- nextch
+ nextch()
val cmstr = cbuf.toString()
cbuf.length = 0
handle.elemDecl(n, cmstr)
@@ -782,44 +780,44 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* }}} */
def attrDecl() = {
xToken("TTLIST")
- xSpace
+ xSpace()
val n = xName
- xSpace
+ xSpace()
var attList: List[AttrDecl] = Nil
// later: find the elemDecl for n
while ('>' != ch) {
val aname = xName
- xSpace
+ xSpace()
// could be enumeration (foo,bar) parse this later :-/
while ('"' != ch && '\'' != ch && '#' != ch && '<' != ch) {
if (!isSpace(ch))
cbuf.append(ch)
- nextch
+ nextch()
}
val atpe = cbuf.toString
cbuf.length = 0
val defdecl: DefaultDecl = ch match {
case '\'' | '"' =>
- DEFAULT(false, xAttributeValue())
+ DEFAULT(fixed = false, xAttributeValue())
case '#' =>
- nextch
+ nextch()
xName match {
- case "FIXED" => xSpace ; DEFAULT(true, xAttributeValue())
+ case "FIXED" => xSpace() ; DEFAULT(fixed = true, xAttributeValue())
case "IMPLIED" => IMPLIED
case "REQUIRED" => REQUIRED
}
case _ =>
null
}
- xSpaceOpt
+ xSpaceOpt()
attList ::= AttrDecl(aname, atpe, defdecl)
cbuf.length = 0
}
- nextch
+ nextch()
handle.attListDecl(n, attList.reverse)
}
@@ -828,41 +826,40 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* }}} */
def entityDecl() = {
var isParameterEntity = false
- var entdef: EntityDef = null
xToken("NTITY")
- xSpace
+ xSpace()
if ('%' == ch) {
- nextch
+ nextch()
isParameterEntity = true
- xSpace
+ xSpace()
}
val n = xName
- xSpace
+ xSpace()
ch match {
case 'S' | 'P' => //sy
val extID = externalID()
if (isParameterEntity) {
- xSpaceOpt
+ xSpaceOpt()
xToken('>')
handle.parameterEntityDecl(n, ExtDef(extID))
} else { // notation?
- xSpace
+ xSpace()
if ('>' != ch) {
xToken("NDATA")
- xSpace
+ xSpace()
val notat = xName
- xSpaceOpt
+ xSpaceOpt()
xToken('>')
handle.unparsedEntityDecl(n, extID, notat)
} else {
- nextch
+ nextch()
handle.parsedEntityDecl(n, ExtDef(extID))
}
}
case '"' | '\'' =>
val av = xEntityValue()
- xSpaceOpt
+ xSpaceOpt()
xToken('>')
if (isParameterEntity)
handle.parameterEntityDecl(n, IntDef(av))
@@ -877,29 +874,29 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
* }}} */
def notationDecl() {
xToken("OTATION")
- xSpace
+ xSpace()
val notat = xName
- xSpace
+ xSpace()
val extID = if (ch == 'S') {
externalID()
}
else if (ch == 'P') {
- /** PublicID (without system, only used in NOTATION) */
- nextch
+ /* PublicID (without system, only used in NOTATION) */
+ nextch()
xToken("UBLIC")
- xSpace
+ xSpace()
val pubID = pubidLiteral()
- xSpaceOpt
+ xSpaceOpt()
val sysID = if (ch != '>')
systemLiteral()
else
- null;
+ null
new PublicID(pubID, sysID)
} else {
- reportSyntaxError("PUBLIC or SYSTEM expected");
+ reportSyntaxError("PUBLIC or SYSTEM expected")
scala.sys.error("died parsing notationdecl")
}
- xSpaceOpt
+ xSpaceOpt()
xToken('>')
handle.notationDecl(notat, extID)
}
@@ -916,7 +913,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
ch
curInput = replacementText(entityName)
- nextch
+ nextch()
}
def pushExternal(systemId: String) {
@@ -927,7 +924,7 @@ trait MarkupParser extends MarkupParserCommon with TokenTests
ch
curInput = externalSource(systemId)
- nextch
+ nextch()
}
def pop() {
diff --git a/src/library/scala/xml/parsing/MarkupParserCommon.scala b/src/library/scala/xml/parsing/MarkupParserCommon.scala
index da640484e0..57c1651558 100644
--- a/src/library/scala/xml/parsing/MarkupParserCommon.scala
+++ b/src/library/scala/xml/parsing/MarkupParserCommon.scala
@@ -6,11 +6,11 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package parsing
import scala.io.Source
-import scala.xml.dtd._
import scala.annotation.switch
import Utility.Escapes.{ pairs => unescape }
@@ -39,7 +39,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
*/
protected def xTag(pscope: NamespaceType): (String, AttributesType) = {
val name = xName
- xSpaceOpt
+ xSpaceOpt()
(name, mkAttributes(name, pscope))
}
@@ -50,7 +50,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
*/
def xProcInstr: ElementType = {
val n = xName
- xSpaceOpt
+ xSpaceOpt()
xTakeUntil(mkProcInstr(_, n, _), () => tmppos, "?>")
}
@@ -78,7 +78,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
private def takeUntilChar(it: Iterator[Char], end: Char): String = {
val buf = new StringBuilder
- while (it.hasNext) it.next match {
+ while (it.hasNext) it.next() match {
case `end` => return buf.toString
case ch => buf append ch
}
@@ -92,7 +92,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
if (xName != startName)
errorNoEnd(startName)
- xSpaceOpt
+ xSpaceOpt()
xToken('>')
}
@@ -139,9 +139,9 @@ private[scala] trait MarkupParserCommon extends TokenTests {
val buf = new StringBuilder
val it = attval.iterator.buffered
- while (it.hasNext) buf append (it.next match {
+ while (it.hasNext) buf append (it.next() match {
case ' ' | '\t' | '\n' | '\r' => " "
- case '&' if it.head == '#' => it.next ; xCharRef(it)
+ case '&' if it.head == '#' => it.next() ; xCharRef(it)
case '&' => attr_unescape(takeUntilChar(it, ';'))
case c => c
})
@@ -158,11 +158,11 @@ private[scala] trait MarkupParserCommon extends TokenTests {
Utility.parseCharRef(ch, nextch, reportSyntaxError _, truncatedError _)
def xCharRef(it: Iterator[Char]): String = {
- var c = it.next
- Utility.parseCharRef(() => c, () => { c = it.next }, reportSyntaxError _, truncatedError _)
+ var c = it.next()
+ Utility.parseCharRef(() => c, () => { c = it.next() }, reportSyntaxError _, truncatedError _)
}
- def xCharRef: String = xCharRef(() => ch, () => nextch)
+ def xCharRef: String = xCharRef(() => ch, () => nextch())
/** Create a lookahead reader which does not influence the input */
def lookahead(): BufferedIterator[Char]
@@ -195,20 +195,20 @@ private[scala] trait MarkupParserCommon extends TokenTests {
}
def xToken(that: Char) {
- if (ch == that) nextch
+ if (ch == that) nextch()
else xHandleError(that, "'%s' expected instead of '%s'".format(that, ch))
}
def xToken(that: Seq[Char]) { that foreach xToken }
/** scan [S] '=' [S]*/
- def xEQ() = { xSpaceOpt; xToken('='); xSpaceOpt }
+ def xEQ() = { xSpaceOpt(); xToken('='); xSpaceOpt() }
/** skip optional space S? */
- def xSpaceOpt() = while (isSpace(ch) && !eof) nextch
+ def xSpaceOpt() = while (isSpace(ch) && !eof) nextch()
/** scan [3] S ::= (#x20 | #x9 | #xD | #xA)+ */
def xSpace() =
- if (isSpace(ch)) { nextch; xSpaceOpt }
+ if (isSpace(ch)) { nextch(); xSpaceOpt() }
else xHandleError(ch, "whitespace expected")
/** Apply a function and return the passed value */
@@ -241,7 +241,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
truncatedError("") // throws TruncatedXMLControl in compiler
sb append ch
- nextch
+ nextch()
}
unreachable
}
@@ -254,7 +254,7 @@ private[scala] trait MarkupParserCommon extends TokenTests {
private def peek(lookingFor: String): Boolean =
(lookahead() take lookingFor.length sameElements lookingFor.iterator) && {
// drop the chars from the real reader (all lookahead + orig)
- (0 to lookingFor.length) foreach (_ => nextch)
+ (0 to lookingFor.length) foreach (_ => nextch())
true
}
}
diff --git a/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala b/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala
index 22dd450072..56ac185f47 100644
--- a/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala
+++ b/src/library/scala/xml/parsing/NoBindingFactoryAdapter.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
package parsing
import factory.NodeFactory
diff --git a/src/library/scala/xml/parsing/TokenTests.scala b/src/library/scala/xml/parsing/TokenTests.scala
index c9cafaeea1..8dd9cdfaa3 100644
--- a/src/library/scala/xml/parsing/TokenTests.scala
+++ b/src/library/scala/xml/parsing/TokenTests.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package parsing
/**
diff --git a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala
index 0edea043a5..1b20901249 100644
--- a/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala
+++ b/src/library/scala/xml/parsing/ValidatingMarkupHandler.scala
@@ -8,13 +8,13 @@
-package scala.xml
+package scala
+package xml
package parsing
import scala.xml.dtd._
-import scala.util.logging.Logged
-abstract class ValidatingMarkupHandler extends MarkupHandler with Logged {
+abstract class ValidatingMarkupHandler extends MarkupHandler {
var rootLabel:String = _
var qStack: List[Int] = Nil
@@ -25,20 +25,6 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged {
final override val isValidating = true
- override def log(msg: String) {}
-
- /*
- override def checkChildren(pos: Int, pre: String, label:String,ns:NodeSeq): Unit = {
- Console.println("checkChildren()");
- val decl = lookupElemDecl(label);
- // @todo: nice error message
- val res = decl.contentModel.validate(ns);
- Console.println("res = "+res);
- if(!res)
- //sys.error("invalid!");
- }
- */
-
override def endDTD(n:String) = {
rootLabel = n
}
@@ -50,8 +36,8 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged {
log("advanceDFA(trans): " + trans)
trans.get(ContentModel.ElemName(label)) match {
case Some(qNew) => qCurrent = qNew
- case _ => reportValidationError(pos, "DTD says, wrong element, expected one of "+trans.keys);
- }
+ case _ => reportValidationError(pos, "DTD says, wrong element, expected one of "+trans.keys)
+ }
}
// advance in current automaton
log("[qCurrent = "+qCurrent+" visiting "+label+"]")
@@ -106,7 +92,7 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged {
}
final override def notationDecl(notat: String, extID: ExternalID) {
- decls = NotationDecl(notat, extID) :: decls;
+ decls = NotationDecl(notat, extID) :: decls
}
final override def peReference(name: String) {
@@ -115,5 +101,4 @@ abstract class ValidatingMarkupHandler extends MarkupHandler with Logged {
/** report a syntax error */
def reportValidationError(pos: Int, str: String): Unit
-
}
diff --git a/src/library/scala/xml/parsing/XhtmlEntities.scala b/src/library/scala/xml/parsing/XhtmlEntities.scala
index 1bb843818a..3683af202c 100644
--- a/src/library/scala/xml/parsing/XhtmlEntities.scala
+++ b/src/library/scala/xml/parsing/XhtmlEntities.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package parsing
import scala.xml.dtd.{ IntDef, ParsedEntityDecl }
diff --git a/src/library/scala/xml/parsing/XhtmlParser.scala b/src/library/scala/xml/parsing/XhtmlParser.scala
index d08cb1fa9c..6ce5bec8d0 100644
--- a/src/library/scala/xml/parsing/XhtmlParser.scala
+++ b/src/library/scala/xml/parsing/XhtmlParser.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package parsing
import scala.io.Source
@@ -26,5 +27,5 @@ class XhtmlParser(val input: Source) extends ConstructingHandler with MarkupPars
* @author Burak Emir
*/
object XhtmlParser {
- def apply(source: Source): NodeSeq = new XhtmlParser(source).initialize.document
+ def apply(source: Source): NodeSeq = new XhtmlParser(source).initialize.document()
}
diff --git a/src/library/scala/xml/persistent/CachedFileStorage.scala b/src/library/scala/xml/persistent/CachedFileStorage.scala
index 916a1a0cf7..57d512a041 100644
--- a/src/library/scala/xml/persistent/CachedFileStorage.scala
+++ b/src/library/scala/xml/persistent/CachedFileStorage.scala
@@ -6,14 +6,15 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package persistent
import java.io.{ File, FileOutputStream }
import java.nio.ByteBuffer
import java.nio.channels.Channels
import java.lang.Thread
-import scala.util.logging.Logged
+
import scala.collection.Iterator
/** Mutable storage of immutable xml trees. Everything is kept in memory,
@@ -25,7 +26,7 @@ import scala.collection.Iterator
*
* @author Burak Emir
*/
-abstract class CachedFileStorage(private val file1: File) extends Thread with Logged {
+abstract class CachedFileStorage(private val file1: File) extends Thread {
private val file2 = new File(file1.getParent, file1.getName+"$")
@@ -76,8 +77,8 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo
log("[load]\nloading "+theFile)
val src = Source.fromFile(theFile)
log("parsing "+theFile)
- val res = ConstructingParser.fromSource(src,false).document.docElem(0)
- switch
+ val res = ConstructingParser.fromSource(src,preserveWS = false).document.docElem(0)
+ switch()
log("[load done]")
res.child.iterator
}
@@ -94,7 +95,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo
// @todo: optimize
val storageNode = <nodes>{ nodes.toList }</nodes>
val w = Channels.newWriter(c, "utf-8")
- XML.write(w, storageNode, "utf-8", true, null)
+ XML.write(w, storageNode, "utf-8", xmlDecl = true, doctype = null)
log("writing to "+theFile)
@@ -102,7 +103,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo
c.close
fos.close
dirty = false
- switch
+ switch()
log("[save done]")
}
@@ -112,7 +113,7 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo
log("[run]\nstarting storage thread, checking every "+interval+" ms")
while (true) {
Thread.sleep( this.interval )
- save
+ save()
}
}
@@ -120,6 +121,9 @@ abstract class CachedFileStorage(private val file1: File) extends Thread with Lo
* update. */
def flush() = {
this.dirty = true
- save
+ save()
}
+
+ @deprecated("This method and its usages will be removed. Use a debugger to debug code.", "2.11")
+ def log(msg: String): Unit = {}
}
diff --git a/src/library/scala/xml/persistent/Index.scala b/src/library/scala/xml/persistent/Index.scala
index defaf67d52..9ee45e7086 100644
--- a/src/library/scala/xml/persistent/Index.scala
+++ b/src/library/scala/xml/persistent/Index.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package persistent
/** an Index returns some unique key that is part of a node
diff --git a/src/library/scala/xml/persistent/SetStorage.scala b/src/library/scala/xml/persistent/SetStorage.scala
index 20a5bb6767..8db56a2e71 100644
--- a/src/library/scala/xml/persistent/SetStorage.scala
+++ b/src/library/scala/xml/persistent/SetStorage.scala
@@ -7,7 +7,8 @@
\* */
-package scala.xml
+package scala
+package xml
package persistent
import scala.collection.mutable
@@ -20,16 +21,14 @@ import java.io.File
*/
class SetStorage(file: File) extends CachedFileStorage(file) {
- private var theSet: mutable.HashSet[Node] = new mutable.HashSet[Node]
+ private val theSet = mutable.HashSet[Node]()
// initialize
{
val it = super.initialNodes
dirty = it.hasNext
- for(x <- it) {
- theSet += x;
- }
+ theSet ++= it
}
/* forwarding methods to hashset*/
diff --git a/src/library/scala/xml/pull/XMLEvent.scala b/src/library/scala/xml/pull/XMLEvent.scala
index a266380f87..3beb3648e7 100644
--- a/src/library/scala/xml/pull/XMLEvent.scala
+++ b/src/library/scala/xml/pull/XMLEvent.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package pull
/** An XML event for pull parsing. All events received during
diff --git a/src/library/scala/xml/pull/XMLEventReader.scala b/src/library/scala/xml/pull/XMLEventReader.scala
index 428c305055..76e51e17fd 100755
--- a/src/library/scala/xml/pull/XMLEventReader.scala
+++ b/src/library/scala/xml/pull/XMLEventReader.scala
@@ -6,7 +6,8 @@
** |/ **
\* */
-package scala.xml
+package scala
+package xml
package pull
import scala.io.Source
@@ -139,10 +140,10 @@ trait ProducerConsumerIterator[T >: Null] extends Iterator[T] {
def hasNext = !eos && (buffer != null || fillBuffer)
def next() = {
- if (eos) throw new NoSuchElementException("ProducerConsumerIterator")
- if (buffer == null) fillBuffer
+ if (eos()) throw new NoSuchElementException("ProducerConsumerIterator")
+ if (buffer == null) fillBuffer()
- drainBuffer
+ drainBuffer()
}
def available() = isElement(buffer) || isElement(queue.peek)
diff --git a/src/library/scala/xml/pull/package.scala b/src/library/scala/xml/pull/package.scala
index 3742c55513..0e3019446b 100644
--- a/src/library/scala/xml/pull/package.scala
+++ b/src/library/scala/xml/pull/package.scala
@@ -1,4 +1,5 @@
-package scala.xml
+package scala
+package xml
/**
* Classes needed to view an XML document as a series of events. The document
diff --git a/src/library/scala/xml/transform/BasicTransformer.scala b/src/library/scala/xml/transform/BasicTransformer.scala
index 1402ccd6aa..c98339fd67 100644
--- a/src/library/scala/xml/transform/BasicTransformer.scala
+++ b/src/library/scala/xml/transform/BasicTransformer.scala
@@ -8,7 +8,8 @@
-package scala.xml
+package scala
+package xml
package transform
/** A class for XML transformations.
@@ -53,7 +54,7 @@ abstract class BasicTransformer extends Function1[Node,Node]
def apply(n: Node): Node = {
val seq = transform(n)
if (seq.length > 1)
- throw new UnsupportedOperationException("transform must return single node for root");
+ throw new UnsupportedOperationException("transform must return single node for root")
else seq.head
}
}
diff --git a/src/library/scala/xml/transform/RewriteRule.scala b/src/library/scala/xml/transform/RewriteRule.scala
index 1dca495a10..1399ee538d 100644
--- a/src/library/scala/xml/transform/RewriteRule.scala
+++ b/src/library/scala/xml/transform/RewriteRule.scala
@@ -8,11 +8,12 @@
-package scala.xml
+package scala
+package xml
package transform
-/** a RewriteRule, when applied to a term, yields either
- * the resulting of rewriting or the term itself it the rule
+/** A RewriteRule, when applied to a term, yields either
+ * the result of rewriting the term or the term itself if the rule
* is not applied.
*
* @author Burak Emir
diff --git a/src/library/scala/xml/transform/RuleTransformer.scala b/src/library/scala/xml/transform/RuleTransformer.scala
index 85e92e5773..3a222ba759 100644
--- a/src/library/scala/xml/transform/RuleTransformer.scala
+++ b/src/library/scala/xml/transform/RuleTransformer.scala
@@ -6,9 +6,8 @@
** |/ **
\* */
-
-
-package scala.xml
+package scala
+package xml
package transform
class RuleTransformer(rules: RewriteRule*) extends BasicTransformer {