added headers, svn keywords, updated pilib examples
git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@18038 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
parent
c4e803dd52
commit
cdf63878e3
|
@ -1,38 +1,37 @@
|
||||||
package examples.pilib
|
package examples.pilib
|
||||||
|
|
||||||
import scala.concurrent.pilib._
|
import scala.concurrent.pilib._
|
||||||
//import pilib._;
|
|
||||||
|
|
||||||
/** Church encoding of naturals in the Pi-calculus */
|
/** Church encoding of naturals in the Pi-calculus */
|
||||||
object piNat extends Application {
|
object piNat extends Application {
|
||||||
|
|
||||||
/** Locations of Pi-calculus natural */
|
/** Locations of Pi-calculus natural */
|
||||||
class NatChan extends Chan[Triple[Chan[unit], Chan[NatChan], Chan[NatChan]]]
|
class NatChan extends Chan[Triple[Chan[Unit], Chan[NatChan], Chan[NatChan]]]
|
||||||
|
|
||||||
/** Zero */
|
/** Zero */
|
||||||
def Z(l: NatChan): unit = choice (
|
def Z(l: NatChan): Unit = choice (
|
||||||
l * { case Triple(z, sd, d) => z.write(()) }
|
l * { case Triple(z, sd, d) => z.write(()) }
|
||||||
)
|
)
|
||||||
|
|
||||||
/** Successor of Double */
|
/** Successor of Double */
|
||||||
def SD(n: NatChan, l: NatChan): unit = choice (
|
def SD(n: NatChan, l: NatChan): Unit = choice (
|
||||||
l * { case Triple(z, sd, d) => sd.write(n) }
|
l * { case Triple(z, sd, d) => sd.write(n) }
|
||||||
)
|
)
|
||||||
|
|
||||||
/** Double */
|
/** Double */
|
||||||
def D(n: NatChan, l: NatChan): unit = choice (
|
def D(n: NatChan, l: NatChan): Unit = choice (
|
||||||
l * { case Triple(z, sd, d) => d.write(n) }
|
l * { case Triple(z, sd, d) => d.write(n) }
|
||||||
)
|
)
|
||||||
|
|
||||||
/** Make "l" a location representing the natural "n" */
|
/** Make "l" a location representing the natural "n" */
|
||||||
def make(n: int, l: NatChan): unit =
|
def make(n: Int, l: NatChan): Unit =
|
||||||
if (n == 0) Z(l)
|
if (n == 0) Z(l)
|
||||||
else if (n % 2 == 0) { val l1 = new NatChan; spawn < D(l1, l) >; make(n/2, l1) }
|
else if (n % 2 == 0) { val l1 = new NatChan; spawn < D(l1, l) >; make(n/2, l1) }
|
||||||
else { val l1 = new NatChan; spawn < SD(l1, l) >; make(n/2, l1) }
|
else { val l1 = new NatChan; spawn < SD(l1, l) >; make(n/2, l1) }
|
||||||
|
|
||||||
/** Consume the natural "m" and put it successor at location "n" */
|
/** Consume the natural "m" and put it successor at location "n" */
|
||||||
def Succ(m: NatChan, n: NatChan): unit = {
|
def Succ(m: NatChan, n: NatChan) {
|
||||||
val z = new Chan[unit]
|
val z = new Chan[Unit]
|
||||||
val sd = new Chan[NatChan]
|
val sd = new Chan[NatChan]
|
||||||
val d = new Chan[NatChan]
|
val d = new Chan[NatChan]
|
||||||
spawn < m.write(Triple(z, sd, d)) >;
|
spawn < m.write(Triple(z, sd, d)) >;
|
||||||
|
@ -44,8 +43,8 @@ object piNat extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Consume the natural "l" and put two copies at locations "m" and "n" */
|
/** Consume the natural "l" and put two copies at locations "m" and "n" */
|
||||||
def Copy(l: NatChan, m: NatChan, n: NatChan): unit = {
|
def Copy(l: NatChan, m: NatChan, n: NatChan) {
|
||||||
val z = new Chan[unit]
|
val z = new Chan[Unit]
|
||||||
val sd = new Chan[NatChan]
|
val sd = new Chan[NatChan]
|
||||||
val d = new Chan[NatChan]
|
val d = new Chan[NatChan]
|
||||||
spawn < l.write(Triple(z, sd, d)) >;
|
spawn < l.write(Triple(z, sd, d)) >;
|
||||||
|
@ -61,8 +60,8 @@ object piNat extends Application {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Consume the natural at location "n" and return its value */
|
/** Consume the natural at location "n" and return its value */
|
||||||
def value(n: NatChan): int = {
|
def value(n: NatChan): Int = {
|
||||||
val z = new Chan[unit]
|
val z = new Chan[Unit]
|
||||||
val sd = new Chan[NatChan]
|
val sd = new Chan[NatChan]
|
||||||
val d = new Chan[NatChan]
|
val d = new Chan[NatChan]
|
||||||
spawn < n.write(Triple(z, sd, d)) >;
|
spawn < n.write(Triple(z, sd, d)) >;
|
||||||
|
@ -84,7 +83,7 @@ object piNat extends Application {
|
||||||
make(i, l) |
|
make(i, l) |
|
||||||
Copy(l, l1, l2) |
|
Copy(l, l1, l2) |
|
||||||
Succ(l2, l3) |
|
Succ(l2, l3) |
|
||||||
System.out.println("" + i + " = " + value(l1)) |
|
println("" + i + " = " + value(l1)) |
|
||||||
System.out.println("succ " + i + " = " + value(l3)) >
|
println("succ " + i + " = " + value(l3)) >
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,14 +7,14 @@ object scheduler {
|
||||||
/**
|
/**
|
||||||
* Random number generator.
|
* Random number generator.
|
||||||
*/
|
*/
|
||||||
val random = new java.util.Random()
|
val random = new util.Random()
|
||||||
|
|
||||||
//***************** Scheduler ******************//
|
//***************** Scheduler ******************//
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cell of the scheduler whose attached agent is allowed to start.
|
* A cell of the scheduler whose attached agent is allowed to start.
|
||||||
*/
|
*/
|
||||||
def A(a: Chan[unit], b: Chan[unit])(d: Chan[unit], c: Chan[unit]): unit = {
|
def A(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
|
||||||
///- ... complete here ...
|
///- ... complete here ...
|
||||||
choice ( a * { x => C(a, b)(d, c) })
|
choice ( a * { x => C(a, b)(d, c) })
|
||||||
///+
|
///+
|
||||||
|
@ -23,7 +23,7 @@ object scheduler {
|
||||||
/**
|
/**
|
||||||
* A cell of the scheduler in another intermediate state.
|
* A cell of the scheduler in another intermediate state.
|
||||||
*/
|
*/
|
||||||
def C(a: Chan[unit], b: Chan[unit])(d: Chan[unit], c: Chan[unit]): unit = {
|
def C(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
|
||||||
///- ... complete here ...
|
///- ... complete here ...
|
||||||
choice (c * { x => B(a, b)(d, c) })
|
choice (c * { x => B(a, b)(d, c) })
|
||||||
///+
|
///+
|
||||||
|
@ -32,7 +32,7 @@ object scheduler {
|
||||||
/**
|
/**
|
||||||
* A cell of the scheduler whose attached agent is allowed to finish.
|
* A cell of the scheduler whose attached agent is allowed to finish.
|
||||||
*/
|
*/
|
||||||
def B(a: Chan[unit], b: Chan[unit])(d: Chan[unit], c: Chan[unit]): unit = {
|
def B(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
|
||||||
///- ... complete here ...
|
///- ... complete here ...
|
||||||
// choice (b * { x => D(a, b)(d, c) }) // incorrect naive solution
|
// choice (b * { x => D(a, b)(d, c) }) // incorrect naive solution
|
||||||
choice (
|
choice (
|
||||||
|
@ -45,7 +45,7 @@ object scheduler {
|
||||||
/**
|
/**
|
||||||
* A cell of the scheduler whose attached agent is not yet allowed to start.
|
* A cell of the scheduler whose attached agent is not yet allowed to start.
|
||||||
*/
|
*/
|
||||||
def D(a: Chan[unit], b: Chan[unit])(d: Chan[unit], c: Chan[unit]): unit = {
|
def D(a: Chan[Unit], b: Chan[Unit])(d: Chan[Unit], c: Chan[Unit]) {
|
||||||
///- ... complete here ...
|
///- ... complete here ...
|
||||||
choice (d(()) * A(a, b)(d, c))
|
choice (d(()) * A(a, b)(d, c))
|
||||||
///+
|
///+
|
||||||
|
@ -53,16 +53,16 @@ object scheduler {
|
||||||
|
|
||||||
//***************** Agents ******************//
|
//***************** Agents ******************//
|
||||||
|
|
||||||
def agent(i: Int)(a: Chan[unit], b: Chan[unit]): unit = {
|
def agent(i: Int)(a: Chan[Unit], b: Chan[Unit]) {
|
||||||
// 50% chance that we sleep forever
|
// 50% chance that we sleep forever
|
||||||
if (i == 0 && random.nextInt(10) < 5) {
|
if (i == 0 && random.nextInt(10) < 5) {
|
||||||
a.attach(x => System.out.println("Start and sleeps ----> " + i))
|
a.attach(x => println("Start and sleeps ----> " + i))
|
||||||
Thread.sleep(random.nextInt(1000))
|
Thread.sleep(random.nextInt(1000))
|
||||||
a.write(())
|
a.write(())
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
a.attach(x => System.out.println("Start ----> " + i))
|
a.attach(x => println("Start ----> " + i))
|
||||||
b.attach(x => System.out.println("Stop -> " + i))
|
b.attach(x => println("Stop -> " + i))
|
||||||
Thread.sleep(random.nextInt(1000))
|
Thread.sleep(random.nextInt(1000))
|
||||||
a.write(())
|
a.write(())
|
||||||
Thread.sleep(random.nextInt(1000))
|
Thread.sleep(random.nextInt(1000))
|
||||||
|
@ -77,7 +77,7 @@ object scheduler {
|
||||||
* Creates a scheduler for five agents (programs).
|
* Creates a scheduler for five agents (programs).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
def main(args: Array[String]): unit = {
|
def main(args: Array[String]) {
|
||||||
val agentNb = 5
|
val agentNb = 5
|
||||||
val agents = List.range(0, agentNb) map agent
|
val agents = List.range(0, agentNb) map agent
|
||||||
scheduleAgents(agents)
|
scheduleAgents(agents)
|
||||||
|
@ -89,22 +89,22 @@ object scheduler {
|
||||||
* A cell is modelled as a function that takes as parameters
|
* A cell is modelled as a function that takes as parameters
|
||||||
* input and output channels and which returns nothing.
|
* input and output channels and which returns nothing.
|
||||||
*/
|
*/
|
||||||
type Cell = (Chan[unit], Chan[unit]) => unit
|
type Cell = (Chan[Unit], Chan[Unit]) => Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a cell composed of two cells linked together.
|
* Creates a cell composed of two cells linked together.
|
||||||
*/
|
*/
|
||||||
def join(cell1: Cell, cell2: Cell): Cell =
|
def join(cell1: Cell, cell2: Cell): Cell =
|
||||||
(l: Chan[unit], r: Chan[unit]) => {
|
(l: Chan[Unit], r: Chan[Unit]) => {
|
||||||
val link = new Chan[unit];
|
val link = new Chan[Unit];
|
||||||
spawn < cell1(l, link) | cell2(link, r) >
|
spawn < cell1(l, link) | cell2(link, r) >
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Links the output of a cell to its input.
|
* Links the output of a cell to its input.
|
||||||
*/
|
*/
|
||||||
def close(cell: Cell): unit = {
|
def close(cell: Cell) {
|
||||||
val a = new Chan[unit]
|
val a = new Chan[Unit]
|
||||||
cell(a, a)
|
cell(a, a)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,25 +117,25 @@ object scheduler {
|
||||||
/**
|
/**
|
||||||
* Creates a cell consisting of a chain of cells.
|
* Creates a cell consisting of a chain of cells.
|
||||||
*/
|
*/
|
||||||
def makeRing(cells: List[Cell]): unit =
|
def makeRing(cells: List[Cell]): Unit =
|
||||||
close(chain(cells))
|
close(chain(cells))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An agent is modelled as a function that takes as parameters channels to
|
* An agent is modelled as a function that takes as parameters channels to
|
||||||
* signal that it has started or finished.
|
* signal that it has started or finished.
|
||||||
*/
|
*/
|
||||||
type Agent = (Chan[unit], Chan[unit]) => unit
|
type Agent = (Chan[Unit], Chan[Unit]) => Unit
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Takes a list of agents and schedules them.
|
* Takes a list of agents and schedules them.
|
||||||
*/
|
*/
|
||||||
def scheduleAgents(agents: List[Agent]): unit = {
|
def scheduleAgents(agents: List[Agent]) {
|
||||||
var firstAgent = true;
|
var firstAgent = true;
|
||||||
val cells = agents map (ag => {
|
val cells = agents map (ag => {
|
||||||
val a = new Chan[unit];
|
val a = new Chan[Unit];
|
||||||
val b = new Chan[unit];
|
val b = new Chan[Unit];
|
||||||
spawn < ag(a, b) >;
|
spawn < ag(a, b) >;
|
||||||
(d: Chan[unit], c: Chan[unit]) => if (firstAgent) {
|
(d: Chan[Unit], c: Chan[Unit]) => if (firstAgent) {
|
||||||
firstAgent = false;
|
firstAgent = false;
|
||||||
A(a, b)(d, c)
|
A(a, b)(d, c)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,19 @@
|
||||||
package examples.pilib
|
package examples.pilib
|
||||||
|
|
||||||
|
import scala.concurrent.pilib._
|
||||||
|
|
||||||
/** Solution of exercise session 6 (first question). */
|
/** Solution of exercise session 6 (first question). */
|
||||||
object semaphore {
|
object semaphore {
|
||||||
|
|
||||||
import scala.concurrent.pilib._
|
class Signal extends Chan[Unit] {
|
||||||
|
|
||||||
class Signal extends Chan[unit] {
|
|
||||||
def send = write(())
|
def send = write(())
|
||||||
def receive = read
|
def receive = read
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Interface. */
|
/** Interface. */
|
||||||
trait Semaphore {
|
trait Semaphore {
|
||||||
def get: unit
|
def get: Unit
|
||||||
def release: unit
|
def release: Unit
|
||||||
}
|
}
|
||||||
|
|
||||||
/** First implementation. */
|
/** First implementation. */
|
||||||
|
@ -22,10 +22,10 @@ object semaphore {
|
||||||
private val g = new Signal
|
private val g = new Signal
|
||||||
private val r = new Signal
|
private val r = new Signal
|
||||||
|
|
||||||
def get: unit = g.send
|
def get: Unit = g.send
|
||||||
def release: unit = r.send
|
def release: Unit = r.send
|
||||||
|
|
||||||
private def Sched: unit = choice (
|
private def Sched: Unit = choice (
|
||||||
g * (x => { r.receive; Sched }),
|
g * (x => { r.receive; Sched }),
|
||||||
r * (x => Sched)
|
r * (x => Sched)
|
||||||
)
|
)
|
||||||
|
@ -38,8 +38,8 @@ object semaphore {
|
||||||
private val a = new Signal
|
private val a = new Signal
|
||||||
private val na = new Signal
|
private val na = new Signal
|
||||||
|
|
||||||
def get: unit = { a.receive; spawn< na.send > }
|
def get { a.receive; spawn< na.send > }
|
||||||
def release: unit = choice (
|
def release: Unit = choice (
|
||||||
a * (x => spawn< a.send >),
|
a * (x => spawn< a.send >),
|
||||||
na * (x => spawn< a.send >)
|
na * (x => spawn< a.send >)
|
||||||
)
|
)
|
||||||
|
@ -47,24 +47,24 @@ object semaphore {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test program. */
|
/** Test program. */
|
||||||
def main(args: Array[String]): unit = {
|
def main(args: Array[String]) {
|
||||||
val random = new java.util.Random()
|
val random = new util.Random()
|
||||||
val sem = new Sem2
|
val sem = new Sem2
|
||||||
def mutex(p: => unit): unit = { sem.get; p; sem.release }
|
def mutex(p: => Unit) { sem.get; p; sem.release }
|
||||||
|
|
||||||
spawn< {
|
spawn< {
|
||||||
Thread.sleep(1 + random.nextInt(100));
|
Thread.sleep(1 + random.nextInt(100));
|
||||||
mutex( {
|
mutex( {
|
||||||
System.out.println("a1");
|
println("a1");
|
||||||
Thread.sleep(1 + random.nextInt(100));
|
Thread.sleep(1 + random.nextInt(100));
|
||||||
System.out.println("a2")
|
println("a2")
|
||||||
} )
|
} )
|
||||||
} | {
|
} | {
|
||||||
Thread.sleep(1 + random.nextInt(100));
|
Thread.sleep(1 + random.nextInt(100));
|
||||||
mutex( {
|
mutex( {
|
||||||
System.out.println("b1");
|
println("b1");
|
||||||
Thread.sleep(1 + random.nextInt(100));
|
Thread.sleep(1 + random.nextInt(100));
|
||||||
System.out.println("b2")
|
println("b2")
|
||||||
} )
|
} )
|
||||||
} >;
|
} >;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,18 @@ object twoPlaceBuffer extends Application {
|
||||||
/**
|
/**
|
||||||
* Specification.
|
* Specification.
|
||||||
*/
|
*/
|
||||||
def Spec[a](in: Chan[a], out: Chan[a]): Unit = {
|
def Spec[A](in: Chan[A], out: Chan[A]) {
|
||||||
|
|
||||||
def B0: unit = choice (
|
def B0: Unit = choice (
|
||||||
in * (x => B1(x))
|
in * (x => B1(x))
|
||||||
)
|
)
|
||||||
|
|
||||||
def B1(x: a): unit = choice (
|
def B1(x: A): Unit = choice (
|
||||||
out(x) * (B0),
|
out(x) * (B0),
|
||||||
in * (y => B2(x, y))
|
in * (y => B2(x, y))
|
||||||
)
|
)
|
||||||
|
|
||||||
def B2(x: a, y: a): unit = choice (
|
def B2(x: A, y: A): Unit = choice (
|
||||||
out(x) * (B1(y))
|
out(x) * (B1(y))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,38 +29,38 @@ object twoPlaceBuffer extends Application {
|
||||||
/**
|
/**
|
||||||
* Implementation using two one-place buffers.
|
* Implementation using two one-place buffers.
|
||||||
*/
|
*/
|
||||||
def Impl[a](in: Chan[a], out: Chan[a]): unit = {
|
def Impl[A](in: Chan[A], out: Chan[A]) {
|
||||||
///- ... complete here ...
|
///- ... complete here ...
|
||||||
// one-place buffer
|
// one-place buffer
|
||||||
def OnePlaceBuffer[a](in: Chan[a], out: Chan[a]): Unit = {
|
def OnePlaceBuffer[A](in: Chan[A], out: Chan[A]) {
|
||||||
def B0: unit = choice ( in * (x => B1(x)) )
|
def B0: Unit = choice ( in * (x => B1(x)) )
|
||||||
def B1(x: a): unit = choice ( out(x) * (B0))
|
def B1(x: A): Unit = choice ( out(x) * (B0))
|
||||||
B0
|
B0
|
||||||
}
|
}
|
||||||
val hidden = new Chan[a]
|
val hidden = new Chan[A]
|
||||||
spawn < OnePlaceBuffer(in, hidden) | OnePlaceBuffer(hidden, out) >
|
spawn < OnePlaceBuffer(in, hidden) | OnePlaceBuffer(hidden, out) >
|
||||||
///+
|
///+
|
||||||
}
|
}
|
||||||
|
|
||||||
val random = new java.util.Random()
|
val random = new util.Random()
|
||||||
|
|
||||||
def Producer(n: Int, in: Chan[String]): Unit = {
|
def Producer(n: Int, in: Chan[String]) {
|
||||||
Thread.sleep(random.nextInt(1000))
|
Thread.sleep(random.nextInt(1000))
|
||||||
val msg = "" + n
|
val msg = "" + n
|
||||||
choice (in(msg) * {})
|
choice (in(msg) * {})
|
||||||
Producer(n + 1, in)
|
Producer(n + 1, in)
|
||||||
}
|
}
|
||||||
|
|
||||||
def Consumer(out: Chan[String]): unit = {
|
def Consumer(out: Chan[String]) {
|
||||||
Thread.sleep(random.nextInt(1000));
|
Thread.sleep(random.nextInt(1000))
|
||||||
choice (out * { msg => () });
|
choice (out * { msg => () })
|
||||||
Consumer(out)
|
Consumer(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
val in = new Chan[String]
|
val in = new Chan[String]
|
||||||
in.attach(s => System.out.println("put " + s))
|
in.attach(s => println("put " + s))
|
||||||
val out = new Chan[String]
|
val out = new Chan[String]
|
||||||
out.attach(s => System.out.println("get " + s))
|
out.attach(s => println("get " + s))
|
||||||
//spawn < Producer(0, in) | Consumer(out) | Spec(in, out) >
|
//spawn < Producer(0, in) | Consumer(out) | Spec(in, out) >
|
||||||
spawn < Producer(0, in) | Consumer(out) | Impl(in, out) >
|
spawn < Producer(0, in) | Consumer(out) | Impl(in, out) >
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
// $Id: Traversable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
trait BitSetFactory[Coll <: BitSet with BitSetTemplate[Coll]] {
|
trait BitSetFactory[Coll <: BitSet with BitSetTemplate[Coll]] {
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import BitSetTemplate._
|
import BitSetTemplate._
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Buffer.scala 15799 2008-08-15 18:23:54Z odersky $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** The base trait of all builders.
|
/** The base trait of all builders.
|
||||||
* A builder lets one construct a collection incrementally, by adding elements
|
* A builder lets one construct a collection incrementally, by adding
|
||||||
* to the builder with += and then converting to the required collection type with
|
* elements to the builder with += and then converting to the required
|
||||||
* `result`.
|
* collection type with `result`.
|
||||||
*/
|
*/
|
||||||
trait Builder[-Elem, +To] extends Growable[Elem] {
|
trait Builder[-Elem, +To] extends Growable[Elem] {
|
||||||
|
|
||||||
|
@ -26,7 +26,8 @@ trait Builder[-Elem, +To] extends Growable[Elem] {
|
||||||
*/
|
*/
|
||||||
def clear()
|
def clear()
|
||||||
|
|
||||||
/** Returns collection resulting from this builder. The buffer's contents are undefined afterwards.
|
/** Returns collection resulting from this builder. The buffer's contents
|
||||||
|
* are undefined afterwards.
|
||||||
*/
|
*/
|
||||||
def result(): To
|
def result(): To
|
||||||
|
|
||||||
|
@ -35,8 +36,8 @@ trait Builder[-Elem, +To] extends Growable[Elem] {
|
||||||
*/
|
*/
|
||||||
def sizeHint(size: Int) {}
|
def sizeHint(size: Int) {}
|
||||||
|
|
||||||
/** Create a new builder which is the same as the current builder except that
|
/** Create a new builder which is the same as the current builder except
|
||||||
* a given function is applied to the current builder's result.
|
* that a given function is applied to the current builder's result.
|
||||||
* @param f the function to apply to the builder's result
|
* @param f the function to apply to the builder's result
|
||||||
*/
|
*/
|
||||||
def mapResult[NewTo](f: To => NewTo): Builder[Elem, NewTo] =
|
def mapResult[NewTo](f: To => NewTo): Builder[Elem, NewTo] =
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: CloneableCollection.scala 16893 2009-01-13 13:09:22Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
// $Id: Traversable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
abstract class Companion[+CC[X] <: Traversable[X]] {
|
abstract class Companion[+CC[X] <: Traversable[X]] {
|
||||||
|
@ -14,7 +17,7 @@ abstract class Companion[+CC[X] <: Traversable[X]] {
|
||||||
def newBuilder[A]: Builder[A, CC[A]]
|
def newBuilder[A]: Builder[A, CC[A]]
|
||||||
|
|
||||||
/** The empty iterable of type CC */
|
/** The empty iterable of type CC */
|
||||||
def empty[A]: CC[A] = newBuilder[A].result
|
def empty[A]: CC[A] = newBuilder[A].result
|
||||||
|
|
||||||
/** Creates an iterable of type CC with specified elements */
|
/** Creates an iterable of type CC with specified elements */
|
||||||
def apply[A](args: A*): CC[A] = {
|
def apply[A](args: A*): CC[A] = {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* __ *\
|
/* __ *\
|
||||||
** ________ ___ / / ___ Scala API **
|
** ________ ___ / / ___ Scala API **
|
||||||
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
** __\ \/ /__/ __ |/ /__/ __ | **
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: DoubleLinkedList.scala 16893 2009-01-13 13:09:22Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,17 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of immutable.Map and subclasses thereof.
|
/** A template for companion objects of <code>immutable.Map</code> and
|
||||||
|
* subclasses thereof.
|
||||||
*/
|
*/
|
||||||
abstract class ImmutableMapFactory[CC[A, +B] <: immutable.Map[A, B] with ImmutableMapTemplate[A, B, CC[A, B]]]
|
abstract class ImmutableMapFactory[CC[A, +B] <: immutable.Map[A, B] with ImmutableMapTemplate[A, B, CC[A, B]]]
|
||||||
extends MapFactory[CC] {
|
extends MapFactory[CC] {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of immutable.Map and subclasses thereof.
|
/** A template for companion objects of immutable.Map and subclasses thereof.
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of mutable.Map and subclasses thereof.
|
/** A template for companion objects of mutable.Map and subclasses thereof.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import Math.MAX_INT
|
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A base class for views of Iterables.
|
/** A base class for views of Iterables.
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import Math.MAX_INT
|
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A base class for views of Iterables.
|
/** A base class for views of Iterables.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
@ -19,8 +19,8 @@ import util.control.Breaks._
|
||||||
/** Class <code>Linear[A]</code> represents linear sequences of elements.
|
/** Class <code>Linear[A]</code> represents linear sequences of elements.
|
||||||
* For such sequences `isEmpty`, `head` and `tail` are guaranteed to be
|
* For such sequences `isEmpty`, `head` and `tail` are guaranteed to be
|
||||||
* efficient constant time (or near so) operations.
|
* efficient constant time (or near so) operations.
|
||||||
* It does not add any methods to Sequence but overrides several
|
* It does not add any methods to <code>Sequence</code> but overrides
|
||||||
* methods with optimized implementations.
|
* several methods with optimized implementations.
|
||||||
*
|
*
|
||||||
* @author Martin Odersky
|
* @author Martin Odersky
|
||||||
* @author Matthias Zenger
|
* @author Matthias Zenger
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: SingleLinkedList.scala 16893 2009-01-13 13:09:22Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
@ -25,13 +25,13 @@ trait LinkedListTemplate[A, This >: Null <: Sequence[A] with LinkedListTemplate[
|
||||||
var elem: A = _
|
var elem: A = _
|
||||||
var next: This = _
|
var next: This = _
|
||||||
|
|
||||||
override def isEmpty = false
|
override def isEmpty = false
|
||||||
|
|
||||||
override def length: Int = 1 + (if (next eq null) 0 else next.length)
|
override def length: Int = 1 + (if (next eq null) 0 else next.length)
|
||||||
|
|
||||||
override def head: A = elem
|
override def head: A = elem
|
||||||
|
|
||||||
override def tail: This = next
|
override def tail: This = next
|
||||||
|
|
||||||
def append(that: This): Unit =
|
def append(that: This): Unit =
|
||||||
if (next eq null) next = that else next.append(that)
|
if (next eq null) next = that else next.append(that)
|
||||||
|
@ -79,7 +79,7 @@ trait LinkedListTemplate[A, This >: Null <: Sequence[A] with LinkedListTemplate[
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def foreach[B](f: A => B): Unit = {
|
override def foreach[B](f: A => B) {
|
||||||
var these = this
|
var these = this
|
||||||
while (these ne null) {
|
while (these ne null) {
|
||||||
f(these.elem);
|
f(these.elem);
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of mutable.Map and subclasses thereof.
|
/** A template for companion objects of <code>mutable.Map</code> and
|
||||||
|
* subclasses thereof.
|
||||||
*/
|
*/
|
||||||
abstract class MapFactory[CC[A, B] <: Map[A, B] with MapTemplate[A, B, CC[A, B]]] {
|
abstract class MapFactory[CC[A, B] <: Map[A, B] with MapTemplate[A, B, CC[A, B]]] {
|
||||||
|
|
||||||
|
|
|
@ -6,26 +6,26 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A generic template for maps from keys of type A to values of type B.
|
/** A generic template for maps from keys of type A to values of type B.
|
||||||
* To implement a concrete map, you need to provide implementations of the following methods:
|
* To implement a concrete map, you need to provide implementations of the
|
||||||
* (where `This` is the type of the map in question):
|
* following methods (where `This` is the type of the map in question):<pre>
|
||||||
*
|
*
|
||||||
* def get(key: A): Option[B]
|
* def get(key: A): Option[B]
|
||||||
* def iterator: Iterator[(A, B)]
|
* def iterator: Iterator[(A, B)]
|
||||||
* def + [B1 >: B](kv: (A, B1)): This
|
* def + [B1 >: B](kv: (A, B1)): This
|
||||||
* def -(key: A): This
|
* def -(key: A): This</pre>
|
||||||
*
|
*
|
||||||
* If you wish that methods like, take, drop, filter return the same kind of map, you should also
|
* If you wish that methods like, take, drop, filter return the same kind of
|
||||||
* override:
|
* map, you should also override:<pre>
|
||||||
*
|
*
|
||||||
* def empty: This
|
* def empty: This</pre>
|
||||||
*
|
*
|
||||||
* It is also good idea to override methods foreach and size for efficiency.
|
* It is also good idea to override methods foreach and size for efficiency.
|
||||||
*/
|
*/
|
||||||
trait MapTemplate[A, +B, +This <: MapTemplate[A, B, This] with Map[A, B]]
|
trait MapTemplate[A, +B, +This <: MapTemplate[A, B, This] with Map[A, B]]
|
||||||
extends PartialFunction[A, B]
|
extends PartialFunction[A, B]
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of mutable.Map and subclasses thereof.
|
/** A template for companion objects of mutable.Map and subclasses thereof.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Map.scala 16884 2009-01-09 16:52:09Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A subtrait of collection.Vector which represents sequences
|
/** A subtrait of collection.Vector which represents sequences
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of Sequence and subclasses thereof.
|
/** A template for companion objects of Sequence and subclasses thereof.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: SeqProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
@ -52,7 +52,7 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]]
|
||||||
* is O(length min len) instead of O(length). The method should be overwritten
|
* is O(length min len) instead of O(length). The method should be overwritten
|
||||||
* if computing length is cheap.
|
* if computing length is cheap.
|
||||||
*/
|
*/
|
||||||
def lengthCompare(len: Int): Int = {
|
def lengthCompare(len: Int): Int = {
|
||||||
var i = 0
|
var i = 0
|
||||||
breakable {
|
breakable {
|
||||||
for (_ <- this) {
|
for (_ <- this) {
|
||||||
|
@ -181,7 +181,8 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]]
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns index of the first element satisying a predicate, or -1. */
|
/** Returns index of the first element satisying a predicate, or -1. */
|
||||||
@deprecated("Use `indexWhere' instead") def findIndexOf(p: A => Boolean): Int = indexWhere(p)
|
@deprecated("Use `indexWhere' instead")
|
||||||
|
def findIndexOf(p: A => Boolean): Int = indexWhere(p)
|
||||||
|
|
||||||
/** Returns the index of the first occurence of the specified
|
/** Returns the index of the first occurence of the specified
|
||||||
* object in this iterable object.
|
* object in this iterable object.
|
||||||
|
@ -265,7 +266,8 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]]
|
||||||
*/
|
*/
|
||||||
def reverseIterator: Iterator[A] = reverse.iterator
|
def reverseIterator: Iterator[A] = reverse.iterator
|
||||||
|
|
||||||
@deprecated("use `reverseIterator' instead") def reversedElements = reverseIterator
|
@deprecated("use `reverseIterator' instead")
|
||||||
|
def reversedElements = reverseIterator
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether the argument sequence is contained at the
|
* Checks whether the argument sequence is contained at the
|
||||||
|
@ -517,6 +519,7 @@ trait SequenceTemplate[+A, +This <: IterableTemplate[A, This] with Sequence[A]]
|
||||||
* <code>map</code>, and <code>flatMap</code> methods that build projections
|
* <code>map</code>, and <code>flatMap</code> methods that build projections
|
||||||
* of the collection.
|
* of the collection.
|
||||||
*/
|
*/
|
||||||
@deprecated("use `view' instead") override def projection = view
|
@deprecated("use `view' instead")
|
||||||
|
override def projection = view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,11 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import Sequence.fill
|
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A non-strict projection of an iterable.
|
/** A non-strict projection of an iterable.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: ListBuffer.scala 14378 2008-03-13 11:39:05Z dragos $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
// import collection.immutable.{List, Nil, ::}
|
// import collection.immutable.{List, Nil, ::}
|
||||||
|
|
||||||
/** The canonical builder for collections that are addable, i.e. that support an efficient + method
|
/** The canonical builder for collections that are addable, i.e. that support
|
||||||
* which adds an element to the collection.
|
* an efficient + method which adds an element to the collection.
|
||||||
* Collections are built from their empty element using this + method.
|
* Collections are built from their empty element using this + method.
|
||||||
* @param empty The empty element of the collection.
|
* @param empty The empty element of the collection.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
// $Id: Traversable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
trait SetClass[A, +CC[X] <: Set[X]] extends TraversableClass[A, CC] {
|
trait SetClass[A, +CC[X] <: Set[X]] extends TraversableClass[A, CC] {
|
||||||
|
|
|
@ -1,6 +1,18 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of Map and subclasses thereof.
|
/** A template for companion objects of <code>Map</code> and subclasses
|
||||||
|
* thereof.
|
||||||
*/
|
*/
|
||||||
abstract class SetFactory[CC[X] <: Set[X] with SetTemplate[X, CC[X]]]
|
abstract class SetFactory[CC[X] <: Set[X] with SetTemplate[X, CC[X]]]
|
||||||
extends Companion[CC] {
|
extends Companion[CC] {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sorted.scala 17537 2009-04-20 18:37:37Z odersky $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of mutable.Map and subclasses thereof.
|
/** A template for companion objects of mutable.Map and subclasses thereof.
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
/* __ *\
|
/* __ *\
|
||||||
** ________ ___ / / ___ Scala API **
|
** ________ ___ / / ___ Scala API **
|
||||||
** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
|
** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
|
||||||
** __\ \/ /__/ __ |/ /__/ __ | **
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: SortedMap.scala 16893 2009-01-13 13:09:22Z cunei $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for maps whose keys are sorted.
|
/** A template for maps whose keys are sorted.
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of Set and subclasses thereof.
|
/** A template for companion objects of Set and subclasses thereof.
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: SortedSet.scala 16893 2009-01-13 13:09:22Z cunei $
|
// $Id$
|
||||||
// !!! todo: integrate in new collections library
|
// !!! todo: integrate in new collections library
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Iterable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
// $Id: Traversable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
trait TraversableClass[+A, +CC[X] <: Traversable[X]] {
|
trait TraversableClass[+A, +CC[X] <: Traversable[X]] {
|
||||||
|
|
|
@ -1,4 +1,15 @@
|
||||||
package scala.collection.generic
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2006-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
|
package scala.collection.generic
|
||||||
|
|
||||||
/** A template for companion objects of Traversable and subclasses thereof.
|
/** A template for companion objects of Traversable and subclasses thereof.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: IterableProxy.scala 15458 2008-06-28 20:23:22Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
|
@ -6,17 +6,20 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Traversable.scala 15188 2008-05-24 15:01:02Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
// import immutable.{List, Stream, Nil} //!!!
|
// import immutable.{List, Stream, Nil} //!!!
|
||||||
import mutable.{Buffer, ArrayBuffer, ListBuffer}
|
import mutable.{Buffer, ArrayBuffer, ListBuffer}
|
||||||
|
|
||||||
/** A template trait for traversable collections.
|
/** A template trait for traversable collections.
|
||||||
* This is a base trait of all kinds of Scala collections. It implements the
|
* This is a base trait of all kinds of Scala collections. It implements
|
||||||
* behavior common to all collections, in terms of a method `foreach` with signature:
|
* the behavior common to all collections, in terms of a method
|
||||||
|
* <code>foreach</code> with signature:<pre>
|
||||||
*
|
*
|
||||||
* def foreach[U](f: Elem => U): Unit
|
* def foreach[U](f: Elem => U): Unit</pre>
|
||||||
*
|
*
|
||||||
* Collection classes mixing in this trait provide a concrete
|
* Collection classes mixing in this trait provide a concrete
|
||||||
* <code>foreach</code> method which traverses all the
|
* <code>foreach</code> method which traverses all the
|
||||||
|
|
|
@ -5,13 +5,17 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import Math.MAX_INT
|
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A base class for views of Traversable.
|
/** A base class for views of Traversable.
|
||||||
* Every subclass has to implenment the foreach method
|
* Every subclass has to implenment the foreach method
|
||||||
|
*
|
||||||
* @author Martin Odersky
|
* @author Martin Odersky
|
||||||
* @version 2.8
|
* @version 2.8
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5,13 +5,18 @@
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import Math.MAX_INT
|
import Math.MAX_INT
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A base class for views of Traversable.
|
/** A base class for views of <code>Traversable</code>.
|
||||||
* Every subclass has to implenment the foreach method
|
* Every subclass has to implenment the foreach method
|
||||||
|
*
|
||||||
* @author Martin Odersky
|
* @author Martin Odersky
|
||||||
* @version 2.8
|
* @version 2.8
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Vector.scala 15437 2008-06-25 16:22:45Z stepancheg $
|
// $Id$
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,15 @@
|
||||||
** |/ **
|
** |/ **
|
||||||
\* */
|
\* */
|
||||||
|
|
||||||
// $Id: Sequence.scala 16092 2008-09-12 10:37:06Z nielsen $
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.collection.generic
|
package scala.collection.generic
|
||||||
|
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A non-strict projection of an iterable.
|
/** A non-strict projection of an iterable.
|
||||||
|
*
|
||||||
* @author Sean McDirmid
|
* @author Sean McDirmid
|
||||||
* @author Martin Odersky
|
* @author Martin Odersky
|
||||||
* @version 2.8
|
* @version 2.8
|
||||||
|
|
|
@ -13,7 +13,8 @@ package scala.collection.generic
|
||||||
|
|
||||||
import TraversableView.NoBuilder
|
import TraversableView.NoBuilder
|
||||||
|
|
||||||
/** A non-strict projection of an iterable.
|
/** A non-strict projection of an iterable.
|
||||||
|
*
|
||||||
* @author Sean McDirmid
|
* @author Sean McDirmid
|
||||||
* @author Martin Odersky
|
* @author Martin Odersky
|
||||||
* @version 2.8
|
* @version 2.8
|
||||||
|
|
|
@ -1,15 +1,26 @@
|
||||||
|
/* __ *\
|
||||||
|
** ________ ___ / / ___ Scala API **
|
||||||
|
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
|
||||||
|
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
||||||
|
** /____/\___/_/ |_/____/_/ | | **
|
||||||
|
** |/ **
|
||||||
|
\* */
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
|
||||||
package scala.util.control
|
package scala.util.control
|
||||||
|
|
||||||
/** An object that can be used for the break control abstraction.
|
/** An object that can be used for the break control abstraction.
|
||||||
* Example usage:
|
* Example usage:<pre>
|
||||||
*
|
*
|
||||||
* import Breaks.{break, breakable}
|
* <b>import</b> Breaks.{break, breakable}
|
||||||
*
|
*
|
||||||
* breakable {
|
* breakable {
|
||||||
* for (...) {
|
* <b>for</b> (...) {
|
||||||
* if (...) break
|
* <b>if</b> (...) break
|
||||||
* }
|
* }
|
||||||
* }
|
* }</pre>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Breaks {
|
class Breaks {
|
||||||
|
|
Loading…
Reference in New Issue