SourceForge: humaitrader/humaitrader: changeset 175:68d54e25f164
Got ArrayList almost working
authorCaoyuan Deng <dcaoyuan@gmail.com>
Tue Nov 03 22:15:38 2009 +0800 (3 weeks ago)
changeset 17568d54e25f164
parent 1745c731986a907
child 1765bc1fe18495d
Got ArrayList almost working
modules/lib.collection/build.xml
modules/lib.collection/nbproject/build-impl.xml
modules/lib.collection/nbproject/genfiles.properties
modules/lib.collection/nbproject/project.properties
modules/lib.collection/nbproject/project.xml
modules/lib.collection/src/org/aiotrade/lib/collection/BitSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/BitSetLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/BufferedIterator.scala
modules/lib.collection/src/org/aiotrade/lib/collection/DefaultMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeqLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeqView.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeqViewLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/Iterable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IterableLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IterableProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IterableProxyLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IterableView.scala
modules/lib.collection/src/org/aiotrade/lib/collection/IterableViewLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/Iterator.scala
modules/lib.collection/src/org/aiotrade/lib/collection/JavaConversions.scala
modules/lib.collection/src/org/aiotrade/lib/collection/LinearSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/LinearSeqLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/Map.scala
modules/lib.collection/src/org/aiotrade/lib/collection/MapLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/MapProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/MapProxyLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/RollbackIterator.scala.disabled
modules/lib.collection/src/org/aiotrade/lib/collection/Seq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SeqLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SeqProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SeqProxyLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SeqView.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SeqViewLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/Set.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SetLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SetProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SetProxyLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SortedMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SortedMapLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SortedSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/SortedSetLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/Traversable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/TraversableLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/TraversableProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/TraversableProxyLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/TraversableView.scala
modules/lib.collection/src/org/aiotrade/lib/collection/TraversableViewLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/Addable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/BitSetFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/CanBuildFrom.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/GenericCompanion.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/GenericSequenceFactory.scala.disabled
modules/lib.collection/src/org/aiotrade/lib/collection/generic/GenericSetTemplate.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/GenericTraversableFactory.scala.disabled
modules/lib.collection/src/org/aiotrade/lib/collection/generic/GenericTraversableTemplate.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/Growable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/ImmutableMapFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/ImmutableSortedMapFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/ImmutableSortedSetFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/IterableForwarder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/MapFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/MutableMapFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/SeqFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/SeqForwarder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/SetFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/Shrinkable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/Sorted.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/SortedMapFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/SortedSetFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/Subtractable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/TraversableFactory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/TraversableForwarder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/generic/TraversableView.scala.1
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/BitSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/GenericRange.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/HashMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/HashSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/ImmutableIterator.scala.disabled
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/IndexedSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/IntMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Iterable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/LinearSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/List.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/ListMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/ListSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/LongMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Map.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/MapLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/MapProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/PagedSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Queue.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Range.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/RedBlack.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Seq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Set.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/SetProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/SortedMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/SortedSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Stack.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Stream.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/StringLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/StringOps.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Traversable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Tree.scala.disabled
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/TreeHashMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/TreeMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/TreeSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/Vector.scala
modules/lib.collection/src/org/aiotrade/lib/collection/immutable/WrappedString.scala
modules/lib.collection/src/org/aiotrade/lib/collection/interfaces/IterableMethods.scala
modules/lib.collection/src/org/aiotrade/lib/collection/interfaces/MapMethods.scala
modules/lib.collection/src/org/aiotrade/lib/collection/interfaces/SeqMethods.scala
modules/lib.collection/src/org/aiotrade/lib/collection/interfaces/SetMethods.scala
modules/lib.collection/src/org/aiotrade/lib/collection/interfaces/TraversableMethods.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/AddingBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ArrayBuffer.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ArrayBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ArrayLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ArrayOps.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ArrayStack.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/BitSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Buffer.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/BufferLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/BufferProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Builder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Cloneable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/CloneableCollection.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/DefaultEntry.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/DefaultMapModel.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/DoubleLinkedList.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/DoubleLinkedListLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/FlatHashTable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/GenericArray.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/HashEntry.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/HashMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/HashSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/HashTable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/History.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ImmutableMapAdaptor.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ImmutableSetAdaptor.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/IndexedSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/IndexedSeqLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/IndexedSeqView.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Iterable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LazyBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LinearSeq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LinkedEntry.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LinkedHashMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LinkedHashSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LinkedList.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/LinkedListLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ListBuffer.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ListMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Map.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/MapBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/MapLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/MapLikeBase.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/MapProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/MultiMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/MutableList.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ObservableBuffer.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ObservableMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ObservableSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/OpenHashMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/PriorityQueue.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/PriorityQueueProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Publisher.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Queue.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/QueueProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/ResizableArray.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/RevertibleHistory.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Seq.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Set.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SetBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SetLike.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SetProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Stack.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/StackProxy.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/StringBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Subscriber.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SynchronizedBuffer.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SynchronizedMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SynchronizedPriorityQueue.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SynchronizedQueue.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SynchronizedSet.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/SynchronizedStack.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Traversable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/Undoable.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/WeakHashMap.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/WrappedArray.scala
modules/lib.collection/src/org/aiotrade/lib/collection/mutable/WrappedArrayBuilder.scala
modules/lib.collection/src/org/aiotrade/lib/collection/script/Location.scala
modules/lib.collection/src/org/aiotrade/lib/collection/script/Message.scala
modules/lib.collection/src/org/aiotrade/lib/collection/script/Scriptable.scala
modules/lib.math/src/org/aiotrade/lib/math/timeseries/DefaultTSer.scala
modules/lib.math/src/org/aiotrade/lib/math/timeseries/TSer.scala
modules/lib.math/src/org/aiotrade/lib/math/timeseries/TStampedMapBasedList.scala
modules/lib.math/src/org/aiotrade/lib/math/timeseries/datasource/AbstractDataServer.scala
modules/lib.math/src/org/aiotrade/lib/math/timeseries/descriptor/AnalysisContents.scala
modules/lib.util/src/org/aiotrade/lib/util/ChangeObservableHelper.scala
modules/lib.util/src/org/aiotrade/lib/util/Observable.scala
modules/lib.util/src/org/aiotrade/lib/util/ServiceLoader.scala
modules/lib.util/src/org/aiotrade/lib/util/collection/ArrayList.scala
modules/lib.util/src/org/aiotrade/lib/util/collection/ResizableArray.scala
modules/lib.util/src/org/aiotrade/lib/util/swing/action/WithActionsHelper.scala
modules/lib.util/test/org/aiotrade/lib/util/collection/ArrayListTest.scala
modules/test/src/org/aiotrade/platform/test/PlainPersistenceManager.scala
     1.1 --- a/modules/lib.collection/build.xml	Tue Nov 03 13:08:38 2009 +0800
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,69 +0,0 @@
     1.4 -<?xml version="1.0" encoding="UTF-8"?>
     1.5 -<!-- You may freely edit this file. See commented blocks below for -->
     1.6 -<!-- some examples of how to customize the build. -->
     1.7 -<!-- (If you delete it and reopen the project it will be recreated.) -->
     1.8 -<project name="lib.collection" default="default" basedir=".">
     1.9 -    <description>Builds, tests, and runs the project lib.collection.</description>
    1.10 -    <import file="nbproject/build-impl.xml"/>
    1.11 -    <!--
    1.12 -
    1.13 -    There exist several targets which are by default empty and which can be 
    1.14 -    used for execution of your tasks. These targets are usually executed 
    1.15 -    before and after some main targets. They are: 
    1.16 -
    1.17 -      -pre-init:                 called before initialization of project properties
    1.18 -      -post-init:                called after initialization of project properties
    1.19 -      -pre-compile:              called before javac compilation
    1.20 -      -post-compile:             called after javac compilation
    1.21 -      -pre-compile-single:       called before javac compilation of single file
    1.22 -      -post-compile-single:      called after javac compilation of single file
    1.23 -      -pre-compile-test:         called before javac compilation of JUnit tests
    1.24 -      -post-compile-test:        called after javac compilation of JUnit tests
    1.25 -      -pre-compile-test-single:  called before javac compilation of single JUnit test
    1.26 -      -post-compile-test-single: called after javac compilation of single JUunit test
    1.27 -      -pre-jar:                  called before JAR building
    1.28 -      -post-jar:                 called after JAR building
    1.29 -      -post-clean:               called after cleaning build products
    1.30 -
    1.31 -    (Targets beginning with '-' are not intended to be called on their own.)
    1.32 -
    1.33 -    Example of inserting an obfuscator after compilation could look like this:
    1.34 -
    1.35 -        <target name="-post-compile">
    1.36 -            <obfuscate>
    1.37 -                <fileset dir="${build.classes.dir}"/>
    1.38 -            </obfuscate>
    1.39 -        </target>
    1.40 -
    1.41 -    For list of available properties check the imported 
    1.42 -    nbproject/build-impl.xml file. 
    1.43 -
    1.44 -
    1.45 -    Another way to customize the build is by overriding existing main targets.
    1.46 -    The targets of interest are: 
    1.47 -
    1.48 -      -init-macrodef-javac:     defines macro for javac compilation
    1.49 -      -init-macrodef-junit:     defines macro for junit execution
    1.50 -      -init-macrodef-debug:     defines macro for class debugging
    1.51 -      -init-macrodef-java:      defines macro for class execution
    1.52 -      -do-jar-with-manifest:    JAR building (if you are using a manifest)
    1.53 -      -do-jar-without-manifest: JAR building (if you are not using a manifest)
    1.54 -      run:                      execution of project 
    1.55 -      -javadoc-build:           Javadoc generation
    1.56 -      test-report:              JUnit report generation
    1.57 -
    1.58 -    An example of overriding the target for project execution could look like this:
    1.59 -
    1.60 -        <target name="run" depends="lib.collection-impl.jar">
    1.61 -            <exec dir="bin" executable="launcher.exe">
    1.62 -                <arg file="${dist.jar}"/>
    1.63 -            </exec>
    1.64 -        </target>
    1.65 -
    1.66 -    Notice that the overridden target depends on the jar target and not only on 
    1.67 -    the compile target as the regular run target does. Again, for a list of available 
    1.68 -    properties which you can use, check the target you are overriding in the
    1.69 -    nbproject/build-impl.xml file. 
    1.70 -
    1.71 -    -->
    1.72 -</project>
     2.1 --- a/modules/lib.collection/nbproject/build-impl.xml	Tue Nov 03 13:08:38 2009 +0800
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,713 +0,0 @@
     2.4 -<?xml version="1.0" encoding="UTF-8"?>
     2.5 -<!--
     2.6 -*** GENERATED FROM project.xml - DO NOT EDIT  ***
     2.7 -***         EDIT ../build.xml INSTEAD         ***
     2.8 -
     2.9 -For the purpose of easier reading the script
    2.10 -is divided into following sections:
    2.11 -
    2.12 -  - initialization
    2.13 -  - compilation
    2.14 -  - jar
    2.15 -  - execution
    2.16 -  - debugging
    2.17 -  - javadoc
    2.18 -  - junit compilation
    2.19 -  - junit execution
    2.20 -  - junit debugging
    2.21 -  - applet
    2.22 -  - cleanup
    2.23 -
    2.24 -        
    2.25 -        -->
    2.26 -<project xmlns:jaxrpc="http://www.netbeans.org/ns/scala-project/jax-rpc" xmlns:scalaProject1="http://www.netbeans.org/ns/scala-project/1" basedir=".." default="default" name="lib.collection-impl">
    2.27 -    <target depends="test,jar,javadoc" description="Build and test whole project." name="default"/>
    2.28 -    <!--
    2.29 -                ======================
    2.30 -                INITIALIZATION SECTION 
    2.31 -                ======================
    2.32 -            -->
    2.33 -    <target name="-pre-init">
    2.34 -        <!-- Empty placeholder for easier customization. -->
    2.35 -        <!-- You can override this target in the ../build.xml file. -->
    2.36 -    </target>
    2.37 -    <target depends="-pre-init" name="-init-private">
    2.38 -        <property file="nbproject/private/config.properties"/>
    2.39 -        <property file="nbproject/private/configs/${config}.properties"/>
    2.40 -        <property file="nbproject/private/private.properties"/>
    2.41 -        <property environment="env"/>
    2.42 -        <condition property="scala.home" value="${env.SCALA_HOME}">
    2.43 -            <isset property="env.SCALA_HOME"/>
    2.44 -        </condition>
    2.45 -        <fail unless="scala.home">
    2.46 -You must set SCALA_HOME or environment property and append "-J-Dscala.home=scalahomepath"
    2.47 -property to the end of "netbeans_default_options" in NetBeansInstallationPath/etc/netbeans.conf to point to
    2.48 -Scala installation directory.
    2.49 -                </fail>
    2.50 -        <property name="scala.compiler" value="${scala.home}/lib/scala-compiler.jar"/>
    2.51 -        <property name="scala.library" value="${scala.home}/lib/scala-library.jar"/>
    2.52 -        <property name="scala.lib" value="${scala.home}/lib"/>
    2.53 -        <taskdef resource="scala/tools/ant/antlib.xml">
    2.54 -            <classpath>
    2.55 -                <pathelement location="${scala.compiler}"/>
    2.56 -                <pathelement location="${scala.library}"/>
    2.57 -            </classpath>
    2.58 -        </taskdef>
    2.59 -        <chmod dir="${scala.home}/bin" includes="**/*" perm="u+rx"/>
    2.60 -    </target>
    2.61 -    <target depends="-pre-init,-init-private" name="-init-user">
    2.62 -        <property file="${user.properties.file}"/>
    2.63 -        <!-- The two properties below are usually overridden -->
    2.64 -        <!-- by the active platform. Just a fallback. -->
    2.65 -        <property name="default.javac.source" value="1.4"/>
    2.66 -        <property name="default.javac.target" value="1.4"/>
    2.67 -    </target>
    2.68 -    <target depends="-pre-init,-init-private,-init-user" name="-init-project">
    2.69 -        <property file="nbproject/configs/${config}.properties"/>
    2.70 -        <property file="nbproject/project.properties"/>
    2.71 -    </target>
    2.72 -    <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">
    2.73 -        <available file="${manifest.file}" property="manifest.available"/>
    2.74 -        <condition property="manifest.available+main.class">
    2.75 -            <and>
    2.76 -                <isset property="manifest.available"/>
    2.77 -                <isset property="main.class"/>
    2.78 -                <not>
    2.79 -                    <equals arg1="${main.class}" arg2="" trim="true"/>
    2.80 -                </not>
    2.81 -            </and>
    2.82 -        </condition>
    2.83 -        <condition property="manifest.available+main.class+mkdist.available">
    2.84 -            <and>
    2.85 -                <istrue value="${manifest.available+main.class}"/>
    2.86 -                <isset property="libs.CopyLibs.classpath"/>
    2.87 -            </and>
    2.88 -        </condition>
    2.89 -        <condition property="have.tests">
    2.90 -            <or>
    2.91 -                <available file="${test.src.dir}"/>
    2.92 -            </or>
    2.93 -        </condition>
    2.94 -        <condition property="have.sources">
    2.95 -            <or>
    2.96 -                <available file="${src.dir}"/>
    2.97 -            </or>
    2.98 -        </condition>
    2.99 -        <condition property="netbeans.home+have.tests">
   2.100 -            <and>
   2.101 -                <isset property="netbeans.home"/>
   2.102 -                <isset property="have.tests"/>
   2.103 -            </and>
   2.104 -        </condition>
   2.105 -        <condition property="no.javadoc.preview">
   2.106 -            <and>
   2.107 -                <isset property="javadoc.preview"/>
   2.108 -                <isfalse value="${javadoc.preview}"/>
   2.109 -            </and>
   2.110 -        </condition>
   2.111 -        <property name="run.jvmargs" value=""/>
   2.112 -        <property name="javac.compilerargs" value=""/>
   2.113 -        <property name="work.dir" value="${basedir}"/>
   2.114 -        <condition property="no.deps">
   2.115 -            <and>
   2.116 -                <istrue value="${no.dependencies}"/>
   2.117 -            </and>
   2.118 -        </condition>
   2.119 -        <property name="javac.debug" value="true"/>
   2.120 -        <property name="javadoc.preview" value="true"/>
   2.121 -        <property name="application.args" value=""/>
   2.122 -        <property name="source.encoding" value="${file.encoding}"/>
   2.123 -        <condition property="javadoc.encoding.used" value="${javadoc.encoding}">
   2.124 -            <and>
   2.125 -                <isset property="javadoc.encoding"/>
   2.126 -                <not>
   2.127 -                    <equals arg1="${javadoc.encoding}" arg2=""/>
   2.128 -                </not>
   2.129 -            </and>
   2.130 -        </condition>
   2.131 -        <property name="javadoc.encoding.used" value="${source.encoding}"/>
   2.132 -        <property name="includes" value="**"/>
   2.133 -        <property name="excludes" value=""/>
   2.134 -        <property name="do.depend" value="false"/>
   2.135 -        <condition property="do.depend.true">
   2.136 -            <istrue value="${do.depend}"/>
   2.137 -        </condition>
   2.138 -        <condition else="" property="javac.compilerargs.jaxws" value="-Djava.endorsed.dirs='${jaxws.endorsed.dir}'">
   2.139 -            <and>
   2.140 -                <isset property="jaxws.endorsed.dir"/>
   2.141 -                <available file="nbproject/jaxws-build.xml"/>
   2.142 -            </and>
   2.143 -        </condition>
   2.144 -    </target>
   2.145 -    <target name="-post-init">
   2.146 -        <!-- Empty placeholder for easier customization. -->
   2.147 -        <!-- You can override this target in the ../build.xml file. -->
   2.148 -    </target>
   2.149 -    <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
   2.150 -        <fail unless="src.dir">Must set src.dir</fail>
   2.151 -        <fail unless="test.src.dir">Must set test.src.dir</fail>
   2.152 -        <fail unless="build.dir">Must set build.dir</fail>
   2.153 -        <fail unless="dist.dir">Must set dist.dir</fail>
   2.154 -        <fail unless="build.classes.dir">Must set build.classes.dir</fail>
   2.155 -        <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
   2.156 -        <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
   2.157 -        <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
   2.158 -        <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
   2.159 -        <fail unless="dist.jar">Must set dist.jar</fail>
   2.160 -    </target>
   2.161 -    <target name="-init-macrodef-property">
   2.162 -        <macrodef name="property" uri="http://www.netbeans.org/ns/scala-project/1">
   2.163 -            <attribute name="name"/>
   2.164 -            <attribute name="value"/>
   2.165 -            <sequential>
   2.166 -                <property name="@{name}" value="${@{value}}"/>
   2.167 -            </sequential>
   2.168 -        </macrodef>
   2.169 -    </target>
   2.170 -    <target name="-init-macrodef-javac">
   2.171 -        <macrodef name="javac" uri="http://www.netbeans.org/ns/scala-project/1">
   2.172 -            <attribute default="${src.dir}" name="srcdir"/>
   2.173 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.174 -            <attribute default="${javac.classpath}" name="classpath"/>
   2.175 -            <attribute default="${includes}" name="includes"/>
   2.176 -            <attribute default="${excludes}" name="excludes"/>
   2.177 -            <attribute default="${javac.debug}" name="debug"/>
   2.178 -            <attribute default="" name="sourcepath"/>
   2.179 -            <element name="customize" optional="true"/>
   2.180 -            <sequential>
   2.181 -                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}">
   2.182 -                    <classpath>
   2.183 -                        <path path="@{classpath}"/>
   2.184 -                        <fileset dir="${scala.lib}">
   2.185 -                            <include name="**/*.jar"/>
   2.186 -                        </fileset>
   2.187 -                    </classpath>
   2.188 -                    <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>
   2.189 -                    <customize/>
   2.190 -                </javac>
   2.191 -            </sequential>
   2.192 -        </macrodef>
   2.193 -        <macrodef name="depend" uri="http://www.netbeans.org/ns/scala-project/1">
   2.194 -            <attribute default="${src.dir}" name="srcdir"/>
   2.195 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.196 -            <attribute default="${javac.classpath}" name="classpath"/>
   2.197 -            <sequential>
   2.198 -                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
   2.199 -                    <classpath>
   2.200 -                        <path path="@{classpath}"/>
   2.201 -                    </classpath>
   2.202 -                </depend>
   2.203 -            </sequential>
   2.204 -        </macrodef>
   2.205 -        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/scala-project/1">
   2.206 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.207 -            <sequential>
   2.208 -                <fail unless="javac.includes">Must set javac.includes</fail>
   2.209 -                <pathconvert pathsep="," property="javac.includes.binary">
   2.210 -                    <path>
   2.211 -                        <filelist dir="@{destdir}" files="${javac.includes}"/>
   2.212 -                    </path>
   2.213 -                    <globmapper from="*.java" to="*.class"/>
   2.214 -                </pathconvert>
   2.215 -                <delete>
   2.216 -                    <files includes="${javac.includes.binary}"/>
   2.217 -                </delete>
   2.218 -            </sequential>
   2.219 -        </macrodef>
   2.220 -    </target>
   2.221 -    <target name="-init-macrodef-scalac">
   2.222 -        <macrodef name="scalac" uri="http://www.netbeans.org/ns/scala-project/1">
   2.223 -            <attribute default="${src.dir}" name="srcdir"/>
   2.224 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.225 -            <attribute default="${javac.classpath}" name="classpath"/>
   2.226 -            <attribute default="${includes}" name="includes"/>
   2.227 -            <attribute default="${excludes}" name="excludes"/>
   2.228 -            <attribute default="${scalac.compilerargs}" name="addparams"/>
   2.229 -            <attribute default="" name="sourcepath"/>
   2.230 -            <element name="customize" optional="true"/>
   2.231 -            <sequential>
   2.232 -                <fsc addparams="@{addparams}" deprecation="${scalac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" includes="@{includes}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="jvm-${javac.target}" unchecked="${scalac.unchecked}">
   2.233 -                    <classpath>
   2.234 -                        <path path="@{classpath}"/>
   2.235 -                        <fileset dir="${scala.lib}">
   2.236 -                            <include name="**/*.jar"/>
   2.237 -                        </fileset>
   2.238 -                    </classpath>
   2.239 -                    <customize/>
   2.240 -                </fsc>
   2.241 -            </sequential>
   2.242 -        </macrodef>
   2.243 -        <macrodef name="depend" uri="http://www.netbeans.org/ns/scala-project/1">
   2.244 -            <attribute default="${src.dir}" name="srcdir"/>
   2.245 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.246 -            <attribute default="${javac.classpath}" name="classpath"/>
   2.247 -            <sequential>
   2.248 -                <depend cache="${build.dir}/depcache" destdir="@{destdir}" excludes="${excludes}" includes="${includes}" srcdir="@{srcdir}">
   2.249 -                    <classpath>
   2.250 -                        <path path="@{classpath}"/>
   2.251 -                    </classpath>
   2.252 -                </depend>
   2.253 -            </sequential>
   2.254 -        </macrodef>
   2.255 -        <macrodef name="force-recompile" uri="http://www.netbeans.org/ns/scala-project/1">
   2.256 -            <attribute default="${build.classes.dir}" name="destdir"/>
   2.257 -            <sequential>
   2.258 -                <fail unless="javac.includes">Must set javac.includes</fail>
   2.259 -                <pathconvert pathsep="," property="javac.includes.binary">
   2.260 -                    <path>
   2.261 -                        <filelist dir="@{destdir}" files="${javac.includes}"/>
   2.262 -                    </path>
   2.263 -                    <globmapper from="*.scala" to="*.class"/>
   2.264 -                </pathconvert>
   2.265 -                <delete>
   2.266 -                    <files includes="${javac.includes.binary}"/>
   2.267 -                </delete>
   2.268 -            </sequential>
   2.269 -        </macrodef>
   2.270 -    </target>
   2.271 -    <target name="-init-macrodef-junit">
   2.272 -        <macrodef name="junit" uri="http://www.netbeans.org/ns/scala-project/1">
   2.273 -            <attribute default="${includes}" name="includes"/>
   2.274 -            <attribute default="${excludes}" name="excludes"/>
   2.275 -            <attribute default="**" name="testincludes"/>
   2.276 -            <sequential>
   2.277 -                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true">
   2.278 -                    <batchtest todir="${build.test.results.dir}">
   2.279 -                        <fileset dir="${build.test.classes.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">
   2.280 -                            <filename name="@{testincludes}"/>
   2.281 -                        </fileset>
   2.282 -                    </batchtest>
   2.283 -                    <classpath>
   2.284 -                        <path path="${run.test.classpath}"/>
   2.285 -                        <fileset dir="${scala.lib}">
   2.286 -                            <include name="**/*.jar"/>
   2.287 -                        </fileset>
   2.288 -                    </classpath>
   2.289 -                    <syspropertyset>
   2.290 -                        <propertyref prefix="test-sys-prop."/>
   2.291 -                        <mapper from="test-sys-prop.*" to="*" type="glob"/>
   2.292 -                    </syspropertyset>
   2.293 -                    <formatter type="brief" usefile="false"/>
   2.294 -                    <formatter type="xml"/>
   2.295 -                    <jvmarg line="${run.jvmargs}"/>
   2.296 -                </junit>
   2.297 -            </sequential>
   2.298 -        </macrodef>
   2.299 -    </target>
   2.300 -    <target name="-init-macrodef-nbjpda">
   2.301 -        <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/scala-project/1">
   2.302 -            <attribute default="${main.class}" name="name"/>
   2.303 -            <attribute default="${debug.classpath}" name="classpath"/>
   2.304 -            <attribute default="" name="stopclassname"/>
   2.305 -            <sequential>
   2.306 -                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
   2.307 -                    <classpath>
   2.308 -                        <path path="@{classpath}"/>
   2.309 -                    </classpath>
   2.310 -                </nbjpdastart>
   2.311 -            </sequential>
   2.312 -        </macrodef>
   2.313 -        <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/scala-project/1">
   2.314 -            <attribute default="${build.classes.dir}" name="dir"/>
   2.315 -            <sequential>
   2.316 -                <nbjpdareload>
   2.317 -                    <fileset dir="@{dir}" includes="${fix.includes}*.class"/>
   2.318 -                </nbjpdareload>
   2.319 -            </sequential>
   2.320 -        </macrodef>
   2.321 -    </target>
   2.322 -    <target name="-init-debug-args">
   2.323 -        <property name="version-output" value="java version &quot;${ant.java.version}"/>
   2.324 -        <condition property="have-jdk-older-than-1.4">
   2.325 -            <or>
   2.326 -                <contains string="${version-output}" substring="java version &quot;1.0"/>
   2.327 -                <contains string="${version-output}" substring="java version &quot;1.1"/>
   2.328 -                <contains string="${version-output}" substring="java version &quot;1.2"/>
   2.329 -                <contains string="${version-output}" substring="java version &quot;1.3"/>
   2.330 -            </or>
   2.331 -        </condition>
   2.332 -        <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
   2.333 -            <istrue value="${have-jdk-older-than-1.4}"/>
   2.334 -        </condition>
   2.335 -    </target>
   2.336 -    <target depends="-init-debug-args" name="-init-macrodef-debug">
   2.337 -        <macrodef name="debug" uri="http://www.netbeans.org/ns/scala-project/1">
   2.338 -            <attribute default="${main.class}" name="classname"/>
   2.339 -            <attribute default="${debug.classpath}" name="classpath"/>
   2.340 -            <element name="customize" optional="true"/>
   2.341 -            <sequential>
   2.342 -                <java classname="@{classname}" dir="${work.dir}" fork="true">
   2.343 -                    <jvmarg line="${debug-args-line}"/>
   2.344 -                    <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
   2.345 -                    <jvmarg line="${run.jvmargs}"/>
   2.346 -                    <classpath>
   2.347 -                        <path path="@{classpath}"/>
   2.348 -                        <fileset dir="${scala.lib}">
   2.349 -                            <include name="**/*.jar"/>
   2.350 -                        </fileset>
   2.351 -                    </classpath>
   2.352 -                    <syspropertyset>
   2.353 -                        <propertyref prefix="run-sys-prop."/>
   2.354 -                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   2.355 -                    </syspropertyset>
   2.356 -                    <customize/>
   2.357 -                </java>
   2.358 -            </sequential>
   2.359 -        </macrodef>
   2.360 -    </target>
   2.361 -    <target name="-init-macrodef-java">
   2.362 -        <macrodef name="java" uri="http://www.netbeans.org/ns/scala-project/1">
   2.363 -            <attribute default="${main.class}" name="classname"/>
   2.364 -            <element name="customize" optional="true"/>
   2.365 -            <sequential>
   2.366 -                <java classname="@{classname}" dir="${work.dir}" fork="true">
   2.367 -                    <jvmarg line="${run.jvmargs}"/>
   2.368 -                    <classpath>
   2.369 -                        <path path="${run.classpath}"/>
   2.370 -                        <fileset dir="${scala.lib}">
   2.371 -                            <include name="**/*.jar"/>
   2.372 -                        </fileset>
   2.373 -                    </classpath>
   2.374 -                    <syspropertyset>
   2.375 -                        <propertyref prefix="run-sys-prop."/>
   2.376 -                        <mapper from="run-sys-prop.*" to="*" type="glob"/>
   2.377 -                    </syspropertyset>
   2.378 -                    <customize/>
   2.379 -                </java>
   2.380 -            </sequential>
   2.381 -        </macrodef>
   2.382 -    </target>
   2.383 -    <target name="-init-presetdef-jar">
   2.384 -        <presetdef name="jar" uri="http://www.netbeans.org/ns/scala-project/1">
   2.385 -            <jar compress="${jar.compress}" jarfile="${dist.jar}">
   2.386 -                <scalaProject1:fileset dir="${build.classes.dir}"/>
   2.387 -            </jar>
   2.388 -        </presetdef>
   2.389 -    </target>
   2.390 -    <target depends="-pre-init,-init-private ,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-scalac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar" name="init"/>
   2.391 -    <!--
   2.392 -                ===================
   2.393 -                COMPILATION SECTION
   2.394 -                ===================
   2.395 -            -->
   2.396 -    <target depends="init" name="deps-jar" unless="no.deps"/>
   2.397 -    <target depends="init,deps-jar" name="-pre-pre-compile">
   2.398 -        <mkdir dir="${build.classes.dir}"/>
   2.399 -    </target>
   2.400 -    <target name="-pre-compile">
   2.401 -        <!-- Empty placeholder for easier customization. -->
   2.402 -        <!-- You can override this target in the ../build.xml file. -->
   2.403 -    </target>
   2.404 -    <target if="do.depend.true" name="-compile-depend">
   2.405 -        <scalaProject1:depend/>
   2.406 -    </target>
   2.407 -    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-compile-depend" if="have.sources" name="-do-compile">
   2.408 -        <scalaProject1:scalac/>
   2.409 -        <scalaProject1:javac/>
   2.410 -        <copy todir="${build.classes.dir}">
   2.411 -            <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}&#10;                        " includes="${includes}"/>
   2.412 -        </copy>
   2.413 -    </target>
   2.414 -    <target name="-post-compile">
   2.415 -        <!-- Empty placeholder for easier customization. -->
   2.416 -        <!-- You can override this target in the ../build.xml file. -->
   2.417 -    </target>
   2.418 -    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
   2.419 -    <target name="-pre-compile-single">
   2.420 -        <!-- Empty placeholder for easier customization. -->
   2.421 -        <!-- You can override this target in the ../build.xml file. -->
   2.422 -    </target>
   2.423 -    <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
   2.424 -        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   2.425 -        <scalaProject1:force-recompile/>
   2.426 -        <scalaProject1:scalac excludes="" includes="${javac.includes}" sourcepath="${src.dir}"/>
   2.427 -    </target>
   2.428 -    <target name="-post-compile-single">
   2.429 -        <!-- Empty placeholder for easier customization. -->
   2.430 -        <!-- You can override this target in the ../build.xml file. -->
   2.431 -    </target>
   2.432 -    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
   2.433 -    <!--
   2.434 -                ====================
   2.435 -                JAR BUILDING SECTION
   2.436 -                ====================
   2.437 -            -->
   2.438 -    <target depends="init" name="-pre-pre-jar">
   2.439 -        <dirname file="${dist.jar}" property="dist.jar.dir"/>
   2.440 -        <mkdir dir="${dist.jar.dir}"/>
   2.441 -    </target>
   2.442 -    <target name="-pre-jar">
   2.443 -        <!-- Empty placeholder for easier customization. -->
   2.444 -        <!-- You can override this target in the ../build.xml file. -->
   2.445 -    </target>
   2.446 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" name="-do-jar-without-manifest" unless="manifest.available">
   2.447 -        <scalaProject1:jar/>
   2.448 -    </target>
   2.449 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" name="-do-jar-with-manifest" unless="manifest.available+main.class">
   2.450 -        <scalaProject1:jar manifest="${manifest.file}"/>
   2.451 -    </target>
   2.452 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" name="-do-jar-with-mainclass" unless="manifest.available+main.class+mkdist.available">
   2.453 -        <scalaProject1:jar manifest="${manifest.file}">
   2.454 -            <scalaProject1:manifest>
   2.455 -                <scalaProject1:attribute name="Main-Class" value="${main.class}"/>
   2.456 -            </scalaProject1:manifest>
   2.457 -        </scalaProject1:jar>
   2.458 -        <echo>To run this application from the command line without Ant, try:</echo>
   2.459 -        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   2.460 -        <property location="${dist.jar}" name="dist.jar.resolved"/>
   2.461 -        <pathconvert property="run.classpath.with.dist.jar">
   2.462 -            <path path="${run.classpath}"/>
   2.463 -            <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
   2.464 -        </pathconvert>
   2.465 -        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}
   2.466 -                </echo>
   2.467 -    </target>
   2.468 -    <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">
   2.469 -        <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>
   2.470 -        <pathconvert property="run.classpath.without.build.classes.dir">
   2.471 -            <path path="${run.classpath}"/>
   2.472 -            <map from="${build.classes.dir.resolved}" to=""/>
   2.473 -        </pathconvert>
   2.474 -        <pathconvert pathsep=" " property="jar.classpath">
   2.475 -            <path path="${run.classpath.without.build.classes.dir}"/>
   2.476 -            <chainedmapper>
   2.477 -                <flattenmapper/>
   2.478 -                <globmapper from="*" to="lib/*"/>
   2.479 -            </chainedmapper>
   2.480 -        </pathconvert>
   2.481 -        <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" classpath="${libs.CopyLibs.classpath}" name="copylibs"/>
   2.482 -        <copylibs compress="${jar.compress}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
   2.483 -            <fileset dir="${build.classes.dir}"/>
   2.484 -            <manifest>
   2.485 -                <attribute name="Main-Class" value="${main.class}"/>
   2.486 -                <attribute name="Class-Path" value="${jar.classpath}"/>
   2.487 -            </manifest>
   2.488 -        </copylibs>
   2.489 -        <echo>To run this application from the command line without Ant, try:</echo>
   2.490 -        <property location="${dist.jar}" name="dist.jar.resolved"/>
   2.491 -        <echo>java -jar "${dist.jar.resolved}"
   2.492 -                </echo>
   2.493 -    </target>
   2.494 -    <target name="-post-jar">
   2.495 -        <!-- Empty placeholder for easier customization. -->
   2.496 -        <!-- You can override this target in the ../build.xml file. -->
   2.497 -    </target>
   2.498 -    <target depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR." name="jar"/>
   2.499 -    <!--
   2.500 -                =================
   2.501 -                EXECUTION SECTION
   2.502 -                =================
   2.503 -            -->
   2.504 -    <target depends="init,compile" description="Run a main class." name="run">
   2.505 -        <scalaProject1:java>
   2.506 -            <customize>
   2.507 -                <arg line="${application.args}"/>
   2.508 -            </customize>
   2.509 -        </scalaProject1:java>
   2.510 -    </target>
   2.511 -    <target name="-do-not-recompile">
   2.512 -        <property name="javac.includes.binary" value=""/>
   2.513 -    </target>
   2.514 -    <target depends="init,-do-not-recompile,compile-single" name="run-single">
   2.515 -        <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
   2.516 -        <scalaProject1:java classname="${run.class}"/>
   2.517 -    </target>
   2.518 -    <!--
   2.519 -                =================
   2.520 -                DEBUGGING SECTION
   2.521 -                =================
   2.522 -            -->
   2.523 -    <target depends="init" if="netbeans.home" name="-debug-start-debugger">
   2.524 -        <scalaProject1:nbjpdastart name="${debug.class}"/>
   2.525 -    </target>
   2.526 -    <target depends="init,compile" name="-debug-start-debuggee">
   2.527 -        <scalaProject1:debug>
   2.528 -            <customize>
   2.529 -                <arg line="${application.args}"/>
   2.530 -            </customize>
   2.531 -        </scalaProject1:debug>
   2.532 -    </target>
   2.533 -    <target depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE." if="netbeans.home" name="debug"/>
   2.534 -    <target depends="init" if="netbeans.home" name="-debug-start-debugger-stepinto">
   2.535 -        <scalaProject1:nbjpdastart stopclassname="${main.class}"/>
   2.536 -    </target>
   2.537 -    <target depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee" if="netbeans.home" name="debug-stepinto"/>
   2.538 -    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-single">
   2.539 -        <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
   2.540 -        <scalaProject1:debug classname="${debug.class}"/>
   2.541 -    </target>
   2.542 -    <target depends="init,-do-not-recompile,compile-single,-debug-start-debugger,-debug-start-debuggee-single" if="netbeans.home" name="debug-single"/>
   2.543 -    <target depends="init" name="-pre-debug-fix">
   2.544 -        <fail unless="fix.includes">Must set fix.includes</fail>
   2.545 -        <property name="javac.includes" value="${fix.includes}.java"/>
   2.546 -    </target>
   2.547 -    <target depends="init,-pre-debug-fix,compile-single" if="netbeans.home" name="-do-debug-fix">
   2.548 -        <scalaProject1:nbjpdareload/>
   2.549 -    </target>
   2.550 -    <target depends="init,-pre-debug-fix,-do-debug-fix" if="netbeans.home" name="debug-fix"/>
   2.551 -    <!--
   2.552 -                ===============
   2.553 -                JAVADOC SECTION
   2.554 -                ===============
   2.555 -            -->
   2.556 -    <target depends="init" name="-javadoc-build">
   2.557 -        <mkdir dir="${dist.javadoc.dir}"/>
   2.558 -        <scaladoc addparams="${javadoc.additionalparam}" deprecation="yes" destdir="${dist.javadoc.dir}" doctitle="${javadoc.windowtitle}" encoding="${javadoc.encoding.used}" srcdir="${src.dir}" unchecked="yes" windowtitle="${javadoc.windowtitle}">
   2.559 -            <classpath>
   2.560 -                <path path="${javac.classpath}"/>
   2.561 -                <fileset dir="${scala.lib}">
   2.562 -                    <include name="**/*.jar"/>
   2.563 -                </fileset>
   2.564 -            </classpath>
   2.565 -        </scaladoc>
   2.566 -    </target>
   2.567 -    <target depends="init,-javadoc-build" if="netbeans.home" name="-javadoc-browse" unless="no.javadoc.preview">
   2.568 -        <nbbrowse file="${dist.javadoc.dir}/index.html"/>
   2.569 -    </target>
   2.570 -    <target depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc." name="javadoc"/>
   2.571 -    <!--
   2.572 -                =========================
   2.573 -                JUNIT COMPILATION SECTION
   2.574 -                =========================
   2.575 -            -->
   2.576 -    <target depends="init,compile" if="have.tests" name="-pre-pre-compile-test">
   2.577 -        <mkdir dir="${build.test.classes.dir}"/>
   2.578 -    </target>
   2.579 -    <target name="-pre-compile-test">
   2.580 -        <!-- Empty placeholder for easier customization. -->
   2.581 -        <!-- You can override this target in the ../build.xml file. -->
   2.582 -    </target>
   2.583 -    <target if="do.depend.true" name="-compile-test-depend">
   2.584 -        <scalaProject1:depend classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   2.585 -    </target>
   2.586 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-compile-test-depend" if="have.tests" name="-do-compile-test">
   2.587 -        <scalaProject1:scalac classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" srcdir="${test.src.dir}"/>
   2.588 -        <copy todir="${build.test.classes.dir}">
   2.589 -            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}&#10;                        " includes="${includes}"/>
   2.590 -        </copy>
   2.591 -    </target>
   2.592 -    <target name="-post-compile-test">
   2.593 -        <!-- Empty placeholder for easier customization. -->
   2.594 -        <!-- You can override this target in the ../build.xml file. -->
   2.595 -    </target>
   2.596 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test" name="compile-test"/>
   2.597 -    <target name="-pre-compile-test-single">
   2.598 -        <!-- Empty placeholder for easier customization. -->
   2.599 -        <!-- You can override this target in the ../build.xml file. -->
   2.600 -    </target>
   2.601 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single" if="have.tests" name="-do-compile-test-single">
   2.602 -        <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
   2.603 -        <scalaProject1:force-recompile destdir="${build.test.classes.dir}"/>
   2.604 -        <scalaProject1:scalac classpath="${javac.test.classpath}" destdir="${build.test.classes.dir}" excludes="" includes="${javac.includes}" sourcepath="${test.src.dir}" srcdir="${test.src.dir}"/>
   2.605 -        <copy todir="${build.test.classes.dir}">
   2.606 -            <fileset dir="${test.src.dir}" excludes="${build.classes.excludes},${excludes}&#10;                        " includes="${includes}"/>
   2.607 -        </copy>
   2.608 -    </target>
   2.609 -    <target name="-post-compile-test-single">
   2.610 -        <!-- Empty placeholder for easier customization. -->
   2.611 -        <!-- You can override this target in the ../build.xml file. -->
   2.612 -    </target>
   2.613 -    <target depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single" name="compile-test-single"/>
   2.614 -    <!--
   2.615 -                =======================
   2.616 -                JUNIT EXECUTION SECTION
   2.617 -                =======================
   2.618 -            -->
   2.619 -    <target depends="init" if="have.tests" name="-pre-test-run">
   2.620 -        <mkdir dir="${build.test.results.dir}"/>
   2.621 -    </target>
   2.622 -    <target depends="init,compile-test,-pre-test-run" if="have.tests" name="-do-test-run">
   2.623 -        <scalaProject1:junit testincludes="**/*Test.class"/>
   2.624 -    </target>
   2.625 -    <target depends="init,compile-test,-pre-test-run,-do-test-run" if="have.tests" name="-post-test-run">
   2.626 -        <fail if="tests.failed">Some tests failed; see details above.</fail>
   2.627 -    </target>
   2.628 -    <target depends="init" if="have.tests" name="test-report"/>
   2.629 -    <target depends="init" if="netbeans.home+have.tests" name="-test-browse"/>
   2.630 -    <target depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests." name="test"/>
   2.631 -    <target depends="init" if="have.tests" name="-pre-test-run-single">
   2.632 -        <mkdir dir="${build.test.results.dir}"/>
   2.633 -    </target>
   2.634 -    <target depends="init,compile-test-single,-pre-test-run-single" if="have.tests" name="-do-test-run-single">
   2.635 -        <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
   2.636 -        <scalaProject1:junit excludes="" includes="${test.includes}"/>
   2.637 -    </target>
   2.638 -    <target depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single" if="have.tests" name="-post-test-run-single">
   2.639 -        <fail if="tests.failed">Some tests failed; see details above.</fail>
   2.640 -    </target>
   2.641 -    <target depends="init,-do-not-recompile,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test." name="test-single"/>
   2.642 -    <!--
   2.643 -                =======================
   2.644 -                JUNIT DEBUGGING SECTION
   2.645 -                =======================
   2.646 -            -->
   2.647 -    <target depends="init,compile-test" if="have.tests" name="-debug-start-debuggee-test">
   2.648 -        <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
   2.649 -        <property location="${build.test.results.dir}/TEST-${test.class}.xml" name="test.report.file"/>
   2.650 -        <delete file="${test.report.file}"/>
   2.651 -        <mkdir dir="${build.test.results.dir}"/>
   2.652 -        <scalaProject1:debug classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" classpath="${ant.home}/lib/ant.jar:${ant.home}/lib/ant-junit.jar:${debug.test.classpath}">
   2.653 -            <customize>
   2.654 -                <syspropertyset>
   2.655 -                    <propertyref prefix="test-sys-prop."/>
   2.656 -                    <mapper from="test-sys-prop.*" to="*" type="glob"/>
   2.657 -                </syspropertyset>
   2.658 -                <arg value="${test.class}"/>
   2.659 -                <arg value="showoutput=true"/>
   2.660 -                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter"/>
   2.661 -                <arg value="formatter=org.apache.tools.ant.taskdefs.optional.junit.XMLJUnitResultFormatter,${test.report.file}"/>
   2.662 -            </customize>
   2.663 -        </scalaProject1:debug>
   2.664 -    </target>
   2.665 -    <target depends="init,compile-test" if="netbeans.home+have.tests" name="-debug-start-debugger-test">
   2.666 -        <scalaProject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/>
   2.667 -    </target>
   2.668 -    <target depends="init,-do-not-recompile,compile-test-single,-debug-start-debugger-test,-debug-start-debuggee-test" name="debug-test"/>
   2.669 -    <target depends="init,-pre-debug-fix,compile-test-single" if="netbeans.home" name="-do-debug-fix-test">
   2.670 -        <scalaProject1:nbjpdareload dir="${build.test.classes.dir}"/>
   2.671 -    </target>
   2.672 -    <target depends="init,-pre-debug-fix,-do-debug-fix-test" if="netbeans.home" name="debug-fix-test"/>
   2.673 -    <!--
   2.674 -                =========================
   2.675 -                APPLET EXECUTION SECTION
   2.676 -                =========================
   2.677 -            -->
   2.678 -    <target depends="init,compile-single" name="run-applet">
   2.679 -        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   2.680 -        <scalaProject1:java classname="sun.applet.AppletViewer">
   2.681 -            <customize>
   2.682 -                <arg value="${applet.url}"/>
   2.683 -            </customize>
   2.684 -        </scalaProject1:java>
   2.685 -    </target>
   2.686 -    <!--
   2.687 -                =========================
   2.688 -                APPLET DEBUGGING  SECTION
   2.689 -                =========================
   2.690 -            -->
   2.691 -    <target depends="init,compile-single" if="netbeans.home" name="-debug-start-debuggee-applet">
   2.692 -        <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
   2.693 -        <scalaProject1:debug classname="sun.applet.AppletViewer">
   2.694 -            <customize>
   2.695 -                <arg value="${applet.url}"/>
   2.696 -            </customize>
   2.697 -        </scalaProject1:debug>
   2.698 -    </target>
   2.699 -    <target depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet" if="netbeans.home" name="debug-applet"/>
   2.700 -    <!--
   2.701 -                ===============
   2.702 -                CLEANUP SECTION
   2.703 -                ===============
   2.704 -            -->
   2.705 -    <target depends="init" name="deps-clean" unless="no.deps"/>
   2.706 -    <target depends="init" name="-do-clean">
   2.707 -        <delete dir="${build.dir}"/>
   2.708 -        <delete dir="${dist.dir}"/>
   2.709 -        <fsc reset="yes" srcdir="${src.dir}"/>
   2.710 -    </target>
   2.711 -    <target name="-post-clean">
   2.712 -        <!-- Empty placeholder for easier customization. -->
   2.713 -        <!-- You can override this target in the ../build.xml file. -->
   2.714 -    </target>
   2.715 -    <target depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products." name="clean"/>
   2.716 -</project>
     3.1 --- a/modules/lib.collection/nbproject/genfiles.properties	Tue Nov 03 13:08:38 2009 +0800
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,8 +0,0 @@
     3.4 -build.xml.data.CRC32=88653601
     3.5 -build.xml.script.CRC32=5c037d57
     3.6 -build.xml.stylesheet.CRC32=ca9d572e@1.3.2
     3.7 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
     3.8 -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
     3.9 -nbproject/build-impl.xml.data.CRC32=88653601
    3.10 -nbproject/build-impl.xml.script.CRC32=64036444
    3.11 -nbproject/build-impl.xml.stylesheet.CRC32=d86c6904@1.3.2
     4.1 --- a/modules/lib.collection/nbproject/project.properties	Tue Nov 03 13:08:38 2009 +0800
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,62 +0,0 @@
     4.4 -build.classes.dir=${build.dir}/classes
     4.5 -build.classes.excludes=**/*.java,**/*.form,**/*.scala
     4.6 -# This directory is removed when the project is cleaned:
     4.7 -build.dir=build
     4.8 -build.generated.dir=${build.dir}/generated
     4.9 -# Only compile against the classpath explicitly listed here:
    4.10 -build.sysclasspath=ignore
    4.11 -build.test.classes.dir=${build.dir}/test/classes
    4.12 -build.test.results.dir=${build.dir}/test/results
    4.13 -debug.classpath=\
    4.14 -    ${run.classpath}
    4.15 -debug.test.classpath=\
    4.16 -    ${run.test.classpath}
    4.17 -# This directory is removed when the project is cleaned:
    4.18 -dist.dir=dist
    4.19 -dist.jar=${dist.dir}/lib.collection.jar
    4.20 -dist.javadoc.dir=${dist.dir}/scaladoc
    4.21 -excludes=
    4.22 -includes=**
    4.23 -jar.compress=false
    4.24 -java.platform.active=java_default_platform
    4.25 -javac.classpath=
    4.26 -# Space-separated list of extra javac options
    4.27 -javac.compilerargs=
    4.28 -javac.deprecation=false
    4.29 -javac.source=1.5
    4.30 -javac.target=1.5
    4.31 -javac.test.classpath=\
    4.32 -    ${javac.classpath}:\
    4.33 -    ${build.classes.dir}:\
    4.34 -    ${libs.junit.classpath}:\
    4.35 -    ${libs.junit_4.classpath}
    4.36 -javadoc.additionalparam=
    4.37 -javadoc.author=false
    4.38 -javadoc.encoding=${source.encoding}
    4.39 -javadoc.noindex=false
    4.40 -javadoc.nonavbar=false
    4.41 -javadoc.notree=false
    4.42 -javadoc.private=false
    4.43 -javadoc.splitindex=true
    4.44 -javadoc.use=true
    4.45 -javadoc.version=false
    4.46 -javadoc.windowtitle=
    4.47 -meta.inf.dir=${src.dir}/META-INF
    4.48 -platform.active=default_platform
    4.49 -run.classpath=\
    4.50 -    ${javac.classpath}:\
    4.51 -    ${build.classes.dir}
    4.52 -# Space-separated list of JVM arguments used when running the project
    4.53 -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
    4.54 -# or test-sys-prop.name=value to set system properties for unit tests):
    4.55 -run.jvmargs=
    4.56 -run.test.classpath=\
    4.57 -    ${javac.test.classpath}:\
    4.58 -    ${build.test.classes.dir}
    4.59 -# Space-separated list of extra scalac options
    4.60 -scalac.compilerargs=
    4.61 -scalac.deprecation=no
    4.62 -scalac.unchecked=no
    4.63 -source.encoding=UTF-8
    4.64 -src.dir=src
    4.65 -test.src.dir=test
     5.1 --- a/modules/lib.collection/nbproject/project.xml	Tue Nov 03 13:08:38 2009 +0800
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,16 +0,0 @@
     5.4 -<?xml version="1.0" encoding="UTF-8"?>
     5.5 -<project xmlns="http://www.netbeans.org/ns/project/1">
     5.6 -    <type>org.netbeans.modules.scala.project</type>
     5.7 -    <configuration>
     5.8 -        <data xmlns="http://www.netbeans.org/ns/scala-project/1">
     5.9 -            <name>lib.collection</name>
    5.10 -            <minimum-ant-version>1.6.5</minimum-ant-version>
    5.11 -            <source-roots>
    5.12 -                <root id="src.dir"/>
    5.13 -            </source-roots>
    5.14 -            <test-roots>
    5.15 -                <root id="test.src.dir"/>
    5.16 -            </test-roots>
    5.17 -        </data>
    5.18 -    </configuration>
    5.19 -</project>
     6.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/BitSet.scala	Tue Nov 03 13:08:38 2009 +0800
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,32 +0,0 @@
     6.4 -/*                     __                                               *\
     6.5 -**     ________ ___   / /  ___     Scala API                            **
     6.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
     6.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
     6.8 -** /____/\___/_/ |_/____/_/ | |                                         **
     6.9 -**                          |/                                          **
    6.10 -\*                                                                      */
    6.11 -
    6.12 -// $Id: BitSet.scala 18799 2009-09-26 15:19:40Z stepancheg $
    6.13 -
    6.14 -
    6.15 -package org.aiotrade.lib.collection
    6.16 -
    6.17 -import generic._
    6.18 -
    6.19 -/** common base class for mutable and immutable bit sets
    6.20 - *
    6.21 - *  @since 1
    6.22 - */
    6.23 -trait BitSet extends Set[Int] 
    6.24 -                with BitSetLike[BitSet] {
    6.25 -  override def empty: BitSet = BitSet.empty
    6.26 -}
    6.27 -
    6.28 -/** A factory object for bitsets
    6.29 - *
    6.30 - *  @since 2.8
    6.31 - */
    6.32 -object BitSet extends BitSetFactory[BitSet] {
    6.33 -  val empty: BitSet = immutable.BitSet.empty
    6.34 -}
    6.35 -
     7.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/BitSetLike.scala	Tue Nov 03 13:08:38 2009 +0800
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,163 +0,0 @@
     7.4 -/*                     __                                               *\
     7.5 -**     ________ ___   / /  ___     Scala API                            **
     7.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
     7.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
     7.8 -** /____/\___/_/ |_/____/_/ | |                                         **
     7.9 -**                          |/                                          **
    7.10 -\*                                                                      */
    7.11 -
    7.12 -// $Id: BitSetLike.scala 19334 2009-10-28 23:04:03Z odersky $
    7.13 -
    7.14 -
    7.15 -package org.aiotrade.lib.collection
    7.16 -
    7.17 -import BitSetLike._
    7.18 -import generic._
    7.19 -import mutable.StringBuilder
    7.20 -
    7.21 -/** common base class for mutable and immutable bit sets
    7.22 - *
    7.23 - *  @since 2.8
    7.24 - */
    7.25 -trait BitSetLike[+This <: BitSetLike[This] with Set[Int]] extends SetLike[Int, This] { self =>
    7.26 -
    7.27 -  def empty: This
    7.28 -
    7.29 -  /** The number of words (each with 64 bits) making up the set */
    7.30 -  protected def nwords: Int
    7.31 -
    7.32 -  /** The words at index `idx', or 0L if outside the range of the set
    7.33 -   *  @pre idx >= 0
    7.34 -   */
    7.35 -  protected def word(idx: Int): Long
    7.36 -
    7.37 -  /** Create a new set of this kind from an array of longs
    7.38 -   */
    7.39 -  protected def fromArray(elems: Array[Long]): This
    7.40 -
    7.41 -  /** The number of elements in the bitset.
    7.42 -   */
    7.43 -  override def size: Int = {
    7.44 -    var s = 0
    7.45 -    var i = nwords
    7.46 -    while (i > 0) {
    7.47 -      i -= 1
    7.48 -      s += popCount(word(i))
    7.49 -    }
    7.50 -    s
    7.51 -  }
    7.52 -
    7.53 -  def iterator = new Iterator[Int] {
    7.54 -    private var current = 0
    7.55 -    private val end = nwords * WordLength
    7.56 -    def hasNext: Boolean = {
    7.57 -      while (current < end && !self.contains(current)) current += 1
    7.58 -      current < end
    7.59 -    }
    7.60 -    def next(): Int = 
    7.61 -      if (hasNext) { val r = current; current += 1; r } 
    7.62 -      else Iterator.empty.next
    7.63 -  }
    7.64 -
    7.65 -  override def foreach[B](f: Int => B) {
    7.66 -    for (i <- 0 until nwords) {
    7.67 -      val w = word(i)
    7.68 -      for (j <- i * WordLength until (i + 1) * WordLength) {
    7.69 -        if ((w & (1L << j)) != 0L) f(j)
    7.70 -      }
    7.71 -    }
    7.72 -  }
    7.73 -
    7.74 -  /** A new bitset which is the logical or of this set and the given argument set.
    7.75 -   */
    7.76 -  def | (other: BitSet): This = {
    7.77 -    val len = this.nwords max other.nwords
    7.78 -    val words = new Array[Long](len)
    7.79 -    for (idx <- 0 until len)
    7.80 -      words(idx) = this.word(idx) | other.word(idx)
    7.81 -    fromArray(words)
    7.82 -  }
    7.83 -
    7.84 -  /** A new bitset which is the logical and of this set and the given argument set.
    7.85 -   */
    7.86 -  def & (other: BitSet): This = {
    7.87 -    val len = this.nwords min other.nwords
    7.88 -    val words = new Array[Long](len)
    7.89 -    for (idx <- 0 until len)
    7.90 -      words(idx) = this.word(idx) & other.word(idx)
    7.91 -    fromArray(words)
    7.92 -  }
    7.93 -
    7.94 -  /** A new bitset which is the logical and-not of this set and the given argument set.
    7.95 -   */
    7.96 -  def &~ (other: BitSet): This = {
    7.97 -    val len = this.nwords
    7.98 -    val words = new Array[Long](len)
    7.99 -    for (idx <- 0 until len)
   7.100 -      words(idx) = this.word(idx) & ~other.word(idx)
   7.101 -    fromArray(words)
   7.102 -  }
   7.103 -
   7.104 -  /** A new bitset which is the logical exclusive or of this set and the given argument set.
   7.105 -   */
   7.106 -  def ^ (other: BitSet): This = {
   7.107 -    val len = this.nwords max other.nwords
   7.108 -    val words = new Array[Long](len)
   7.109 -    for (idx <- 0 until len)
   7.110 -      words(idx) = this.word(idx) ^ other.word(idx)
   7.111 -    fromArray(words)
   7.112 -  }
   7.113 -
   7.114 -  /** Does the set contain the given element?
   7.115 -   */
   7.116 -  def contains(elem: Int): Boolean =
   7.117 -    0 <= elem && (word(elem >> LogWL) & (1L << elem)) != 0L
   7.118 -
   7.119 -  /** Is the set a subset of the given bitset
   7.120 -   */
   7.121 -  def subSet(other: BitSet): Boolean =
   7.122 -    (0 until nwords) forall (idx => (this.word(idx) & ~ other.word(idx)) == 0L)
   7.123 -
   7.124 -  /** Add bitset elements as numbers to string buffer
   7.125 -   */
   7.126 -  override def addString(sb: StringBuilder, start: String, sep: String, end: String) = {
   7.127 -    sb append start
   7.128 -    var pre = ""
   7.129 -    for (i <- 0 until nwords * WordLength)
   7.130 -      if (contains(i)) {
   7.131 -        sb append pre append i
   7.132 -        pre = sep
   7.133 -      }
   7.134 -    sb append end
   7.135 -  }
   7.136 -
   7.137 -  override def stringPrefix = "BitSet"                                                                                      
   7.138 -}
   7.139 -
   7.140 -object BitSetLike {
   7.141 -  private[collection] val LogWL = 6
   7.142 -  private val WordLength = 64
   7.143 -
   7.144 -  private[collection] def updateArray(elems: Array[Long], idx: Int, w: Long): Array[Long] = {
   7.145 -    var len = elems.length
   7.146 -    while (len > 0 && (elems(len - 1) == 0L || w == 0L && idx == len - 1)) len -= 1
   7.147 -    var newlen = len
   7.148 -    if (idx >= newlen && w != 0L) newlen = idx + 1
   7.149 -    val newelems = new Array[Long](newlen)
   7.150 -    Array.copy(elems, 0, newelems, 0, len)
   7.151 -    if (idx < newlen) newelems(idx) = w
   7.152 -    else assert(w == 0L)
   7.153 -    newelems
   7.154 -  }
   7.155 -
   7.156 -  private val pc1: Array[Int] = {
   7.157 -    def countBits(x: Int): Int = if (x == 0) 0 else x % 2 + countBits(x >>> 1)
   7.158 -    Array.tabulate(256)(countBits _)
   7.159 -  }
   7.160 -
   7.161 -  private def popCount(w: Long): Int = {
   7.162 -    def pc2(w: Int) = if (w == 0) 0 else pc1(w & 0xff) + pc1(w >>> 8)
   7.163 -    def pc4(w: Int) = if (w == 0) 0 else pc2(w & 0xffff) + pc2(w >>> 16)
   7.164 -    if (w == 0L) 0 else pc4(w.toInt) + pc4((w >>> 32).toInt)
   7.165 -  }
   7.166 -}
     8.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/BufferedIterator.scala	Tue Nov 03 13:08:38 2009 +0800
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,28 +0,0 @@
     8.4 -/*                     __                                               *\
     8.5 -**     ________ ___   / /  ___     Scala API                            **
     8.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
     8.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
     8.8 -** /____/\___/_/ |_/____/_/ | |                                         **
     8.9 -**                          |/                                          **
    8.10 -\*                                                                      */
    8.11 -
    8.12 -// $Id: BufferedIterator.scala 18799 2009-09-26 15:19:40Z stepancheg $
    8.13 -
    8.14 -
    8.15 -package org.aiotrade.lib.collection
    8.16 -
    8.17 -/** Buffered iterators are iterators which provide a method <code>head</code>
    8.18 - *  that inspects the next element without discarding it.
    8.19 - *
    8.20 - *  @author  Martin Odersky
    8.21 - *  @version 2.8
    8.22 - *  @since   2.8
    8.23 - */
    8.24 -trait BufferedIterator[+A] extends Iterator[A] {
    8.25 -
    8.26 -  /** Returns next element of iterator without advancing beyond it.
    8.27 -   */
    8.28 -  def head: A
    8.29 -
    8.30 -  override def buffered: this.type = this
    8.31 -}
     9.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/DefaultMap.scala	Tue Nov 03 13:08:38 2009 +0800
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,52 +0,0 @@
     9.4 -/*                     __                                               *\
     9.5 -**     ________ ___   / /  ___     Scala API                            **
     9.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
     9.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
     9.8 -** /____/\___/_/ |_/____/_/ | |                                         **
     9.9 -**                          |/                                          **
    9.10 -\*                                                                      */
    9.11 -
    9.12 -// $Id: DefaultMap.scala 18799 2009-09-26 15:19:40Z stepancheg $
    9.13 -
    9.14 -
    9.15 -package org.aiotrade.lib.collection
    9.16 -
    9.17 -import generic._
    9.18 -
    9.19 -/** <p>
    9.20 - *    A default map which implements the <code>updated</code> and <code>-</code>
    9.21 - *    methods of maps.<br/>
    9.22 - *    Instances that inherit from <code>DefaultMap[A, B]</code> still have to
    9.23 - *    define:
    9.24 - *  </p><pre>
    9.25 - *    <b>def</b> get(key: A): Option[B]
    9.26 - *    <b>def</b> iterator: Iterator[(A, B)]</pre>
    9.27 - *  <p>
    9.28 - *    It refers back to the original map.
    9.29 - *  </p>
    9.30 - *  <p>
    9.31 - *    It might also be advisable to override <code>foreach</code> or
    9.32 - *    <code>size</code> if efficient implementations can be found.
    9.33 - *  </p>
    9.34 - *
    9.35 - *  @since 2.8
    9.36 - */
    9.37 -trait DefaultMap[A, +B] extends Map[A, B] { self =>
    9.38 -
    9.39 -  /** A default implementation which creates a new immutable map.
    9.40 -   */
    9.41 -  override def +[B1 >: B](kv: (A, B1)): Map[A, B1] = {
    9.42 -    val b = Map.newBuilder[A, B1]
    9.43 -    b ++= this
    9.44 -    b += ((kv._1, kv._2))
    9.45 -    b.result
    9.46 -  }
    9.47 -
    9.48 -  /** A default implementation which creates a new immutable map.
    9.49 -   */
    9.50 -  override def - (key: A): Map[A, B] = {
    9.51 -    val b = newBuilder
    9.52 -    b ++= this filter (key !=)
    9.53 -    b.result
    9.54 -  }
    9.55 -}
    10.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeq.scala	Tue Nov 03 13:08:38 2009 +0800
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,40 +0,0 @@
    10.4 -/*                     __                                               *\
    10.5 -**     ________ ___   / /  ___     Scala API                            **
    10.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    10.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    10.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    10.9 -**                          |/                                          **
   10.10 -\*                                                                      */
   10.11 -
   10.12 -// $Id: IndexedSeq.scala 19354 2009-10-30 07:51:23Z rompf $
   10.13 -
   10.14 -
   10.15 -package org.aiotrade.lib.collection
   10.16 -
   10.17 -import generic._
   10.18 -import mutable.Builder
   10.19 -
   10.20 -/** <p>
   10.21 - *    Sequences that support O(1) element access and O(1) length computation.
   10.22 - *  </p>
   10.23 - *  <p>
   10.24 - *    This class does not add any methods to <code>Sequence</code> but
   10.25 - *    overrides several methods with optimized implementations.
   10.26 - *  </p>
   10.27 - *
   10.28 - *  @author Sean McDirmid
   10.29 - *  @author Martin Odersky
   10.30 - *  @version 2.8
   10.31 - *  @since   2.8
   10.32 - */
   10.33 -trait IndexedSeq[+A] extends Seq[A] 
   10.34 -                    with GenericTraversableTemplate[A, IndexedSeq]
   10.35 -                    with IndexedSeqLike[A, IndexedSeq[A]] {
   10.36 -  override def companion: GenericCompanion[IndexedSeq] = IndexedSeq
   10.37 -}
   10.38 -
   10.39 -object IndexedSeq extends SeqFactory[IndexedSeq] {
   10.40 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeq[A]] = new GenericCanBuildFrom[A]
   10.41 -  def newBuilder[A]: Builder[A, IndexedSeq[A]] = immutable.IndexedSeq.newBuilder[A]
   10.42 -}
   10.43 -
    11.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeqLike.scala	Tue Nov 03 13:08:38 2009 +0800
    11.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.3 @@ -1,273 +0,0 @@
    11.4 -/*                     __                                               *\
    11.5 -**     ________ ___   / /  ___     Scala API                            **
    11.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    11.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    11.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    11.9 -**                          |/                                          **
   11.10 -\*                                                                      */
   11.11 -
   11.12 -// $Id: IndexedSeqLike.scala 19210 2009-10-21 21:13:58Z rompf $
   11.13 -
   11.14 -
   11.15 -package org.aiotrade.lib.collection
   11.16 -
   11.17 -import generic._
   11.18 -import mutable.ArrayBuffer
   11.19 -import scala.annotation.tailrec
   11.20 -
   11.21 -/** Sequences that support O(1) element access and O(1) length computation.
   11.22 - *  This class does not add any methods to Seq but overrides several
   11.23 - *  methods with optimized implementations.
   11.24 - * 
   11.25 - *  @author Sean McDirmid
   11.26 - *  @author Martin Odersky
   11.27 - *  @version 2.8
   11.28 - *  @since   2.8
   11.29 - */
   11.30 -trait IndexedSeqLike[+A, +Repr] extends SeqLike[A, Repr] { self =>
   11.31 -
   11.32 -  override protected[this] def thisCollection: IndexedSeq[A] = this.asInstanceOf[IndexedSeq[A]]
   11.33 -  override protected[this] def toCollection(repr: Repr): IndexedSeq[A] = repr.asInstanceOf[IndexedSeq[A]]
   11.34 -
   11.35 -  // Overridden methods from IterableLike
   11.36 -
   11.37 -  /** The iterator returned by the iterator method
   11.38 -   */
   11.39 -  @serializable @SerialVersionUID(1756321872811029277L)
   11.40 -  protected class Elements(start: Int, end: Int) extends BufferedIterator[A] {
   11.41 -    private var i = start
   11.42 -
   11.43 -    def hasNext: Boolean = i < end
   11.44 -
   11.45 -    def next: A = 
   11.46 -      if (i < end) {
   11.47 -        val x = self(i)
   11.48 -        i += 1
   11.49 -        x
   11.50 -      } else Iterator.empty.next
   11.51 -
   11.52 -    def head = 
   11.53 -      if (i < end) self(i) else Iterator.empty.next
   11.54 -
   11.55 -    /** drop is overridden to enable fast searching in the middle of random access sequences */
   11.56 -    override def drop(n: Int): Iterator[A] =
   11.57 -      if (n > 0) new Elements(start + n, end) else this
   11.58 -
   11.59 -    /** take is overridden to be symmetric to drop */
   11.60 -    override def take(n: Int): Iterator[A] =
   11.61 -      if (n <= 0) Iterator.empty.buffered
   11.62 -      else if (start + n < end) new Elements(start, start + n) 
   11.63 -      else this
   11.64 -  }
   11.65 -
   11.66 -  override def iterator: Iterator[A] = new Elements(0, length)
   11.67 -
   11.68 -  override def isEmpty: Boolean = { length == 0 }
   11.69 -
   11.70 -  override def foreach[U](f: A =>  U): Unit = {
   11.71 -    var i = 0
   11.72 -    val len = length
   11.73 -    while (i < len) { f(this(i)); i += 1 }
   11.74 -  }
   11.75 -
   11.76 -  override def forall(p: A => Boolean): Boolean = prefixLength(p(_)) == length
   11.77 -  override def exists(p: A => Boolean): Boolean = prefixLength(!p(_)) != length
   11.78 -
   11.79 -  override def find(p: A => Boolean): Option[A] = {
   11.80 -    val i = prefixLength(!p(_))
   11.81 -    if (i < length) Some(this(i)) else None
   11.82 -  }
   11.83 -
   11.84 -  @tailrec
   11.85 -  private def foldl[B](start: Int, end: Int, z: B, op: (B, A) => B): B =
   11.86 -    if (start == end) z
   11.87 -    else foldl(start + 1, end, op(z, this(start)), op)
   11.88 -
   11.89 -  @tailrec
   11.90 -  private def foldr[B](start: Int, end: Int, z: B, op: (A, B) => B): B =
   11.91 -    if (start == end) z
   11.92 -    else foldr(start, end - 1, op(this(end - 1), z), op)
   11.93 -
   11.94 -  override def foldLeft[B](z: B)(op: (B, A) => B): B = 
   11.95 -    foldl(0, length, z, op)
   11.96 -  override def foldRight[B](z: B)(op: (A, B) => B): B = 
   11.97 -    foldr(0, length, z, op)
   11.98 -  override def reduceLeft[B >: A](op: (B, A) => B): B = 
   11.99 -    if (length > 0) foldl(1, length, this(0), op) else super.reduceLeft(op)
  11.100 -  override def reduceRight[B >: A](op: (A, B) => B): B = 
  11.101 -    if (length > 0) foldr(0, length - 1, this(length - 1), op) else super.reduceRight(op)
  11.102 -  
  11.103 -  override def zip[A1 >: A, B, That](that: Iterable[B])(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = that match {
  11.104 -    case that: IndexedSeq[_] =>
  11.105 -      val b = bf(repr)
  11.106 -      var i = 0
  11.107 -      val len = this.length min that.length
  11.108 -      b.sizeHint(len)
  11.109 -      while (i < len) {
  11.110 -        b += ((this(i), that(i).asInstanceOf[B]))
  11.111 -        i += 1
  11.112 -      }
  11.113 -      b.result
  11.114 -    case _ =>
  11.115 -      super.zip[A1, B, That](that)(bf)
  11.116 -  }
  11.117 -
  11.118 -  override def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[Repr, (A1, Int), That]): That = {
  11.119 -    val b = bf(repr)
  11.120 -    val len = length
  11.121 -    b.sizeHint(len)
  11.122 -    var i = 0
  11.123 -    while (i < len) {
  11.124 -      b += ((this(i), i))
  11.125 -      i += 1
  11.126 -    }
  11.127 -    b.result
  11.128 -  }
  11.129 -  
  11.130 -  override def slice(from: Int, until: Int): Repr = {
  11.131 -    var i = from max 0
  11.132 -    val end = until min length
  11.133 -    val b = newBuilder
  11.134 -    b.sizeHint(end - i)
  11.135 -    while (i < end) {
  11.136 -      b += this(i)
  11.137 -      i += 1
  11.138 -    }
  11.139 -    b.result
  11.140 -  }
  11.141 -
  11.142 -  override def head: A = if (isEmpty) super.head else this(0)
  11.143 -  override def tail: Repr = if (isEmpty) super.tail else slice(1, length)
  11.144 -  override def last: A = if (length > 0) this(length - 1) else super.last
  11.145 -  override def init: Repr = if (length > 0) slice(0, length - 1) else super.init
  11.146 -  override def take(n: Int): Repr = slice(0, n)
  11.147 -  override def drop(n: Int): Repr = slice(n, length)
  11.148 -  override def takeRight(n: Int): Repr = slice(length - n, length)
  11.149 -  override def dropRight(n: Int): Repr = slice(0, length - n)
  11.150 -  override def splitAt(n: Int): (Repr, Repr) = (take(n), drop(n))
  11.151 -  override def takeWhile(p: A => Boolean): Repr = take(prefixLength(p))
  11.152 -  override def dropWhile(p: A => Boolean): Repr = drop(prefixLength(p))
  11.153 -  override def span(p: A => Boolean): (Repr, Repr) = splitAt(prefixLength(p))
  11.154 -
  11.155 -  override def sameElements[B >: A](that: Iterable[B]): Boolean = that match {
  11.156 -    case that: IndexedSeq[_] =>
  11.157 -      val len = length
  11.158 -      len == that.length && {
  11.159 -        var i = 0
  11.160 -        while (i < len && this(i) == that(i)) i += 1
  11.161 -        i == len
  11.162 -      }
  11.163 -    case _ =>
  11.164 -      super.sameElements(that)
  11.165 -  }        
  11.166 -  
  11.167 -  override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
  11.168 -    var i = 0
  11.169 -    var j = start
  11.170 -    val end = length min len min (xs.length - start)
  11.171 -    while (i < end) {
  11.172 -      xs(j) = this(i)
  11.173 -      i += 1
  11.174 -      j += 1
  11.175 -    }
  11.176 -  }
  11.177 -
  11.178 -
  11.179 -  // Overridden methods from Seq
  11.180 -  
  11.181 -  override def lengthCompare(len: Int): Int = length - len
  11.182 -  
  11.183 -  override def segmentLength(p: A => Boolean, from: Int): Int = {
  11.184 -    val start = from
  11.185 -    val len = length
  11.186 -    var i = start
  11.187 -    while (i < len && p(this(i))) i += 1
  11.188 -    i - start
  11.189 -  }
  11.190 -
  11.191 -  private def negLength(n: Int) = if (n == length) -1 else n
  11.192 -
  11.193 -  override def indexWhere(p: A => Boolean, from: Int): Int = {
  11.194 -    val start = from max 0
  11.195 -    negLength(start + segmentLength(!p(_), start))
  11.196 -  }	
  11.197 -
  11.198 -  override def lastIndexWhere(p: A => Boolean, end: Int): Int = {
  11.199 -    var i = end
  11.200 -    while (i >= 0 && !p(this(i))) i -= 1
  11.201 -    i
  11.202 -  }
  11.203 -
  11.204 -  override def reverse: Repr = {
  11.205 -    val b = newBuilder
  11.206 -    b.sizeHint(length)
  11.207 -    var i = length
  11.208 -    while (0 < i) {
  11.209 -      i -= 1
  11.210 -      b += this(i)
  11.211 -    }
  11.212 -    b.result
  11.213 -  }
  11.214 -
  11.215 -  override def reverseIterator: Iterator[A] = new Iterator[A] {
  11.216 -    private var i = self.length
  11.217 -    def hasNext: Boolean = 0 < i
  11.218 -    def next: A = 
  11.219 -      if (0 < i) {
  11.220 -        i -= 1
  11.221 -        self(i)
  11.222 -      } else Iterator.empty.next
  11.223 -  }
  11.224 -
  11.225 -  override def startsWith[B](that: Seq[B], offset: Int): Boolean = that match {
  11.226 -    case that: IndexedSeq[_] =>
  11.227 -      var i = offset
  11.228 -      var j = 0
  11.229 -      val thisLen = length
  11.230 -      val thatLen = that.length
  11.231 -      while (i < thisLen && j < thatLen && this(i) == that(j)) {
  11.232 -        i += 1
  11.233 -        j += 1
  11.234 -      }
  11.235 -      j == thatLen
  11.236 -    case _ =>
  11.237 -      var i = offset
  11.238 -      val thisLen = length
  11.239 -      val thatElems = that.iterator
  11.240 -      while (i < thisLen && thatElems.hasNext) {
  11.241 -        if (this(i) != thatElems.next())
  11.242 -          return false
  11.243 -        
  11.244 -        i += 1
  11.245 -      }
  11.246 -      !thatElems.hasNext
  11.247 -  }
  11.248 -
  11.249 -  override def endsWith[B](that: Seq[B]): Boolean = that match {
  11.250 -    case that: IndexedSeq[_] =>
  11.251 -      var i = length - 1
  11.252 -      var j = that.length - 1
  11.253 -      
  11.254 -      (j <= i) && {
  11.255 -        while (j >= 0) {
  11.256 -          if (this(i) != that(j))
  11.257 -            return false
  11.258 -          i -= 1
  11.259 -          j -= 1
  11.260 -        }
  11.261 -        true
  11.262 -      }
  11.263 -    case _ =>
  11.264 -      super.endsWith(that)
  11.265 -  }
  11.266 -
  11.267 -  override def view = new IndexedSeqView[A, Repr] {
  11.268 -    protected lazy val underlying = self.repr
  11.269 -    override def iterator = self.iterator
  11.270 -    override def length = self.length
  11.271 -    override def apply(idx: Int) = self.apply(idx)
  11.272 -  }
  11.273 -
  11.274 -  override def view(from: Int, until: Int) = view.slice(from, until)
  11.275 -}
  11.276 -
    12.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeqView.scala	Tue Nov 03 13:08:38 2009 +0800
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,38 +0,0 @@
    12.4 -/*                     __                                               *\
    12.5 -**     ________ ___   / /  ___     Scala API                            **
    12.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    12.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    12.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    12.9 -**                          |/                                          **
   12.10 -\*                                                                      */
   12.11 -
   12.12 -// $Id: IndexedSeqView.scala 19210 2009-10-21 21:13:58Z rompf $
   12.13 -
   12.14 -
   12.15 -package org.aiotrade.lib.collection
   12.16 -
   12.17 -import TraversableView.NoBuilder
   12.18 -import generic._
   12.19 -
   12.20 -/** A non-strict projection of an iterable.
   12.21 - *
   12.22 - * @author Sean McDirmid
   12.23 - * @author Martin Odersky
   12.24 - * @version 2.8
   12.25 - * @since   2.8
   12.26 - */
   12.27 -trait IndexedSeqView[+A, +Coll] extends IndexedSeqViewLike[A, Coll, IndexedSeqView[A, Coll]]
   12.28 -
   12.29 -object IndexedSeqView {
   12.30 -  type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
   12.31 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IndexedSeqView[A, IndexedSeq[_]]] = 
   12.32 -    new CanBuildFrom[Coll, A, IndexedSeqView[A, IndexedSeq[_]]] { 
   12.33 -      def apply(from: Coll) = new NoBuilder 
   12.34 -      def apply() = new NoBuilder 
   12.35 -    }
   12.36 -  implicit def arrCanBuildFrom[A]: CanBuildFrom[TraversableView[_, Array[_]], A, IndexedSeqView[A, Array[A]]] = 
   12.37 -    new CanBuildFrom[TraversableView[_, Array[_]], A, IndexedSeqView[A, Array[A]]] { 
   12.38 -      def apply(from: TraversableView[_, Array[_]]) = new NoBuilder 
   12.39 -      def apply() = new NoBuilder 
   12.40 -    }
   12.41 -}
    13.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IndexedSeqViewLike.scala	Tue Nov 03 13:08:38 2009 +0800
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,109 +0,0 @@
    13.4 -/*                     __                                               *\
    13.5 -**     ________ ___   / /  ___     Scala API                            **
    13.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    13.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    13.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    13.9 -**                          |/                                          **
   13.10 -\*                                                                      */
   13.11 -
   13.12 -// $Id: Seq.scala 16092 2008-09-12 10:37:06Z nielsen $
   13.13 -
   13.14 -
   13.15 -package org.aiotrade.lib.collection
   13.16 -
   13.17 -import generic._
   13.18 -import TraversableView.NoBuilder
   13.19 -
   13.20 -/** A template trait for a non-strict view of a IndexedSeq.
   13.21 - *
   13.22 - * @author Sean McDirmid
   13.23 - * @author Martin Odersky
   13.24 - * @version 2.8
   13.25 - * @since   2.8
   13.26 - */
   13.27 -trait IndexedSeqViewLike[+A, 
   13.28 -                         +Coll,
   13.29 -                         +This <: IndexedSeqView[A, Coll] with IndexedSeqViewLike[A, Coll, This]] 
   13.30 -  extends IndexedSeq[A] with IndexedSeqLike[A, This] with SeqView[A, Coll] with SeqViewLike[A, Coll, This] 
   13.31 -{ self =>
   13.32 -
   13.33 -  trait Transformed[+B] extends IndexedSeqView[B, Coll] with super.Transformed[B]
   13.34 -
   13.35 -  trait Sliced extends Transformed[A] with super.Sliced {
   13.36 -    /** Override to use IndexedSeq's foreach; todo: see whether this is really faster */
   13.37 -    override def foreach[U](f: A =>  U) = super[Transformed].foreach(f)
   13.38 -  }
   13.39 -
   13.40 -  trait Mapped[B] extends Transformed[B] with super.Mapped[B] {
   13.41 -    override def foreach[U](f: B =>  U) = super[Transformed].foreach(f)
   13.42 -  }
   13.43 -
   13.44 -  trait FlatMapped[B] extends Transformed[B] with super.FlatMapped[B] {
   13.45 -    override def foreach[U](f: B =>  U) = super[Transformed].foreach(f)
   13.46 -  }
   13.47 -    
   13.48 -  trait Appended[B >: A] extends Transformed[B] with super.Appended[B] {
   13.49 -    override def foreach[U](f: B =>  U) = super[Transformed].foreach(f)
   13.50 -  }
   13.51 -    
   13.52 -  trait Filtered extends Transformed[A] with super.Filtered {
   13.53 -    override def foreach[U](f: A =>  U) = super[Transformed].foreach(f)
   13.54 -  }
   13.55 -    
   13.56 -  trait TakenWhile extends Transformed[A] with super.TakenWhile {
   13.57 -    override def foreach[U](f: A =>  U) = super[Transformed].foreach(f)
   13.58 -  }
   13.59 -
   13.60 -  trait DroppedWhile extends Transformed[A] with super.DroppedWhile {
   13.61 -    override def foreach[U](f: A =>  U) = super[Transformed].foreach(f)
   13.62 -  }
   13.63 -
   13.64 -  trait Reversed extends Transformed[A] with super.Reversed {
   13.65 -    override def foreach[U](f: A =>  U) = super[Transformed].foreach(f)
   13.66 -  }
   13.67 -
   13.68 -  trait Patched[B >: A] extends Transformed[B] with super.Patched[B] {
   13.69 -    override def foreach[U](f: B =>  U) = super[Transformed].foreach(f)
   13.70 -  }
   13.71 -
   13.72 -  trait Zipped[B] extends Transformed[(A, B)] {
   13.73 -    protected[this] val other: Iterable[B]
   13.74 -    def length = self.length min other.size
   13.75 -    def apply(idx: Int): (A, B) = (self.apply(idx), other.iterator drop idx next)
   13.76 -    override def stringPrefix = self.stringPrefix+"Z"
   13.77 -  } 
   13.78 -
   13.79 -  trait ZippedAll[A1 >: A, B] extends Transformed[(A1, B)] {
   13.80 -    protected[this] val other: Iterable[B]
   13.81 -    val thisElem: A1
   13.82 -    val thatElem: B
   13.83 -    override def iterator: Iterator[(A1, B)] = 
   13.84 -      self.iterator.zipAll(other.iterator, thisElem, thatElem)
   13.85 -      
   13.86 -    def length = self.length max other.size
   13.87 -    def apply(idx: Int): (A1, B) = {
   13.88 -      val z1 = if (idx < self.length) self.apply(idx) else thisElem
   13.89 -      val z2 = if (idx < other.size) other drop idx head else thatElem
   13.90 -      (z1, z2)
   13.91 -    }      
   13.92 -    override def stringPrefix = self.stringPrefix+"Z"      
   13.93 -  }
   13.94 -
   13.95 -  /** Boilerplate method, to override in each subclass
   13.96 -   *  This method could be eliminated if Scala had virtual classes
   13.97 -   */
   13.98 -  protected override def newAppended[B >: A](that: Traversable[B]): Transformed[B] = new Appended[B] { val rest = that }
   13.99 -  protected override def newMapped[B](f: A => B): Transformed[B] = new Mapped[B] { val mapping = f }
  13.100 -  protected override def newFlatMapped[B](f: A => Traversable[B]): Transformed[B] = new FlatMapped[B] { val mapping = f }
  13.101 -  protected override def newFiltered(p: A => Boolean): Transformed[A] = new Filtered { val pred = p }
  13.102 -  protected override def newSliced(_from: Int, _until: Int): Transformed[A] = new Sliced { val from = _from; val until = _until }
  13.103 -  protected override def newDroppedWhile(p: A => Boolean): Transformed[A] = new DroppedWhile { val pred = p }
  13.104 -  protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new TakenWhile { val pred = p }
  13.105 -  protected override def newZipped[B](that: Iterable[B]): Transformed[(A, B)] = new Zipped[B] { val other = that }
  13.106 -  protected override def newZippedAll[A1 >: A, B](that: Iterable[B], _thisElem: A1, _thatElem: B): Transformed[(A1, B)] = new ZippedAll[A1, B] { val other = that; val thisElem = _thisElem; val thatElem = _thatElem }
  13.107 -  protected override def newReversed: Transformed[A] = new Reversed { }
  13.108 -  protected override def newPatched[B >: A](_from: Int, _patch: Seq[B], _replaced: Int): Transformed[B] = new Patched[B] {
  13.109 -    val from = _from; val patch = _patch; val replaced = _replaced
  13.110 -  }
  13.111 -  override def stringPrefix = "IndexedSeqView"
  13.112 -}
    14.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/Iterable.scala	Tue Nov 03 13:08:38 2009 +0800
    14.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.3 @@ -1,82 +0,0 @@
    14.4 -/*                     __                                               *\
    14.5 -**     ________ ___   / /  ___     Scala API                            **
    14.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    14.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    14.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    14.9 -**                          |/                                          **
   14.10 -\*                                                                      */
   14.11 -
   14.12 -// $Id: Iterable.scala 19219 2009-10-22 09:43:14Z moors $
   14.13 -
   14.14 -
   14.15 -package org.aiotrade.lib.collection
   14.16 -
   14.17 -import generic._
   14.18 -import scala.util.control.Breaks._
   14.19 -import mutable.Builder
   14.20 -
   14.21 -/** <p>
   14.22 - *    A template trait for iterable collections.
   14.23 - *  </p>
   14.24 - *  <p>
   14.25 - *    Collection classes mixing in this trait provide a method
   14.26 - *    <code>iterator</code> which returns an iterator over all the
   14.27 - *    elements contained in the collection. They also provide a method
   14.28 - *    <code>newBuilder</code> which creates a builder for collections
   14.29 - *    of the same kind.
   14.30 - *  </p>
   14.31 - *  <p>
   14.32 - *    This trait implements <code>Traversable</code>'s <code>foreach</code>
   14.33 - *    method by stepping through all elements. Subclasses of <code>Iterable</code>
   14.34 - *    should re-implement <code>foreach</code> with something more efficient,
   14.35 - *    if possible.
   14.36 - *  </p>
   14.37 - *  <p>
   14.38 - *    This trait adds methods <code>iterator</code>, <code>zip</code>,
   14.39 - *    <code>zipAll</code>, <code>zipWithIndex</code>, <code>sameElements</code>,
   14.40 - *    <code>takeRight</code>, <code>dropRight</code> to the methods inherited
   14.41 - *    from trait <code>Traversable</code>.
   14.42 - *  </p>
   14.43 - *
   14.44 - *  @author Martin Odersky
   14.45 - *  @version 2.8
   14.46 - *  @since   2.8
   14.47 - */
   14.48 -trait Iterable[+A] extends Traversable[A] 
   14.49 -                      with GenericTraversableTemplate[A, Iterable]
   14.50 -                      with IterableLike[A, Iterable[A]] {
   14.51 -   override def companion: GenericCompanion[Iterable] = Iterable
   14.52 - 
   14.53 -  /* The following methods are inherited from trait IterableLike
   14.54 -   *
   14.55 -  override def iterator: Iterator[A]
   14.56 -  override def takeRight(n: Int): Iterable[A]
   14.57 -  override def dropRight(n: Int): Iterable[A]
   14.58 -  override def sameElements[B >: A](that: Iterable[B]): Boolean
   14.59 -  override def view
   14.60 -  override def view(from: Int, until: Int)
   14.61 -  */
   14.62 -
   14.63 -}
   14.64 -                                         
   14.65 -/** Factory methods and utilities for instances of type <code>Iterable</code>.
   14.66 - *
   14.67 - *  @author Martin Odersky
   14.68 - *  @version 2.8
   14.69 - */
   14.70 -object Iterable extends TraversableFactory[Iterable] {
   14.71 -  
   14.72 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Iterable[A]] = new GenericCanBuildFrom[A]
   14.73 -  def newBuilder[A]: Builder[A, Iterable[A]] = immutable.Iterable.newBuilder[A]
   14.74 -  
   14.75 -  /** The minimum element of a non-empty sequence of ordered elements */
   14.76 -  @deprecated("use seq.min instead")
   14.77 -  def min[A](seq: Iterable[A])(implicit ord: Ordering[A]): A = seq.min
   14.78 -
   14.79 -  /** The maximum element of a non-empty sequence of ordered elements */
   14.80 -  @deprecated("use seq.max instead")
   14.81 -  def max[A](seq: Iterable[A])(implicit ord: Ordering[A]): A = seq.max
   14.82 -
   14.83 -  @deprecated("use View instead")
   14.84 -  type Projection[A] = IterableView[A, Coll]
   14.85 -}
    15.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IterableLike.scala	Tue Nov 03 13:08:38 2009 +0800
    15.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.3 @@ -1,375 +0,0 @@
    15.4 -/*                     __                                               *\
    15.5 -**     ________ ___   / /  ___     Scala API                            **
    15.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    15.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    15.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    15.9 -**                          |/                                          **
   15.10 -\*                                                                      */
   15.11 -
   15.12 -// $Id: IterableLike.scala 19334 2009-10-28 23:04:03Z odersky $
   15.13 -
   15.14 -package org.aiotrade.lib.collection
   15.15 -import generic._
   15.16 -import immutable.{List, Stream}
   15.17 -import annotation.unchecked.uncheckedVariance
   15.18 -
   15.19 -/** <p>
   15.20 - *    A template trait for iterable collections.
   15.21 - *  </p>
   15.22 - *  <p>
   15.23 - *    Collection classes mixing in this trait provide a method
   15.24 - *    <code>iterator</code> which returns an iterator over all the
   15.25 - *    elements contained in the collection. They also provide a method
   15.26 - *    <code>newBuilder</code> which creates a builder for collections of the
   15.27 - *    same kind.
   15.28 - *  </p>
   15.29 - *  <p>
   15.30 - *    This trait implements <code>Iterable</code>'s <code>foreach</code>
   15.31 - *    method by stepping through all elements. Subclasses of <code>Iterable</code>
   15.32 - *    should re-implement <code>foreach</code> with something more efficient,
   15.33 - *    if possible.
   15.34 - *  </p>
   15.35 - *  <p>
   15.36 - *    This trait adds methods <code>iterator</code>, <code>sameElements</code>,
   15.37 - *    <code>takeRight</code>, <code>dropRight</code> to the methods inherited
   15.38 - *    from trait <a href="../Iterable.html" target="ContentFrame">
   15.39 - *    <code>Iterable</code></a>.
   15.40 - *  </p>
   15.41 - *
   15.42 - *  @note  This trait replaces every method that uses breaks in the original by an iterator version.
   15.43 - *
   15.44 - *  @author Martin Odersky
   15.45 - *  @version 2.8
   15.46 - *  @since   2.8
   15.47 - */
   15.48 -trait IterableLike[+A, +Repr] extends Equals with TraversableLike[A, Repr] { 
   15.49 -self =>
   15.50 -
   15.51 -  override protected[this] def thisCollection: Iterable[A] = this.asInstanceOf[Iterable[A]]
   15.52 -  override protected[this] def toCollection(repr: Repr): Iterable[A] = repr.asInstanceOf[Iterable[A]]
   15.53 -
   15.54 -  /** Creates a new iterator over all elements contained in this
   15.55 -   *  iterable object.
   15.56 -   *  
   15.57 -   *  @return the new iterator
   15.58 -   */
   15.59 -  def iterator: Iterator[A]
   15.60 -  
   15.61 -  @deprecated("use `iterator' instead")
   15.62 -  def elements = iterator
   15.63 -
   15.64 -  /** Apply a function <code>f</code> to all elements of this
   15.65 -   *  iterable object.
   15.66 -   *
   15.67 -   *  @param  f   A function that is applied for its side-effect to every element.
   15.68 -   *              The result (of arbitrary type U) of function `f` is discarded.
   15.69 -   *              
   15.70 -   *  @note This method underlies the implementation of most other bulk operations.
   15.71 -   *        Implementing `foreach` with `iterator` is often suboptimal.
   15.72 -   *        So `foreach` should be overridden in concrete collection classes if a more
   15.73 -   *        efficient implementation is available.
   15.74 -   */
   15.75 -  def foreach[U](f: A => U): Unit = iterator.foreach(f)
   15.76 -
   15.77 -  
   15.78 -  /** Return true iff the given predicate `p` yields true for all elements
   15.79 -   *  of this iterable. 
   15.80 -   *
   15.81 -   *  @note May not terminate for infinite-sized collections.
   15.82 -   *  @param   p     the predicate
   15.83 -   */
   15.84 -  override def forall(p: A => Boolean): Boolean = iterator.forall(p)
   15.85 -
   15.86 -  /** Return true iff there is an element in this iterable for which the
   15.87 -   *  given predicate `p` yields true.
   15.88 -   *
   15.89 -   *  @note May not terminate for infinite-sized collections.
   15.90 -   *  @param   p     the predicate
   15.91 -   */
   15.92 -  override def exists(p: A => Boolean): Boolean = iterator.exists(p)
   15.93 -
   15.94 -  /** Find and return the first element of the iterable object satisfying a
   15.95 -   *  predicate, if any.
   15.96 -   *
   15.97 -   *  @note may not terminate for infinite-sized collections.
   15.98 -   *  @note Might return different results for different runs, unless this iterable is ordered.
   15.99 -   *  @param p the predicate
  15.100 -   *  @return an option containing the first element in the iterable object
  15.101 -   *  satisfying <code>p</code>, or <code>None</code> if none exists.
  15.102 -   */
  15.103 -  override def find(p: A => Boolean): Option[A] = iterator.find(p)
  15.104 -
  15.105 -  /** Does this iterable contain no elements? 
  15.106 -   */
  15.107 -  override def isEmpty: Boolean = !this.iterator.hasNext
  15.108 -
  15.109 -  /** Combines the elements of this iterable together using the binary
  15.110 -   *  function <code>f</code>, from right to left, and starting with
  15.111 -   *  the value <code>z</code>.
  15.112 -   *
  15.113 -   *  @note Will not terminate for infinite-sized collections.
  15.114 -   *  @note Might return different results for different runs, unless this iterable is ordered, or
  15.115 -   *        the operator is associative and commutative.
  15.116 -   *  @return <code>f(a<sub>0</sub>, f(a<sub>1</sub>, f(..., f(a<sub>n</sub>, z)...)))</code>
  15.117 -   *          if the iterable is <code>[a<sub>0</sub>, a1, ..., a<sub>n</sub>]</code>.
  15.118 -   */
  15.119 -  override def foldRight[B](z: B)(op: (A, B) => B): B =
  15.120 -    this.iterator.foldRight(z)(op)
  15.121 -
  15.122 -  /** Combines the elements of this iterable object together using the binary
  15.123 -   *  operator <code>op</code>, from right to left
  15.124 -   *  @note Will not terminate for infinite-sized collections.
  15.125 -   *  @note Might return different results for different runs, unless this iterable is ordered, or
  15.126 -   *        the operator is associative and commutative.
  15.127 -   *  @param op  The operator to apply
  15.128 -   *
  15.129 -   *  @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
  15.130 -   *          if the iterable object has elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
  15.131 -   *          a<sub>n</sub></code>.
  15.132 -   *
  15.133 -   *  @throws Predef.UnsupportedOperationException if the iterator is empty.
  15.134 -   */
  15.135 -  override def reduceRight[B >: A](op: (A, B) => B): B = 
  15.136 -    this.iterator.reduceRight(op)
  15.137 -
  15.138 -  /** The iterable itself */
  15.139 -  override def toIterable: Iterable[A] = thisCollection
  15.140 - 
  15.141 -  /** The first element of this iterable.
  15.142 -   *
  15.143 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.144 -   *  @throws Predef.NoSuchElementException if the iterable is empty.
  15.145 -   */
  15.146 -  override def head: A =
  15.147 -    if (isEmpty)
  15.148 -      throw new NoSuchElementException
  15.149 -    else
  15.150 -      this.iterator.next
  15.151 -
  15.152 -  /** Return an iterable consisting only of the first <code>n</code>
  15.153 -   *  elements of this iterable, or else the whole iterable, if it has less
  15.154 -   *  than <code>n</code> elements.
  15.155 -   *
  15.156 -   *  @param n the number of elements to take
  15.157 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.158 -   */
  15.159 -  override def take(n: Int): Repr = {
  15.160 -    val b = newBuilder
  15.161 -    var i = 0
  15.162 -    val it = iterator
  15.163 -    while (i < n && it.hasNext) {
  15.164 -      b += it.next
  15.165 -      i += 1
  15.166 -    }
  15.167 -    b.result
  15.168 -  }
  15.169 -  
  15.170 -  /** A sub-iterable starting at index `from`
  15.171 -   *  and extending up to (but not including) index `until`.
  15.172 -   *
  15.173 -   *  @note c.slice(from, to)  is equivalent to (but possibly more efficient than)
  15.174 -   *  c.drop(from).take(to - from)
  15.175 -   *
  15.176 -   *  @param from   The index of the first element of the returned subsequence
  15.177 -   *  @param until  The index of the element following the returned subsequence
  15.178 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.179 -   */
  15.180 -  override def slice(from: Int, until: Int): Repr = {
  15.181 -    val b = newBuilder
  15.182 -    var i = from
  15.183 -    val it = iterator drop from
  15.184 -    while (i < until && it.hasNext) {
  15.185 -      b += it.next
  15.186 -      i += 1
  15.187 -    }
  15.188 -    b.result
  15.189 -  }
  15.190 -
  15.191 -  /** Returns the longest prefix of this iterable whose elements satisfy
  15.192 -   *  the predicate <code>p</code>.
  15.193 -   *
  15.194 -   *  @param p the test predicate.
  15.195 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.196 -   */
  15.197 -  override def takeWhile(p: A => Boolean): Repr = {
  15.198 -    val b = newBuilder
  15.199 -    val it = iterator
  15.200 -    while (it.hasNext) {
  15.201 -      val x = it.next
  15.202 -      if (!p(x)) return b.result
  15.203 -      b += x
  15.204 -    }
  15.205 -    b.result
  15.206 -  }
  15.207 -
  15.208 -  /** Returns the rightmost <code>n</code> elements from this iterable.
  15.209 -   *
  15.210 -   *  @param n the number of elements to take
  15.211 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.212 -   */
  15.213 -  def takeRight(n: Int): Repr = {
  15.214 -    val b = newBuilder
  15.215 -    val lead = this.iterator drop n
  15.216 -    var go = false
  15.217 -    for (x <- this) {
  15.218 -      if (lead.hasNext) lead.next
  15.219 -      else go = true
  15.220 -      if (go) b += x
  15.221 -    }
  15.222 -    b.result
  15.223 -  }
  15.224 -
  15.225 -  /** Returns the iterable wihtout its rightmost <code>n</code> elements.
  15.226 -   *
  15.227 -   *  @param n the number of elements to take
  15.228 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.229 -   */
  15.230 -  def dropRight(n: Int): Repr = {
  15.231 -    val b = newBuilder
  15.232 -    val lead = iterator drop n
  15.233 -    val it = iterator
  15.234 -    while (lead.hasNext) {
  15.235 -      b += it.next
  15.236 -      lead.next
  15.237 -    }
  15.238 -    b.result
  15.239 -  }
  15.240 -
  15.241 -  /** Fills the given array <code>xs</code> with at most `len` elements of
  15.242 -   *  this iterable starting at position `start`.
  15.243 -   *  Copying will stop once either the end of the current iterable is reached or
  15.244 -   *  `len` elements have been copied or the end of the array is reached.
  15.245 -   *
  15.246 -   *  @note Will not terminate for infinite-sized collections.
  15.247 -   *  @param  xs the array to fill.
  15.248 -   *  @param  start starting index.
  15.249 -   *  @param  len number of elements to copy
  15.250 -   */
  15.251 -  override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int) {
  15.252 -    var i = start
  15.253 -    val end = (start + len) min xs.length
  15.254 -    val it = iterator
  15.255 -    while (i < end && it.hasNext) {
  15.256 -      xs(i) = it.next
  15.257 -      i += 1
  15.258 -    }
  15.259 -  }
  15.260 -
  15.261 -  /** Returns an iterable formed from this iterable and another iterable
  15.262 -   *  by combining corresponding elements in pairs.
  15.263 -   *  If one of the two iterables is longer than the other, its remaining elements are ignored.
  15.264 -   *  @param   that  The iterable providing the second half of each result pair
  15.265 -   */
  15.266 -  def zip[A1 >: A, B, That](that: Iterable[B])(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = {
  15.267 -    val b = bf(repr)
  15.268 -    val these = this.iterator
  15.269 -    val those = that.iterator
  15.270 -    while (these.hasNext && those.hasNext)
  15.271 -      b += ((these.next, those.next))
  15.272 -    b.result
  15.273 -  }
  15.274 -
  15.275 -  /** Returns an iterable formed from this iterable and the specified iterable
  15.276 -   *  <code>that</code> by associating each element of the former with
  15.277 -   *  the element at the same position in the latter.
  15.278 -   *
  15.279 -   *  @param that     iterable <code>that</code> may have a different length
  15.280 -   *                  as the self iterable.
  15.281 -   *  @param thisElem element <code>thisElem</code> is used to fill up the
  15.282 -   *                  resulting iterable if the self iterable is shorter than
  15.283 -   *                  <code>that</code>
  15.284 -   *  @param thatElem element <code>thatElem</code> is used to fill up the
  15.285 -   *                  resulting iterable if <code>that</code> is shorter than
  15.286 -   *                  the self iterable
  15.287 -   *  @return         <code>Sequence((a<sub>0</sub>,b<sub>0</sub>), ...,
  15.288 -   *                  (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
  15.289 -   *                  ..., {elem,b<sub>m</sub>})</code>
  15.290 -   *                  when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
  15.291 -   *                  [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
  15.292 -   *                  invoked where <code>m &gt; n</code>.
  15.293 -   *  
  15.294 -   */
  15.295 -  def zipAll[B, A1 >: A, That](that: Iterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[Repr, (A1, B), That]): That = {  
  15.296 -    val b = bf(repr)
  15.297 -    val these = this.iterator
  15.298 -    val those = that.iterator
  15.299 -    while (these.hasNext && those.hasNext)
  15.300 -      b += ((these.next, those.next))
  15.301 -    while (these.hasNext)
  15.302 -      b += ((these.next, thatElem))
  15.303 -    while (those.hasNext)
  15.304 -      b += ((thisElem, those.next))
  15.305 -    b.result
  15.306 -  }
  15.307 -
  15.308 -  /** Zips this iterable with its indices (startiong from 0). 
  15.309 -   */
  15.310 -  def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[Repr, (A1, Int), That]): That = {
  15.311 -    val b = bf(repr)
  15.312 -    var i = 0
  15.313 -    for (x <- this) {
  15.314 -      b += ((x, i))
  15.315 -      i +=1 
  15.316 -    }
  15.317 -    b.result
  15.318 -  }
  15.319 -
  15.320 -  /** Checks if the other iterable object contains the same elements as this one.
  15.321 -   *
  15.322 -   *  @note will not terminate for infinite-sized iterables.
  15.323 -   *  @param that  the other iterable
  15.324 -   *  @return true, iff both iterables contain the same elements in the same order.
  15.325 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.326 -   */
  15.327 -  def sameElements[B >: A](that: Iterable[B]): Boolean = {
  15.328 -    val these = this.iterator
  15.329 -    val those = that.iterator
  15.330 -    while (these.hasNext && those.hasNext)
  15.331 -      if (these.next != those.next)
  15.332 -        return false
  15.333 -
  15.334 -    !these.hasNext && !those.hasNext
  15.335 -  }                                                                                         
  15.336 -
  15.337 -  /** Returns a stream with all elements in this iterable object.
  15.338 -   */
  15.339 -  override def toStream: Stream[A] = iterator.toStream
  15.340 -
  15.341 -  /** Method called from equality methods, so that user-defined subclasses can 
  15.342 -   *  refuse to be equal to other collections of the same kind.
  15.343 -   */
  15.344 -  override def canEqual(that: Any) = true
  15.345 -
  15.346 -  /** Creates a view of this iterable @see IterableView
  15.347 -   */
  15.348 -  override def view = new IterableView[A, Repr] {
  15.349 -    protected lazy val underlying = self.repr
  15.350 -    override def iterator = self.iterator
  15.351 -  }
  15.352 -
  15.353 -  /** A sub-iterable view  starting at index `from`
  15.354 -   *  and extending up to (but not including) index `until`.
  15.355 -   *
  15.356 -   *  @param from   The index of the first element of the slice
  15.357 -   *  @param until  The index of the element following the slice
  15.358 -   *  @note  The difference between `view` and `slice` is that `view` produces
  15.359 -   *         a view of the current iterable, whereas `slice` produces a new iterable.
  15.360 -   *
  15.361 -   *  @note  Might return different results for different runs, unless this iterable is ordered
  15.362 -   *  @note view(from, to)  is equivalent to view.slice(from, to)
  15.363 -   */
  15.364 -  override def view(from: Int, until: Int) = view.slice(from, until)
  15.365 -  
  15.366 -  @deprecated("use `head' instead") def first: A = head
  15.367 -
  15.368 -  /** <code>None</code> if iterable is empty. */
  15.369 -  @deprecated("use `headOption' instead") def firstOption: Option[A] = headOption
  15.370 -
  15.371 -  /** 
  15.372 -   * returns a projection that can be used to call non-strict <code>filter</code>,
  15.373 -   * <code>map</code>, and <code>flatMap</code> methods that build projections
  15.374 -   * of the collection.
  15.375 -   */
  15.376 -  @deprecated("use `view' instead")
  15.377 -  def projection = view
  15.378 -}
    16.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IterableProxy.scala	Tue Nov 03 13:08:38 2009 +0800
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,25 +0,0 @@
    16.4 -/*                     __                                               *\
    16.5 -**     ________ ___   / /  ___     Scala API                            **
    16.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    16.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    16.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    16.9 -**                          |/                                          **
   16.10 -\*                                                                      */
   16.11 -
   16.12 -// $Id: IterableProxy.scala 18799 2009-09-26 15:19:40Z stepancheg $
   16.13 -
   16.14 -
   16.15 -package org.aiotrade.lib.collection
   16.16 -
   16.17 -import generic._
   16.18 -
   16.19 -/** <p>
   16.20 - *    This trait implements a proxy for iterable objects. It forwards
   16.21 - *    all calls to a different iterable object.
   16.22 - *  </p>
   16.23 - *
   16.24 - *  @author  Martin Odersky
   16.25 - *  @version 2.8
   16.26 - *  @since   2.8
   16.27 - */
   16.28 -trait IterableProxy[+A] extends Iterable[A] with IterableProxyLike[A, Iterable[A]] 
    17.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IterableProxyLike.scala	Tue Nov 03 13:08:38 2009 +0800
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,47 +0,0 @@
    17.4 -/*                     __                                               *\
    17.5 -**     ________ ___   / /  ___     Scala API                            **
    17.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    17.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    17.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    17.9 -**                          |/                                          **
   17.10 -\*                                                                      */
   17.11 -
   17.12 -// $Id: IterableProxyLike.scala 19190 2009-10-21 13:24:41Z moors $
   17.13 -
   17.14 -
   17.15 -package org.aiotrade.lib.collection
   17.16 -
   17.17 -import generic._
   17.18 -import mutable.Buffer
   17.19 -
   17.20 -// Methods could be printed by  cat IterableLike.scala | egrep '^  (override )?def'
   17.21 -
   17.22 -
   17.23 -/** This trait implements a proxy for iterable objects. It forwards
   17.24 - *  all calls to a different iterable object
   17.25 - *
   17.26 - *  @author  Martin Odersky
   17.27 - *  @version 2.8
   17.28 - *  @since   2.8
   17.29 - */
   17.30 -trait IterableProxyLike[+A, +This <: IterableLike[A, This] with Iterable[A]]
   17.31 -    extends IterableLike[A, This]
   17.32 -    with TraversableProxyLike[A, This]
   17.33 -{   
   17.34 -  override def iterator: Iterator[A] = self.iterator
   17.35 -  override def foreach[U](f: A => U): Unit = self.foreach(f)
   17.36 -  override def isEmpty: Boolean = self.isEmpty
   17.37 -  override def foldRight[B](z: B)(op: (A, B) => B): B = self.foldRight(z)(op)
   17.38 -  override def reduceRight[B >: A](op: (A, B) => B): B = self.reduceRight(op)
   17.39 -  override def toIterable: Iterable[A] = self.toIterable
   17.40 -  override def zip[A1 >: A, B, That](that: Iterable[B])(implicit bf: CanBuildFrom[This, (A1, B), That]): That = self.zip[A1, B, That](that)(bf)
   17.41 -  override def zipAll[B, A1 >: A, That](that: Iterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[This, (A1, B), That]): That = self.zipAll(that, thisElem, thatElem)(bf)
   17.42 -  override def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[This, (A1, Int), That]): That = self.zipWithIndex(bf)
   17.43 -  override def head: A = self.head
   17.44 -  override def takeRight(n: Int): This = self.takeRight(n)
   17.45 -  override def dropRight(n: Int): This = self.dropRight(n)
   17.46 -  override def sameElements[B >: A](that: Iterable[B]): Boolean = self.sameElements(that)
   17.47 -  override def toStream: Stream[A] = self.toStream
   17.48 -  override def view = self.view
   17.49 -  override def view(from: Int, until: Int) = self.view(from, until)
   17.50 -}
    18.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IterableView.scala	Tue Nov 03 13:08:38 2009 +0800
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,32 +0,0 @@
    18.4 -/*                     __                                               *\
    18.5 -**     ________ ___   / /  ___     Scala API                            **
    18.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    18.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    18.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    18.9 -**                          |/                                          **
   18.10 -\*                                                                      */
   18.11 -
   18.12 -// $Id: IterableView.scala 19190 2009-10-21 13:24:41Z moors $
   18.13 -
   18.14 -
   18.15 -package org.aiotrade.lib.collection
   18.16 -
   18.17 -import generic._
   18.18 -import TraversableView.NoBuilder
   18.19 -
   18.20 -/** A base class for views of Iterables.
   18.21 - *
   18.22 - *  @author Martin Odersky
   18.23 - *  @version 2.8
   18.24 - *  @since   2.8
   18.25 - */
   18.26 -trait IterableView[+A, +Coll] extends IterableViewLike[A, Coll, IterableView[A, Coll]]
   18.27 -
   18.28 -object IterableView {
   18.29 -  type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
   18.30 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, IterableView[A, Iterable[_]]] = 
   18.31 -    new CanBuildFrom[Coll, A, IterableView[A, Iterable[_]]] { 
   18.32 -      def apply(from: Coll) = new NoBuilder 
   18.33 -      def apply() = new NoBuilder 
   18.34 -    }
   18.35 -}
    19.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/IterableViewLike.scala	Tue Nov 03 13:08:38 2009 +0800
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,108 +0,0 @@
    19.4 -/*                     __                                               *\
    19.5 -**     ________ ___   / /  ___     Scala API                            **
    19.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    19.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    19.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    19.9 -**                          |/                                          **
   19.10 -\*                                                                      */
   19.11 -
   19.12 -// $Id: IterableViewLike.scala 19334 2009-10-28 23:04:03Z odersky $
   19.13 -
   19.14 -
   19.15 -package org.aiotrade.lib.collection
   19.16 -
   19.17 -import generic._
   19.18 -import collection.immutable.Stream
   19.19 -import TraversableView.NoBuilder
   19.20 -
   19.21 -/** A template trait for a non-strict view of an iterable.
   19.22 - *
   19.23 - *  @author Martin Odersky
   19.24 - *  @version 2.8
   19.25 - *  @since   2.8
   19.26 - */
   19.27 -trait IterableViewLike[+A, 
   19.28 -                       +Coll,
   19.29 -                       +This <: IterableView[A, Coll] with IterableViewLike[A, Coll, This]] 
   19.30 -extends Iterable[A] with IterableLike[A, This] with TraversableView[A, Coll] with TraversableViewLike[A, Coll, This]  
   19.31 -{ self =>
   19.32 -
   19.33 -  trait Transformed[+B] extends IterableView[B, Coll] with super.Transformed[B] 
   19.34 -
   19.35 -  trait Sliced extends Transformed[A] with super.Sliced {
   19.36 -    override def iterator = self.iterator slice (from, until)
   19.37 -  }
   19.38 -
   19.39 -  trait Mapped[B] extends Transformed[B] with super.Mapped[B] {
   19.40 -    override def iterator = self.iterator map mapping
   19.41 -  }
   19.42 -
   19.43 -  trait FlatMapped[B] extends Transformed[B] with super.FlatMapped[B] {
   19.44 -    override def iterator = self.iterator flatMap (mapping(_).toIterable.iterator)
   19.45 -  }
   19.46 -    
   19.47 -  trait Appended[B >: A] extends Transformed[B] with super.Appended[B] {
   19.48 -    override def iterator = self.iterator ++ rest.toIterable.iterator
   19.49 -  }
   19.50 -
   19.51 -  trait Filtered extends Transformed[A] with super.Filtered {
   19.52 -    override def iterator = self.iterator filter pred
   19.53 -  }
   19.54 -    
   19.55 -  trait TakenWhile extends Transformed[A] with super.TakenWhile {
   19.56 -    override def iterator = self.iterator takeWhile pred
   19.57 -  }
   19.58 -
   19.59 -  trait DroppedWhile extends Transformed[A] with super.DroppedWhile {
   19.60 -    override def iterator = self.iterator dropWhile pred
   19.61 -  }
   19.62 -
   19.63 -  trait Zipped[B] extends Transformed[(A, B)] {
   19.64 -    protected[this] val other: Iterable[B]
   19.65 -    override def iterator: Iterator[(A, B)] = self.iterator zip other.iterator
   19.66 -    override def stringPrefix = self.stringPrefix+"Z"
   19.67 -  }
   19.68 -  
   19.69 -  trait ZippedAll[A1 >: A, B] extends Transformed[(A1, B)] {
   19.70 -    protected[this] val other: Iterable[B]
   19.71 -    protected[this] val thisElem: A1
   19.72 -    protected[this] val thatElem: B
   19.73 -    override def iterator: Iterator[(A1, B)] = 
   19.74 -      self.iterator.zipAll(other.iterator, thisElem, thatElem)
   19.75 -  }
   19.76 -  
   19.77 -  override def zip[A1 >: A, B, That](that: Iterable[B])(implicit bf: CanBuildFrom[This, (A1, B), That]): That = {
   19.78 -    newZipped(that).asInstanceOf[That]
   19.79 -// was:    val b = bf(repr)
   19.80 -//    if (b.isInstanceOf[NoBuilder[_]]) newZipped(that).asInstanceOf[That]
   19.81 -//    else super.zip[A1, B, That](that)(bf)    
   19.82 -  }
   19.83 -
   19.84 -  override def zipWithIndex[A1 >: A, That](implicit bf: CanBuildFrom[This, (A1, Int), That]): That =
   19.85 -    zip[A1, Int, That](Stream from 0)(bf)
   19.86 -
   19.87 -  override def zipAll[B, A1 >: A, That](that: Iterable[B], thisElem: A1, thatElem: B)(implicit bf: CanBuildFrom[This, (A1, B), That]): That =
   19.88 -    newZippedAll(that, thisElem, thatElem).asInstanceOf[That]
   19.89 -
   19.90 -  protected def newZipped[B](that: Iterable[B]): Transformed[(A, B)] = new Zipped[B] {
   19.91 -    val other = that
   19.92 -  }
   19.93 -  protected def newZippedAll[A1 >: A, B](that: Iterable[B], _thisElem: A1, _thatElem: B): Transformed[(A1, B)] = new ZippedAll[A1, B] {
   19.94 -    val other: Iterable[B] = that
   19.95 -    val thisElem = _thisElem
   19.96 -    val thatElem = _thatElem
   19.97 -  }
   19.98 -   
   19.99 -  /** Boilerplate method, to override in each subclass
  19.100 -   *  This method could be eliminated if Scala had virtual classes
  19.101 -   */
  19.102 -  protected override def newAppended[B >: A](that: Traversable[B]): Transformed[B] = new Appended[B] { val rest = that }
  19.103 -  protected override def newMapped[B](f: A => B): Transformed[B] = new Mapped[B] { val mapping = f }
  19.104 -  protected override def newFlatMapped[B](f: A => Traversable[B]): Transformed[B] = new FlatMapped[B] { val mapping = f }
  19.105 -  protected override def newFiltered(p: A => Boolean): Transformed[A] = new Filtered { val pred = p }
  19.106 -  protected override def newSliced(_from: Int, _until: Int): Transformed[A] = new Sliced { val from = _from; val until = _until }
  19.107 -  protected override def newDroppedWhile(p: A => Boolean): Transformed[A] = new DroppedWhile { val pred = p }
  19.108 -  protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new TakenWhile { val pred = p }
  19.109 -
  19.110 -  override def stringPrefix = "IterableView"
  19.111 -}
    20.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/Iterator.scala	Tue Nov 03 13:08:38 2009 +0800
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,1145 +0,0 @@
    20.4 -/*                     __                                               *\
    20.5 -**     ________ ___   / /  ___     Scala API                            **
    20.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    20.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    20.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    20.9 -**                          |/                                          **
   20.10 -\*                                                                      */
   20.11 -
   20.12 -// $Id: Iterator.scala 19334 2009-10-28 23:04:03Z odersky $
   20.13 -
   20.14 -
   20.15 -package org.aiotrade.lib.collection
   20.16 -
   20.17 -import mutable.{Buffer, ArrayBuffer, ListBuffer, StringBuilder}
   20.18 -import immutable.{List, Stream}
   20.19 -import annotation.{ tailrec, experimental }
   20.20 -// import immutable.{List, Nil, ::, Stream}
   20.21 -
   20.22 -/** The <code>Iterator</code> object provides various functions for
   20.23 - *  creating specialized iterators.
   20.24 - *
   20.25 - *  @author  Martin Odersky
   20.26 - *  @author  Matthias Zenger
   20.27 - *  @version 2.8
   20.28 - *  @since   2.8
   20.29 - */
   20.30 -object Iterator {
   20.31 -
   20.32 -  val empty = new Iterator[Nothing] {
   20.33 -    def hasNext: Boolean = false
   20.34 -    def next(): Nothing = throw new NoSuchElementException("next on empty iterator")
   20.35 -  }
   20.36 -
   20.37 -  /** An iterator with a single element.
   20.38 -   *  @param elem the element
   20.39 -   *  @note  Equivalent, but more efficient than Iterator(elem)
   20.40 -   */
   20.41 -  def single[A](elem: A) = new Iterator[A] {
   20.42 -    private var hasnext = true
   20.43 -    def hasNext: Boolean = hasnext
   20.44 -    def next(): A =
   20.45 -      if (hasnext) { hasnext = false; elem }
   20.46 -      else empty.next()
   20.47 -  }
   20.48 -
   20.49 -  /** Creates an iterator with given elements
   20.50 -   *  @param elems  The elements returned one-by-one from the iterator
   20.51 -   */
   20.52 -  def apply[A](elems: A*): Iterator[A] = elems.iterator
   20.53 -
   20.54 -  /** Concatenates the given argument iterators into a single iterator.
   20.55 -   *
   20.56 -   *  @param its the argument iterators that are to be concatenated
   20.57 -   *  @return the concatenation of all the argument iterators
   20.58 -   */
   20.59 -  @deprecated("use <code>++</code>")
   20.60 -  def concat[A](xss: Iterator[A]*): Iterator[A] = xss.iterator.flatten
   20.61 -
   20.62 -  /** An iterator that returns the results of some element computation a number of times.
   20.63 -   *  @param   len  The number of elements returned
   20.64 -   *  @param   elem The element computation determinining each result
   20.65 -   */
   20.66 -  def fill[A](len: Int)(elem: => A) = new Iterator[A] {
   20.67 -    private var i = 0
   20.68 -    def hasNext: Boolean = i < len
   20.69 -    def next(): A =
   20.70 -      if (hasNext) { i += 1; elem }
   20.71 -      else empty.next()
   20.72 -  }
   20.73 -
   20.74 -  /** An iterator that returns values of a given function over a range of
   20.75 -   *  integer values starting from 0.
   20.76 -   *
   20.77 -   *  @param end   The argument up to which values are tabulated.
   20.78 -   *  @param f     The function computing the results
   20.79 -   *  @return  An iterator with values `f(0) ... f(end-1)` 
   20.80 -   */ 
   20.81 -  def tabulate[A](end: Int)(f: Int => A) = new Iterator[A] {
   20.82 -    private var i = 0
   20.83 -    def hasNext: Boolean = i < end
   20.84 -    def next(): A =
   20.85 -      if (hasNext) { val result = f(i); i += 1; result }
   20.86 -      else empty.next()
   20.87 -  }    
   20.88 -
   20.89 -  /** An iterator returning successive values in some integer interval.
   20.90 -   *  
   20.91 -   *  @param start the start value of the iterator
   20.92 -   *  @param end   the end value of the iterator (the first value NOT returned)
   20.93 -   *  @return      the iterator with values in range `start, start + 1, ..., end - 1`
   20.94 -   */
   20.95 -  def range(start: Int, end: Int): Iterator[Int] = range(start, end, 1)
   20.96 -
   20.97 -  /** An iterator returning equally spaced values in some integer interval.
   20.98 -   *
   20.99 -   *  @param start the start value of the iterator
  20.100 -   *  @param end   the end value of the iterator (the first value NOT returned)
  20.101 -   *  @param step  the increment value of the iterator (must be positive or negative)
  20.102 -   *  @return      the iterator with values in `start, start + step, ...` up to, but excluding `end`
  20.103 -   */
  20.104 -  def range(start: Int, end: Int, step: Int) = new Iterator[Int] {
  20.105 -    if (step == 0) throw new IllegalArgumentException("zero step")
  20.106 -    private var i = start
  20.107 -    def hasNext: Boolean = (step <= 0 || i < end) && (step >= 0 || i > end)
  20.108 -    def next(): Int =
  20.109 -      if (hasNext) { val result = i; i += step; result }
  20.110 -      else empty.next()
  20.111 -  }
  20.112 -
  20.113 -  /** An infinite iterator that repeatedly applies a given function to the previous result.
  20.114 -   *
  20.115 -   *  @param start the start value of the iterator
  20.116 -   *  @param f     the function that's repeatedly applied
  20.117 -   *  @return      the iterator returning the infinite sequence of values `start, f(start), f(f(start)), ...`
  20.118 -   */
  20.119 -  def iterate[T](start: T)(f: T => T): Iterator[T] = new Iterator[T] {
  20.120 -    private[this] var acc = start
  20.121 -    def hasNext: Boolean = true
  20.122 -    def next(): T = { val res = acc ; acc = f(acc) ; res }
  20.123 -  }
  20.124 -
  20.125 -  /** An infinite-length iterator which returns successive values from some start value.
  20.126 -
  20.127 -   *  @param start the start value of the iterator
  20.128 -   *  @return      the iterator returning the infinite sequence of values `start, start + 1, start + 2, ...`
  20.129 -   */
  20.130 -  def from(start: Int): Iterator[Int] = from(start, 1)
  20.131 -
  20.132 -  /** An infinite-length iterator returning values equally spaced apart.
  20.133 -   *
  20.134 -   *  @param start the start value of the iterator
  20.135 -   *  @param step  the increment between successive values
  20.136 -   *  @return      the iterator returning the infinite sequence of values `start, start + 1 * step, start + 2 * step, ...`
  20.137 -   */
  20.138 -  def from(start: Int, step: Int): Iterator[Int] = new Iterator[Int] {
  20.139 -    private var i = start
  20.140 -    def hasNext: Boolean = true
  20.141 -    def next(): Int = { val result = i; i += step; result }
  20.142 -  }
  20.143 -
  20.144 -  /** Create an infinite iterator based on the given expression
  20.145 -   *  (which is recomputed for every element)
  20.146 -   *
  20.147 -   *  @param elem the element composing the resulting iterator
  20.148 -   *  @return the iterator containing an infinite number of elem
  20.149 -   */
  20.150 -  def continually[A](elem: => A): Iterator[A] = new Iterator[A] {
  20.151 -    def hasNext = true
  20.152 -    def next = elem
  20.153 -  }
  20.154 -
  20.155 -  /** A wrapper class for the <code>flatten</code> method that is added to
  20.156 -   *  class <code>Iterator</code> with implicit conversion
  20.157 -   *  @see iteratorIteratorWrapper.
  20.158 -   */
  20.159 -  class IteratorIteratorOps[A](its: Iterator[Iterator[A]]) {
  20.160 -    /** If `its` is an iterator of iterators, `its.flatten` gives the iterator
  20.161 -     *  that is the concatenation of all iterators in `its`.
  20.162 -     */
  20.163 -    def flatten: Iterator[A] = new Iterator[A] {
  20.164 -      private var it: Iterator[A] = empty
  20.165 -      def hasNext: Boolean = it.hasNext || its.hasNext && { it = its.next(); hasNext }
  20.166 -      def next(): A = if (hasNext) it.next() else empty.next()
  20.167 -    }
  20.168 -  }
  20.169 -
  20.170 -  /** An implicit conversion which adds the `flatten` method to class `Iterator` */
  20.171 -  implicit def iteratorIteratorWrapper[A](its: Iterator[Iterator[A]]): IteratorIteratorOps[A] = 
  20.172 -    new IteratorIteratorOps[A](its)
  20.173 -
  20.174 -  @deprecated("use `xs.iterator' or `Iterator(xs)' instead")
  20.175 -  def fromValues[a](xs: a*) = xs.iterator
  20.176 -
  20.177 -  /**
  20.178 -   *  @param xs the array of elements
  20.179 -   *  @see also: IndexedSeq.iterator and slice
  20.180 -   */
  20.181 -  @deprecated("use `xs.iterator' instead")
  20.182 -  def fromArray[a](xs: Array[a]): Iterator[a] =
  20.183 -    fromArray(xs, 0, xs.length)
  20.184 -
  20.185 -  /**
  20.186 -   *  @param xs     the array of elements
  20.187 -   *  @param start  the start index
  20.188 -   *  @param length  the length
  20.189 -   *  @see also: IndexedSeq.iterator and slice
  20.190 -   */
  20.191 -  @deprecated("use `xs.slice(start, start + length).iterator' instead")
  20.192 -  def fromArray[a](xs: Array[a], start: Int, length: Int): Iterator[a] =
  20.193 -    xs.slice(start, start + length).iterator
  20.194 -
  20.195 -  /**
  20.196 -   *  @param str the given string
  20.197 -   *  @return    the iterator on <code>str</code>
  20.198 -   */
  20.199 -  @deprecated("replaced by <code>str.iterator</code>")
  20.200 -  def fromString(str: String): Iterator[Char] = str.iterator
  20.201 -
  20.202 -  /**
  20.203 -   *  @param n the product arity
  20.204 -   *  @return  the iterator on <code>Product&lt;n&gt;</code>.
  20.205 -   */
  20.206 -  @deprecated("use product.productIterator instead")
  20.207 -  def fromProduct(n: Product): Iterator[Any] = new Iterator[Any] {
  20.208 -    private var c: Int = 0
  20.209 -    private val cmax = n.productArity
  20.210 -    def hasNext = c < cmax
  20.211 -    def next() = { val a = n productElement c; c += 1; a }
  20.212 -  }
  20.213 -
  20.214 -  /** Create an iterator with elements
  20.215 -   *  <code>e<sub>n+1</sub> = step(e<sub>n</sub>)</code>
  20.216 -   *  where <code>e<sub>0</sub> = start</code>
  20.217 -   *  and elements are in the range between <code>start</code> (inclusive)
  20.218 -   *  and <code>end</code> (exclusive)
  20.219 -   *
  20.220 -   *  @param start the start value of the iterator
  20.221 -   *  @param end   the end value of the iterator
  20.222 -   *  @param step  the increment function of the iterator, must be monotonically increasing or decreasing
  20.223 -   *  @return      the iterator with values in range <code>[start;end)</code>.
  20.224 -   */
  20.225 -  @deprecated("use Iterator.iterate(start, end - start)(step) instead")
  20.226 -  def range(start: Int, end: Int, step: Int => Int) = new Iterator[Int] {
  20.227 -    private val up = step(start) > start
  20.228 -    private val down = step(start) < start
  20.229 -    private var i = start
  20.230 -    def hasNext: Boolean = (!up || i < end) && (!down || i > end)
  20.231 -    def next(): Int =
  20.232 -      if (hasNext) { val j = i; i = step(i); j }
  20.233 -      else empty.next()
  20.234 -  }
  20.235 -
  20.236 -  /** Create an iterator with elements
  20.237 -   *  <code>e<sub>n+1</sub> = step(e<sub>n</sub>)</code>
  20.238 -   *  where <code>e<sub>0</sub> = start</code>.
  20.239 -   *
  20.240 -   *  @param start the start value of the iterator
  20.241 -   *  @param step  the increment function of the iterator
  20.242 -   *  @return      the iterator starting at value <code>start</code>.
  20.243 -   */
  20.244 -  @deprecated("use iterate(start)(step) instead")
  20.245 -  def from(start: Int, step: Int => Int): Iterator[Int] = new Iterator[Int] {
  20.246 -    private var i = start
  20.247 -    override def hasNext: Boolean = true
  20.248 -    def next(): Int = { val j = i; i = step(i); j }
  20.249 -  }
  20.250 -
  20.251 -  /** Create an iterator that is the concantenation of all iterators
  20.252 -   *  returned by a given iterator of iterators.
  20.253 -   *   @param its   The iterator which returns on each call to next
  20.254 -   *                a new iterator whose elements are to be concatenated to the result.
  20.255 -   */
  20.256 -  @deprecated("use its.flatten instead")
  20.257 -  def flatten[T](its: Iterator[Iterator[T]]): Iterator[T] = new Iterator[T] {
  20.258 -    private var cur = its.next
  20.259 -    def hasNext: Boolean = {
  20.260 -      while (!cur.hasNext && its.hasNext) cur = its.next
  20.261 -      cur.hasNext
  20.262 -    }
  20.263 -    def next(): T = 
  20.264 -      (if (hasNext) cur else empty).next()
  20.265 -  }
  20.266 -}
  20.267 -
  20.268 -import Iterator.empty
  20.269 -
  20.270 -/** Iterators are data structures that allow to iterate over a sequence
  20.271 - *  of elements. They have a <code>hasNext</code> method for checking
  20.272 - *  if there is a next element available, and a <code>next</code> method
  20.273 - *  which returns the next element and discards it from the iterator.
  20.274 - *
  20.275 - *  @author  Martin Odersky, Matthias Zenger
  20.276 - *  @version 2.8
  20.277 - *  @since   2.8
  20.278 - */
  20.279 -trait Iterator[+A] { self =>
  20.280 -
  20.281 -  /** Does this iterator provide another element?
  20.282 -   */
  20.283 -  def hasNext: Boolean
  20.284 -
  20.285 -  /** Returns the next element of this iterator.
  20.286 -   */
  20.287 -  def next(): A
  20.288 -  
  20.289 -  /** Returns a new iterator that iterates only over the first <code>n</code>
  20.290 -   *  elements of this iterator, or the length of the iterator, whichever is smaller.
  20.291 -   *
  20.292 -   *  @param n the number of elements to take
  20.293 -   *  @return  the new iterator
  20.294 -   */
  20.295 -  def take(n: Int): Iterator[A] = new Iterator[A] {
  20.296 -    private var remaining = n
  20.297 -    def hasNext = remaining > 0 && self.hasNext
  20.298 -    def next(): A =
  20.299 -      if (hasNext) { remaining -= 1; self.next }
  20.300 -      else empty.next()
  20.301 -  }
  20.302 -
  20.303 -  /** Advances this iterator past the first <code>n</code> elements,
  20.304 -   *  or the length of the iterator, whichever is smaller.
  20.305 -   *
  20.306 -   *  @param n the number of elements to drop
  20.307 -   *  @return  the new iterator
  20.308 -   */
  20.309 -  def drop(n: Int): Iterator[A] = {
  20.310 -    @tailrec
  20.311 -    def loop(left: Int): Iterator[A] =
  20.312 -      if (left > 0 && hasNext) { next; loop(left - 1) }
  20.313 -      else this
  20.314 -    
  20.315 -    loop(n)
  20.316 -  }
  20.317 -
  20.318 -  /** Advances this iterator past the first `from` elements using `drop`,
  20.319 -   *  and then takes `until - from` elements, using `take`.
  20.320 -   *
  20.321 -   *  @param from   The index of the first element of the slice
  20.322 -   *  @param until    The index of the element following the slice
  20.323 -   */
  20.324 -  def slice(from: Int, until: Int): Iterator[A] = drop(from).take(until - from)
  20.325 -
  20.326 -  /** Returns a new iterator that maps all elements of this iterator
  20.327 -   *  to new elements using function <code>f</code>.
  20.328 -   */
  20.329 -  def map[B](f: A => B): Iterator[B] = new Iterator[B] {
  20.330 -    def hasNext = self.hasNext
  20.331 -    def next() = f(self.next())
  20.332 -  }
  20.333 -
  20.334 -  /** Returns a new iterator that first yields the elements of this
  20.335 -   *  iterator followed by the elements provided by iterator <code>that</code>.
  20.336 -   */
  20.337 -  def ++[B >: A](that: => Iterator[B]) = new Iterator[B] {
  20.338 -    // optimize a little bit to prevent n log n behavior.
  20.339 -    var cur : Iterator[B] = self 
  20.340 -    def hasNext = cur.hasNext || (cur eq self) && { cur = that; hasNext }
  20.341 -    def next() = { hasNext; cur.next() }
  20.342 -  }
  20.343 -
  20.344 -  /** Applies the given function <code>f</code> to each element of
  20.345 -   *  this iterator, then concatenates the results.
  20.346 -   *
  20.347 -   *  @param f the function to apply on each element.
  20.348 -   *  @return  an iterator over <code>f(a<sub>0</sub>), ... ,
  20.349 -   *           f(a<sub>n</sub>)</code> if this iterator yields the
  20.350 -   *           elements <code>a<sub>0</sub>, ..., a<sub>n</sub></code>.
  20.351 -   */
  20.352 -  def flatMap[B](f: A => Iterator[B]): Iterator[B] = new Iterator[B] {
  20.353 -    private var cur: Iterator[B] = empty
  20.354 -    def hasNext: Boolean = 
  20.355 -      cur.hasNext || self.hasNext && { cur = f(self.next); hasNext }
  20.356 -    def next(): B = (if (hasNext) cur else empty).next() 
  20.357 -  }
  20.358 -
  20.359 -  /** Returns an iterator over all the elements of this iterator that
  20.360 -   *  satisfy the predicate <code>p</code>. The order of the elements
  20.361 -   *  is preserved.
  20.362 -   *
  20.363 -   *  @param p the predicate used to filter the iterator.
  20.364 -   *  @return  the elements of this iterator satisfying <code>p</code>.
  20.365 -   */
  20.366 -  def filter(p: A => Boolean): Iterator[A] = {
  20.367 -    val self = buffered
  20.368 -    new Iterator[A] {
  20.369 -      private def skip() = while (self.hasNext && !p(self.head)) self.next()
  20.370 -      def hasNext = { skip(); self.hasNext }
  20.371 -      def next() = { skip(); self.next() }
  20.372 -    }
  20.373 -  }
  20.374 -  
  20.375 -  /** !!! Temporary, awaiting more general implementation.
  20.376 -   *  ... better wait longer, this fails once flatMap gets in the mix.
  20.377 -   */
  20.378 -  // def withFilter(p: A => Boolean) = this.toStream withFilter p
  20.379 -  
  20.380 -  /** Returns an iterator over all the elements of this iterator which
  20.381 -   *  do not satisfy the predicate <code>p</code>.
  20.382 -   *
  20.383 -   *  @param p the predicate used to filter.
  20.384 -   *  @return  the elements of this iterator not satisfying <code>p</code>.
  20.385 -   */
  20.386 -  
  20.387 -  def filterNot(p: A => Boolean): Iterator[A] = filter(!p(_))
  20.388 -  
  20.389 - /** Returns a new iterator based on the partial function <code>pf</code>,  
  20.390 -  *  containing <code>pf(x)</code> for all the elements which are defined on pf.
  20.391 -  *  The order of the elements is preserved.
  20.392 -  *
  20.393 -  *  @param pf the partial function which filters and maps the iterator.
  20.394 -  *  @return the new iterator.
  20.395 -  */
  20.396 -  @experimental
  20.397 -  def filterMap[B](pf: PartialFunction[Any, B]): Iterator[B] = {
  20.398 -    val self = buffered
  20.399 -    new Iterator[B] {
  20.400 -      private def skip() = while (self.hasNext && !pf.isDefinedAt(self.head)) self.next()
  20.401 -      def hasNext = { skip(); self.hasNext }
  20.402 -      def next() = { skip(); pf(self.next()) }
  20.403 -    }
  20.404 -  }
  20.405 -
  20.406 -  /** Returns an iterator over the longest prefix of this iterator such that
  20.407 -   *  all elements of the result satisfy the predicate <code>p</code>. 
  20.408 -   *  The order of the elements is preserved.
  20.409 -   *
  20.410 -   *  @param p the predicate used to filter the iterator.
  20.411 -   *  @return  the longest prefix of this iterator satisfying <code>p</code>.
  20.412 -   */
  20.413 -  def takeWhile(p: A => Boolean): Iterator[A] = {
  20.414 -    val self = buffered
  20.415 -    new Iterator[A] {
  20.416 -      def hasNext = { self.hasNext && p(self.head) }
  20.417 -      def next() = (if (hasNext) self else empty).next()
  20.418 -    }
  20.419 -  }
  20.420 -
  20.421 -  /** Partitions this iterator in two iterators according to a predicate.
  20.422 -   *
  20.423 -   *  @param p the predicate on which to partition
  20.424 -   *  @return  a pair of iterators: the iterator that satisfies the predicate
  20.425 -   *           <code>p</code> and the iterator that does not.
  20.426 -   *           The relative order of the elements in the resulting iterators
  20.427 -   *           is the same as in the original iterator.
  20.428 -   */
  20.429 -  def partition(p: A => Boolean): (Iterator[A], Iterator[A]) = {
  20.430 -    val self = buffered
  20.431 -    class PartitionIterator(p: A => Boolean) extends Iterator[A] {
  20.432 -      var other: PartitionIterator = _
  20.433 -      val lookahead = new scala.collection.mutable.Queue[A]
  20.434 -      def skip() = 
  20.435 -        while (self.hasNext && !p(self.head)) {
  20.436 -          other.lookahead += self.next
  20.437 -        }
  20.438 -      def hasNext = !lookahead.isEmpty || { skip(); self.hasNext }
  20.439 -      def next() = if (!lookahead.isEmpty) lookahead.dequeue() 
  20.440 -                   else { skip(); self.next() }
  20.441 -    }
  20.442 -    val l = new PartitionIterator(p)
  20.443 -    val r = new PartitionIterator(!p(_))
  20.444 -    l.other = r
  20.445 -    r.other = l
  20.446 -    (l, r)
  20.447 -  }
  20.448 -
  20.449 -  /** Skips longest sequence of elements of this iterator which satisfy given 
  20.450 -   *  predicate <code>p</code>, and returns an iterator of the remaining elements.
  20.451 -   *
  20.452 -   *  @param p the predicate used to skip elements.
  20.453 -   *  @return  an iterator consisting of the remaining elements
  20.454 -   */
  20.455 -  def dropWhile(p: A => Boolean): Iterator[A] = {
  20.456 -    val self = buffered
  20.457 -    new Iterator[A] {
  20.458 -      var dropped = false
  20.459 -      private def skip() =
  20.460 -        if (!dropped) {
  20.461 -          while (self.hasNext && p(self.head)) self.next()
  20.462 -          dropped = true
  20.463 -        }
  20.464 -      def hasNext = { skip(); self.hasNext }
  20.465 -      def next() = { skip(); self.next() }
  20.466 -    }
  20.467 -  }
  20.468 -
  20.469 -  /** Return an iterator formed from this iterator and the specified iterator
  20.470 -   *  <code>that</code> by associating each element of the former with
  20.471 -   *  the element at the same position in the latter.
  20.472 -   *  If one of the two iterators is longer than the other, its remaining
  20.473 -   *  elements are ignored.
  20.474 -   */	
  20.475 -  def zip[B](that: Iterator[B]) = new Iterator[(A, B)] {
  20.476 -    def hasNext = self.hasNext && that.hasNext
  20.477 -    def next = (self.next, that.next)
  20.478 -  }
  20.479 -
  20.480 -  /** Return a new iterator with a length equal or longer to <code>len</code>.
  20.481 -   *  If the current iterator returns fewer than `len` elements
  20.482 -   *  return `elem` until the required length `len` is reached. 
  20.483 -   */
  20.484 -  def padTo[A1 >: A](len: Int, elem: A1) = new Iterator[A1] {
  20.485 -    private var count = 0
  20.486 -    def hasNext = self.hasNext || count < len 
  20.487 -    def next = {
  20.488 -      count += 1
  20.489 -      if (self.hasNext) self.next
  20.490 -      else if (count <= len) elem
  20.491 -      else empty.next
  20.492 -    }
  20.493 -  }
  20.494 -
  20.495 -  /** Return an iterator that pairs each element of this iterator
  20.496 -   *  with its index, counting from 0.
  20.497 -   * 
  20.498 -   */
  20.499 -  def zipWithIndex = new Iterator[(A, Int)] {
  20.500 -    var idx = 0
  20.501 -    def hasNext = self.hasNext
  20.502 -    def next = {
  20.503 -      val ret = (self.next, idx)
  20.504 -      idx += 1
  20.505 -      ret
  20.506 -    }
  20.507 -  }
  20.508 -
  20.509 -  /** Returns an iterator formed from this iterator and the specified iterator
  20.510 -   *  <code>that</code> by associating each element of the former with
  20.511 -   *  the element at the same position in the latter.
  20.512 -   *
  20.513 -   *  @param that     iterator <code>that</code> may have a different length
  20.514 -   *                  as the self iterator.
  20.515 -   *  @param thisElem element <code>thisElem</code> is used to fill up the
  20.516 -   *                  resulting iterator if the self iterator is shorter than
  20.517 -   *                  <code>that</code>
  20.518 -   *  @param thatElem element <code>thatElem</code> is used to fill up the
  20.519 -   *                  resulting iterator if <code>that</code> is shorter than
  20.520 -   *                  the self iterator
  20.521 -   *  @return         <code>Iterator((a<sub>0</sub>,b<sub>0</sub>), ...,
  20.522 -   *                  (a<sub>n</sub>,b<sub>n</sub>), (elem,b<sub>n+1</sub>),
  20.523 -   *                  ..., {elem,b<sub>m</sub>})</code>
  20.524 -   *                  when <code>[a<sub>0</sub>, ..., a<sub>n</sub>] zip
  20.525 -   *                  [b<sub>0</sub>, ..., b<sub>m</sub>]</code> is
  20.526 -   *                  invoked where <code>m &gt; n</code>.
  20.527 -   */
  20.528 -  def zipAll[B, A1 >: A, B1 >: B](that: Iterator[B], thisElem: A1, thatElem: B1) = new Iterator[(A1, B1)] {  
  20.529 -    def hasNext = self.hasNext || that.hasNext
  20.530 -    def next(): (A1, B1) = 
  20.531 -      if (self.hasNext) {
  20.532 -        if (that.hasNext) (self.next(), that.next())
  20.533 -        else (self.next(), thatElem)
  20.534 -      } else {
  20.535 -        if (that.hasNext) (thisElem, that.next())
  20.536 -        else empty.next()
  20.537 -      }
  20.538 -  }
  20.539 -
  20.540 -  /** Execute a function <code>f</code> for all elements of this
  20.541 -   *  iterator.
  20.542 -   *
  20.543 -   *  @param  f   a function that is applied to every element.
  20.544 -   */
  20.545 -  def foreach[U](f: A =>  U) { while (hasNext) f(next()) }
  20.546 -
  20.547 -  /** Apply a predicate <code>p</code> to all elements of this
  20.548 -   *  iterable object and return <code>true</code> iff the predicate yields
  20.549 -   *  <code>true</code> for all elements.
  20.550 -   *
  20.551 -   *  @param p the predicate
  20.552 -   *  @return  <code>true</code> iff the predicate yields <code>true</code>
  20.553 -   *           for all elements.
  20.554 -   */
  20.555 -  def forall(p: A => Boolean): Boolean = {
  20.556 -    var res = true
  20.557 -    while (res && hasNext) res = p(next())
  20.558 -    res
  20.559 -  }
  20.560 -
  20.561 -  /** Apply a predicate <code>p</code> to all elements of this
  20.562 -   *  iterable object and return true iff there is at least one
  20.563 -   *  element for which <code>p</code> yields <code>true</code>.
  20.564 -   *
  20.565 -   *  @param p the predicate
  20.566 -   *  @return  <code>true</code> iff the predicate yields <code>true</code>
  20.567 -   *           for at least one element.
  20.568 -   */
  20.569 -  def exists(p: A => Boolean): Boolean = {
  20.570 -    var res = false
  20.571 -    while (!res && hasNext) res = p(next())
  20.572 -    res
  20.573 -  }
  20.574 -
  20.575 - /** Tests if the given value <code>elem</code> is a member of this iterator.
  20.576 -   *
  20.577 -   *  @param elem element whose membership has to be tested.
  20.578 -   */
  20.579 -  def contains(elem: Any): Boolean = exists(_ == elem)
  20.580 -
  20.581 -  /** Find and return the first value returned by the iterator satisfying a
  20.582 -   *  predicate, if any.
  20.583 -   *
  20.584 -   *  @param p the predicate
  20.585 -   *  @return  the first element in the iterable object satisfying
  20.586 -   *           <code>p</code>, or <code>None</code> if none exists.
  20.587 -   */
  20.588 -  def find(p: A => Boolean): Option[A] = {
  20.589 -    var res: Option[A] = None
  20.590 -    while (res.isEmpty && hasNext) {
  20.591 -      val e = next()
  20.592 -      if (p(e)) res = Some(e)
  20.593 -    }
  20.594 -    res
  20.595 -  }
  20.596 -  
  20.597 -  /** Returns index of the first element satisfying a predicate, or -1.
  20.598 -   *
  20.599 -   *  @note may not terminate for infinite-sized collections.
  20.600 -   *  @param  p the predicate
  20.601 -   *  @return   the index of the first element satisfying <code>p</code>,
  20.602 -   *           or -1 if such an element does not exist
  20.603 -   */
  20.604 -  def indexWhere(p: A => Boolean): Int = {
  20.605 -    var i = 0
  20.606 -    var found = false
  20.607 -    while (!found && hasNext) {
  20.608 -      if (p(next())) {
  20.609 -        found = true
  20.610 -      } else {
  20.611 -        i += 1
  20.612 -      }
  20.613 -    }
  20.614 -    if (found) i else -1
  20.615 -  }
  20.616 -  
  20.617 -  /** Returns the index of the first occurence of the specified
  20.618 -   *  object in this iterable object.
  20.619 -   *
  20.620 -   *  @note may not terminate for infinite-sized collections.
  20.621 -   *  @param  elem  element to search for.
  20.622 -   *  @return the index in this sequence of the first occurence of the
  20.623 -   *          specified element, or -1 if the sequence does not contain
  20.624 -   *          this element.
  20.625 -   */
  20.626 -  def indexOf[B >: A](elem: B): Int = {
  20.627 -    var i = 0
  20.628 -    var found = false
  20.629 -    while (!found && hasNext) {
  20.630 -      if (next() == elem) {
  20.631 -        found = true
  20.632 -      } else {
  20.633 -        i += 1
  20.634 -      }
  20.635 -    }
  20.636 -    if (found) i else -1
  20.637 -  }
  20.638 -
  20.639 -  /** Combines the elements of this iterator together using the binary
  20.640 -   *  operator <code>op</code>, from left to right, and starting with
  20.641 -   *  the value <code>z</code>.
  20.642 -   *
  20.643 -   *  @return <code>op(... (op(op(z,a<sub>0</sub>),a<sub>1</sub>) ...),
  20.644 -   *          a<sub>n</sub>)</code> if the iterator yields elements
  20.645 -   *          <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
  20.646 -   */
  20.647 -  def foldLeft[B](z: B)(op: (B, A) => B): B = {
  20.648 -    var acc = z
  20.649 -    while (hasNext) acc = op(acc, next())
  20.650 -    acc
  20.651 -  }
  20.652 -
  20.653 -  /** Combines the elements of this iterator together using the binary
  20.654 -   *  operator <code>op</code>, from right to left, and starting with
  20.655 -   *  the value <code>z</code>.
  20.656 -   *
  20.657 -   *  @return <code>a<sub>0</sub> op (... op (a<sub>n</sub> op z)...)</code>
  20.658 -   *          if the iterator yields elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
  20.659 -   *          a<sub>n</sub></code>.
  20.660 -   */
  20.661 -  def foldRight[B](z: B)(op: (A, B) => B): B =
  20.662 -    if (hasNext) op(next(), foldRight(z)(op)) else z
  20.663 -
  20.664 -  /** Similar to <code>foldLeft</code> but can be used as
  20.665 -   *  an operator with the order of iterator and zero arguments reversed.
  20.666 -   *  That is, <code>z /: xs</code> is the same as <code>xs foldLeft z</code>.
  20.667 -   *
  20.668 -   *  @param z the left argument of the first application of <code>op</code>
  20.669 -   *           (evaluation occurs from left to right).
  20.670 -   *  @param op the applied operator.
  20.671 -   *  @return  the result value
  20.672 -   *  @see     <code><a href="#foldLeft">foldLeft</a></code>.
  20.673 -   */
  20.674 -  def /:[B](z: B)(op: (B, A) => B): B = foldLeft(z)(op)
  20.675 -
  20.676 -  /** An alias for <code>foldRight</code>.
  20.677 -   *  That is, <code>xs :\ z</code> is the same as <code>xs foldRight z</code>.
  20.678 -   *
  20.679 -   *  @param z the right argument of the first application of <code>op</code>
  20.680 -   *           (evaluation occurs from right to left).
  20.681 -   *  @param op the applied operator.
  20.682 -   *  @return  the result value.
  20.683 -   *  @see     <code><a href="#foldRight">foldRight</a></code>.
  20.684 -   */
  20.685 -  def :\[B](z: B)(op: (A, B) => B): B = foldRight(z)(op)
  20.686 -
  20.687 -  /** Combines the elements of this iterator together using the binary
  20.688 -   *  operator <code>op</code>, from left to right.
  20.689 -   *
  20.690 -   *  @param op  The operator to apply
  20.691 -   *  @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code> 
  20.692 -   *  if the iterator yields elements
  20.693 -   *          <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
  20.694 -   *  @throws Predef.UnsupportedOperationException if the iterator is empty.
  20.695 -   */
  20.696 -  def reduceLeft[B >: A](op: (B, A) => B): B = {
  20.697 -    if (hasNext) foldLeft[B](next())(op)
  20.698 -    else throw new UnsupportedOperationException("empty.reduceLeft")
  20.699 -  }
  20.700 -
  20.701 -  /** Combines the elements of this iterator together using the binary
  20.702 -   *  operator <code>op</code>, from right to left
  20.703 -   *  @param op  The operator to apply
  20.704 -   *
  20.705 -   *  @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
  20.706 -   *          if the iterator yields elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
  20.707 -   *          a<sub>n</sub></code>.
  20.708 -
  20.709 -   *  @throws Predef.UnsupportedOperationException if the iterator is empty.
  20.710 -   */
  20.711 -  def reduceRight[B >: A](op: (A, B) => B): B = {
  20.712 -    if (hasNext) foldRight[B](next())(op)
  20.713 -    else throw new UnsupportedOperationException("empty.reduceRight")
  20.714 -  }
  20.715 -
  20.716 -  /** Combines the elements of this iterator together using the binary
  20.717 -   *  operator <code>op</code>, from left to right
  20.718 -   *  @param op  The operator to apply
  20.719 -   *  @return  If the iterable is non-empty, the result of the operations as an Option, otherwise None.
  20.720 -   */
  20.721 -  def reduceLeftOption[B >: A](op: (B, A) => B): Option[B] = {
  20.722 -    if (!hasNext) None else Some(reduceLeft(op))
  20.723 -  }
  20.724 -
  20.725 -  /** Combines the elements of this iterable object together using the binary
  20.726 -   *  operator <code>op</code>, from right to left.
  20.727 -   *
  20.728 -   *  @param op  The operator to apply
  20.729 -   *  @return  If the iterable is non-empty, the result of the operations as an Option, otherwise None.
  20.730 -   */
  20.731 -  def reduceRightOption[B >: A](op: (A, B) => B): Option[B] = {
  20.732 -    if (!hasNext) None else Some(reduceRight(op))
  20.733 -  }
  20.734 -  
  20.735 -  /** Returns a buffered iterator from this iterator.
  20.736 -   */
  20.737 -  def buffered = new BufferedIterator[A] {
  20.738 -    private var hd: A = _
  20.739 -    private var hdDefined: Boolean = false
  20.740 -
  20.741 -    def head: A = {
  20.742 -      if (!hdDefined) { 
  20.743 -        hd = next()
  20.744 -        hdDefined = true
  20.745 -      }
  20.746 -      hd
  20.747 -    }
  20.748 -
  20.749 -    def hasNext = 
  20.750 -      hdDefined || self.hasNext
  20.751 -
  20.752 -    def next = 
  20.753 -      if (hdDefined) {
  20.754 -        hdDefined = false
  20.755 -        hd
  20.756 -      } else self.next
  20.757 -  }
  20.758 -  
  20.759 -  /** Since I cannot reliably get take(n) to influence the original
  20.760 -   *  iterator (it seems to depend on some ordering issue I don't
  20.761 -   *  understand) this method takes the way one might expect, leaving
  20.762 -   *  the original iterator with 'size' fewer elements.
  20.763 -   */
  20.764 -  private def takeDestructively(size: Int): Seq[A] = {
  20.765 -    val buf = new ArrayBuffer[A]
  20.766 -    var i = 0
  20.767 -    while (self.hasNext && i < size) {
  20.768 -      buf += self.next
  20.769 -      i += 1
  20.770 -    }
  20.771 -    buf
  20.772 -  }
  20.773 -  
  20.774 -  /** A flexible iterator for transforming an <code>Iterator[A]</code> into an
  20.775 -   *  Iterator[Seq[A]], with configurable sequence size, step, and
  20.776 -   *  strategy for dealing with elements which don't fit evenly.
  20.777 -   * 
  20.778 -   *  Typical uses can be achieved via methods `grouped' and `sliding'.
  20.779 -   */
  20.780 -  class GroupedIterator[B >: A](self: Iterator[A], size: Int, step: Int) extends Iterator[Seq[B]] {
  20.781 -    require(size >= 1 && step >= 1)
  20.782 -
  20.783 -    private[this] var buffer: ArrayBuffer[B] = ArrayBuffer()  // the buffer    
  20.784 -    private[this] var filled = false                          // whether the buffer is "hot"
  20.785 -    private[this] var _partial = true                         // whether we deliver short sequences
  20.786 -    private[this] var pad: Option[() => B] = None             // what to pad short sequences with
  20.787 -    
  20.788 -    /** Public functions which can be used to configure the iterator before use. */
  20.789 -    def withPadding(x: => B): this.type = {
  20.790 -      pad = Some(() => x)
  20.791 -      this
  20.792 -    }
  20.793 -    def withPartial(x: Boolean): this.type = {
  20.794 -      _partial = x
  20.795 -      if (_partial == true) // reset pad since otherwise it will take precedence
  20.796 -        pad = None
  20.797 -
  20.798 -      this
  20.799 -    }
  20.800 -    
  20.801 -    private def padding(x: Int) = List.fill(x)(pad.get())
  20.802 -    private def gap = (step - size) max 0
  20.803 -    
  20.804 -    private def go(count: Int) = {
  20.805 -      val prevSize = buffer.size
  20.806 -      def isFirst = prevSize == 0
  20.807 -      // If there is padding defined we insert it immediately
  20.808 -      // so the rest of the code can be oblivious
  20.809 -      val xs: Seq[B] = {
  20.810 -        val res = self takeDestructively count      
  20.811 -        // extra checks so we don't calculate length unless there's reason
  20.812 -        if (pad.isDefined && !self.hasNext) {
  20.813 -          val shortBy = count - res.length
  20.814 -          if (shortBy > 0) res ++ padding(shortBy) else res
  20.815 -        }
  20.816 -        else res
  20.817 -      }
  20.818 -      lazy val len = xs.length
  20.819 -      lazy val incomplete = len < count
  20.820 -      
  20.821 -      // if 0 elements are requested, or if the number of newly obtained
  20.822 -      // elements is less than the gap between sequences, we are done.
  20.823 -      def deliver(howMany: Int) = {
  20.824 -        (howMany > 0 && len > gap) && {          
  20.825 -          if (!isFirst)
  20.826 -            buffer trimStart (step min prevSize)
  20.827 -          
  20.828 -          val available =
  20.829 -            if (isFirst) len
  20.830 -            else howMany min (len - gap)
  20.831 -          
  20.832 -          buffer ++= (xs takeRight available)
  20.833 -          filled = true
  20.834 -          true
  20.835 -        }
  20.836 -      }
  20.837 -      
  20.838 -      if (xs.isEmpty) false                         // self ran out of elements
  20.839 -      else if (_partial) deliver(len min size)      // if _partial is true, we deliver regardless
  20.840 -      else if (incomplete) false                    // !_partial && incomplete means no more seqs
  20.841 -      else if (isFirst) deliver(len)                // first element
  20.842 -      else deliver(step min size)                   // the typical case
  20.843 -    }
  20.844 -    
  20.845 -    // fill() returns false if no more sequences can be produced
  20.846 -    private def fill(): Boolean = {
  20.847 -      if (!self.hasNext) false
  20.848 -      // the first time we grab size, but after that we grab step
  20.849 -      else if (buffer.isEmpty) go(size)
  20.850 -      else go(step)
  20.851 -    }
  20.852 -      
  20.853 -    def hasNext = filled || fill()
  20.854 -    def next = {
  20.855 -      if (!filled)
  20.856 -        fill()
  20.857 -      
  20.858 -      filled = false
  20.859 -      buffer.toList
  20.860 -    }      
  20.861 -  }
  20.862 -
  20.863 -  /** Returns an iterator which groups this iterator into fixed size 
  20.864 -   *  blocks.  Example usages:
  20.865 -   *
  20.866 -   *  <pre>
  20.867 -   *    // Returns List(List(1, 2, 3), List(4, 5, 6), List(7)))
  20.868 -   *    (1 to 7).iterator grouped 3 toList
  20.869 -   *    // Returns List(List(1, 2, 3), List(4, 5, 6))
  20.870 -   *    (1 to 7).iterator grouped 3 withPartial false toList
  20.871 -   *    // Returns List(List(1, 2, 3), List(4, 5, 6), List(7, 20, 25)
  20.872 -   *    // Illustrating that withPadding's argument is by-name.
  20.873 -   *    val it2 = Iterator.iterate(20)(_ + 5)
  20.874 -   *    (1 to 7).iterator grouped 3 withPadding it2.next toList
  20.875 -   *  </pre>
  20.876 -   */
  20.877 -  def grouped[B >: A](size: Int): GroupedIterator[B] =
  20.878 -    new GroupedIterator[B](self, size, size)
  20.879 -
  20.880 -  /** Returns an iterator which presents a "sliding window" view of
  20.881 -   *  another iterator.  The first argument is the window size, and
  20.882 -   *  the second is how far to advance the window on each iteration;
  20.883 -   *  defaults to 1.  Example usages:
  20.884 -   * 
  20.885 -   *  <pre>
  20.886 -   *    // Returns List(List(1, 2, 3), List(2, 3, 4), List(3, 4, 5))
  20.887 -   *    (1 to 5).iterator.sliding(3).toList
  20.888 -   *    // Returns List(List(1, 2, 3, 4), List(4, 5))
  20.889 -   *    (1 to 5).iterator.sliding(4, 3).toList
  20.890 -   *    // Returns List(List(1, 2, 3, 4))
  20.891 -   *    (1 to 5).iterator.sliding(4, 3).withPartial(false).toList
  20.892 -   *    // Returns List(List(1, 2, 3, 4), List(4, 5, 20, 25))
  20.893 -   *    // Illustrating that withPadding's argument is by-name.
  20.894 -   *    val it2 = Iterator.iterate(20)(_ + 5)
  20.895 -   *    (1 to 5).iterator.sliding(4, 3).withPadding(it2.next).toList
  20.896 -   *  </pre>
  20.897 -   */
  20.898 -  def sliding[B >: A](size: Int, step: Int = 1): GroupedIterator[B] =
  20.899 -    new GroupedIterator[B](self, size, step)
  20.900 -
  20.901 -  /** Returns the number of elements in this iterator.
  20.902 -   *  @note The iterator is at its end after this method returns.
  20.903 -   */
  20.904 -  def length: Int = {
  20.905 -    var i = 0
  20.906 -    while (hasNext) {
  20.907 -      next(); i += 1
  20.908 -    }
  20.909 -    i
  20.910 -  }
  20.911 -  
  20.912 -  /** Creates two new iterators that both iterate over the same elements
  20.913 -   *  as this iterator (in the same order).
  20.914 -   *
  20.915 -   *  @return a pair of iterators
  20.916 -   */
  20.917 -  def duplicate: (Iterator[A], Iterator[A]) = {
  20.918 -    val gap = new scala.collection.mutable.Queue[A]
  20.919 -    var ahead: Iterator[A] = null
  20.920 -    class Partner extends Iterator[A] {
  20.921 -      def hasNext: Boolean = self.synchronized {
  20.922 -        (this ne ahead) && !gap.isEmpty || self.hasNext
  20.923 -      }	
  20.924 -      def next(): A = self.synchronized {
  20.925 -        if (gap.isEmpty) ahead = this
  20.926 -        if (this eq ahead) {
  20.927 -          val e = self.next()
  20.928 -          gap enqueue e
  20.929 -          e
  20.930 -        } else gap.dequeue
  20.931 -      }	
  20.932 -    }
  20.933 -    (new Partner, new Partner)
  20.934 -  }
  20.935 -
  20.936 -  /** Returns this iterator with patched values.
  20.937 -   *  @param from     The start index from which to patch
  20.938 -   *  @param ps       The iterator of patch values
  20.939 -   *  @param replaced The number of values in the original iterator that are replaced by the patch.
  20.940 -   */
  20.941 -  def patch[B >: A](from: Int, patchElems: Iterator[B], replaced: Int) = new Iterator[B] {
  20.942 -    private var origElems = self
  20.943 -    private var i = 0
  20.944 -    def hasNext: Boolean = 
  20.945 -      if (i < from) origElems.hasNext 
  20.946 -      else patchElems.hasNext || origElems.hasNext
  20.947 -    def next(): B = {
  20.948 -      val result: B = 
  20.949 -        if (i < from || !patchElems.hasNext) origElems.next()
  20.950 -        else patchElems.next()
  20.951 -      i += 1
  20.952 -      if (i == from) origElems = origElems drop replaced
  20.953 -      result
  20.954 -    }
  20.955 -  }
  20.956 - 
  20.957 -  /** Fills the given array `xs` with at most `len` elements of
  20.958 -   *  this iterator starting at position `start` until either `len` elements have been copied,
  20.959 -   *  or the end of the iterator is reached, or the end of the array `xs` is reached.
  20.960 -   *
  20.961 -   *  @param  xs the array to fill.
  20.962 -   *  @param  start starting index.
  20.963 -   *  @param  len number of elements to copy
  20.964 -   */
  20.965 -  def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = {
  20.966 -    var i = start
  20.967 -    val end = start + len min xs.length
  20.968 -    while (hasNext && i < end) {
  20.969 -      xs(i) = next()
  20.970 -      i += 1
  20.971 -    }
  20.972 -  }
  20.973 -
  20.974 -  /** Fills the given array <code>xs</code> with the elements of
  20.975 -   *  this iterator starting at position <code>start</code>
  20.976 -   *  until either the end of the current iterator or the end of array `xs` is reached.
  20.977 -   *
  20.978 -   *  @param  xs the array to fill.
  20.979 -   *  @param  start starting index.
  20.980 -   */
  20.981 -  def copyToArray[B >: A](xs: Array[B], start: Int): Unit = 
  20.982 -    copyToArray(xs, start, xs.length - start)
  20.983 -
  20.984 -  /** Fills the given array <code>xs</code> with the elements of
  20.985 -   *  this iterator starting at position <code>0</code>
  20.986 -   *  until either the end of the current iterator or the end of array `xs` is reached.
  20.987 -   *
  20.988 -   *  @param  xs the array to fill.
  20.989 -   */
  20.990 -  def copyToArray[B >: A](xs: Array[B]): Unit = copyToArray(xs, 0, xs.length)
  20.991 -
  20.992 -  /** Copy all elements to a buffer 
  20.993 -   *  @param  dest The buffer to which elements are copied
  20.994 -   */
  20.995 -  def copyToBuffer[B >: A](dest: Buffer[B]) {
  20.996 -    while (hasNext) dest += next
  20.997 -  }
  20.998 -
  20.999 -  /** Traverse this iterator and return all elements in a list.
 20.1000 -   *
 20.1001 -   *  @return  A list which enumerates all elements of this iterator.
 20.1002 -   */
 20.1003 -  def toList: List[A] = {
 20.1004 -    val res = new ListBuffer[A]
 20.1005 -    while (hasNext) res += next
 20.1006 -    res.toList
 20.1007 -  }
 20.1008 -
 20.1009 -  /** Traverse this iterator and return all elements in a stream.
 20.1010 -   *
 20.1011 -   *  @return  A stream which enumerates all elements of this iterator.
 20.1012 -   */ 
 20.1013 -  def toStream: Stream[A] =
 20.1014 -    if (hasNext) Stream.cons(next, toStream) else Stream.empty
 20.1015 -  
 20.1016 -  /** Traverse this iterator and return all elements in a sequence.
 20.1017 -   *
 20.1018 -   *  @return  A sequence which enumerates all elements of this iterator.
 20.1019 -   */ 
 20.1020 -  def toSeq: Seq[A] = {
 20.1021 -    val buffer = new ArrayBuffer[A]
 20.1022 -    this copyToBuffer buffer
 20.1023 -    buffer 
 20.1024 -  }
 20.1025 -  
 20.1026 -  /** Returns a string representation of the elements in this iterator. The resulting string
 20.1027 -   *  begins with the string <code>start</code> and is finished by the string
 20.1028 -   *  <code>end</code>. Inside, the string representations of elements (w.r.t.
 20.1029 -   *  the method <code>toString</code>) are separated by the string
 20.1030 -   *  <code>sep</code>.
 20.1031 -   *  <p/>
 20.1032 -   *  Ex: <br/>
 20.1033 -   *  <code>List(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"</code>
 20.1034 -   *
 20.1035 -   *  @param start starting string.
 20.1036 -   *  @param sep separator string.
 20.1037 -   *  @param end ending string.
 20.1038 -   *  @return a string representation of this iterable object.
 20.1039 -   */
 20.1040 -  def mkString(start: String, sep: String, end: String): String = {
 20.1041 -    val buf = new StringBuilder
 20.1042 -    addString(buf, start, sep, end).toString
 20.1043 -  }
 20.1044 -
 20.1045 -  /** Returns a string representation of this iterable object. The string
 20.1046 -   *  representations of elements (w.r.t. the method <code>toString()</code>)
 20.1047 -   *  are separated by the string <code>sep</code>.
 20.1048 -   *
 20.1049 -   *  @param sep separator string.
 20.1050 -   *  @return a string representation of this iterable object.
 20.1051 -   */
 20.1052 -  def mkString(sep: String): String = mkString("", sep, "")
 20.1053 -
 20.1054 -  /** Returns a string representation of this iterable object. The string
 20.1055 -   *  representations of elements (w.r.t. the method <code>toString()</code>)
 20.1056 -   *  are concatenated without any separator string.
 20.1057 -   *
 20.1058 -   *  @return a string representation of this iterable object.
 20.1059 -   */
 20.1060 -  def mkString: String = mkString("")
 20.1061 -
 20.1062 -  /** Write all elements of this iterator into given string builder.
 20.1063 -   *  The written text begins with the string <code>start</code> and is finished by the string
 20.1064 -   *  <code>end</code>. Inside, the string representations of elements (w.r.t.
 20.1065 -   *  the method <code>toString()</code>) are separated by the string
 20.1066 -   *  <code>sep</code>.
 20.1067 -   */
 20.1068 -  def addString(buf: StringBuilder, start: String, sep: String, end: String): StringBuilder = {
 20.1069 -    buf.append(start)
 20.1070 -    val elems = this
 20.1071 -    if (elems.hasNext) buf.append(elems.next)
 20.1072 -    while (elems.hasNext) {
 20.1073 -      buf.append(sep); buf.append(elems.next)
 20.1074 -    }
 20.1075 -    buf.append(end)
 20.1076 -  }
 20.1077 -  
 20.1078 -  /** Write all elements of this iterator into given string builder.
 20.1079 -   *  The string representations of elements (w.r.t. the method <code>toString()</code>)
 20.1080 -   *  are separated by the string <code>sep</code>.
 20.1081 -   */
 20.1082 -  def addString(buf: StringBuilder, sep: String): StringBuilder = addString(buf, "", sep, "")
 20.1083 -
 20.1084 -  /** Write all elements of this string into given string builder without using
 20.1085 -   *  any separator between consecutive elements.
 20.1086 -   */
 20.1087 -  def addString(buf: StringBuilder): StringBuilder = addString(buf, "", "", "")
 20.1088 -  
 20.1089 -  override def toString = (if (hasNext) "non-empty" else "empty")+" iterator"
 20.1090 -
 20.1091 -  /** Returns a new iterator that first yields the elements of this
 20.1092 -   *  iterator followed by the elements provided by iterator <code>that</code>.
 20.1093 -   */
 20.1094 -  @deprecated("use <code>++</code>")
 20.1095 -  def append[B >: A](that: Iterator[B]) = new Iterator[B] {
 20.1096 -    def hasNext = self.hasNext || that.hasNext
 20.1097 -    def next() = (if (self.hasNext) self else that).next()
 20.1098 -  }
 20.1099 -
 20.1100 -  /** Returns index of the first element satisfying a predicate, or -1. */
 20.1101 -  @deprecated("use `indexWhere` instead")
 20.1102 -  def findIndexOf(p: A => Boolean): Int = indexWhere(p)
 20.1103 -
 20.1104 -  /** Collect elements into a seq.
 20.1105 -   *
 20.1106 -   * @return  a sequence which enumerates all elements of this iterator.
 20.1107 -   */
 20.1108 -  @deprecated("use toSeq instead")
 20.1109 -  def collect: Seq[A] = toSeq
 20.1110 -
 20.1111 -  /** Returns a counted iterator from this iterator.
 20.1112 -   */
 20.1113 -  @deprecated("use zipWithIndex in Iterator")
 20.1114 -  def counted = new CountedIterator[A] {
 20.1115 -    private var cnt = 0
 20.1116 -    def count = cnt
 20.1117 -    def hasNext: Boolean = self.hasNext
 20.1118 -    def next(): A = { cnt += 1; self.next }
 20.1119 -  }
 20.1120 -  
 20.1121 -  /** Fills the given array <code>xs</code> with the elements of
 20.1122 -   *  this sequence starting at position <code>start</code>.  Like <code>copyToArray</code>, 
 20.1123 -   *  but designed to accomodate IO stream operations. 
 20.1124 -   *
 20.1125 -   *  @param  xs    the array to fill.
 20.1126 -   *  @param  start the starting index.
 20.1127 -   *  @param  sz    the maximum number of elements to be read.
 20.1128 -   *  @pre          the array must be large enough to hold <code>sz</code> elements.
 20.1129 -   */
 20.1130 -  @deprecated("use copyToArray instead")
 20.1131 -  def readInto[B >: A](xs: Array[B], start: Int, sz: Int) {
 20.1132 -    var i = start
 20.1133 -    while (hasNext && i - start < sz) {
 20.1134 -      xs(i) = next
 20.1135 -      i += 1
 20.1136 -    }
 20.1137 -  }
 20.1138 -
 20.1139 -  @deprecated("use copyToArray instead")
 20.1140 -  def readInto[B >: A](xs: Array[B], start: Int) {
 20.1141 -    readInto(xs, start, xs.length - start)
 20.1142 -  }
 20.1143 -
 20.1144 -  @deprecated("use copyToArray instead")
 20.1145 -  def readInto[B >: A](xs: Array[B]) {
 20.1146 -    readInto(xs, 0, xs.length)
 20.1147 -  }
 20.1148 -}
    21.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/JavaConversions.scala	Tue Nov 03 13:08:38 2009 +0800
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,503 +0,0 @@
    21.4 -/*                     __                                               *\
    21.5 -**     ________ ___   / /  ___     Scala API                            **
    21.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    21.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://www.scala-lang.org/           **
    21.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    21.9 -**                          |/                                          **
   21.10 -\*                                                                      */
   21.11 -
   21.12 -// $Id: JavaConversions.scala 19076 2009-10-13 17:07:32Z odersky $
   21.13 -
   21.14 -
   21.15 -package org.aiotrade.lib.collection
   21.16 -
   21.17 -/** <p>
   21.18 - *    A collection of implicit conversions supporting interoperability between
   21.19 - *    Scala and Java collections.
   21.20 - *  </p>
   21.21 - *  <p>
   21.22 - *    The following conversions are supported:
   21.23 - *  </p>
   21.24 - *  <ul>
   21.25 - *    <li><code>scala.collection.Iterable</code> <=> <code>java.lang.Iterable</code></li>
   21.26 - *    <li><code>scala.collection.Iterable</code> <=> <code>java.util.Collection</code></li>
   21.27 - *    <li><code>scala.collection.Iterator</code> <=> <code>java.util.{ Iterator, Enumeration }</code></li>
   21.28 - *    <li><code>scala.collection.mutable.Buffer</code> <=> <code>java.util.List</code></li>
   21.29 - *    <li><code>scala.collection.mutable.Set</code> <=> <code>java.util.Set</code></li>
   21.30 - *    <li><code>scala.collection.mutable.Map</code> <=> <code>java.util.Map</code></li>
   21.31 - *  </ul>
   21.32 - *  <p>
   21.33 - *    In all cases, converting from a source type to a target type and back
   21.34 - *    again will return the original source object, eg.
   21.35 - *  </p>
   21.36 - *  <pre>
   21.37 - *    <b>import</b> scala.collection.JavaConversions._
   21.38 - * 
   21.39 - *    <b>val</b> sl = <b>new</b> scala.collection.mutable.ListBuffer[Int]
   21.40 - *    <b>val</b> jl : java.util.List[Int] = sl
   21.41 - *    <b>val</b> sl2 : scala.collection.mutable.Buffer[Int] = jl
   21.42 - *    assert(sl eq sl2)g</pre>
   21.43 - *  <p>
   21.44 - *    Note that no conversion is provided from <code>scala.collection.immutable.List</code>
   21.45 - *    to <code>java.util.List</code>. Instead it is convertible to an immutable
   21.46 - *    <code>java.util.Collection</code> which provides size and interation
   21.47 - *    capabilities, but not access by index as would be provided by
   21.48 - *    <code>java.util.List</code>.<br/>
   21.49 - *    This is intentional: in combination the implementation of
   21.50 - *    <code>scala.collection.immutable.List</code> and the typical usage
   21.51 - *    patterns of <code>java.util.List</code> would perform extremely poorly.
   21.52 - *  </p>
   21.53 - * 
   21.54 - *  @author Miles Sabin
   21.55 - *  @since  2.8
   21.56 - */
   21.57 -object JavaConversions {
   21.58 -  import java.{ lang => jl, util => ju }
   21.59 -  import scala.collection.{ generic, immutable, mutable, Traversable }
   21.60 -  import scala.reflect.ClassManifest
   21.61 -  
   21.62 -  // Scala => Java
   21.63 -  
   21.64 -  /**
   21.65 -   * Implicitly converts a Scala <code>Iterator</code> to a Java <code>Iterator</code>.
   21.66 -   * The returned Java <code>Iterator</code> is backed by the provided Scala
   21.67 -   * <code>Iterator</code> and any side-effects of using it via the Java interface will
   21.68 -   * be visible via the Scala interface and vice versa.
   21.69 -   * <p>
   21.70 -   * If the Scala <code>Iterator</code> was previously obtained from an implicit or
   21.71 -   * explicit call of <code>asIterator(java.util.Iterator)</code> then the original
   21.72 -   * Java <code>Iterator</code> will be returned.
   21.73 -   * 
   21.74 -   * @param i The <code>Iterator</code> to be converted.
   21.75 -   * @return A Java <code>Iterator</code> view of the argument.
   21.76 -   */
   21.77 -  implicit def asIterator[A](i : Iterator[A]) = i match {
   21.78 -    case JIteratorWrapper(wrapped) => wrapped
   21.79 -    case _ => IteratorWrapper(i)
   21.80 -  }
   21.81 -
   21.82 -  /**
   21.83 -   * Implicitly converts a Scala <code>Iterator</code> to a Java <code>Enumeration</code>.
   21.84 -   * The returned Java <code>Enumeration</code> is backed by the provided Scala
   21.85 -   * <code>Iterator</code> and any side-effects of using it via the Java interface will
   21.86 -   * be visible via the Scala interface and vice versa.
   21.87 -   * <p>
   21.88 -   * If the Scala <code>Iterator</code> was previously obtained from an implicit or
   21.89 -   * explicit call of <code>asIterator(java.util.Enumeration)</code> then the
   21.90 -   * original Java <code>Enumeration</code> will be returned.
   21.91 -   * 
   21.92 -   * @param i The <code>Iterator</code> to be converted.
   21.93 -   * @return A Java <code>Enumeration</code> view of the argument.
   21.94 -   */
   21.95 -  implicit def asEnumeration[A](i : Iterator[A]) = i match {
   21.96 -    case JEnumerationWrapper(wrapped) => wrapped
   21.97 -    case _ => IteratorWrapper(i)
   21.98 -  }
   21.99 -
  21.100 -  /**
  21.101 -   * Implicitly converts a Scala <code>Iterable</code> to a Java <code>Iterable</code>.
  21.102 -   * The returned Java <code>Iterable</code> is backed by the provided Scala
  21.103 -   * <code>Iterable</code> and any side-effects of using it via the Java interface will
  21.104 -   * be visible via the Scala interface and vice versa.
  21.105 -   * <p>
  21.106 -   * If the Scala <code>Iterable</code> was previously obtained from an implicit or
  21.107 -   * explicit call of <code>asIterable(java.lang.Iterable)</code> then the original
  21.108 -   * Java <code>Iterable</code> will be returned.
  21.109 -   * 
  21.110 -   * @param i The <code>Iterable</code> to be converted.
  21.111 -   * @return A Java <code>Iterable</code> view of the argument.
  21.112 -   */
  21.113 -  implicit def asIterable[A](i : Iterable[A]) = i match {
  21.114 -    case JIterableWrapper(wrapped) => wrapped
  21.115 -    case _ => IterableWrapper(i)
  21.116 -  }
  21.117 -
  21.118 -  /**
  21.119 -   * Implicitly converts a Scala <code>Iterable</code> to an immutable Java
  21.120 -   * <code>Collection</code>.
  21.121 -   * <p>
  21.122 -   * If the Scala <code>Iterable</code> was previously obtained from an implicit or
  21.123 -   * explicit call of <code>asSizedIterable(java.util.Collection)</code> then the original
  21.124 -   * Java <code>Collection</code> will be returned.
  21.125 -   * 
  21.126 -   * @param i The <code>SizedIterable</code> to be converted.
  21.127 -   * @return A Java <code>Collection</code> view of the argument.
  21.128 -   */
  21.129 -  implicit def asCollection[A](i : Iterable[A]) = i match {
  21.130 -    case JCollectionWrapper(wrapped) => wrapped
  21.131 -    case _ => new IterableWrapper(i)
  21.132 -  }
  21.133 -  
  21.134 -  /**
  21.135 -   * Implicitly converts a Scala mutable <code>Buffer</code> to a Java <code>List</code>.
  21.136 -   * The returned Java <code>List</code> is backed by the provided Scala
  21.137 -   * <code>Buffer</code> and any side-effects of using it via the Java interface will
  21.138 -   * be visible via the Scala interface and vice versa.
  21.139 -   * <p>
  21.140 -   * If the Scala <code>Buffer</code> was previously obtained from an implicit or
  21.141 -   * explicit call of <code>asBuffer(java.util.List)</code> then the original
  21.142 -   * Java <code>List</code> will be returned.
  21.143 -   * 
  21.144 -   * @param b The <code>Buffer</code> to be converted.
  21.145 -   * @return A Java <code>List</code> view of the argument.
  21.146 -   */
  21.147 -  implicit def asList[A](b : mutable.Buffer[A]) : ju.List[A] = b match {
  21.148 -    case JListWrapper(wrapped) => wrapped
  21.149 -    case _ => new MutableBufferWrapper(b)
  21.150 -  }
  21.151 -  
  21.152 -  /**
  21.153 -   * Implicitly converts a Scala mutable <code>Set</code> to a Java <code>Set</code>.
  21.154 -   * The returned Java <code>Set</code> is backed by the provided Scala
  21.155 -   * <code>Set</code> and any side-effects of using it via the Java interface will
  21.156 -   * be visible via the Scala interface and vice versa.
  21.157 -   * <p>
  21.158 -   * If the Scala <code>Set</code> was previously obtained from an implicit or
  21.159 -   * explicit call of <code>asSet(java.util.Set)</code> then the original
  21.160 -   * Java <code>Set</code> will be returned.
  21.161 -   * 
  21.162 -   * @param s The <code>Set</code> to be converted.
  21.163 -   * @return A Java <code>Set</code> view of the argument.
  21.164 -   */
  21.165 -  implicit def asSet[A](s : mutable.Set[A])(implicit m : ClassManifest[A]) : ju.Set[A] = s match {
  21.166 -    case JSetWrapper(wrapped) => wrapped
  21.167 -    case _ => new MutableSetWrapper(s)(m)
  21.168 -  }
  21.169 -
  21.170 -  /**
  21.171 -   * Implicitly converts a Scala mutable <code>Map</code> to a Java <code>Map</code>.
  21.172 -   * The returned Java <code>Map</code> is backed by the provided Scala
  21.173 -   * <code>Map</code> and any side-effects of using it via the Java interface will
  21.174 -   * be visible via the Scala interface and vice versa.
  21.175 -   * <p>
  21.176 -   * If the Scala <code>Map</code> was previously obtained from an implicit or
  21.177 -   * explicit call of <code>asMap(java.util.Map)</code> then the original
  21.178 -   * Java <code>Map</code> will be returned.
  21.179 -   * 
  21.180 -   * @param m The <code>Map</code> to be converted.
  21.181 -   * @return A Java <code>Map</code> view of the argument.
  21.182 -   */
  21.183 -  implicit def asMap[A, B](m : mutable.Map[A, B])(implicit ma : ClassManifest[A]) : ju.Map[A, B] = m match {
  21.184 -    case JMapWrapper(wrapped) => wrapped
  21.185 -    case _ => new MutableMapWrapper(m)(ma)
  21.186 -  }
  21.187 -  
  21.188 -  // Java => Scala
  21.189 -  
  21.190 -  /**
  21.191 -   * Implicitly converts a Java <code>Iterator</code> to a Scala <code>Iterator</code>.
  21.192 -   * The returned Scala <code>Iterator</code> is backed by the provided Java
  21.193 -   * <code>Iterator</code> and any side-effects of using it via the Scala interface will
  21.194 -   * be visible via the Java interface and vice versa.
  21.195 -   * <p>
  21.196 -   * If the Java <code>Iterator</code> was previously obtained from an implicit or
  21.197 -   * explicit call of <code>asIterator(scala.collection.Iterator)</code> then the original
  21.198 -   * Scala <code>Iterator</code> will be returned.
  21.199 -   * 
  21.200 -   * @param i The <code>Iterator</code> to be converted.
  21.201 -   * @return A Scala <code>Iterator</code> view of the argument.
  21.202 -   */
  21.203 -  implicit def asIterator[A](i : ju.Iterator[A]) = i match {
  21.204 -    case IteratorWrapper(wrapped) => wrapped
  21.205 -    case _ => JIteratorWrapper(i)
  21.206 -  }
  21.207 -  
  21.208 -  /**
  21.209 -   * Implicitly converts a Java <code>Enumeration</code> to a Scala <code>Iterator</code>.
  21.210 -   * The returned Scala <code>Iterator</code> is backed by the provided Java
  21.211 -   * <code>Enumeration</code> and any side-effects of using it via the Scala interface will
  21.212 -   * be visible via the Java interface and vice versa.
  21.213 -   * <p>
  21.214 -   * If the Java <code>Enumeration</code> was previously obtained from an implicit or
  21.215 -   * explicit call of <code>asEnumeration(scala.collection.Iterator)</code> then the
  21.216 -   * original Scala <code>Iterator</code> will be returned.
  21.217 -   * 
  21.218 -   * @param i The <code>Enumeration</code> to be converted.
  21.219 -   * @return A Scala <code>Iterator</code> view of the argument.
  21.220 -   */
  21.221 -  implicit def asIterator[A](i : ju.Enumeration[A]) = i match {
  21.222 -    case IteratorWrapper(wrapped) => wrapped
  21.223 -    case _ => JEnumerationWrapper(i)
  21.224 -  }
  21.225 -  
  21.226 -  /**
  21.227 -   * Implicitly converts a Java <code>Iterable</code> to a Scala <code>Iterable</code>.
  21.228 -   * The returned Scala <code>Iterable</code> is backed by the provided Java
  21.229 -   * <code>Iterable</code> and any side-effects of using it via the Scala interface will
  21.230 -   * be visible via the Java interface and vice versa.
  21.231 -   * <p>
  21.232 -   * If the Java <code>Iterable</code> was previously obtained from an implicit or
  21.233 -   * explicit call of <code>asIterable(scala.collection.Iterable)</code> then the original
  21.234 -   * Scala <code>Iterable</code> will be returned.
  21.235 -   * 
  21.236 -   * @param i The <code>Iterable</code> to be converted.
  21.237 -   * @return A Scala <code>Iterable</code> view of the argument.
  21.238 -   */
  21.239 -  implicit def asIterable[A](i : jl.Iterable[A]) = i match {
  21.240 -    case IterableWrapper(wrapped) => wrapped
  21.241 -    case _ => JIterableWrapper(i)
  21.242 -  }
  21.243 -  
  21.244 -  /**
  21.245 -   * Implicitly converts a Java <code>Collection</code> to an Scala <code>Iterable</code>.
  21.246 -   * <p>
  21.247 -   * If the Java <code>Collection</code> was previously obtained from an implicit or
  21.248 -   * explicit call of <code>asCollection(scala.collection.SizedIterable)</code> then
  21.249 -   * the original Scala <code>SizedIterable</code> will be returned.
  21.250 -   * 
  21.251 -   * @param i The <code>Collection</code> to be converted.
  21.252 -   * @return A Scala <code>SizedIterable</code> view of the argument.
  21.253 -   */
  21.254 -  implicit def asIterable[A](i : ju.Collection[A]) = i match {
  21.255 -    case IterableWrapper(wrapped) => wrapped
  21.256 -    case _ => JCollectionWrapper(i)
  21.257 -  }
  21.258 -  
  21.259 -  /**
  21.260 -   * Implicitly converts a Java <code>List</code> to a Scala mutable <code>Buffer</code>.
  21.261 -   * The returned Scala <code>Buffer</code> is backed by the provided Java
  21.262 -   * <code>List</code> and any side-effects of using it via the Scala interface will
  21.263 -   * be visible via the Java interface and vice versa.
  21.264 -   * <p>
  21.265 -   * If the Java <code>List</code> was previously obtained from an implicit or
  21.266 -   * explicit call of <code>asList(scala.collection.mutable.Buffer)</code> then the original
  21.267 -   * Scala <code>Buffer</code> will be returned.
  21.268 -   * 
  21.269 -   * @param l The <code>List</code> to be converted.
  21.270 -   * @return A Scala mutable <code>Buffer</code> view of the argument.
  21.271 -   */
  21.272 -  implicit def asBuffer[A](l : ju.List[A]) = l match {
  21.273 -    case MutableBufferWrapper(wrapped) => wrapped
  21.274 -    case _ =>new JListWrapper(l)
  21.275 -  }
  21.276 -
  21.277 -  /**
  21.278 -   * Implicitly converts a Java <code>Set</code> to a Scala mutable <code>Set</code>.
  21.279 -   * The returned Scala <code>Set</code> is backed by the provided Java
  21.280 -   * <code>Set</code> and any side-effects of using it via the Scala interface will
  21.281 -   * be visible via the Java interface and vice versa.
  21.282 -   * <p>
  21.283 -   * If the Java <code>Set</code> was previously obtained from an implicit or
  21.284 -   * explicit call of <code>asSet(scala.collection.mutable.Set)</code> then the original
  21.285 -   * Scala <code>Set</code> will be returned.
  21.286 -   * 
  21.287 -   * @param s The <code>Set</code> to be converted.
  21.288 -   * @return A Scala mutable <code>Set</code> view of the argument.
  21.289 -   */
  21.290 -  implicit def asSet[A](s : ju.Set[A]) = s match {
  21.291 -    case MutableSetWrapper(wrapped) => wrapped
  21.292 -    case _ =>new JSetWrapper(s)
  21.293 -  }
  21.294 -
  21.295 -  /**
  21.296 -   * Implicitly converts a Java <code>Map</code> to a Scala mutable <code>Map</code>.
  21.297 -   * The returned Scala <code>Map</code> is backed by the provided Java
  21.298 -   * <code>Map</code> and any side-effects of using it via the Scala interface will
  21.299 -   * be visible via the Java interface and vice versa.
  21.300 -   * <p>
  21.301 -   * If the Java <code>Map</code> was previously obtained from an implicit or
  21.302 -   * explicit call of <code>asMap(scala.collection.mutable.Map)</code> then the original
  21.303 -   * Scala <code>Map</code> will be returned.
  21.304 -   * 
  21.305 -   * @param m The <code>Map</code> to be converted.
  21.306 -   * @return A Scala mutable <code>Map</code> view of the argument.
  21.307 -   */
  21.308 -  implicit def asMap[A, B](m : ju.Map[A, B]) = m match {
  21.309 -    case MutableMapWrapper(wrapped) => wrapped
  21.310 -    case _ =>new JMapWrapper(m)
  21.311 -  }
  21.312 -
  21.313 -  // Private implementations ...
  21.314 -
  21.315 -  case class IteratorWrapper[A](underlying : Iterator[A]) extends ju.Iterator[A] with ju.Enumeration[A] {
  21.316 -    def hasNext = underlying.hasNext
  21.317 -    def next = underlying.next
  21.318 -    def hasMoreElements = underlying.hasNext
  21.319 -    def nextElement = underlying.next
  21.320 -    def remove = throw new UnsupportedOperationException
  21.321 -  }
  21.322 -
  21.323 -  case class JIteratorWrapper[A](underlying : ju.Iterator[A]) extends Iterator[A] {
  21.324 -    def hasNext = underlying.hasNext
  21.325 -    def next = underlying.next
  21.326 -  }
  21.327 -
  21.328 -  case class JEnumerationWrapper[A](underlying : ju.Enumeration[A]) extends Iterator[A] {
  21.329 -    def hasNext = underlying.hasMoreElements
  21.330 -    def next = underlying.nextElement
  21.331 -  }
  21.332 -
  21.333 -  case class IterableWrapper[A](underlying : Iterable[A]) extends ju.AbstractCollection[A] {
  21.334 -    def iterator = underlying.iterator
  21.335 -    def size = underlying.size
  21.336 -    override def isEmpty = underlying.isEmpty
  21.337 -  }
  21.338 -
  21.339 -  case class JIterableWrapper[A](underlying : jl.Iterable[A]) extends Iterable[A] {
  21.340 -    def iterator = underlying.iterator
  21.341 -    def newBuilder[B] = new mutable.ArrayBuffer[B]
  21.342 -  }
  21.343 -
  21.344 -  case class JCollectionWrapper[A](underlying : ju.Collection[A]) extends Iterable[A] {
  21.345 -    def iterator = underlying.iterator
  21.346 -    override def size = underlying.size
  21.347 -    override def isEmpty = underlying.isEmpty
  21.348 -    def newBuilder[B] = new mutable.ArrayBuffer[B]
  21.349 -  }
  21.350 -  
  21.351 -  case class MutableBufferWrapper[A](underlying : mutable.Buffer[A]) extends ju.AbstractList[A] {
  21.352 -    def size = underlying.length
  21.353 -    def get(i : Int) = underlying(i)
  21.354 -    override def set(i : Int, elem: A) = { val p = underlying(i) ; underlying(i) = elem ; p }
  21.355 -    override def add(elem : A) = { underlying.append(elem) ; true }
  21.356 -    override def remove(i : Int) = underlying.remove(i)
  21.357 -  }
  21.358 -  
  21.359 -  case class JListWrapper[A](val underlying : ju.List[A]) extends mutable.Buffer[A] {
  21.360 -    def length = underlying.size
  21.361 -    override def isEmpty = underlying.isEmpty
  21.362 -    override def iterator : Iterator[A] = underlying.iterator
  21.363 -    def apply(i : Int) = underlying.get(i)
  21.364 -    def update(i : Int, elem : A) = underlying.set(i, elem)
  21.365 -    def +=:(elem : A) = { underlying.subList(0, 0).add(elem) ; this } 
  21.366 -    def +=(elem : A): this.type = { underlying.add(elem); this }
  21.367 -    def insertAll(i : Int, elems : Traversable[A]) = { val ins = underlying.subList(0, i) ;  elems.foreach(ins.add(_)) }
  21.368 -    def remove(i : Int) = underlying.remove(i)
  21.369 -    def clear = underlying.clear
  21.370 -    def result = this
  21.371 -  }
  21.372 -  
  21.373 -  case class MutableSetWrapper[A](underlying : mutable.Set[A])(m : ClassManifest[A]) extends ju.AbstractSet[A] {
  21.374 -    self =>
  21.375 -    def size = underlying.size
  21.376 -    override def add(elem: A) = { val sz = underlying.size ; underlying += elem ; sz < underlying.size }
  21.377 -    override def remove(elem : AnyRef) = {
  21.378 -      m.erasure.isInstance(elem) && {
  21.379 -        val sz = underlying.size
  21.380 -        underlying -= elem.asInstanceOf[A]
  21.381 -        sz > underlying.size
  21.382 -      }
  21.383 -    }
  21.384 -    def iterator = new ju.Iterator[A] {
  21.385 -      val ui = underlying.iterator
  21.386 -      var prev : Option[A] = None
  21.387 -      
  21.388 -      def hasNext = ui.hasNext
  21.389 -      def next = { val e = ui.next ; prev = Some(e) ; e }
  21.390 -      def remove = prev match {
  21.391 -        case Some(e) => self.remove(e.asInstanceOf[AnyRef]) ; prev = None
  21.392 -        case _ => throw new IllegalStateException("next must be called at least once before remove")
  21.393 -      }
  21.394 -    }
  21.395 -
  21.396 -  }
  21.397 -  
  21.398 -  case class JSetWrapper[A](underlying : ju.Set[A]) extends mutable.Set[A] with mutable.SetLike[A, JSetWrapper[A]] {
  21.399 -    override def size = underlying.size
  21.400 -
  21.401 -    def iterator = underlying.iterator
  21.402 -  
  21.403 -    def contains(elem: A): Boolean = underlying.contains(elem)
  21.404 -  
  21.405 -    def +=(elem: A): this.type = { underlying.add(elem); this }
  21.406 -    def -=(elem: A): this.type = { underlying.remove(elem); this }
  21.407 -
  21.408 -    override def add(elem: A): Boolean = underlying.add(elem)
  21.409 -    override def remove(elem: A): Boolean = underlying.remove(elem)
  21.410 -  
  21.411 -    override def clear = underlying.clear
  21.412 -
  21.413 -    override def empty = JSetWrapper(new ju.HashSet[A])
  21.414 -  }
  21.415 -  
  21.416 -  case class MutableMapWrapper[A, B](underlying : mutable.Map[A, B])(m : ClassManifest[A]) extends ju.AbstractMap[A, B] {
  21.417 -    self =>
  21.418 -    override def size = underlying.size
  21.419 -
  21.420 -    override def put(k : A, v : B) = underlying.put(k, v) match {
  21.421 -      case Some(v1) => v1
  21.422 -      case None => null.asInstanceOf[B]
  21.423 -    }
  21.424 -    
  21.425 -    override def remove(k : AnyRef) = {
  21.426 -      if (!m.erasure.isInstance(k))
  21.427 -        null.asInstanceOf[B]
  21.428 -      else {
  21.429 -        val k1 = k.asInstanceOf[A]
  21.430 -        underlying.get(k1) match {
  21.431 -          case Some(v) => underlying -= k1 ; v
  21.432 -          case None => null.asInstanceOf[B]
  21.433 -        }
  21.434 -      }
  21.435 -    }
  21.436 -    
  21.437 -    override def entrySet : ju.Set[ju.Map.Entry[A, B]] = new ju.AbstractSet[ju.Map.Entry[A, B]] {
  21.438 -      def size = self.size
  21.439 -
  21.440 -      def iterator = new ju.Iterator[ju.Map.Entry[A, B]] {
  21.441 -        val ui = underlying.iterator
  21.442 -        var prev : Option[A] = None
  21.443 -        
  21.444 -        def hasNext = ui.hasNext
  21.445 -      
  21.446 -        def next = {
  21.447 -          val (k, v) = ui.next
  21.448 -          prev = Some(k)
  21.449 -          new ju.Map.Entry[A, B] {
  21.450 -            def getKey = k
  21.451 -            def getValue = v
  21.452 -            def setValue(v1 : B) = self.put(k, v1)
  21.453 -            override def equals(other : Any) = other match {
  21.454 -              case e : ju.Map.Entry[_, _] => k == e.getKey && v == e.getValue
  21.455 -              case _ => false
  21.456 -            }
  21.457 -          }
  21.458 -        }
  21.459 -        
  21.460 -        def remove = prev match {
  21.461 -          case Some(k) => val v = self.remove(k.asInstanceOf[AnyRef]) ; prev = None ; v
  21.462 -          case _ => throw new IllegalStateException("next must be called at least once before remove")
  21.463 -        }
  21.464 -      }
  21.465 -    }
  21.466 -  }
  21.467 -  
  21.468 -  case class JMapWrapper[A, B](underlying : ju.Map[A, B]) extends mutable.Map[A, B] with mutable.MapLike[A, B, JMapWrapper[A, B]] {
  21.469 -    override def size = underlying.size
  21.470 -    
  21.471 -    def get(k : A) = {
  21.472 -      val v = underlying.get(k)
  21.473 -      if (v != null)
  21.474 -        Some(v)
  21.475 -      else if(underlying.containsKey(k))
  21.476 -        Some(null.asInstanceOf[B])
  21.477 -      else
  21.478 -        None
  21.479 -    }
  21.480 -
  21.481 -    def +=(kv: (A, B)): this.type = { underlying.put(kv._1, kv._2); this }
  21.482 -    def -=(key: A): this.type = { underlying.remove(key); this }
  21.483 -
  21.484 -    override def put(k : A, v : B): Option[B] = {
  21.485 -      val r = underlying.put(k, v)
  21.486 -      if (r != null) Some(r) else None
  21.487 -    }
  21.488 -      
  21.489 -    override def update(k : A, v : B) { underlying.put(k, v) }
  21.490 -    
  21.491 -    override def remove(k : A): Option[B] = { 
  21.492 -      val r = underlying.remove(k)
  21.493 -      if (r != null) Some(r) else None
  21.494 -    }
  21.495 -
  21.496 -    def iterator = new Iterator[(A, B)] {
  21.497 -      val ui = underlying.entrySet.iterator
  21.498 -      def hasNext = ui.hasNext
  21.499 -      def next = { val e = ui.next ; (e.getKey, e.getValue) }
  21.500 -    }
  21.501 -    
  21.502 -    override def clear = underlying.clear
  21.503 -
  21.504 -    override def empty = JMapWrapper(new ju.HashMap[A, B])
  21.505 -  }
  21.506 -}
    22.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/LinearSeq.scala	Tue Nov 03 13:08:38 2009 +0800
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,43 +0,0 @@
    22.4 -/*                     __                                               *\
    22.5 -**     ________ ___   / /  ___     Scala API                            **
    22.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    22.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    22.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    22.9 -**                          |/                                          **
   22.10 -\*                                                                      */
   22.11 -
   22.12 -// $Id: LinearSeq.scala 19219 2009-10-22 09:43:14Z moors $
   22.13 -
   22.14 -
   22.15 -package org.aiotrade.lib.collection
   22.16 -
   22.17 -import generic._
   22.18 -import mutable.Builder
   22.19 -
   22.20 -/** <p>
   22.21 - *    Class <code>Linear[A]</code> represents linear sequences of elements.
   22.22 - *    For such sequences <code>isEmpty</code>, <code>head</code> and
   22.23 - *    <code>tail</code> are guaranteed to be efficient constant time (or near so)
   22.24 - *    operations.<br/>
   22.25 - *    It does not add any methods to <code>Seq</code> but overrides several
   22.26 - *    methods with optimized implementations.
   22.27 - *  </p>
   22.28 - *
   22.29 - *  @author  Martin Odersky
   22.30 - *  @author  Matthias Zenger
   22.31 - *  @version 1.0, 16/07/2003
   22.32 - *  @since   2.8
   22.33 - */
   22.34 -trait LinearSeq[+A] extends Seq[A] 
   22.35 -                            with GenericTraversableTemplate[A, LinearSeq]
   22.36 -                            with LinearSeqLike[A, LinearSeq[A]] {
   22.37 -  override def companion: GenericCompanion[LinearSeq] = LinearSeq
   22.38 -}
   22.39 -
   22.40 -/**
   22.41 - *  @since 2.8
   22.42 - */
   22.43 -object LinearSeq extends SeqFactory[LinearSeq] {
   22.44 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, LinearSeq[A]] = new GenericCanBuildFrom[A]
   22.45 -  def newBuilder[A]: Builder[A, LinearSeq[A]] = immutable.LinearSeq.newBuilder[A]
   22.46 -}
    23.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/LinearSeqLike.scala	Tue Nov 03 13:08:38 2009 +0800
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,406 +0,0 @@
    23.4 -/*                     __                                               *\
    23.5 -**     ________ ___   / /  ___     Scala API                            **
    23.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    23.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    23.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    23.9 -**                          |/                                          **
   23.10 -\*                                                                      */
   23.11 -
   23.12 -// $Id: LinearSeqLike.scala 19334 2009-10-28 23:04:03Z odersky $
   23.13 -
   23.14 -
   23.15 -package org.aiotrade.lib.collection
   23.16 -import generic._
   23.17 -
   23.18 -import mutable.ListBuffer
   23.19 -import immutable.List
   23.20 -import scala.util.control.Breaks._
   23.21 -
   23.22 -/** Class <code>Linear[A]</code> represents linear sequences of elements.
   23.23 - *  For such sequences `isEmpty`, `head` and `tail` are guaranteed to be
   23.24 - *  efficient constant time (or near so) operations.
   23.25 - *  It does not add any methods to <code>Seq</code> but overrides 
   23.26 - *  several methods with optimized implementations.
   23.27 - * 
   23.28 - *  @author  Martin Odersky
   23.29 - *  @author  Matthias Zenger
   23.30 - *  @version 1.0, 16/07/2003
   23.31 - *  @since   2.8
   23.32 - */
   23.33 -trait LinearSeqLike[+A, +Repr <: LinearSeqLike[A, Repr]] extends SeqLike[A, Repr] { self: Repr =>
   23.34 -
   23.35 -  override protected[this] def thisCollection: LinearSeq[A] = this.asInstanceOf[LinearSeq[A]]
   23.36 -  override protected[this] def toCollection(repr: Repr): LinearSeq[A] = repr.asInstanceOf[LinearSeq[A]]
   23.37 -
   23.38 -  /** Abstract method to be implemented in a subclass */
   23.39 -  def isEmpty: Boolean
   23.40 -
   23.41 -  /** Abstract method to be implemented in a subclass */
   23.42 -  def head: A
   23.43 -
   23.44 -  /** Abstract method to be implemented in a subclass */
   23.45 -  def tail: Repr
   23.46 -  
   23.47 -   /** Returns the number of elements in the linear sequence.
   23.48 -    */	
   23.49 -  def length: Int = {
   23.50 -    var these = self
   23.51 -    var len = 0
   23.52 -    while (!these.isEmpty) {
   23.53 -      len += 1
   23.54 -      these = these.tail
   23.55 -    }
   23.56 -    len
   23.57 -  }
   23.58 -
   23.59 -  /** Returns the <code>n</code>-th element of this linear sequence. The first element
   23.60 -   *  (head of the linear sequence) is at position 0.
   23.61 -   *
   23.62 -   *  @param n index of the element to return
   23.63 -   *  @return  the element at position <code>n</code> in this linear sequence.
   23.64 -   *  @throws Predef.NoSuchElementException if the linear sequence is too short.
   23.65 -   */
   23.66 -  def apply(n: Int): A = drop(n).head
   23.67 -
   23.68 -  /** Returns the elements in the sequence as an iterator
   23.69 -   */
   23.70 -  override def iterator: Iterator[A] = new Iterator[A] {
   23.71 -    var these = self
   23.72 -    def hasNext: Boolean = !these.isEmpty
   23.73 -    def next: A = 
   23.74 -      if (hasNext) {
   23.75 -        val result = these.head; these = these.tail; result
   23.76 -      } else Iterator.empty.next
   23.77 -    override def toList: List[A] = these.toList
   23.78 -  }
   23.79 -
   23.80 -  /** Apply the given function <code>f</code> to each element of this linear sequence
   23.81 -   *  (while respecting the order of the elements).
   23.82 -   *
   23.83 -   *  @param f the treatment to apply to each element.
   23.84 -   */
   23.85 -  override def foreach[B](f: A => B) {
   23.86 -    var these = this
   23.87 -    while (!these.isEmpty) {
   23.88 -      f(these.head)
   23.89 -      these = these.tail
   23.90 -    }
   23.91 -  }
   23.92 -
   23.93 -  /** Tests if the predicate <code>p</code> is satisfied by all elements
   23.94 -   *  in this list.
   23.95 -   *
   23.96 -   *  @param p the test predicate.
   23.97 -   *  @return  <code>true</code> iff all elements of this list satisfy the
   23.98 -   *           predicate <code>p</code>.
   23.99 -   */
  23.100 -  override def forall(p: A => Boolean): Boolean = {
  23.101 -    var these = this
  23.102 -    while (!these.isEmpty) {
  23.103 -      if (!p(these.head)) return false
  23.104 -      these = these.tail
  23.105 -    }
  23.106 -    true
  23.107 -  }
  23.108 -
  23.109 -  /** Tests the existence in this list of an element that satisfies the
  23.110 -   *  predicate <code>p</code>.
  23.111 -   *
  23.112 -   *  @param p the test predicate.
  23.113 -   *  @return  <code>true</code> iff there exists an element in this list that
  23.114 -   *           satisfies the predicate <code>p</code>.
  23.115 -   */
  23.116 -  override def exists(p: A => Boolean): Boolean = {
  23.117 -    var these = this
  23.118 -    while (!these.isEmpty) {
  23.119 -      if (p(these.head)) return true
  23.120 -      these = these.tail
  23.121 -    }
  23.122 -    false
  23.123 -  }
  23.124 -
  23.125 -  /** Count the number of elements in the iterable which satisfy a predicate.
  23.126 -   *
  23.127 -   *  @param p the predicate for which to count
  23.128 -   *  @return  the number of elements satisfying the predicate <code>p</code>.
  23.129 -   */
  23.130 -  override def count(p: A => Boolean): Int = {
  23.131 -    var these = this
  23.132 -    var cnt = 0
  23.133 -    while (!these.isEmpty) {
  23.134 -      if (p(these.head)) cnt += 1
  23.135 -      these = these.tail
  23.136 -    }
  23.137 -    cnt
  23.138 -  }
  23.139 -
  23.140 -  /** Find and return the first element of the list satisfying a
  23.141 -   *  predicate, if any.
  23.142 -   *
  23.143 -   *  @param p the predicate
  23.144 -   *  @return the first element in the list satisfying <code>p</code>,
  23.145 -   *  or <code>None</code> if none exists.
  23.146 -   */
  23.147 -  override def find(p: A => Boolean): Option[A] = {
  23.148 -    var these = this
  23.149 -    while (!these.isEmpty) {
  23.150 -      if (p(these.head)) return Some(these.head)
  23.151 -      these = these.tail
  23.152 -    }
  23.153 -    None
  23.154 -  }
  23.155 -
  23.156 -  /** Combines the elements of this list together using the binary
  23.157 -   *  function <code>f</code>, from left to right, and starting with
  23.158 -   *  the value <code>z</code>.
  23.159 -   *
  23.160 -   *  @return <code>f(... (f(f(z, a<sub>0</sub>), a<sub>1</sub>) ...),
  23.161 -   *          a<sub>n</sub>)</code> if the list is
  23.162 -   *          <code>[a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub>]</code>.
  23.163 -   */
  23.164 -  override def foldLeft[B](z: B)(f: (B, A) => B): B = {
  23.165 -    var acc = z
  23.166 -    var these = this
  23.167 -    while (!these.isEmpty) {
  23.168 -      acc = f(acc, these.head)
  23.169 -      these = these.tail
  23.170 -    }
  23.171 -    acc
  23.172 -  }
  23.173 -
  23.174 -  /** Combines the elements of this list together using the binary
  23.175 -   *  function <code>f</code>, from right to left, and starting with
  23.176 -   *  the value <code>z</code>.
  23.177 -   *
  23.178 -   *  @return <code>f(a<sub>0</sub>, f(a<sub>1</sub>, f(..., f(a<sub>n</sub>, z)...)))</code>
  23.179 -   *          if the list is <code>[a<sub>0</sub>, a1, ..., a<sub>n</sub>]</code>.
  23.180 -   */
  23.181 -  override def foldRight[B](z: B)(f: (A, B) => B): B = 
  23.182 -    if (this.isEmpty) z
  23.183 -    else f(head, tail.foldRight(z)(f))
  23.184 -
  23.185 -  /** Combines the elements of this list together using the binary
  23.186 -   *  operator <code>op</code>, from left to right
  23.187 -   *  @param op  The operator to apply
  23.188 -   *  @return <code>op(... op(a<sub>0</sub>,a<sub>1</sub>), ..., a<sub>n</sub>)</code> 
  23.189 -      if the list has elements
  23.190 -   *          <code>a<sub>0</sub>, a<sub>1</sub>, ..., a<sub>n</sub></code>.
  23.191 -   *  @throws Predef.UnsupportedOperationException if the list is empty.
  23.192 -   */
  23.193 -  override def reduceLeft[B >: A](f: (B, A) => B): B = 
  23.194 -    if (isEmpty) throw new UnsupportedOperationException("empty.reduceLeft")
  23.195 -    else tail.foldLeft[B](head)(f)
  23.196 -
  23.197 -  /** Combines the elements of this iterable object together using the binary
  23.198 -   *  operator <code>op</code>, from right to left
  23.199 -   *  @note Will not terminate for infinite-sized collections.
  23.200 -   *  @param op  The operator to apply
  23.201 -   *
  23.202 -   *  @return <code>a<sub>0</sub> op (... op (a<sub>n-1</sub> op a<sub>n</sub>)...)</code>
  23.203 -   *          if the iterable object has elements <code>a<sub>0</sub>, a<sub>1</sub>, ...,
  23.204 -   *          a<sub>n</sub></code>.
  23.205 -   *
  23.206 -   *  @throws Predef.UnsupportedOperationException if the iterator is empty.
  23.207 -   */
  23.208 -  override def reduceRight[B >: A](op: (A, B) => B): B = 
  23.209 -    if (isEmpty) throw new UnsupportedOperationException("Nil.reduceRight")
  23.210 -    else if (tail.isEmpty) head
  23.211 -    else op(head, tail.reduceRight(op))
  23.212 -  
  23.213 -  /** The last element of this linear sequence.
  23.214 -   *
  23.215 -   *  @throws Predef.NoSuchElementException if the linear sequence is empty.
  23.216 -   */
  23.217 -  override def last: A = {
  23.218 -    if (isEmpty) throw new NoSuchElementException
  23.219 -    var these = this
  23.220 -    var nx = these.tail
  23.221 -    while (!nx.isEmpty) {
  23.222 -      these = nx
  23.223 -      nx = nx.tail
  23.224 -    }
  23.225 -    these.head
  23.226 -  }
  23.227 -  
  23.228 -  override def take(n: Int): Repr = {
  23.229 -    val b = newBuilder
  23.230 -    var i = 0
  23.231 -    var these = repr
  23.232 -    while (!these.isEmpty && i < n) {
  23.233 -      i += 1
  23.234 -      b += these.head
  23.235 -      these = these.tail
  23.236 -    }
  23.237 -    b.result
  23.238 -  }
  23.239 -  
  23.240 -  override def drop(n: Int): Repr = {
  23.241 -    var these: Repr = repr
  23.242 -    var count = n
  23.243 -    while (!these.isEmpty && count > 0) {
  23.244 -      these = these.tail
  23.245 -      count -= 1
  23.246 -    }
  23.247 -    these
  23.248 -  }
  23.249 -
  23.250 -  /** Returns the rightmost <code>n</code> elements from this iterable.
  23.251 -   *  @param n the number of elements to take
  23.252 -   */
  23.253 -  override def dropRight(n: Int): Repr = {
  23.254 -    val b = newBuilder
  23.255 -    var these = this
  23.256 -    var lead = this drop n
  23.257 -    while (!lead.isEmpty) {
  23.258 -      b += these.head
  23.259 -      these = these.tail
  23.260 -      lead = lead.tail
  23.261 -    }
  23.262 -    b.result
  23.263 -  }
  23.264 -
  23.265 -  /** A sub-traversable starting at index `from`
  23.266 -   *  and extending up to (but not including) index `until`.
  23.267 -   *
  23.268 -   *  @note c.slice(from, to)  is equivalent to (but possibly more efficient than)
  23.269 -   *  c.drop(from).take(to - from)
  23.270 -   *
  23.271 -   *  @param from   The index of the first element of the returned subsequence
  23.272 -   *  @param until  The index of the element following the returned subsequence
  23.273 -   *  @note  Might return different results for different runs, unless this traversable is ordered
  23.274 -   */
  23.275 -  override def slice(from: Int, until: Int): Repr = {
  23.276 -    val b = newBuilder 
  23.277 -    var i = from
  23.278 -    var these = this drop from
  23.279 -    while (i < until && !these.isEmpty) {
  23.280 -      b += these.head
  23.281 -      these = these.tail
  23.282 -      i += 1
  23.283 -    }
  23.284 -    b.result
  23.285 -  }
  23.286 -
  23.287 -  /** Returns the longest prefix of this traversable whose elements satisfy
  23.288 -   *  the predicate <code>p</code>.
  23.289 -   *
  23.290 -   *  @param p the test predicate.
  23.291 -   *  @note  Might return different results for different runs, unless this traversable is ordered
  23.292 -   */
  23.293 -  override def takeWhile(p: A => Boolean): Repr = {
  23.294 -    val b = newBuilder
  23.295 -    var these = this
  23.296 -    while (!these.isEmpty && p(these.head)) {
  23.297 -      b += these.head
  23.298 -      these = these.tail
  23.299 -    }
  23.300 -    b.result
  23.301 -  }
  23.302 -
  23.303 -  /** Returns a pair consisting of the longest prefix of the linear sequence whose
  23.304 -   *  elements all satisfy the given predicate, and the rest of the linear sequence.
  23.305 -   *
  23.306 -   *  @param p the test predicate
  23.307 -   */
  23.308 -  override def span(p: A => Boolean): (Repr, Repr) = {
  23.309 -    var these: Repr = repr
  23.310 -    val b = newBuilder
  23.311 -    while (!these.isEmpty && p(these.head)) {
  23.312 -      b += these.head
  23.313 -      these = these.tail
  23.314 -    }
  23.315 -    (b.result, these)
  23.316 -  }  
  23.317 -
  23.318 -  /** Returns <code>true</code> iff the other linear sequence contains the
  23.319 -   *  same elements as this one.
  23.320 -   *
  23.321 -   *  @note will not terminate for two infinite-sized linear sequences.
  23.322 -   *  @param that  the other linear sequence
  23.323 -   */
  23.324 -  override def sameElements[B >: A](that: Iterable[B]): Boolean = that match {
  23.325 -    case that1: LinearSeq[_] =>
  23.326 -      var these = this
  23.327 -      var those = that1
  23.328 -      while (!these.isEmpty && !those.isEmpty && these.head == those.head) {
  23.329 -        these = these.tail
  23.330 -        those = those.tail
  23.331 -      }
  23.332 -      these.isEmpty && those.isEmpty
  23.333 -    case _ =>
  23.334 -      super.sameElements(that)
  23.335 -  }
  23.336 -  
  23.337 -  // Overridden methods from Seq
  23.338 -
  23.339 -  /** Result of comparing <code>length</code> with operand <code>len</code>.
  23.340 -   *  returns <code>x</code> where
  23.341 -   *  <code>x &lt; 0</code>    iff    <code>this.length &lt; len</code>
  23.342 -   *  <code>x == 0</code>   iff    <code>this.length == len</code>
  23.343 -   *  <code>x &gt; 0</code>    iff    <code>this.length &gt; len</code>.
  23.344 -   */
  23.345 -  override def lengthCompare(len: Int): Int =  {
  23.346 -    var i = 0
  23.347 -    var these = self
  23.348 -    while (!these.isEmpty && i <= len) {
  23.349 -      i += 1
  23.350 -      these = these.tail
  23.351 -    }
  23.352 -    i - len
  23.353 -  }
  23.354 -
  23.355 -  /** Is this partial function defined for the index <code>x</code>?
  23.356 -   */
  23.357 -  override def isDefinedAt(x: Int): Boolean = x >= 0 && lengthCompare(x) > 0
  23.358 -
  23.359 -  /** Returns length of longest segment starting from a start index `from`
  23.360 -   *  such that every element of the segment satisfies predicate `p`.
  23.361 -   *  @note may not terminate for infinite-sized collections.
  23.362 -   *  @param  p the predicate
  23.363 -   *  @param  from  the start index
  23.364 -   */
  23.365 -  override def segmentLength(p: A => Boolean, from: Int): Int = {
  23.366 -    var i = 0
  23.367 -    var these = this drop from
  23.368 -    while (!these.isEmpty && p(these.head)) {
  23.369 -      i += 1
  23.370 -      these = these.tail
  23.371 -    }
  23.372 -    i
  23.373 -  }
  23.374 -
  23.375 -  /** Returns index of the first element starting from a start index
  23.376 -   *  satisying a predicate, or -1, if none exists.
  23.377 -   *
  23.378 -   *  @note may not terminate for infinite-sized linear sequences.
  23.379 -   *  @param  p the predicate
  23.380 -   *  @param  from  the start index
  23.381 -   */
  23.382 -  override def indexWhere(p: A => Boolean, from: Int): Int = {
  23.383 -    var i = from
  23.384 -    var these = this drop from
  23.385 -    while (!these.isEmpty && !p(these.head)) {
  23.386 -      i += 1
  23.387 -      these = these.tail
  23.388 -    }
  23.389 -    if (these.isEmpty) -1 else i
  23.390 -  }
  23.391 -
  23.392 -  /** Returns index of the last element satisying a predicate, or -1, if none exists.
  23.393 -   *
  23.394 -   *  @param  p the predicate
  23.395 -   *  @return   the index of the last element satisfying <code>p</code>,
  23.396 -   *            or -1 if such an element does not exist
  23.397 -   */
  23.398 -  override def lastIndexWhere(p: A => Boolean, end: Int): Int = {
  23.399 -    var i = 0
  23.400 -    var these = this
  23.401 -    var last = -1
  23.402 -    while (!these.isEmpty && i <= end) {
  23.403 -      if (p(these.head)) last = i
  23.404 -      these = these.tail
  23.405 -      i += 1
  23.406 -    }
  23.407 -    last
  23.408 -  }
  23.409 -}
    24.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/Map.scala	Tue Nov 03 13:08:38 2009 +0800
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,54 +0,0 @@
    24.4 -/*                     __                                               *\
    24.5 -**     ________ ___   / /  ___     Scala API                            **
    24.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    24.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    24.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    24.9 -**                          |/                                          **
   24.10 -\*                                                                      */
   24.11 -
   24.12 -// $Id: Map.scala 19190 2009-10-21 13:24:41Z moors $
   24.13 -
   24.14 -
   24.15 -package org.aiotrade.lib.collection
   24.16 -
   24.17 -import generic._
   24.18 -
   24.19 -/** <p>
   24.20 - *    A map from keys of type <code>A</code> to values of type <code>B</code>.
   24.21 - *    To implement a concrete map, you need to provide implementations of the
   24.22 - *    following methods (where <code>This</code> is the type of the map in question):
   24.23 - *  </p><pre>
   24.24 - *    <b>def</b> get(key: A): Option[B]
   24.25 - *    <b>def</b> iterator: Iterator[(A, B)]
   24.26 - *    <b>def</b> + [B1 >: B](kv: (A, B1)): This
   24.27 - *    <b>def</b> -(key: A): This</pre>
   24.28 - *  <p>
   24.29 - *    If you wish that methods like, take, drop, filter return the same kind
   24.30 - *    of map, you should also override:
   24.31 - *  </p><pre>
   24.32 - *    <b>def</b> empty: This</pre>
   24.33 - *  <p>
   24.34 - *    It might also be a good idea to override methods <code>foreach</code>
   24.35 - *    and <code>size</code> for efficiency.
   24.36 - *  </p>
   24.37 - *
   24.38 - * @note If you do not have specific implementations for `add` and `-` in mind,
   24.39 - *       you might consider inheriting from <code>DefaultMap</code> instead.
   24.40 - *
   24.41 - * @note Of you additions and mutations return the same kind of map as the map
   24.42 - *       you are defining, you should inherit from <code>MapLike</code> as well.
   24.43 - *
   24.44 - * @since 1
   24.45 - */
   24.46 -trait Map[A, +B] extends Iterable[(A, B)] with MapLike[A, B, Map[A, B]] {
   24.47 -  def empty: Map[A, B] = Map.empty
   24.48 -}
   24.49 -
   24.50 -/* Factory object for `Map` class
   24.51 - *
   24.52 - * @since 2.5
   24.53 - */
   24.54 -object Map extends ImmutableMapFactory[immutable.Map] {
   24.55 -  def empty[A, B]: immutable.Map[A, B] = immutable.Map.empty
   24.56 -  implicit def canBuildFrom[A, B]: CanBuildFrom[Coll, (A, B), Map[A, B]] = new MapCanBuildFrom[A, B]
   24.57 -}
    25.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/MapLike.scala	Tue Nov 03 13:08:38 2009 +0800
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,298 +0,0 @@
    25.4 -/*                     __                                               *\
    25.5 -**     ________ ___   / /  ___     Scala API                            **
    25.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    25.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    25.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    25.9 -**                          |/                                          **
   25.10 -\*                                                                      */
   25.11 -
   25.12 -// $Id: MapLike.scala 19334 2009-10-28 23:04:03Z odersky $
   25.13 -
   25.14 -package org.aiotrade.lib.collection
   25.15 -
   25.16 -import generic._
   25.17 -import mutable.{Builder, StringBuilder, MapBuilder}
   25.18 -import PartialFunction._
   25.19 -
   25.20 -/** <p>
   25.21 - *    A generic template for maps from keys of type <code>A</code> to values
   25.22 - *    of type <code>B</code>.<br/>
   25.23 - *    To implement a concrete map, you need to provide implementations of the
   25.24 - *    following methods (where <code>This</code> is the type of the map in
   25.25 - *    question):
   25.26 - *  </p>
   25.27 - *  <pre>
   25.28 - *    <b>def</b> get(key: A): Option[B]
   25.29 - *    <b>def</b> iterator: Iterator[(A, B)]
   25.30 - *    <b>def</b> + [B1 >: B](kv: (A, B1)): This
   25.31 - *    <b>def</b> -(key: A): This</pre>
   25.32 - *  <p>
   25.33 - *    If you wish that methods <code>like</code>, <code>take</code>, <code>drop</code>,
   25.34 - *    <code>filter</code> return the same kind of map, you should also override:
   25.35 - *  </p>
   25.36 - *  <pre>
   25.37 - *   <b>def</b> empty: This</pre>
   25.38 - *  <p>
   25.39 - *    It is also good idea to override methods <code>foreach</code> and
   25.40 - *    <code>size</code> for efficiency.
   25.41 - *  </p>
   25.42 - *
   25.43 - *  @author  Martin Odersky
   25.44 - *  @version 2.8
   25.45 - *  @since   2.8
   25.46 - */
   25.47 -trait MapLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]]
   25.48 -  extends PartialFunction[A, B] 
   25.49 -     with IterableLike[(A, B), This] 
   25.50 -     with Subtractable[A, This] { 
   25.51 -self =>
   25.52 -
   25.53 -  /* The empty map of the dame type as this map */
   25.54 -  def empty: This
   25.55 -       
   25.56 -  /** A common implementation of `newBuilder` for all maps in terms of `empty`.
   25.57 -   *  Overridden for mutable maps in `mutable.MapLike`.
   25.58 -   */
   25.59 -  override protected[this] def newBuilder: Builder[(A, B), This] = new MapBuilder[A, B, This](empty)
   25.60 -
   25.61 -  /** Check if this map maps <code>key</code> to a value and return the
   25.62 -   *  value as an option if it exists, None if not.
   25.63 -   *
   25.64 -   *  @param      key the key of the mapping of interest.
   25.65 -   *  @return     the value of the mapping as an option, if it exists, or None.
   25.66 -   */
   25.67 -  def get(key: A): Option[B]
   25.68 -
   25.69 -  /** An iterator yielding all key/value mappings of this map. */
   25.70 -  def iterator: Iterator[(A, B)]
   25.71 -    
   25.72 -  /** Add a key/value pair to this map, returning a new map. 
   25.73 -   *  @param    kv the key/value pair
   25.74 -   *  @return   A new map with the new binding added to this map
   25.75 -   */
   25.76 -  def + [B1 >: B] (kv: (A, B1)): Map[A, B1]
   25.77 -
   25.78 -  /** Removes a key from this map, returning a new map
   25.79 -   *  @param    key the key to be removed
   25.80 -   *  @return   A new map without a binding for <code>key</code>
   25.81 -   */
   25.82 -  def - (key: A): This
   25.83 -
   25.84 -  /** Is this an empty map?
   25.85 -   *
   25.86 -   *  @return <code>true</code> iff the map does not contain any key/value mapping.
   25.87 -   */
   25.88 -  override def isEmpty: Boolean = size == 0
   25.89 -
   25.90 -  /**  Check if this map maps <code>key</code> to a value.
   25.91 -   *   Return that value if it exists, otherwise return <code>default</code>.
   25.92 -   *   @param   key      the key.
   25.93 -   *   @param   default  a computation that yields a default value in case no binding for the key is
   25.94 -   *                     found in the map.
   25.95 -   */
   25.96 -  def getOrElse[B1 >: B](key: A, default: => B1): B1 = get(key) match {
   25.97 -    case Some(v) => v
   25.98 -    case None => default 
   25.99 -  }
  25.100 -
  25.101 -  /** Retrieve the value which is associated with the given key. This
  25.102 -   *  method throws an exception if there is no mapping from the given
  25.103 -   *  key to a value.
  25.104 -   *
  25.105 -   *  @param  key the key
  25.106 -   *  @return     the value associated with the given key.
  25.107 -   */
  25.108 -  def apply(key: A): B = get(key) match {
  25.109 -    case None => default(key)
  25.110 -    case Some(value) => value
  25.111 -  }
  25.112 -
  25.113 -  /** Is the given key mapped to a value by this map?
  25.114 -   *
  25.115 -   *  @param key the key
  25.116 -   *  @return    <code>true</code> iff there is a mapping for key in this map
  25.117 -   */
  25.118 -  def contains(key: A): Boolean = get(key) match {
  25.119 -    case None => false
  25.120 -    case Some(_) => true
  25.121 -  }
  25.122 -
  25.123 -  /** Does this map contain a mapping from the given key to a value?
  25.124 -   *
  25.125 -   *  @param key the key
  25.126 -   *  @return    <code>true</code> iff there is a mapping for key in this map
  25.127 -   */
  25.128 -  def isDefinedAt(key: A) = contains(key)
  25.129 -
  25.130 -  /** @return the keys of this map as a set. */
  25.131 -  def keySet: Set[A] = new DefaultKeySet
  25.132 -
  25.133 -  protected class DefaultKeySet extends Set[A] {
  25.134 -    def contains(key : A) = self.contains(key)
  25.135 -    def iterator = self.iterator.map(_._1)
  25.136 -    def + (elem: A): Set[A] = (Set[A]() ++ this + elem).asInstanceOf[Set[A]] // !!! concrete overrides abstract problem
  25.137 -    def - (elem: A): Set[A] = (Set[A]() ++ this - elem).asInstanceOf[Set[A]] // !!! concrete overrides abstract problem
  25.138 -    override def size = self.size
  25.139 -    override def foreach[C](f: A => C) = for ((k, v) <- self) f(k)
  25.140 -  }
  25.141 -
  25.142 -  /** Creates an iterator for all keys.
  25.143 -   *
  25.144 -   *  @return an iterator over all keys.
  25.145 -   */
  25.146 -  def keysIterator: Iterator[A] = new Iterator[A] {
  25.147 -    val iter = self.iterator
  25.148 -    def hasNext = iter.hasNext
  25.149 -    def next = iter.next._1
  25.150 -  }
  25.151 -
  25.152 -  /** Creates an iterator for all keys.
  25.153 -   *
  25.154 -   *  @return an iterator over all keys.
  25.155 -   */
  25.156 -  @deprecated("use `keysIterator' instead")
  25.157 -  def keys: Iterator[A] = keysIterator
  25.158 -
  25.159 -  /** @return the values of this map as an iterable.
  25.160 -   */
  25.161 -  def valueIterable: Iterable[B] = new DefaultValuesIterable
  25.162 -
  25.163 -  protected class DefaultValuesIterable extends Iterable[B] {
  25.164 -    def iterator = self.iterator.map(_._2)
  25.165 -    override def size = self.size
  25.166 -    override def foreach[C](f: B => C) = for ((k, v) <- self) f(v)
  25.167 -  }
  25.168 -
  25.169 -  /** Creates an iterator for a contained values.
  25.170 -   *
  25.171 -   *  @return an iterator over all values.
  25.172 -   */
  25.173 -  def valuesIterator: Iterator[B] = new Iterator[B] {
  25.174 -    val iter = self.iterator
  25.175 -    def hasNext = iter.hasNext
  25.176 -    def next = iter.next._2
  25.177 -  }
  25.178 -
  25.179 -  /** Creates an iterator for a contained values.
  25.180 -   *
  25.181 -   *  @return an iterator over all values.
  25.182 -   */
  25.183 -  @deprecated("use `valuesIterator' instead")
  25.184 -  def values: Iterator[B] = valuesIterator
  25.185 -
  25.186 -  /** The default value for the map, returned when a key is not found
  25.187 -   *  The method implemented here yields an error,
  25.188 -   *  but it might be overridden in subclasses.
  25.189 -   *
  25.190 -   *  @param key the given key value
  25.191 -   *  @throws Predef.NoSuchElementException
  25.192 -   */
  25.193 -  def default(key: A): B =
  25.194 -    throw new NoSuchElementException("key not found: " + key)
  25.195 -    
  25.196 -  /** A map view consisting only of those key value pairs where the key satisfies a given
  25.197 -   *  predicate `p`.
  25.198 -   */
  25.199 -  def filterKeys(p: A => Boolean) = new DefaultMap[A, B] {
  25.200 -    override def foreach[C](f: ((A, B)) => C): Unit = for (kv <- self) if (p(kv._1)) f(kv)
  25.201 -    def iterator = self.iterator.filter(kv => p(kv._1))
  25.202 -    override def contains(key: A) = self.contains(key) && p(key)
  25.203 -    def get(key: A) = if (!p(key)) None else self.get(key)
  25.204 -  }    
  25.205 -
  25.206 -  /** A map view resulting from applying a given function `f` to each value
  25.207 -   *  associated with a key in this map.
  25.208 -   */
  25.209 -  def mapValues[C](f: B => C) = new DefaultMap[A, C] {
  25.210 -    override def foreach[D](g: ((A, C)) => D): Unit = for ((k, v) <- self) g((k, f(v)))
  25.211 -    def iterator = for ((k, v) <- self.iterator) yield (k, f(v))
  25.212 -    override def size = self.size
  25.213 -    override def contains(key: A) = self.contains(key)
  25.214 -    def get(key: A) = self.get(key).map(f)
  25.215 -  }
  25.216 -
  25.217 -  @deprecated("use `mapValues' instead") def mapElements[C](f: B => C) = mapValues(f)
  25.218 -
  25.219 -  // The following 5 operations (updated, two times +, two times ++) should really be
  25.220 -  // generic, returning This[B]. We need better covariance support to express that though.
  25.221 -  // So right now we do the brute force approach of code duplication.
  25.222 -
  25.223 -  /** A new immutable map containing updating this map with a given key/value mapping. 
  25.224 -   *  @param    key the key
  25.225 -   *  @param    value the value
  25.226 -   *  @return   A new map with the new key/value mapping 
  25.227 -   */
  25.228 -  def updated [B1 >: B](key: A, value: B1): Map[A, B1] = this + ((key, value))
  25.229 -
  25.230 -  /** Adds two or more elements to this collection and returns
  25.231 -   *  a new collection.
  25.232 -   *
  25.233 -   *  @param elem1 the first element to add.
  25.234 -   *  @param elem2 the second element to add.
  25.235 -   *  @param elems the remaining elements to add.
  25.236 -   */
  25.237 -  def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): Map[A, B1] =
  25.238 -    this + elem1 + elem2 ++ elems
  25.239 -
  25.240 -  /** Adds a number of elements provided by a traversable object
  25.241 -   *  and returns a new collection with the added elements.
  25.242 -   *
  25.243 -   *  @param elems     the traversable object.
  25.244 -   */
  25.245 -  def ++[B1 >: B](elems: Traversable[(A, B1)]): Map[A, B1] = 
  25.246 -    ((repr: Map[A, B1]) /: elems) (_ + _)
  25.247 -
  25.248 -  /** Adds a number of elements provided by an iterator
  25.249 -   *  and returns a new collection with the added elements.
  25.250 -   *
  25.251 -   *  @param iter   the iterator
  25.252 -   */
  25.253 -  def ++[B1 >: B] (iter: Iterator[(A, B1)]): Map[A, B1] = 
  25.254 -    ((repr: Map[A, B1]) /: iter) (_ + _)
  25.255 -
  25.256 -  /** Creates a string representation for this map.
  25.257 -   *
  25.258 -   *  @return    a string showing all mappings
  25.259 -   */
  25.260 -  override def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder =
  25.261 -    this.iterator.map { case (k, v) => k+" -> "+v }.addString(b, start, sep, end)
  25.262 -
  25.263 -  /** Defines the prefix of this object's <code>toString</code> representation.
  25.264 -   *  !!! todo: remove stringPrefix overrides where possible
  25.265 -   */
  25.266 -  override def stringPrefix: String = "Map"
  25.267 -
  25.268 -  /** Need to override string, so that it's not the Function1's string that gets mixed in.
  25.269 -   */
  25.270 -  override def toString = super[IterableLike].toString
  25.271 -  
  25.272 -  override def hashCode() = this map (_.hashCode) sum
  25.273 -  
  25.274 -  /** Compares two maps structurally; i.e. checks if all mappings
  25.275 -   *  contained in this map are also contained in the other map,
  25.276 -   *  and vice versa.
  25.277 -   *
  25.278 -   *  @param that the other map
  25.279 -   *  @return     <code>true</code> iff both maps contain exactly the
  25.280 -   *              same mappings.
  25.281 -   */
  25.282 -  override def equals(that: Any): Boolean = that match {
  25.283 -    case that: Map[b, _] => 
  25.284 -      (this eq that) ||
  25.285 -      (that canEqual this) &&
  25.286 -      (this.size == that.size) && {
  25.287 -      try {
  25.288 -        this forall { 
  25.289 -          case (k, v) => that.get(k.asInstanceOf[b]) match {
  25.290 -            case Some(`v`) => true
  25.291 -            case _ => false
  25.292 -          }
  25.293 -        }
  25.294 -      } catch { 
  25.295 -        case ex: ClassCastException => 
  25.296 -          println("calss cast "); false 
  25.297 -      }}
  25.298 -    case _ =>
  25.299 -      false
  25.300 -  }
  25.301 -}
    26.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/MapProxy.scala	Tue Nov 03 13:08:38 2009 +0800
    26.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.3 @@ -1,23 +0,0 @@
    26.4 -/*                     __                                               *\
    26.5 -**     ________ ___   / /  ___     Scala API                            **
    26.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    26.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    26.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    26.9 -**                          |/                                          **
   26.10 -\*                                                                      */
   26.11 -
   26.12 -// $Id: MapProxy.scala 18799 2009-09-26 15:19:40Z stepancheg $
   26.13 -
   26.14 -
   26.15 -package org.aiotrade.lib.collection
   26.16 -
   26.17 -/** This is a simple wrapper class for <a href="Map.html"
   26.18 - *  target="contentFrame"><code>scala.collection.Map</code></a>.
   26.19 - *  It is most useful for assembling customized map abstractions
   26.20 - *  dynamically using object composition and forwarding.
   26.21 - *
   26.22 - *  @author  Matthias Zenger
   26.23 - *  @version 1.0, 21/07/2003
   26.24 - *  @since   1
   26.25 - */
   26.26 -trait MapProxy[A, +B] extends Map[A, B] with MapProxyLike[A, B, Map[A, B]]
    27.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/MapProxyLike.scala	Tue Nov 03 13:08:38 2009 +0800
    27.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.3 @@ -1,54 +0,0 @@
    27.4 -/*                     __                                               *\
    27.5 -**     ________ ___   / /  ___     Scala API                            **
    27.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    27.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    27.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    27.9 -**                          |/                                          **
   27.10 -\*                                                                      */
   27.11 -
   27.12 -package org.aiotrade.lib.collection
   27.13 -
   27.14 -import generic._
   27.15 -
   27.16 -// Methods could be printed by  cat MapLike.scala | egrep '^  (override )?def'
   27.17 -
   27.18 -/** This trait implements a proxy for iterable objects. It forwards
   27.19 - *  all calls to a different iterable object
   27.20 - *
   27.21 - *  @author  Martin Odersky
   27.22 - *  @version 2.8
   27.23 - *  @since   2.8
   27.24 - */
   27.25 -trait MapProxyLike[A, +B, +This <: MapLike[A, B, This] with Map[A, B]]
   27.26 -      extends MapLike[A, B, This]
   27.27 -      with IterableProxyLike[(A, B), This]
   27.28 -{  
   27.29 -  // def empty: This
   27.30 -  // def + [B1 >: B] (kv: (A, B1)): Map[A, B1]
   27.31 -  // def - (key: A): This
   27.32 -  
   27.33 -  override def get(key: A): Option[B] = self.get(key)
   27.34 -  override def iterator: Iterator[(A, B)] = self.iterator
   27.35 -  override def isEmpty: Boolean = self.isEmpty
   27.36 -  override def getOrElse[B1 >: B](key: A, default: => B1): B1 = self.getOrElse(key, default)
   27.37 -  override def apply(key: A): B = self.apply(key)
   27.38 -  override def contains(key: A): Boolean = self.contains(key)
   27.39 -  override def isDefinedAt(key: A) = self.isDefinedAt(key)
   27.40 -  override def keySet: Set[A] = self.keySet
   27.41 -  override def keysIterator: Iterator[A] = self.keysIterator
   27.42 -  override def keys: Iterator[A] = self.keysIterator
   27.43 -  override def valueIterable: Iterable[B] = self.valueIterable
   27.44 -  override def valuesIterator: Iterator[B] = self.valuesIterator
   27.45 -  override def values: Iterator[B] = self.valuesIterator
   27.46 -  override def default(key: A): B = self.default(key)
   27.47 -  override def filterKeys(p: A => Boolean) = self.filterKeys(p)
   27.48 -  override def mapValues[C](f: B => C) = self.mapValues(f)
   27.49 -  
   27.50 -  // override def updated [B1 >: B](key: A, value: B1) = self + ((key, value))
   27.51 -  // override def + [B1 >: B](elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *) = self.+(elem1, elem2, elems: _*)
   27.52 -  // override def ++[B1 >: B](elems: Traversable[(A, B1)]) = self.++(elems)
   27.53 -  // override def ++[B1 >: B](iter: Iterator[(A, B1)]) = self.++(iter)
   27.54 -  
   27.55 -  override def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder =
   27.56 -    self.addString(b, start, sep, end)
   27.57 -}
    28.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/RollbackIterator.scala.disabled	Tue Nov 03 13:08:38 2009 +0800
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,88 +0,0 @@
    28.4 -/*                     __                                               *\
    28.5 -**     ________ ___   / /  ___     Scala API                            **
    28.6 -**    / __/ __// _ | / /  / _ |    (c) 2007-2009, LAMP/EPFL             **
    28.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    28.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    28.9 -**                          |/                                          **
   28.10 -\*                                                                      */
   28.11 -
   28.12 -// $Id: RollbackIterator.scala.disabled 18799 2009-09-26 15:19:40Z stepancheg $
   28.13 -
   28.14 -package org.aiotrade.lib.collection
   28.15 -
   28.16 -import scala.collection.mutable.{ArrayBuffer}
   28.17 -
   28.18 -/** Rollback iterators are buffered iterators which allow for unbounded rollbacks
   28.19 - *
   28.20 - *  @author  Sean McDirmid
   28.21 - *  @since   2.5
   28.22 - */
   28.23 -class RollbackIterator[+A](underlying: Iterator[A]) extends BufferedIterator.Default[A] {
   28.24 -  private[this] var rollback: ArrayBuffer[A] = null
   28.25 -  protected def fill(sz: Int): Seq[A] =
   28.26 -    if (underlying.hasNext) underlying.next :: Nil else Nil
   28.27 -
   28.28 -  override def next: A = {
   28.29 -    val ret = super.next
   28.30 -    if (rollback != null) rollback += ret
   28.31 -    ret
   28.32 -  }
   28.33 -
   28.34 -  private def initRollback =
   28.35 -    if (rollback == null) {
   28.36 -      rollback = new ArrayBuffer[A]
   28.37 -      None
   28.38 -    }
   28.39 -    else Some(rollback.length)
   28.40 -
   28.41 -  /** will rollback all elements iterated during 
   28.42 -   *  <code>f</code>'s execution if <code>f</code> return false 
   28.43 -   */
   28.44 -  def tryRead[T](f: => Option[T]): Option[T] = {
   28.45 -    val oldLength = initRollback
   28.46 -    var g : Option[T] = None
   28.47 -    try {
   28.48 -      g = f
   28.49 -    } finally {
   28.50 -      if (g.isEmpty) {
   28.51 -        //putBack(rollback(0))
   28.52 -        val sz = oldLength.getOrElse(0)
   28.53 -        val i = rollback.drop(sz).reverse.iterator
   28.54 -        while (i.hasNext) putBack(i.next)
   28.55 -        if (oldLength.isEmpty) rollback = null          
   28.56 -        else rollback.reduceToSize(sz)
   28.57 -      }
   28.58 -    }
   28.59 -    if (!g.isEmpty && oldLength.isEmpty) 
   28.60 -      rollback = null
   28.61 -    g
   28.62 -
   28.63 -  }
   28.64 -  /** remembers elements iterated over during <code>g</code>'s execution
   28.65 -   *  and provides these elements to the result of <code>g</code>'s execution
   28.66 -   */
   28.67 -  def remember[T](g: => (Seq[A] => T)): T = {
   28.68 -    val oldLength = initRollback
   28.69 -    var in: Seq[A] = Nil
   28.70 -    val f = try {
   28.71 -      g
   28.72 -    } finally {
   28.73 -      in = rollback.drop(oldLength.getOrElse(0))
   28.74 -      if (oldLength.isEmpty) rollback = null
   28.75 -    }
   28.76 -    f(in)
   28.77 -  }
   28.78 -
   28.79 -  /** returns true if any elements are iterated over during <code>f</code>'s execution 
   28.80 -   */
   28.81 -  def read(f: => Unit): Boolean = remember[Boolean] {
   28.82 -    f; seq => !seq.isEmpty
   28.83 -  }
   28.84 -
   28.85 -  /** if elements of <code>seq</code> will be iterated over next in this iterator,
   28.86 -   *  returns true and iterates over these elements
   28.87 -   */
   28.88 -  override def readIfStartsWith(seq : Seq[Any]) : Boolean = 
   28.89 -    !tryRead{if (seq.forall(a => hasNext && next == a)) Some(()) else None}.isEmpty
   28.90 -
   28.91 -}
    29.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/Seq.scala	Tue Nov 03 13:08:38 2009 +0800
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,62 +0,0 @@
    29.4 -/*                     __                                               *\
    29.5 -**     ________ ___   / /  ___     Scala API                            **
    29.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    29.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    29.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    29.9 -**                          |/                                          **
   29.10 -\*                                                                      */
   29.11 -
   29.12 -// $Id: Seq.scala 19219 2009-10-22 09:43:14Z moors $
   29.13 -
   29.14 -
   29.15 -package org.aiotrade.lib.collection
   29.16 -
   29.17 -import generic._
   29.18 -import mutable.Builder
   29.19 -
   29.20 -/** <p>
   29.21 - *    Class <code>Seq[A]</code> represents sequences of elements
   29.22 - *    of type <code>A</code>.<br/>
   29.23 - *    It adds the following methods to class <code>Iterable</code>:
   29.24 - *    <code>length</code>, <code>lengthCompare</code>, <code>apply</code>,
   29.25 - *    <code>isDefinedAt</code>, <code>segmentLength</code>,
   29.26 - *    <code>prefixLength</code>, <code>indexWhere</code>, <code>indexOf</code>,
   29.27 - *    <code>lastIndexWhere</code>, <code>lastIndexOf</code>, <code>reverse</code>,
   29.28 - *    <code>reverseIterator</code>, <code>startsWith</code>,
   29.29 - *    <code>endsWith</code>, <code>indexOfSeq</code>.
   29.30 - *  </p>
   29.31 - *
   29.32 - *  @author  Martin Odersky
   29.33 - *  @author  Matthias Zenger
   29.34 - *  @version 1.0, 16/07/2003
   29.35 - */
   29.36 -trait Seq[+A] extends PartialFunction[Int, A] 
   29.37 -                      with Iterable[A] 
   29.38 -                      with GenericTraversableTemplate[A, Seq]
   29.39 -                      with SeqLike[A, Seq[A]] {
   29.40 -  override def companion: GenericCompanion[Seq] = Seq
   29.41 -}
   29.42 -
   29.43 -/** Factory object for <code>Seq</code> trait.
   29.44 - *
   29.45 - *  @author  Martin Odersky
   29.46 - *  @version 2.8
   29.47 - */
   29.48 -object Seq extends SeqFactory[Seq] {
   29.49 -
   29.50 -  private[collection] val hashSeed = "Seq".hashCode
   29.51 -  
   29.52 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Seq[A]] = new GenericCanBuildFrom[A]
   29.53 -  def newBuilder[A]: Builder[A, Seq[A]] = immutable.Seq.newBuilder[A]
   29.54 -  
   29.55 -  @deprecated("use View instead")
   29.56 -  type Projection[A] = SeqView[A, Coll] 
   29.57 -  
   29.58 -  @deprecated("use Seq(value) instead")
   29.59 -  def singleton[A](value: A) = Seq(value) 
   29.60 -
   29.61 -  /** Builds a singleton sequence. */
   29.62 -  @deprecated("use <code>Seq(x)</code> instead.")
   29.63 -  def single[A](x: A) = singleton(x)
   29.64 -}
   29.65 -
    30.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SeqLike.scala	Tue Nov 03 13:08:38 2009 +0800
    30.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.3 @@ -1,638 +0,0 @@
    30.4 -/*                     __                                               *\
    30.5 -**     ________ ___   / /  ___     Scala API                            **
    30.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    30.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    30.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    30.9 -**                          |/                                          **
   30.10 -\*                                                                      */
   30.11 -
   30.12 -// $Id: SeqLike.scala 19353 2009-10-30 07:51:19Z rompf $
   30.13 -
   30.14 -
   30.15 -package org.aiotrade.lib.collection
   30.16 -import generic._
   30.17 -import mutable.{ListBuffer, HashMap, GenericArray}
   30.18 -import immutable.{List, Range}
   30.19 -import annotation.experimental
   30.20 -
   30.21 -// import immutable.{List, Nil, ::}
   30.22 -import generic._
   30.23 -
   30.24 -/** Contains a KMP implementation, based on the undoubtedly reliable wikipedia entry.
   30.25 - *
   30.26 - *  @author paulp
   30.27 - *  @since  2.8
   30.28 - */
   30.29 -object SeqLike {
   30.30 -
   30.31 -  private def KMP[B](S: Seq[B], W: Seq[B]): Option[Int] = {
   30.32 -    // trivial cases
   30.33 -    if (W.isEmpty) return Some(0)
   30.34 -    else if (W drop 1 isEmpty) return (S indexOf W(0)) match {
   30.35 -      case -1 => None
   30.36 -      case x  => Some(x)
   30.37 -    }
   30.38 -    
   30.39 -    val T: Array[Int] = {
   30.40 -      val arr = new Array[Int](W.length)
   30.41 -      var pos = 2
   30.42 -      var cnd = 0
   30.43 -      arr(0) = -1
   30.44 -      arr(1) = 0
   30.45 -      while (pos < W.length) {
   30.46 -        if (W(pos - 1) == W(cnd)) {
   30.47 -          arr(pos) = cnd + 1
   30.48 -          pos += 1
   30.49 -          cnd += 1
   30.50 -        }
   30.51 -        else if (cnd > 0) {
   30.52 -          cnd = arr(cnd)
   30.53 -        }
   30.54 -        else {
   30.55 -          arr(pos) = 0
   30.56 -          pos += 1
   30.57 -        }
   30.58 -      }
   30.59 -      arr
   30.60 -    }
   30.61 -    
   30.62 -    var m, i = 0
   30.63 -    def mi = m + i
   30.64 -    
   30.65 -    while (mi < S.length) {
   30.66 -      if (W(i) == S(mi)) {
   30.67 -        i += 1
   30.68 -        if (i == W.length)
   30.69 -          return Some(m)
   30.70 -      }
   30.71 -      else {
   30.72 -        m = mi - T(i)
   30.73 -        if (i > 0)
   30.74 -          i = T(i)
   30.75 -      }
   30.76 -    }
   30.77 -    None
   30.78 -  }
   30.79 -
   30.80 -  def indexOf[B](
   30.81 -    source: Seq[B], sourceOffset: Int, sourceCount: Int,
   30.82 -    target: Seq[B], targetOffset: Int, targetCount: Int,
   30.83 -    fromIndex: Int): Int =
   30.84 -      KMP(source.slice(sourceOffset, sourceCount) drop fromIndex, target.slice(targetOffset, targetCount)) match {
   30.85 -        case None    => -1
   30.86 -        case Some(x) => x + fromIndex
   30.87 -      }
   30.88 -
   30.89 -  def lastIndexOf[B](
   30.90 -    source: Seq[B], sourceOffset: Int, sourceCount: Int,
   30.91 -    target: Seq[B], targetOffset: Int, targetCount: Int,
   30.92 -    fromIndex: Int): Int = {
   30.93 -      val src = (source.slice(sourceOffset, sourceCount) take fromIndex).reverse
   30.94 -      val tgt = target.slice(targetOffset, targetCount).reverse
   30.95 -
   30.96 -      KMP(src, tgt) match {
   30.97 -        case None    => -1
   30.98 -        case Some(x) => (src.length - tgt.length - x) + sourceOffset
   30.99 -      }
  30.100 -    }
  30.101 -}
  30.102 -
  30.103 -/** Class <code>Seq[A]</code> represents sequences of elements
  30.104 - *  of type <code>A</code>.
  30.105 - *  It adds the following methods to class Iterable:
  30.106 - *   `length`, `lengthCompare`, `apply`, `isDefinedAt`, `segmentLength`, `prefixLength`,
  30.107 - *   `indexWhere`, `indexOf`, `lastIndexWhere`, `lastIndexOf`, `reverse`, `reverseIterator`,
  30.108 - *   `startsWith`, `endsWith`, `indexOfSeq`, , `zip`, `zipAll`, `zipWithIndex`.
  30.109 - * 
  30.110 - *
  30.111 - *  @author  Martin Odersky
  30.112 - *  @author  Matthias Zenger
  30.113 - *  @version 1.0, 16/07/2003
  30.114 - *  @since   2.8
  30.115 - */
  30.116 -trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] { self =>
  30.117 -
  30.118 -  override protected[this] def thisCollection: Seq[A] = this.asInstanceOf[Seq[A]]
  30.119 -  override protected[this] def toCollection(repr: Repr): Seq[A] = repr.asInstanceOf[Seq[A]]
  30.120 -
  30.121 -  /** Returns the length of the sequence.
  30.122 -   */
  30.123 -  def length: Int
  30.124 -
  30.125 -  /** Returns the elements at position `idx`
  30.126 -   */
  30.127 -  def apply(idx: Int): A
  30.128 -
  30.129 -  /** Result of comparing <code>length</code> with operand <code>len</code>.
  30.130 -   *  returns <code>x</code> where
  30.131 -   *  <code>x &lt; 0</code>    iff    <code>this.length &lt; len</code>
  30.132 -   *  <code>x == 0</code>   iff    <code>this.length == len</code>
  30.133 -   *  <code>x &gt; 0</code>    iff    <code>this.length &gt; len</code>.
  30.134 -   *
  30.135 -   *  The method as implemented here does not call length directly; its running time
  30.136 -   *  is O(length min len) instead of O(length). The method should be overwritten
  30.137 -   *  if computing length is cheap.
  30.138 -   */
  30.139 -  def lengthCompare(len: Int): Int = {
  30.140 -    var i = 0
  30.141 -    val it = iterator
  30.142 -    while (it.hasNext && i <= len) {
  30.143 -      it.next()
  30.144 -      i += 1
  30.145 -    }
  30.146 -    i - len
  30.147 -  }
  30.148 -
  30.149 -  /** Should always be <code>length</code> */
  30.150 -  override def size = length
  30.151 -
  30.152 -  /** Is this partial function defined for the index <code>x</code>?
  30.153 -   */
  30.154 -  def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length)
  30.155 -
  30.156 -  /** Returns length of longest segment starting from a start index `from`
  30.157 -   *  such that every element of the segment satisfies predicate `p`.
  30.158 -   *  @note may not terminate for infinite-sized collections.
  30.159 -   *  @param  p the predicate
  30.160 -   *  @param  from  the start index
  30.161 -   */
  30.162 -  def segmentLength(p: A => Boolean, from: Int): Int = {
  30.163 -    var i = 0
  30.164 -    var it = iterator.drop(from)
  30.165 -    while (it.hasNext && p(it.next()))
  30.166 -      i += 1
  30.167 -    i
  30.168 -  }
  30.169 -
  30.170 -  /** Returns length of longest prefix of this seqence
  30.171 -   *  such that every element of the prefix satisfies predicate `p`.
  30.172 -   *  @note may not terminate for infinite-sized collections.
  30.173 -   *  @param  p the predicate
  30.174 -   */
  30.175 -  def prefixLength(p: A => Boolean) = segmentLength(p, 0)
  30.176 -
  30.177 -  /** Returns index of the first element satisfying a predicate, or -1, if none exists.
  30.178 -   *
  30.179 -   *  @note may not terminate for infinite-sized collections.
  30.180 -   *  @param  p the predicate
  30.181 -   */
  30.182 -  def indexWhere(p: A => Boolean): Int = indexWhere(p, 0)
  30.183 -
  30.184 -  /** Returns index of the first element starting from a start index
  30.185 -   *  satisying a predicate, or -1, if none exists.
  30.186 -   *
  30.187 -   *  @note may not terminate for infinite-sized collections.
  30.188 -   *  @param  p the predicate
  30.189 -   *  @param  from  the start index
  30.190 -   */
  30.191 -  def indexWhere(p: A => Boolean, from: Int): Int = {
  30.192 -    var i = from
  30.193 -    var it = iterator.drop(from)
  30.194 -    while (it.hasNext && !p(it.next()))
  30.195 -      i += 1
  30.196 -    if (it.hasNext) i else -1
  30.197 -  }
  30.198 -
  30.199 -  /** Returns index of the first element satisying a predicate, or -1. */
  30.200 -  @deprecated("Use `indexWhere' instead")
  30.201 -  def findIndexOf(p: A => Boolean): Int = indexWhere(p)
  30.202 -
  30.203 -  /** Returns the index of the first occurence of the specified
  30.204 -   *  object in this sequence.
  30.205 -   *
  30.206 -   *  @note may not terminate for infinite-sized collections.
  30.207 -   *  @param  elem  element to search for.
  30.208 -   *  @return the index in this sequence of the first occurence of the
  30.209 -   *          specified element, or -1 if the sequence does not contain
  30.210 -   *          this element.
  30.211 -   */
  30.212 -  def indexOf[B >: A](elem: B): Int = indexOf(elem, 0)
  30.213 -
  30.214 -  /** Returns the index of the first occurence of the specified
  30.215 -   *  object in this sequence, starting from a start index, or
  30.216 -   *  -1, if none exists.
  30.217 -   *
  30.218 -   *  @note may not terminate for infinite-sized collections.
  30.219 -   *  @param  elem  element to search for.
  30.220 -   */
  30.221 -  def indexOf[B >: A](elem: B, from: Int): Int = indexWhere(elem ==, from)
  30.222 -
  30.223 - /** Returns the index of the last occurence of the specified element
  30.224 -   *  in this sequence, or -1 if the sequence does not contain this element.
  30.225 -   *
  30.226 -   *  @param  elem   element to search for.
  30.227 -   *  @return the index in this sequence of the last occurence of the
  30.228 -   *          specified element, or -1 if the sequence does not contain
  30.229 -   *          this element.
  30.230 -   */
  30.231 -  def lastIndexOf[B >: A](elem: B): Int = lastIndexWhere(elem ==)
  30.232 -
  30.233 -  /** Returns the index of the last
  30.234 -    *  occurence of the specified element in this sequence
  30.235 -    *  before or at a given end index,
  30.236 -    *  or -1 if the sequence does not contain this element.
  30.237 -    *
  30.238 -    *  @param  elem   element to search for.
  30.239 -    *  @param  end    the end index
  30.240 -    */
  30.241 -  def lastIndexOf[B >: A](elem: B, end: Int): Int = lastIndexWhere(elem ==, end)
  30.242 -
  30.243 -  /** Returns index of the last element satisying a predicate, or -1, if none exists.
  30.244 -   *
  30.245 -   *  @param  p the predicate
  30.246 -   *  @return   the index of the last element satisfying <code>p</code>,
  30.247 -   *            or -1 if such an element does not exist
  30.248 -   */
  30.249 -  def lastIndexWhere(p: A => Boolean): Int = lastIndexWhere(p, length - 1)
  30.250 -
  30.251 -  /** Returns index of the last element not exceeding a given end index
  30.252 -   *  and satisying a predicate, or -1 if none exists.
  30.253 -   *
  30.254 -   *  @param  end the end index
  30.255 -   *  @param  p the predicate
  30.256 -   */
  30.257 -  def lastIndexWhere(p: A => Boolean, end: Int): Int = {
  30.258 -    var i = length - 1
  30.259 -    val it = reverseIterator
  30.260 -    while (it.hasNext && { val elem = it.next; (i > end || !p(elem)) }) i -= 1
  30.261 -    i
  30.262 -  }
  30.263 -
  30.264 -  /** A sequence of type <code>C</code> consisting of all elements of 
  30.265 -   *  this sequence in reverse order.
  30.266 -   *  @note  the operation is implemented by building a new sequence
  30.267 -   *         from <code>this(length - 1), ..., this(0)</code>
  30.268 -   *  If random access is inefficient for the given sequence implementation, 
  30.269 -   *  this operation should be overridden.
  30.270 -   */
  30.271 -  def reverse: Repr = {
  30.272 -    var xs: List[A] = List()
  30.273 -    for (x <- this) 
  30.274 -      xs = x :: xs
  30.275 -    val b = newBuilder
  30.276 -    for (x <- xs)
  30.277 -      b += x
  30.278 -    b.result
  30.279 -  }
  30.280 -
  30.281 -  /** The elements of this sequence in reversed order
  30.282 -   */
  30.283 -  def reverseIterator: Iterator[A] = toCollection(reverse).iterator
  30.284 -
  30.285 -  @deprecated("use `reverseIterator' instead")
  30.286 -  def reversedElements = reverseIterator
  30.287 -
  30.288 -  /**
  30.289 -   * Checks whether the argument sequence is contained at the 
  30.290 -   * specified index within the receiver object. 
  30.291 -   * 
  30.292 -   * If the both the receiver object, <code>this</code> and 
  30.293 -   * the argument, <code>that</code> are infinite sequences 
  30.294 -   * this method may not terminate.
  30.295 -   *
  30.296 -   * @return true if <code>that</code> is contained in 
  30.297 -   * <code>this</code>, at the specified index, otherwise false 
  30.298 -   *
  30.299 -   * @see String.startsWith
  30.300 -   */
  30.301 -  def startsWith[B](that: Seq[B], offset: Int): Boolean = {  
  30.302 -    val i = this.iterator drop offset
  30.303 -    val j = that.iterator
  30.304 -    while (j.hasNext && i.hasNext)
  30.305 -      if (i.next != j.next)
  30.306 -        return false
  30.307 -
  30.308 -    !j.hasNext
  30.309 -  }
  30.310 -
  30.311 -  /**
  30.312 -   * Check whether the receiver object starts with the argument sequence.
  30.313 -   *
  30.314 -   * @return true if <code>that</code> is a prefix of <code>this</code>,
  30.315 -   * otherwise false 
  30.316 -   */
  30.317 -  def startsWith[B](that: Seq[B]): Boolean = startsWith(that, 0)
  30.318 -
  30.319 -  /** @return true if this sequence end with that sequence 
  30.320 -   *  @see String.endsWith 
  30.321 -   */
  30.322 -  def endsWith[B](that: Seq[B]): Boolean = {
  30.323 -    val i = this.iterator.drop(length - that.length)
  30.324 -    val j = that.iterator
  30.325 -    while (i.hasNext && j.hasNext)
  30.326 -      if (i.next != j.next)
  30.327 -        return false
  30.328 -    
  30.329 -    !j.hasNext
  30.330 -  }
  30.331 -
  30.332 -  /** @return -1 if <code>that</code> not contained in this, otherwise the
  30.333 -   *  first index where <code>that</code> is contained.
  30.334 -   */
  30.335 -  def indexOfSeq[B >: A](that: Seq[B]): Int = indexOfSeq(that, 0)
  30.336 -  
  30.337 -  def indexOfSeq[B >: A](that: Seq[B], fromIndex: Int): Int = 
  30.338 -    if (this.hasDefiniteSize && that.hasDefiniteSize)
  30.339 -      SeqLike.indexOf(thisCollection, 0, length, that, 0, that.length, fromIndex)
  30.340 -    else {
  30.341 -      var i = fromIndex
  30.342 -      var s: Seq[A] = thisCollection drop i
  30.343 -      while (!s.isEmpty) {
  30.344 -        if (s startsWith that)
  30.345 -          return i
  30.346 -        
  30.347 -        i += 1
  30.348 -        s = s.tail
  30.349 -      }
  30.350 -      -1
  30.351 -    }
  30.352 -      
  30.353 -  /** @return -1 if <code>that</code> not contained in this, otherwise the
  30.354 -  *  last index where <code>that</code> is contained.
  30.355 -  *  @note may not terminate for infinite-sized collections.
  30.356 -  */
  30.357 -  def lastIndexOfSeq[B >: A](that: Seq[B]): Int = lastIndexOfSeq(that, that.length)
  30.358 -
  30.359 -  // since there's no way to find the last index in an infinite sequence,
  30.360 -  // we just document it may not terminate and assume it will.
  30.361 -  def lastIndexOfSeq[B >: A](that: Seq[B], fromIndex: Int): Int = 
  30.362 -    SeqLike.lastIndexOf(thisCollection, 0, length, that, 0, that.length, fromIndex)
  30.363 -
  30.364 -  /** Tests if the given value <code>elem</code> is a member of this 
  30.365 -   *  sequence.
  30.366 -   *
  30.367 -   *  @param elem element whose membership has to be tested.
  30.368 -   *  @return     <code>true</code> iff there is an element of this sequence
  30.369 -   *              which is equal (w.r.t. <code>==</code>) to <code>elem</code>.
  30.370 -   */
  30.371 -  def contains(elem: Any): Boolean = exists (_ == elem)
  30.372 -
  30.373 -  /** <p>
  30.374 -   *    Computes the multiset union of this sequence and the given sequence
  30.375 -   *    <code>that</code>. For example:
  30.376 -   *  </p><pre>
  30.377 -   *    <b>val</b> xs = List(1, 1, 2)
  30.378 -   *    <b>val</b> ys = List(1, 2, 2, 3)
  30.379 -   *    println(xs union ys)  // prints "List(1, 1, 2, 1, 2, 2, 3)"
  30.380 -   *    println(ys union xs)  // prints "List(1, 2, 2, 3, 1, 1, 2)"
  30.381 -   *  </pre>
  30.382 -   *
  30.383 -   *  @param that the sequence of elements to add to the sequence.
  30.384 -   *  @return     a sequence containing the elements of this
  30.385 -   *              sequence and those of the given sequence <code>that</code>.
  30.386 -   */
  30.387 -  def union[B >: A, That](that: Seq[B])(implicit bf: CanBuildFrom[Repr, B, That]): That = 
  30.388 -    this ++ that
  30.389 -
  30.390 -  /** <p>
  30.391 -   *    Computes the multiset difference between this sequence and the
  30.392 -   *    given sequence <code>that</code>. If an element appears more
  30.393 -   *    than once in both sequences, the difference contains <i>m</i> copies
  30.394 -   *    of that element, where <i>m</i> is the difference between the
  30.395 -   *    number of times the element appears in this sequence and the number
  30.396 -   *    of times it appears in <code>that</code>. For example:
  30.397 -   *  </p><pre>
  30.398 -   *    <b>val</b> xs = List(1, 1, 2)
  30.399 -   *    <b>val</b> ys = List(1, 2, 2, 3)
  30.400 -   *    println(xs diff ys)  // prints "List(1)"
  30.401 -   *    println(xs -- ys)    // prints "List()"
  30.402 -   *  </pre>
  30.403 -   *
  30.404 -   *  @param that the sequence of elements to remove from this sequence.
  30.405 -   *  @return     the sequence of elements contained only in this sequence plus
  30.406 -   *              <i>m</i> copies of each element present in both sequences,
  30.407 -   *              where <i>m</i> is defined as above.
  30.408 -   */
  30.409 -  def diff[B >: A, That](that: Seq[B]): Repr = {
  30.410 -    val occ = occCounts(that)
  30.411 -    val b = newBuilder
  30.412 -    for (x <- this)
  30.413 -      if (occ(x) == 0) b += x
  30.414 -      else occ(x) -= 1 
  30.415 -    b.result
  30.416 -  }
  30.417 -
  30.418 -  /** <p>
  30.419 -   *    Computes the multiset intersection between this sequence and the
  30.420 -   *    given sequence <code>that</code>; the intersection contains <i>m</i>
  30.421 -   *    copies of an element contained in both sequences, where <i>m</i> is
  30.422 -   *    the smaller of the number of times the element appears in this
  30.423 -   *    sequence or in <code>that</code>. For example:
  30.424 -   *  </p><pre>
  30.425 -   *    <b>val</b> xs = List(1, 1, 2)
  30.426 -   *    <b>val</b> ys = List(3, 2, 2, 1)
  30.427 -   *    println(xs intersect ys)  // prints "List(1, 2)"
  30.428 -   *    println(ys intersect xs)  // prints "List(2, 1)"
  30.429 -   *  </pre>
  30.430 -   *
  30.431 -   *  @param that the sequence to intersect.
  30.432 -   *  @return     the sequence of elements contained both in this sequence and
  30.433 -   *              in the given sequence <code>that</code>.
  30.434 -   */
  30.435 -  def intersect[B >: A, That](that: Seq[B]): Repr = {
  30.436 -    val occ = occCounts(that)
  30.437 -    val b = newBuilder
  30.438 -    for (x <- this)
  30.439 -      if (occ(x) > 0) {
  30.440 -        b += x
  30.441 -        occ(x) -= 1
  30.442 -      }
  30.443 -    b.result
  30.444 -  }
  30.445 -
  30.446 -  private def occCounts[B](seq: Seq[B]): mutable.Map[B, Int] = {
  30.447 -    val occ = new mutable.HashMap[B, Int] { override def default(k: B) = 0 }
  30.448 -    for (y <- seq) occ(y) += 1
  30.449 -    occ
  30.450 -  }
  30.451 -
  30.452 -  /** Builds a new sequence from this sequence in which any duplicates (wrt to ==) removed.
  30.453 -   *  Among duplicate elements, only the first one is retained in the result sequence
  30.454 -   */
  30.455 -  def removeDuplicates: Repr = {
  30.456 -    val b = newBuilder
  30.457 -    var seen = Set[A]() //TR: should use mutable.HashSet?
  30.458 -    for (x <- this) {
  30.459 -      if (!(seen contains x)) {
  30.460 -        b += x
  30.461 -        seen = (seen + x)
  30.462 -      }
  30.463 -    }
  30.464 -    b.result
  30.465 -  }
  30.466 -
  30.467 -  /** A new sequence, consisting of all elements of current sequence 
  30.468 -   *  except that `replaced` elements starting from `from` are replaced
  30.469 -   *  by `patch`.
  30.470 -   */
  30.471 -  def patch[B >: A, That](from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
  30.472 -    val b = bf(repr)
  30.473 -    val (prefix, rest) = this.splitAt(from)
  30.474 -    b ++= toCollection(prefix)
  30.475 -    b ++= patch
  30.476 -    b ++= toCollection(rest).view drop replaced
  30.477 -    b.result
  30.478 -  }
  30.479 -
  30.480 -  /** Returns a copy of this sequence with the element at position `index` replaced by `elem`.
  30.481 -   */
  30.482 -  def updated[B >: A, That](index: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
  30.483 -    val b = bf(repr)
  30.484 -    val (prefix, rest) = this.splitAt(index)
  30.485 -    b ++= toCollection(prefix)
  30.486 -    b += elem
  30.487 -    b ++= toCollection(rest).view.tail
  30.488 -    b.result
  30.489 -  }
  30.490 -
  30.491 -  /** Returns a new sequence consisting of `elem` followed by the elements of this sequence.
  30.492 -   */
  30.493 -  def +:[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
  30.494 -    val b = bf(repr)
  30.495 -    b += elem
  30.496 -    b ++= thisCollection
  30.497 -    b.result
  30.498 -  }
  30.499 -
  30.500 -  /** Returns a new sequence consisting of the elements of this sequence followed by `elem`.
  30.501 -   */
  30.502 -  def :+[B >: A, That](elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
  30.503 -    val b = bf(repr)
  30.504 -    b ++= thisCollection
  30.505 -    b += elem
  30.506 -    b.result
  30.507 -  }
  30.508 -
  30.509 -
  30.510 -
  30.511 -
  30.512 -  /** Returns a new sequence of given length containing the elements of this sequence followed by zero
  30.513 -   *  or more occurrences of given elements. 
  30.514 -   */
  30.515 -  def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[Repr, B, That]): That = {
  30.516 -    val b = bf(repr)
  30.517 -    b.sizeHint(length max len)
  30.518 -    var diff = len - length
  30.519 -    b ++= thisCollection
  30.520 -    while (diff > 0) {
  30.521 -      b += elem
  30.522 -      diff -=1 
  30.523 -    }
  30.524 -    b.result
  30.525 -  }
  30.526 -
  30.527 -  /** Sort the sequence according to the comparison function
  30.528 -   *  <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>,
  30.529 -   *  which should be true iff <code>e1</code> is smaller than
  30.530 -   *  <code>e2</code>.
  30.531 -   *  The sort is stable. That is elements that are equal wrt `lt` appear in the
  30.532 -   *  same order in the sorted sequence as in the original.
  30.533 -   *  
  30.534 -   *  @param lt the comparison function
  30.535 -   *  @return   a sequence sorted according to the comparison function
  30.536 -   *            <code>&lt;(e1: a, e2: a) =&gt; Boolean</code>.
  30.537 -   *  @ex <pre>
  30.538 -   *    List("Steve", "Tom", "John", "Bob")
  30.539 -   *      .sortWith((e1, e2) => (e1 compareTo e2) &lt; 0) =
  30.540 -   *    List("Bob", "John", "Steve", "Tom")</pre>
  30.541 -   */
  30.542 -  def sortWith(lt: (A, A) => Boolean): Repr = sortWith(Ordering fromLessThan lt)
  30.543 -
  30.544 -  def sortWith[B >: A](ord: Ordering[B]): Repr = {
  30.545 -    val arr = new GenericArray[A](this.length)
  30.546 -    var i = 0
  30.547 -    for (x <- this) {
  30.548 -      arr(i) = x
  30.549 -      i += 1
  30.550 -    }
  30.551 -    java.util.Arrays.sort(
  30.552 -      arr.array, ord.asInstanceOf[Ordering[Object]])
  30.553 -    val b = newBuilder
  30.554 -    for (x <- arr) b += x
  30.555 -    b.result
  30.556 -  }
  30.557 -  
  30.558 -  /** Sort the sequence according to the Ordering which results from transforming
  30.559 -   *  the implicitly given Ordering[B] to an Ordering[A].  For example:
  30.560 -   *
  30.561 -   *  <code>
  30.562 -   *    val words = "The quick brown fox jumped over the lazy dog".split(' ')
  30.563 -   *    // this works because scala.Ordering will implicitly provide an Ordering[Tuple2[Int, Char]]
  30.564 -   *    words.sortBy(x => (x.length, x.head))
  30.565 -   *    res0: Array[String] = Array(The, dog, fox, the, lazy, over, brown, quick, jumped)
  30.566 -   *  </code>
  30.567 -   *
  30.568 -   *  @param    f   the transformation function A => B
  30.569 -   *  @param    ord the Ordering[B]
  30.570 -   *  @return       the sorted representation
  30.571 -   */  
  30.572 -  def sortBy[B](f: A => B)(implicit ord: Ordering[B]): Repr = sortWith(ord on f)
  30.573 -
  30.574 -  /**
  30.575 -   *  Overridden for efficiency.
  30.576 -   *
  30.577 -   *  @return  the sequence itself
  30.578 -   */
  30.579 -  override def toSeq: Seq[A] = thisCollection
  30.580 -
  30.581 -  /** The range of all indices of this sequence.
  30.582 -   */
  30.583 -  def indices: Range = 0 until length
  30.584 -
  30.585 -  override def view = new SeqView[A, Repr] {
  30.586 -    protected lazy val underlying = self.repr
  30.587 -    override def iterator = self.iterator
  30.588 -    override def length = self.length
  30.589 -    override def apply(idx: Int) = self.apply(idx)
  30.590 -  }
  30.591 -
  30.592 -  override def view(from: Int, until: Int) = view.slice(from, until)
  30.593 -
  30.594 -  override def hashCode() = (Seq.hashSeed /: this)(_ * 41 + _.hashCode)
  30.595 -
  30.596 -  override def equals(that: Any): Boolean = that match {
  30.597 -    case that: Seq[_]  => (that canEqual this) && (this sameElements that)
  30.598 -    case _                  => false
  30.599 -  }
  30.600 -
  30.601 -  /** Need to override string, so that it's not the Function1's string that gets mixed in.
  30.602 -   */
  30.603 -  override def toString = super[IterableLike].toString
  30.604 -
  30.605 -  /** Returns index of the last element satisying a predicate, or -1. */
  30.606 -  @deprecated("use `lastIndexWhere' instead")
  30.607 -  def findLastIndexOf(p: A => Boolean): Int = lastIndexWhere(p)
  30.608 -  
  30.609 -  /** A sub-sequence starting at index <code>from</code> 
  30.610 -    *  and extending up to the length of the current sequence
  30.611 -    *
  30.612 -    *  @param from   The index of the first element of the slice
  30.613 -    *  @throws IndexOutOfBoundsException if <code>from &lt; 0</code>
  30.614 -    */
  30.615 -  @deprecated("use `drop' instead")
  30.616 -  def slice(from: Int): Seq[A] = toCollection(slice(from, length))
  30.617 -
  30.618 -  @deprecated("Should be replaced by <code>(s1, s2) forall { case (x, y) => f(x, y) }</code>")
  30.619 -  def equalsWith[B](that: Seq[B])(f: (A,B) => Boolean): Boolean = {
  30.620 -    val i = this.iterator
  30.621 -    val j = that.iterator
  30.622 -    while (i.hasNext && j.hasNext)
  30.623 -      if (!f(i.next, j.next))
  30.624 -        return false
  30.625 -    
  30.626 -    !i.hasNext && !j.hasNext
  30.627 -  }
  30.628 -
  30.629 -  /** Is <code>that</code> a slice in this? */
  30.630 -  @deprecated("Should be replaced by <code>indexOfSeq(that) != -1</code>")
  30.631 -  def containsSlice[B](that: Seq[B]): Boolean = indexOfSeq(that) != -1 
  30.632 -
  30.633 - /**
  30.634 -   * returns a projection that can be used to call non-strict <code>filter</code>,
  30.635 -   * <code>map</code>, and <code>flatMap</code> methods that build projections
  30.636 -   * of the collection.
  30.637 -   */
  30.638 -  @deprecated("use `view' instead")
  30.639 -  override def projection = view
  30.640 -}
  30.641 -
    31.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SeqProxy.scala	Tue Nov 03 13:08:38 2009 +0800
    31.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.3 @@ -1,21 +0,0 @@
    31.4 -/*                     __                                               *\
    31.5 -**     ________ ___   / /  ___     Scala API                            **
    31.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    31.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    31.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    31.9 -**                          |/                                          **
   31.10 -\*                                                                      */
   31.11 -
   31.12 -// $Id: SeqProxy.scala 18895 2009-10-02 17:57:16Z odersky $
   31.13 -
   31.14 -
   31.15 -package org.aiotrade.lib.collection
   31.16 -
   31.17 -/** This trait implements a proxy for sequence objects. It forwards
   31.18 - *  all calls to a different sequence object.
   31.19 - *
   31.20 - *  @author  Martin Odersky
   31.21 - *  @version 2.8
   31.22 - *  @since   2.8
   31.23 - */
   31.24 -trait SeqProxy[+A] extends Seq[A] with SeqProxyLike[A, Seq[A]] 
    32.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SeqProxyLike.scala	Tue Nov 03 13:08:38 2009 +0800
    32.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.3 @@ -1,63 +0,0 @@
    32.4 -/*                     __                                               *\
    32.5 -**     ________ ___   / /  ___     Scala API                            **
    32.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    32.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    32.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    32.9 -**                          |/                                          **
   32.10 -\*                                                                      */
   32.11 -
   32.12 -// $Id: SeqProxyLike.scala 19190 2009-10-21 13:24:41Z moors $
   32.13 -
   32.14 -
   32.15 -package org.aiotrade.lib.collection
   32.16 -
   32.17 -import generic._
   32.18 -
   32.19 -// Methods could be printed by  cat SeqLike.scala | egrep '^  (override )?def'
   32.20 -
   32.21 -
   32.22 -/** This trait implements a proxy for sequences. It forwards
   32.23 - *  all calls to a different sequence.
   32.24 - *
   32.25 - *  @author  Martin Odersky
   32.26 - *  @version 2.8
   32.27 - *  @since   2.8
   32.28 - */
   32.29 -trait SeqProxyLike[+A, +This <: SeqLike[A, This] with Seq[A]] extends SeqLike[A, This] with IterableProxyLike[A, This] { 
   32.30 -  override def length: Int = self.length
   32.31 -  override def apply(idx: Int): A = self.apply(idx)
   32.32 -  override def lengthCompare(len: Int): Int = self.lengthCompare(len)
   32.33 -  override def size = self.size
   32.34 -  override def isDefinedAt(x: Int): Boolean = self.isDefinedAt(x)
   32.35 -  override def segmentLength(p: A => Boolean, from: Int): Int = self.segmentLength(p, from)
   32.36 -  override def prefixLength(p: A => Boolean) = self.prefixLength(p)
   32.37 -  override def indexWhere(p: A => Boolean): Int = self.indexWhere(p)
   32.38 -  override def indexWhere(p: A => Boolean, from: Int): Int = self.indexWhere(p, from)
   32.39 -  override def findIndexOf(p: A => Boolean): Int = self.indexWhere(p)
   32.40 -  override def indexOf[B >: A](elem: B): Int = self.indexOf(elem)
   32.41 -  override def indexOf[B >: A](elem: B, from: Int): Int = self.indexOf(elem, from)
   32.42 -  override def lastIndexOf[B >: A](elem: B): Int = self.lastIndexOf(elem)
   32.43 -  override def lastIndexOf[B >: A](elem: B, end: Int): Int = self.lastIndexWhere(elem ==, end)
   32.44 -  override def lastIndexWhere(p: A => Boolean): Int = self.lastIndexWhere(p, length - 1)
   32.45 -  override def lastIndexWhere(p: A => Boolean, end: Int): Int = self.lastIndexWhere(p)
   32.46 -  override def reverse: This = self.reverse
   32.47 -  override def reverseIterator: Iterator[A] = self.reverseIterator
   32.48 -  override def startsWith[B](that: Seq[B], offset: Int): Boolean = self.startsWith(that, offset)
   32.49 -  override def startsWith[B](that: Seq[B]): Boolean = self.startsWith(that)
   32.50 -  override def endsWith[B](that: Seq[B]): Boolean = self.endsWith(that)
   32.51 -  override def indexOfSeq[B >: A](that: Seq[B]): Int = self.indexOfSeq(that)
   32.52 -  override def contains(elem: Any): Boolean = self.contains(elem)
   32.53 -  override def union[B >: A, That](that: Seq[B])(implicit bf: CanBuildFrom[This, B, That]): That = self.union(that)(bf)
   32.54 -  override def diff[B >: A, That](that: Seq[B]): This = self.diff(that)
   32.55 -  override def intersect[B >: A, That](that: Seq[B]): This = self.intersect(that)
   32.56 -  override def removeDuplicates: This = self.removeDuplicates
   32.57 -  override def patch[B >: A, That](from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[This, B, That]): That = self.patch(from, patch, replaced)(bf)
   32.58 -  override def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[This, B, That]): That = self.padTo(len, elem)(bf)
   32.59 -  override def indices: Range = self.indices
   32.60 -  override def view = self.view
   32.61 -  override def view(from: Int, until: Int) = self.view(from, until)
   32.62 -  override def findLastIndexOf(p: A => Boolean): Int = self.lastIndexWhere(p)
   32.63 -  override def slice(from: Int): Seq[A] = self.drop(from)
   32.64 -  override def equalsWith[B](that: Seq[B])(f: (A,B) => Boolean): Boolean = (self zip that) forall { case (x,y) => f(x,y) }
   32.65 -  override def containsSlice[B](that: Seq[B]): Boolean = self.indexOfSeq(that) != -1
   32.66 -}
    33.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SeqView.scala	Tue Nov 03 13:08:38 2009 +0800
    33.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.3 @@ -1,32 +0,0 @@
    33.4 -/*                     __                                               *\
    33.5 -**     ________ ___   / /  ___     Scala API                            **
    33.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    33.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    33.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    33.9 -**                          |/                                          **
   33.10 -\*                                                                      */
   33.11 -
   33.12 -// $Id: SeqView.scala 19190 2009-10-21 13:24:41Z moors $
   33.13 -
   33.14 -
   33.15 -package org.aiotrade.lib.collection
   33.16 -
   33.17 -import generic._
   33.18 -import TraversableView.NoBuilder
   33.19 -
   33.20 -/** A non-strict projection of an iterable. 
   33.21 - * @author Sean McDirmid
   33.22 - * @author Martin Odersky
   33.23 - * @version 2.8
   33.24 - */
   33.25 -trait SeqView[+A, +Coll] extends SeqViewLike[A, Coll, SeqView[A, Coll]] 
   33.26 -
   33.27 -object SeqView {
   33.28 -  type Coll = TraversableView[_, C] forSome {type C <: Traversable[_]}
   33.29 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, SeqView[A, Seq[_]]] = 
   33.30 -    new CanBuildFrom[Coll, A, SeqView[A, Seq[_]]] { 
   33.31 -      def apply(from: Coll) = new NoBuilder 
   33.32 -      def apply() = new NoBuilder 
   33.33 -    }
   33.34 -}
   33.35 -
    34.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SeqViewLike.scala	Tue Nov 03 13:08:38 2009 +0800
    34.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.3 @@ -1,172 +0,0 @@
    34.4 -/*                     __                                               *\
    34.5 -**     ________ ___   / /  ___     Scala API                            **
    34.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    34.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    34.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    34.9 -**                          |/                                          **
   34.10 -\*                                                                      */
   34.11 -
   34.12 -// $Id: SeqViewLike.scala 19190 2009-10-21 13:24:41Z moors $
   34.13 -
   34.14 -
   34.15 -package org.aiotrade.lib.collection
   34.16 -
   34.17 -import generic._
   34.18 -import Seq.fill
   34.19 -import TraversableView.NoBuilder
   34.20 -
   34.21 -/** A template trait for a non-strict view of a sequence.
   34.22 - * @author Sean McDirmid
   34.23 - * @author Martin Odersky
   34.24 - * @version 2.8
   34.25 - */
   34.26 -trait SeqViewLike[+A, 
   34.27 -                           +Coll,
   34.28 -                           +This <: SeqView[A, Coll] with SeqViewLike[A, Coll, This]] 
   34.29 -  extends Seq[A] with SeqLike[A, This] with IterableView[A, Coll] with IterableViewLike[A, Coll, This] 
   34.30 -{ self =>
   34.31 -
   34.32 -  trait Transformed[+B] extends SeqView[B, Coll] with super.Transformed[B] {
   34.33 -    override def length: Int
   34.34 -    override def apply(idx: Int): B
   34.35 -  }
   34.36 -
   34.37 -  trait Sliced extends Transformed[A] with super.Sliced {
   34.38 -    override def length = ((until min self.length) - from) max 0
   34.39 -    override def apply(idx: Int): A =
   34.40 -      if (idx + from < until) self.apply(idx + from)
   34.41 -      else throw new IndexOutOfBoundsException(idx.toString)
   34.42 -  }
   34.43 -
   34.44 -  trait Mapped[B] extends Transformed[B] with super.Mapped[B] {
   34.45 -    override def length = self.length
   34.46 -    override def apply(idx: Int): B = mapping(self apply idx)
   34.47 -  }
   34.48 -
   34.49 -  trait FlatMapped[B] extends Transformed[B] with super.FlatMapped[B] {
   34.50 -    protected[this] lazy val index = {
   34.51 -      val index = new Array[Int](self.length + 1)
   34.52 -      index(0) = 0
   34.53 -      for (i <- 0 until self.length) 
   34.54 -        index(i + 1) = index(i) + mapping(self(i)).size
   34.55 -      index
   34.56 -    }      
   34.57 -    protected[this] def findRow(idx: Int, lo: Int, hi: Int): Int = {
   34.58 -      val mid = (lo + hi) / 2
   34.59 -      if (idx < index(mid)) findRow(idx, lo, mid - 1)
   34.60 -      else if (idx >= index(mid + 1)) findRow(idx, mid + 1, hi)
   34.61 -      else mid
   34.62 -    }
   34.63 -    override def length = index(self.length)
   34.64 -    override def apply(idx: Int) = {
   34.65 -      val row = findRow(idx, 0, self.length - 1)
   34.66 -      mapping(self(row)).toSeq(idx - index(row))
   34.67 -    }
   34.68 -  }
   34.69 -    
   34.70 -  trait Appended[B >: A] extends Transformed[B] with super.Appended[B] {
   34.71 -    protected[this] lazy val restSeq = rest.toSeq
   34.72 -    override def length = self.length + restSeq.length
   34.73 -    override def apply(idx: Int) = 
   34.74 -      if (idx < self.length) self(idx) else restSeq(idx - self.length)
   34.75 -  }
   34.76 -
   34.77 -  trait Filtered extends Transformed[A] with super.Filtered {
   34.78 -    protected[this] lazy val index = {
   34.79 -      var len = 0
   34.80 -      val arr = new Array[Int](self.length)
   34.81 -      for (i <- 0 until self.length) 
   34.82 -        if (pred(self(i))) { 
   34.83 -          arr(len) = i
   34.84 -          len += 1
   34.85 -        }
   34.86 -      arr take len
   34.87 -    }
   34.88 -    override def length = index.length
   34.89 -    override def apply(idx: Int) = self(index(idx))
   34.90 -  }
   34.91 -    
   34.92 -  trait TakenWhile extends Transformed[A] with super.TakenWhile {
   34.93 -    protected[this] lazy val len = self prefixLength pred
   34.94 -    override def length = len
   34.95 -    override def apply(idx: Int) =
   34.96 -      if (idx < len) self(idx)
   34.97 -      else throw new IndexOutOfBoundsException(idx.toString)
   34.98 -  }
   34.99 -
  34.100 -  trait DroppedWhile extends Transformed[A] with super.DroppedWhile {
  34.101 -    protected[this] lazy val start = self prefixLength pred
  34.102 -    override def length = self.length - start
  34.103 -    override def apply(idx: Int) =
  34.104 -      if (idx >= 0) self(idx + start)
  34.105 -      else throw new IndexOutOfBoundsException(idx.toString)
  34.106 -  }
  34.107 -
  34.108 -  trait Zipped[B] extends Transformed[(A, B)] with super.Zipped[B] {
  34.109 -    protected[this] lazy val thatSeq = other.toSeq
  34.110 -    override def length: Int = self.length min thatSeq.length
  34.111 -    override def apply(idx: Int) = (self.apply(idx), thatSeq.apply(idx))
  34.112 -  }
  34.113 -  
  34.114 -  trait ZippedAll[A1 >: A, B] extends Transformed[(A1, B)] with super.ZippedAll[A1, B] {
  34.115 -    protected[this] lazy val thatSeq = other.toSeq
  34.116 -    override def length: Int = self.length max thatSeq.length
  34.117 -    override def apply(idx: Int) = 
  34.118 -      (if (idx < self.length) self.apply(idx) else thisElem,
  34.119 -       if (idx < thatSeq.length) thatSeq.apply(idx) else thatElem)
  34.120 -  }
  34.121 -  
  34.122 -  trait Reversed extends Transformed[A] {
  34.123 -    override def iterator: Iterator[A] = self.reverseIterator 
  34.124 -    override def length: Int = self.length
  34.125 -    override def apply(idx: Int): A = self.apply(length - 1 - idx)
  34.126 -    override def stringPrefix = self.stringPrefix+"R"
  34.127 -  }
  34.128 -
  34.129 -  trait Patched[B >: A] extends Transformed[B] {
  34.130 -    protected[this] val from: Int
  34.131 -    protected[this] val patch: Seq[B]
  34.132 -    protected[this] val replaced: Int
  34.133 -    private lazy val plen = patch.length
  34.134 -    override def iterator: Iterator[B] = self.iterator patch (from, patch.iterator, replaced)
  34.135 -    override def length: Int = self.length + plen - replaced
  34.136 -    override def apply(idx: Int): B = 
  34.137 -      if (idx < from) self.apply(idx)
  34.138 -      else if (idx < from + plen) patch.apply(idx - from)
  34.139 -      else self.apply(idx - plen + replaced)
  34.140 -    override def stringPrefix = self.stringPrefix+"P"
  34.141 -  }
  34.142 -
  34.143 -  /** Boilerplate method, to override in each subclass
  34.144 -   *  This method could be eliminated if Scala had virtual classes
  34.145 -   */
  34.146 -  protected override def newAppended[B >: A](that: Traversable[B]): Transformed[B] = new Appended[B] { val rest = that }
  34.147 -  protected override def newMapped[B](f: A => B): Transformed[B] = new Mapped[B] { val mapping = f }
  34.148 -  protected override def newFlatMapped[B](f: A => Traversable[B]): Transformed[B] = new FlatMapped[B] { val mapping = f }
  34.149 -  protected override def newFiltered(p: A => Boolean): Transformed[A] = new Filtered { val pred = p }
  34.150 -  protected override def newSliced(_from: Int, _until: Int): Transformed[A] = new Sliced { val from = _from; val until = _until }
  34.151 -  protected override def newDroppedWhile(p: A => Boolean): Transformed[A] = new DroppedWhile { val pred = p }
  34.152 -  protected override def newTakenWhile(p: A => Boolean): Transformed[A] = new TakenWhile { val pred = p }
  34.153 -  protected override def newZipped[B](that: Iterable[B]): Transformed[(A, B)] = new Zipped[B] { val other = that }
  34.154 -  protected override def newZippedAll[A1 >: A, B](that: Iterable[B], _thisElem: A1, _thatElem: B): Transformed[(A1, B)] = new ZippedAll[A1, B] { val other = that; val thisElem = _thisElem; val thatElem = _thatElem }
  34.155 -  protected def newReversed: Transformed[A] = new Reversed { }
  34.156 -  protected def newPatched[B >: A](_from: Int, _patch: Seq[B], _replaced: Int): Transformed[B] = new Patched[B] { val from = _from; val patch = _patch; val replaced = _replaced }
  34.157 -
  34.158 -  override def reverse: This = newReversed.asInstanceOf[This]
  34.159 -
  34.160 -  override def patch[B >: A, That](from: Int, patch: Seq[B], replaced: Int)(implicit bf: CanBuildFrom[This, B, That]): That = {
  34.161 -    newPatched(from, patch, replaced).asInstanceOf[That]
  34.162 -// was:    val b = bf(repr)
  34.163 -//    if (b.isInstanceOf[NoBuilder[_]]) newPatched(from, patch, replaced).asInstanceOf[That]
  34.164 -//    else super.patch[B, That](from, patch, replaced)(bf) 
  34.165 -  }
  34.166 -
  34.167 -  //TR TODO: updated, +: ed :+ ed
  34.168 -
  34.169 -  override def padTo[B >: A, That](len: Int, elem: B)(implicit bf: CanBuildFrom[This, B, That]): That =
  34.170 -    patch(length, fill(len - length)(elem), 0)
  34.171 -
  34.172 -  override def stringPrefix = "SeqView"
  34.173 -}
  34.174 -
  34.175 -
    35.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/Set.scala	Tue Nov 03 13:08:38 2009 +0800
    35.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.3 @@ -1,40 +0,0 @@
    35.4 -/*                     __                                               *\
    35.5 -**     ________ ___   / /  ___     Scala API                            **
    35.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    35.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    35.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    35.9 -**                          |/                                          **
   35.10 -\*                                                                      */
   35.11 -
   35.12 -// $Id: Set.scala 19190 2009-10-21 13:24:41Z moors $
   35.13 -
   35.14 -package org.aiotrade.lib.collection
   35.15 -
   35.16 -import generic._
   35.17 -
   35.18 -/** <p>
   35.19 - *    A set is a collection that includes at most one of any object.
   35.20 - *  </p>
   35.21 - *    
   35.22 - *  @author  Matthias Zenger
   35.23 - *  @author  Martin Odersky
   35.24 - *  @version 2.8
   35.25 - *  @since   1
   35.26 - */
   35.27 -trait Set[A] extends (A => Boolean) 
   35.28 -                with Iterable[A] 
   35.29 -                with GenericSetTemplate[A, Set]
   35.30 -                with SetLike[A, Set[A]] {
   35.31 -  override def companion: GenericCompanion[Set] = Set
   35.32 -}
   35.33 -
   35.34 -/** Factory object for <code>Set</code> class.
   35.35 - *
   35.36 - *  @author  Martin Odersky
   35.37 - *  @version 2.8
   35.38 - *  @since   2.8
   35.39 - */
   35.40 -object Set extends SetFactory[Set] {
   35.41 -  override def empty[A]: Set[A] = immutable.Set.empty[A]
   35.42 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Set[A]] = setCanBuildFrom[A]
   35.43 -}
    36.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SetLike.scala	Tue Nov 03 13:08:38 2009 +0800
    36.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.3 @@ -1,188 +0,0 @@
    36.4 -/*                     __                                               *\
    36.5 -**     ________ ___   / /  ___     Scala API                            **
    36.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    36.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    36.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    36.9 -**                          |/                                          **
   36.10 -\*                                                                      */
   36.11 -
   36.12 -// $Id: SetLike.scala 18791 2009-09-25 16:20:13Z odersky $
   36.13 -
   36.14 -package org.aiotrade.lib.collection
   36.15 -
   36.16 -import generic._
   36.17 -import mutable.{Builder, AddingBuilder}
   36.18 -import PartialFunction._
   36.19 -
   36.20 -/** <p>
   36.21 - *    A generic template for sets of type <code>A</code>.<br/>
   36.22 - *    To implement a concrete set, you need to provide implementations of the
   36.23 - *    following methods (where <code>This</code> is the type of the set in
   36.24 - *    question):
   36.25 - *  </p>
   36.26 - *  <pre>
   36.27 - *    <b>def</b> contains(key: A): Boolean
   36.28 - *    <b>def</b> iterator: Iterator[A]
   36.29 - *    <b>def</b> +(elem: A): This
   36.30 - *    <b>def</b> -(elem: A): This</pre>
   36.31 - *  <p>
   36.32 - *    If you wish that methods <code>like</code>, <code>take</code>, <code>drop</code>,
   36.33 - *    <code>filter</code> return the same kind of set, you should also override:
   36.34 - *  </p>
   36.35 - *  <pre>
   36.36 - *   <b>def</b> empty: This</pre>
   36.37 - *  <p>
   36.38 - *    It is also good idea to override methods <code>foreach</code> and
   36.39 - *    <code>size</code> for efficiency.
   36.40 - *  </p>
   36.41 - *
   36.42 - *  @author  Martin Odersky
   36.43 - *  @version 2.8
   36.44 - */
   36.45 -trait SetLike[A, +This <: SetLike[A, This] with Set[A]] extends IterableLike[A, This] with Addable[A, This] with Subtractable[A, This] { 
   36.46 -self =>
   36.47 -
   36.48 -  /* The empty set of the dame type as this set */
   36.49 -  def empty: This
   36.50 -
   36.51 -  /** A common implementation of <code>newBuilder</code> for all sets in terms
   36.52 -   *  of <code>empty</code>. Overridden for mutable sets in
   36.53 -   *  <a href="mutable/SetLike.html" target="ContentFrame">
   36.54 -   *  <code>mutable.SetLike</code></a>.
   36.55 -   */
   36.56 -  override protected[this] def newBuilder: Builder[A, This] = new AddingBuilder[A, This](empty)
   36.57 -
   36.58 -  /** Checks if this set contains element <code>elem</code>.
   36.59 -   *
   36.60 -   *  @param elem the element to check for membership.
   36.61 -   *  @return     <code>true</code> iff <code>elem</code> is contained in
   36.62 -   *              this set.
   36.63 -   */
   36.64 -  def contains(elem: A): Boolean
   36.65 -
   36.66 -  /** Creates a new set with an additional element, unless the element is
   36.67 -   *  already present.
   36.68 -   *
   36.69 -   *  @param elem the element to be added
   36.70 -   */
   36.71 -  def + (elem: A): This
   36.72 -
   36.73 -  /** Creates a new set with given element removed from this set, unless the
   36.74 -   *  element is not present.
   36.75 -   *
   36.76 -   *  @param elem the element to be removed
   36.77 -   */
   36.78 -  def - (elem: A): This
   36.79 -
   36.80 -  /** Checks if this set is empty.
   36.81 -   *
   36.82 -   *  @return <code>true</code> iff there is no element in the set.
   36.83 -   */
   36.84 -  override def isEmpty: Boolean = size == 0
   36.85 -
   36.86 -  /** This method allows sets to be interpreted as predicates.
   36.87 -   *  It returns <code>true</code>, iff this set contains element
   36.88 -   *  <code>elem</code>.
   36.89 -   *
   36.90 -   *  @param elem the element to check for membership.
   36.91 -   *  @return     <code>true</code> iff <code>elem</code> is contained in
   36.92 -   *              this set.
   36.93 -   */
   36.94 -  def apply(elem: A): Boolean = contains(elem)
   36.95 -
   36.96 -  /** Returns a new set consisting of all elements that are both in the current
   36.97 -   *  set and in the argument set.
   36.98 -   *
   36.99 -   *  @param that the set to intersect with.
  36.100 -   */
  36.101 -  def intersect(that: Set[A]): This = filter(that.contains)
  36.102 -
  36.103 -  /** Returns a new set consisting of all elements that are both in the current
  36.104 -   *  set and in the argument set.
  36.105 -   *
  36.106 -   *  @param that the set to intersect with.
  36.107 -   *  @note  same as <code>intersect</code>.
  36.108 -   */
  36.109 -  def &(that: Set[A]): This = intersect(that)
  36.110 -
  36.111 - /**  This method is an alias for <code>intersect</code>. 
  36.112 -   *  It computes an intersection with set <code>that</code>.
  36.113 -   *  It removes all the elements that are not present in <code>that</code>.
  36.114 -   *
  36.115 -   *  @param that the set to intersect with
  36.116 -   */
  36.117 -  @deprecated("use & instead") def ** (that: Set[A]): This = intersect(that)
  36.118 -  
  36.119 -  /** The union of this set and the given set <code>that</code>.
  36.120 -   *
  36.121 -   *  @param that the set of elements to add
  36.122 -   *  @return     a set containing the elements of this
  36.123 -   *              set and those of the given set <code>that</code>.
  36.124 -   */
  36.125 -  def union(that: Set[A]): This = this.++(that)
  36.126 -
  36.127 -  /** The union of this set and the given set <code>that</code>.
  36.128 -   *
  36.129 -   *  @param that the set of elements to add
  36.130 -   *  @return     a set containing the elements of this
  36.131 -   *              set and those of the given set <code>that</code>.
  36.132 -   *  @note       same as <code>union</code>.
  36.133 -   */
  36.134 -  def | (that: Set[A]): This = union(that)
  36.135 -
  36.136 -  /** The difference of this set and the given set <code>that</code>.
  36.137 -   *
  36.138 -   *  @param that the set of elements to remove
  36.139 -   *  @return     a set containing those elements of this
  36.140 -   *              set that are not also contained in the given set <code>that</code>.
  36.141 -   */
  36.142 -  def diff(that: Set[A]): This = --(that)
  36.143 -
  36.144 -  /** The difference of this set and the given set <code>that</code>.
  36.145 -   *
  36.146 -   *  @param that the set of elements to remove
  36.147 -   *  @return     a set containing those elements of this
  36.148 -   *              set that are not also contained in the given set <code>that</code>.
  36.149 -   *  @note       same as <code>diff</code>.
  36.150 -   */
  36.151 -  def &~(that: Set[A]): This = diff(that)
  36.152 -
  36.153 -  /** Checks if this set is a subset of set <code>that</code>.
  36.154 -   *
  36.155 -   *  @param that another set.
  36.156 -   *  @return     <code>true</code> iff the other set is a superset of
  36.157 -   *              this set.
  36.158 -   *  todo: rename to isSubsetOf  
  36.159 -   */
  36.160 -  def subsetOf(that: Set[A]): Boolean = forall(that.contains)
  36.161 -
  36.162 -  /** Defines the prefix of this object's <code>toString</code> representation.
  36.163 -   */
  36.164 -  override def stringPrefix: String = "Set"
  36.165 -
  36.166 -  /** Need to override string, so that it's not the Function1's string that gets mixed in.
  36.167 -   */
  36.168 -  override def toString = super[IterableLike].toString
  36.169 -  
  36.170 -  override def hashCode() = this map (_.hashCode) sum
  36.171 -  
  36.172 -  /** Compares this set with another object and returns true, iff the
  36.173 -   *  other object is also a set which contains the same elements as
  36.174 -   *  this set.
  36.175 -   *
  36.176 -   *  @param that the other object
  36.177 -   *  @note not necessarily run-time type safe.
  36.178 -   *  @return     <code>true</code> iff this set and the other set
  36.179 -   *              contain the same elements.
  36.180 -   */
  36.181 -  override def equals(that: Any): Boolean = that match {
  36.182 -    case that: Set[A] =>
  36.183 -      (this eq that) ||
  36.184 -      (that canEqual this) &&
  36.185 -      (this.size == that.size) &&
  36.186 -      (try this subsetOf that.asInstanceOf[Set[A]]
  36.187 -       catch { case ex: ClassCastException => false })
  36.188 -    case _ =>
  36.189 -      false
  36.190 -  }
  36.191 -}
    37.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SetProxy.scala	Tue Nov 03 13:08:38 2009 +0800
    37.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.3 @@ -1,24 +0,0 @@
    37.4 -/*                     __                                               *\
    37.5 -**     ________ ___   / /  ___     Scala API                            **
    37.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    37.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    37.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    37.9 -**                          |/                                          **
   37.10 -\*                                                                      */
   37.11 -
   37.12 -// $Id: SetProxy.scala 18791 2009-09-25 16:20:13Z odersky $
   37.13 -
   37.14 -
   37.15 -package org.aiotrade.lib.collection
   37.16 -
   37.17 -/** This is a simple wrapper class for <a href="Set.html"
   37.18 - *  target="contentFrame"><code>scala.collection.Set</code></a>.
   37.19 - *  It is most useful for assembling customized set abstractions
   37.20 - *  dynamically using object composition and forwarding.
   37.21 - *
   37.22 - *  @author  Matthias Zenger
   37.23 - *  @author  Martin Odersky
   37.24 - *  @version 2.0, 01/01/2007
   37.25 - */
   37.26 -
   37.27 -trait SetProxy[A] extends Set[A] with SetProxyLike[A, Set[A]]
    38.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SetProxyLike.scala	Tue Nov 03 13:08:38 2009 +0800
    38.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.3 @@ -1,37 +0,0 @@
    38.4 -/*                     __                                               *\
    38.5 -**     ________ ___   / /  ___     Scala API                            **
    38.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    38.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    38.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    38.9 -**                          |/                                          **
   38.10 -\*                                                                      */
   38.11 -
   38.12 -
   38.13 -package org.aiotrade.lib.collection
   38.14 -
   38.15 -import generic._
   38.16 -
   38.17 -// Methods could be printed by  cat SetLike.scala | egrep '^  (override )?def'
   38.18 -
   38.19 -/** This trait implements a proxy for sets. It forwards
   38.20 - *  all calls to a different set.
   38.21 - *
   38.22 - *  @author  Martin Odersky
   38.23 - *  @version 2.8
   38.24 - */
   38.25 -trait SetProxyLike[A, +This <: SetLike[A, This] with Set[A]] extends SetLike[A, This] with IterableProxyLike[A, This]
   38.26 -{ 
   38.27 -  // def empty: This
   38.28 -  // def + (elem: A): This
   38.29 -  // def - (elem: A): This
   38.30 -  override def contains(elem: A): Boolean = self.contains(elem)
   38.31 -  override def isEmpty: Boolean = self.isEmpty
   38.32 -  override def apply(elem: A): Boolean = self.apply(elem)
   38.33 -  override def intersect(that: Set[A]) = self.intersect(that)
   38.34 -  override def &(that: Set[A]): This = self.&(that)
   38.35 -  override def union(that: Set[A]): This = self.union(that)
   38.36 -  override def | (that: Set[A]): This = self.|(that)
   38.37 -  override def diff(that: Set[A]): This = self.diff(that)
   38.38 -  override def &~(that: Set[A]): This = self.&~(that)
   38.39 -  override def subsetOf(that: Set[A]): Boolean = self.subsetOf(that)
   38.40 -}
    39.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SortedMap.scala	Tue Nov 03 13:08:38 2009 +0800
    39.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.3 @@ -1,39 +0,0 @@
    39.4 -/*                     __                                               *\
    39.5 -**     ________ ___   / /  ___     Scala API                            **
    39.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    39.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    39.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    39.9 -**                          |/                                          **
   39.10 -\*                                                                      */
   39.11 -
   39.12 -// $Id: SortedMap.scala 19190 2009-10-21 13:24:41Z moors $
   39.13 -package org.aiotrade.lib.collection
   39.14 -
   39.15 -import generic._
   39.16 -import mutable.Builder
   39.17 -
   39.18 -/** A map whose keys are sorted.
   39.19 - *
   39.20 - *  @author Sean McDirmid
   39.21 - *  @author Martin Odersky
   39.22 - *  @version 2.8
   39.23 - *  @since   2.4
   39.24 - */
   39.25 -trait SortedMap[A, +B] extends Map[A, B] with SortedMapLike[A, B, SortedMap[A, B]] {
   39.26 -  /** Needs to be overridden in subclasses. */
   39.27 -  override def empty = SortedMap.empty[A, B]
   39.28 -
   39.29 -  override protected[this] def newBuilder : Builder[(A, B), SortedMap[A, B]] = 
   39.30 -    immutable.SortedMap.newBuilder[A, B]
   39.31 -}
   39.32 -
   39.33 -/**
   39.34 - * @since 2.8
   39.35 - */
   39.36 -object SortedMap extends ImmutableSortedMapFactory[immutable.SortedMap] {
   39.37 -  implicit def canBuildFrom[A, B](implicit ord: Ordering[A]): CanBuildFrom[Coll, (A, B), SortedMap[A, B]] = new SortedMapCanBuildFrom[A, B]
   39.38 -  def empty[A, B](implicit ord: Ordering[A]): immutable.SortedMap[A, B] = immutable.SortedMap.empty[A, B](ord)
   39.39 -}
   39.40 -
   39.41 -
   39.42 -
    40.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SortedMapLike.scala	Tue Nov 03 13:08:38 2009 +0800
    40.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.3 @@ -1,76 +0,0 @@
    40.4 -/*                     __                                               *\
    40.5 -**     ________ ___   / /  ___     Scala API                            **
    40.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    40.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    40.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    40.9 -**                          |/                                          **
   40.10 -\*                                                                      */
   40.11 -
   40.12 -// $Id: SortedMapLike.scala 18865 2009-10-01 19:31:06Z extempore $
   40.13 -
   40.14 -
   40.15 -package org.aiotrade.lib.collection
   40.16 -
   40.17 -import generic._
   40.18 -
   40.19 -/** A template for maps whose keys are sorted.
   40.20 - *  To create a concrete sorted map, you need to implement the rangeImpl method,
   40.21 - *  in addition to those of `MapLike`.
   40.22 - *
   40.23 - *  @author Sean McDirmid
   40.24 - *  @author Martin Odersky
   40.25 - *  @version 2.8
   40.26 - *  @since   2.8
   40.27 - */
   40.28 -trait SortedMapLike[A, +B, +This <: SortedMapLike[A, B, This] with SortedMap[A, B]] extends Sorted[A, This] with MapLike[A, B, This] { 
   40.29 -self =>
   40.30 -
   40.31 -  def firstKey : A = head._1
   40.32 -  def lastKey : A = last._1
   40.33 -
   40.34 -  implicit def ordering: Ordering[A]
   40.35 -
   40.36 -  // XXX: implement default version
   40.37 -  def rangeImpl(from : Option[A], until : Option[A]) : This
   40.38 -
   40.39 -  override def keySet : SortedSet[A] = new DefaultKeySortedSet
   40.40 -
   40.41 -  protected class DefaultKeySortedSet extends super.DefaultKeySet with SortedSet[A] {
   40.42 -    implicit def ordering = self.ordering
   40.43 -    override def + (elem: A): SortedSet[A] = (SortedSet[A]() ++ this + elem)
   40.44 -    override def - (elem: A): SortedSet[A] = (SortedSet[A]() ++ this - elem)
   40.45 -    override def rangeImpl(from : Option[A], until : Option[A]) : SortedSet[A] = {
   40.46 -      val map = self.rangeImpl(from, until)
   40.47 -      new map.DefaultKeySortedSet
   40.48 -    }
   40.49 -  }
   40.50 -
   40.51 -  /** Add a key/value pair to this map. 
   40.52 -   *  @param    key the key
   40.53 -   *  @param    value the value
   40.54 -   *  @return   A new map with the new binding added to this map
   40.55 -   */
   40.56 -  override def updated[B1 >: B](key: A, value: B1): SortedMap[A, B1] = this+((key, value))
   40.57 -
   40.58 -  /** Add a key/value pair to this map. 
   40.59 -   *  @param    kv the key/value pair
   40.60 -   *  @return   A new map with the new binding added to this map
   40.61 -   */
   40.62 -  def + [B1 >: B] (kv: (A, B1)): SortedMap[A, B1]
   40.63 -
   40.64 -  // todo: Add generic +,-, and so on.
   40.65 -
   40.66 -  /** Adds two or more elements to this collection and returns
   40.67 -   *  either the collection itself (if it is mutable), or a new collection
   40.68 -   *  with the added elements.
   40.69 -   *
   40.70 -   *  @param elem1 the first element to add.
   40.71 -   *  @param elem2 the second element to add.
   40.72 -   *  @param elems the remaining elements to add.
   40.73 -   */
   40.74 -  override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): SortedMap[A, B1] = {
   40.75 -    var m = this + elem1 + elem2;
   40.76 -    for (e <- elems) m = m + e
   40.77 -    m
   40.78 -  }
   40.79 -}
    41.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SortedSet.scala	Tue Nov 03 13:08:38 2009 +0800
    41.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.3 @@ -1,35 +0,0 @@
    41.4 -/*                     __                                               *\
    41.5 -**     ________ ___   / /  ___     Scala API                            **
    41.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    41.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    41.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    41.9 -**                          |/                                          **
   41.10 -\*                                                                      */
   41.11 -
   41.12 -// $Id: SortedSet.scala 19190 2009-10-21 13:24:41Z moors $
   41.13 -
   41.14 -package org.aiotrade.lib.collection
   41.15 -import generic._
   41.16 -
   41.17 -/** A sorted set.
   41.18 - *
   41.19 - *  @author Sean McDirmid
   41.20 - *  @author Martin Odersky
   41.21 - *  @version 2.8
   41.22 - *  @since   2.4
   41.23 - */
   41.24 -trait SortedSet[A] extends Set[A] with SortedSetLike[A, SortedSet[A]] {
   41.25 -  /** Needs to be overridden in subclasses. */
   41.26 -  override def empty: SortedSet[A] = SortedSet.empty[A]
   41.27 -}
   41.28 -
   41.29 -/**
   41.30 - * @since 2.8
   41.31 - */
   41.32 -object SortedSet extends ImmutableSortedSetFactory[immutable.SortedSet] {
   41.33 -  implicit def canBuildFrom[A](implicit ord: Ordering[A]): CanBuildFrom[Coll, A, SortedSet[A]] = new SortedSetCanBuildFrom[A]
   41.34 -  def empty[A](implicit ord: Ordering[A]): immutable.SortedSet[A] = immutable.SortedSet.empty[A](ord)
   41.35 -}
   41.36 -
   41.37 -
   41.38 -
    42.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/SortedSetLike.scala	Tue Nov 03 13:08:38 2009 +0800
    42.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.3 @@ -1,44 +0,0 @@
    42.4 -/*                     __                                               *\
    42.5 -**     ________ ___   / /  ___     Scala API                            **
    42.6 -**    / __/ __// _ | / /  / _ |    (c) 2006-2009, LAMP/EPFL             **
    42.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    42.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    42.9 -**                          |/                                          **
   42.10 -\*                                                                      */
   42.11 -
   42.12 -// $Id: SortedSetLike.scala 18865 2009-10-01 19:31:06Z extempore $
   42.13 -
   42.14 -package org.aiotrade.lib.collection
   42.15 -import generic._
   42.16 -
   42.17 -/** A template for sets which are sorted.
   42.18 - *
   42.19 - *  @author Sean McDirmid
   42.20 - *  @author Martin Odersky
   42.21 - *  @version 2.8
   42.22 - *  @since   2.8
   42.23 - */
   42.24 -trait SortedSetLike[A, +This <: SortedSet[A] with SortedSetLike[A, This]] extends Sorted[A, This] with SetLike[A, This] {
   42.25 -self =>
   42.26 -
   42.27 -  implicit def ordering: Ordering[A]
   42.28 -
   42.29 -  override def keySet = repr
   42.30 -
   42.31 -  override def firstKey: A = head
   42.32 -  override def lastKey: A = last
   42.33 -
   42.34 -  def rangeImpl(from: Option[A], until: Option[A]): This
   42.35 -
   42.36 -  override def from(from: A): This = rangeImpl(Some(from), None)
   42.37 -  override def until(until: A): This = rangeImpl(None, Some(until))
   42.38 -  override def range(from: A, until: A): This = rangeImpl(Some(from), Some(until))
   42.39 -
   42.40 -  override def subsetOf(that: Set[A]): Boolean = that match {
   42.41 -    // TODO: It may actually be pretty rare that the guard here ever 
   42.42 -    // passes. Is this really worth keeping? If it is, we should add
   42.43 -    // more sensible implementations of == to Ordering. 
   42.44 -    case that: SortedSet[_] if that.ordering == ordering => that.hasAll(this.iterator)
   42.45 -    case that => super.subsetOf(that)
   42.46 -  }
   42.47 -}
    43.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/Traversable.scala	Tue Nov 03 13:08:38 2009 +0800
    43.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.3 @@ -1,111 +0,0 @@
    43.4 -/*                     __                                               *\
    43.5 -**     ________ ___   / /  ___     Scala API                            **
    43.6 -**    / __/ __// _ | / /  / _ |    (c) 2003-2009, LAMP/EPFL             **
    43.7 -**  __\ \/ /__/ __ |/ /__/ __ |    http://scala-lang.org/               **
    43.8 -** /____/\___/_/ |_/____/_/ | |                                         **
    43.9 -**                          |/                                          **
   43.10 -\*                                                                      */
   43.11 -
   43.12 -// $Id: Traversable.scala 19219 2009-10-22 09:43:14Z moors $
   43.13 -
   43.14 -
   43.15 -package org.aiotrade.lib.collection
   43.16 -
   43.17 -import generic._
   43.18 -import mutable.{Builder, Buffer, ArrayBuffer, ListBuffer}
   43.19 -import scala.util.control.Breaks
   43.20 -
   43.21 -/** <p>
   43.22 - *    A template trait for traversable collections.
   43.23 - *  </p>
   43.24 - *  <p>
   43.25 - *    Collection classes mixing in this trait provide a method
   43.26 - *    <code>foreach</code> which traverses all the
   43.27 - *    elements contained in the collection, applying a given procedure to each.
   43.28 - *    They also provide a method <code>newBuilder</code>
   43.29 - *    which creates a builder for collections of the same kind.
   43.30 - *  </p>
   43.31 - *
   43.32 - *  @author Martin Odersky
   43.33 - *  @version 2.8
   43.34 - *  @since   2.8
   43.35 - */
   43.36 -trait Traversable[+A] extends TraversableLike[A, Traversable[A]] 
   43.37 -                         with GenericTraversableTemplate[A, Traversable] {
   43.38 -  def companion: GenericCompanion[Traversable] = Traversable
   43.39 -
   43.40 -  /* The following methods are inherited from TraversableLike
   43.41 -   * 
   43.42 -  override def isEmpty: Boolean
   43.43 -  override def size: Int
   43.44 -  override def hasDefiniteSize
   43.45 -  override def ++[B >: A, That](that: Traversable[B])(implicit bf: CanBuildFrom[Traversable[A], B, That]): That
   43.46 -  override def ++[B >: A, That](that: Iterator[B])(implicit bf: CanBuildFrom[Traversable[A], B, That]): That
   43.47 -  override def map[B, That](f: A => B)(implicit bf: CanBuildFrom[Traversable[A], B, That]): That
   43.48 -  override def flatMap[B, That](f: A => Traversable[B])(implicit bf: CanBuildFrom[Traversable[A], B, That]): That
   43.49 -  override def filter(p: A => Boolean): Traversable[A]
   43.50 -  override def remove(p: A => Boolean): Traversable[A]
   43.51 -  override def partition(p: A => Boolean): (Traversable[A], Traversable[A])
   43.52 -  override def groupBy[K](f: A => K): Map[K, Traversable[A]]
   43.53 -  override def foreach[U](f: A =>  U): Unit
   43.54 -  override def forall(p: A => Boolean): Boolean
   43.55 -  override def exists(p: A => Boolean): Boolean
   43.56 -  override def count(p: A => Boolean): Int
   43.57 -  override def find(p: A => Boolean): Option[A]
   43.58 -  override def foldLeft[B](z: B)(op: (B, A) => B): B
   43.59 -  override def /: [B](z: B)(op: (B, A) => B): B
   43.60 -  override def foldRight[B](z: B)(op: (A, B) => B): B
   43.61 -  override def :\ [B](z: B)(op: (A, B) => B): B
   43.62 -  override def reduceLeft[B >: A](op: (B, A) => B): B
   43.63 -  override def reduceLeftOption[B >: A](op: (B, A) => B): Option[B]
   43.64 -  override def reduceRight[B >: A](op: (A, B) => B): B
   43.65 -  override def reduceRightOption[B >: A](op: (A, B) => B): Option[B]
   43.66 -  override def head: A
   43.67 -  override def headOption: Option[A]
   43.68 -  override def tail: Traversable[A]
   43.69 -  override def last: A
   43.70 -  override def lastOption: Option[A]
   43.71 -  override def init: Traversable[A]
   43.72 -  override def take(n: Int): Traversable[A]
   43.73 -  override def drop(n: Int): Traversable[A]
   43.74 -  override def slice(from: Int, until: Int): Traversable[A]
   43.75 -  override def takeWhile(p: A => Boolean): Traversable[A]
   43.76 -  override def dropWhile(p: A => Boolean): Traversable[A]
   43.77 -  override def span(p: A => Boolean): (Traversable[A], Traversable[A])
   43.78 -  override def splitAt(n: Int): (Traversable[A], Traversable[A])
   43.79 -  override def copyToBuffer[B >: A](dest: Buffer[B])
   43.80 -  override def copyToArray[B >: A](xs: Array[B], start: Int, len: Int)
   43.81 -  override def copyToArray[B >: A](xs: Array[B], start: Int)
   43.82 -  override def toArray[B >: A : ClassManifest]: Array[B]
   43.83 -  override def toList: List[A]
   43.84 -  override def toIterable: Iterable[A]
   43.85 -  override def toSeq: Seq[A]
   43.86 -  override def toStream: Stream[A]
   43.87 -//  override def sortWith(lt : (A,A) => Boolean): Traversable[A]
   43.88 -  override def mkString(start: String, sep: String, end: String): String
   43.89 -  override def mkString(sep: String): String
   43.90 -  override def mkString: String
   43.91 -  override def addString(b: StringBuilder, start: String, sep: String, end: String): StringBuilder
   43.92 -  override def addString(b: StringBuilder, sep: String): StringBuilder
   43.93 -  override def addString(b: StringBuilder): StringBuilder
   43.94 -  override def toString
   43.95 -  override def stringPrefix : String
   43.96 -  override def view
   43.97 -  override def view(from: Int, until: Int): TraversableView[A, Traversable[A]]
   43.98 -  */
   43.99 -}
  43.100 -
  43.101 -/** Factory methods and utilities for instances of type <code>Traversable</code>.
  43.102 - *
  43.103 - *  @author Martin Odersky
  43.104 - *  @version 2.8
  43.105 - */
  43.106 -object Traversable extends TraversableFactory[Traversable] { self =>
  43.107 -
  43.108 -  /** provide break functionality separate from client code */
  43.109 -  private[collection] val breaks: Breaks = new Breaks
  43.110 -  
  43.111 -  implicit def canBuildFrom[A]: CanBuildFrom[Coll, A, Traversable[A]] = new GenericCanBuildFrom[A]
  43.112 -  def newBuilder[A]: Builder[A, Traversable[A]] = immutable.Traversable.newBuilder[A]
  43.113 -}
  43.114 -
    44.1 --- a/modules/lib.collection/src/org/aiotrade/lib/collection/TraversableLike.scala	Tue Nov 03 13:08:38 2009 +0800
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,856 +0,0 @@
    44.4 -/*                     __                                               *\
    44.5 -**     ________ ___   / /  ___     Scala API                            **