summaryrefslogtreecommitdiff
path: root/sources
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2003-08-25 09:25:13 +0000
committermichelou <michelou@epfl.ch>2003-08-25 09:25:13 +0000
commitb0a00e8558e0794275640c1342874c9c24b7da95 (patch)
treefb1c01a4aaa33056c425ec884397738ddfbd01b1 /sources
parent1d4933eab0518189477401af2de9990cf89be22a (diff)
downloadscala-b0a00e8558e0794275640c1342874c9c24b7da95.tar.gz
scala-b0a00e8558e0794275640c1342874c9c24b7da95.tar.bz2
scala-b0a00e8558e0794275640c1342874c9c24b7da95.zip
- modified javadoc comments
Diffstat (limited to 'sources')
-rw-r--r--sources/scala/BufferedIterator.scala18
-rw-r--r--sources/scala/Iterable.scala22
-rw-r--r--sources/scala/PartialFunction.scala24
-rw-r--r--sources/scala/Seq.scala27
-rw-r--r--sources/scala/StructuralEquality.scala41
-rw-r--r--sources/scala/collection/Map.scala127
-rwxr-xr-xsources/scala/collection/immutable/GBTree.scala98
-rw-r--r--sources/scala/collection/immutable/Queue.scala104
-rw-r--r--sources/scala/collection/immutable/Stack.scala101
-rw-r--r--sources/scala/collection/mutable/Buffer.scala62
-rw-r--r--sources/scala/collection/mutable/Queue.scala73
-rw-r--r--sources/scala/collection/mutable/Stack.scala91
12 files changed, 469 insertions, 319 deletions
diff --git a/sources/scala/BufferedIterator.scala b/sources/scala/BufferedIterator.scala
index 7d65973630..a27f4cc34f 100644
--- a/sources/scala/BufferedIterator.scala
+++ b/sources/scala/BufferedIterator.scala
@@ -4,23 +4,27 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala;
-/** Buffered iterators are iterators which allow to inspect the next
- * element without discarding it.
+/**
+ * Buffered iterators are iterators which allow to inspect the next
+ * element without discarding it.
*
- * @author Martin Odersky
- * @version 1.0, 16/07/2003
+ * @author Martin Odersky
+ * @version 1.0, 16/07/2003
*/
trait BufferedIterator[+A] extends Iterator[A] {
- /** Checks what the next available element is.
+ /**
+ * Checks what the next available element is.
*
- * @returns the current element
+ * @return the current element
*/
def head: A;
+
}
diff --git a/sources/scala/Iterable.scala b/sources/scala/Iterable.scala
index 64aff4c8b6..bd13c40dfe 100644
--- a/sources/scala/Iterable.scala
+++ b/sources/scala/Iterable.scala
@@ -4,25 +4,29 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala;
-/** Collection classes supporting this trait provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
+/**
+ * Collection classes supporting this trait provide a method
+ * <code>elements</code> which returns an iterator over all the
+ * elements contained in the collection.
*
- * @author Matthias Zenger
- * @version 1.0, 16/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 16/07/2003
*/
trait Iterable[+A] {
- /** Creates a new iterator over all elements contained in this
- * object.
+ /**
+ * Creates a new iterator over all elements contained in this
+ * object.
*
- * @returns the new iterator
+ * @return the new iterator
*/
def elements: Iterator[A];
+
}
diff --git a/sources/scala/PartialFunction.scala b/sources/scala/PartialFunction.scala
index e0ed25c0bf..2d72625b76 100644
--- a/sources/scala/PartialFunction.scala
+++ b/sources/scala/PartialFunction.scala
@@ -4,26 +4,30 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala;
-/** A partial function of type <code>PartialFunction[A, B]</code> is a
- * unary function where the domain does not include all values of type
- * <code>A</code>. The function <code>isDefinedAt</code> allows to
- * test dynamically, if a value is in the domain of the function.
+/**
+ * A partial function of type <code>PartialFunction[A, B]</code> is a
+ * unary function where the domain does not include all values of type
+ * <code>A</code>. The function <code>isDefinedAt</code> allows to
+ * test dynamically, if a value is in the domain of the function.
*
- * @author Martin Odersky
- * @version 1.0, 16/07/2003
+ * @author Martin Odersky
+ * @version 1.0, 16/07/2003
*/
trait PartialFunction[-A, +B] with Function1[A, B] {
- /** Checks if a value is contained in the functions domain.
+ /**
+ * Checks if a value is contained in the functions domain.
*
- * @param x the value to test
- * @returns true, iff <code>x</code> is in the domain of this function.
+ * @param x the value to test
+ * @return true, iff <code>x</code> is in the domain of this function.
*/
def isDefinedAt(x: A): Boolean;
+
}
diff --git a/sources/scala/Seq.scala b/sources/scala/Seq.scala
index 30db5ec3cf..29a63c2f72 100644
--- a/sources/scala/Seq.scala
+++ b/sources/scala/Seq.scala
@@ -4,35 +4,40 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala;
-/** Class <code>Seq[A]</code> represents finite sequences of elements
- * of type <code>A</code>.
+/**
+ * Class <code>Seq[A]</code> represents finite sequences of elements
+ * of type <code>A</code>.
*
- * @author Martin Odersky
- * @version 1.0, 16/07/2003
+ * @author Martin Odersky
+ * @version 1.0, 16/07/2003
*/
trait Seq[+A] with PartialFunction[Int, A] with Iterable[A] {
- /** Returns the length of the sequence.
+ /**
+ * Returns the length of the sequence.
*
- * @returns the sequence length.
+ * @return the sequence length.
*/
def length: Int;
- /** Is this partial function defined for the index <code>x</code>?
+ /**
+ * Is this partial function defined for the index <code>x</code>?
*
- * @returns true, iff <code>x</code> is a legal sequence index.
+ * @return true, iff <code>x</code> is a legal sequence index.
*/
def isDefinedAt(x: Int): Boolean = (x >= 0) && (x < length);
- /** Customizes the <code>toString</code> method.
+ /**
+ * Customizes the <code>toString</code> method.
*
- * @returns a string representation of this sequence.
+ * @return a string representation of this sequence.
*/
override def toString() = {
def toString1(it: Iterator[A]):String = {
diff --git a/sources/scala/StructuralEquality.scala b/sources/scala/StructuralEquality.scala
index 38e0b6a44c..08d5d2eb09 100644
--- a/sources/scala/StructuralEquality.scala
+++ b/sources/scala/StructuralEquality.scala
@@ -4,38 +4,43 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala;
-/** Collection classes supporting this trait provide a method
- * <code>elements</code> which returns an iterator over all the
- * elements contained in the collection.
+/**
+ * Collection classes supporting this trait provide a method
+ * <code>elements</code> which returns an iterator over all the
+ * elements contained in the collection.
*
- * @author Matthias Zenger
- * @version 1.0, 16/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 16/07/2003
*/
trait StructuralEquality[+A <: StructuralEquality[A]] {
- /** Compares this object with the provided object structurally;
- * i.e. by looking at the internal structure of aggregated objects.
- * <code>===</code> does not have to be compatible with the
- * <code>hashCode</code> method.
+ /**
+ * Compares this object with the provided object structurally;
+ * i.e. by looking at the internal structure of aggregated objects.
+ * <code>===</code> does not have to be compatible with the
+ * <code>hashCode</code> method.
*
- * @param that the other object
- * @returns true, iff <code>this</code> and <code>that</code> are
- * structurally equivalent.
+ * @param that the other object
+ * @return true, iff <code>this</code> and <code>that</code> are
+ * structurally equivalent.
*/
def ===[B >: A](that: B): Boolean = (this == that);
- /** Compares this object with the provided object structurally
- * and returns true, iff the two objects differ.
+ /**
+ * Compares this object with the provided object structurally
+ * and returns true, iff the two objects differ.
*
- * @param that the other object
- * @returns false, iff <code>this</code> and <code>that</code> are
- * structurally equivalent.
+ * @param that the other object
+ * @return false, iff <code>this</code> and <code>that</code> are
+ * structurally equivalent.
*/
def !==[B >: A](that: B): Boolean = !(this === that);
+
}
diff --git a/sources/scala/collection/Map.scala b/sources/scala/collection/Map.scala
index c06048fd05..82ae25a317 100644
--- a/sources/scala/collection/Map.scala
+++ b/sources/scala/collection/Map.scala
@@ -4,82 +4,91 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala.collection;
-/** This trait defines the interface of collections that unambiguously map
- * keys to values (i.e. a key is mapped to at least one value).
- * Trait <code>Map</code> may only be used for
- * accessing elements from map implementations. Two different extensions
- * of trait <code>Map</code> in the package <code>scala.collections.mutable</code>
- * and <code>scala.collections.immutable</code> provide functionality for
- * adding new key/value mappings to a map. The trait in the first package is
- * implemented by maps that are modified destructively, whereas the trait in
- * the second package is used by functional map implementations that rely on
- * immutable data structures.
+/**
+ * This trait defines the interface of collections that unambiguously map
+ * keys to values (i.e. a key is mapped to at least one value).
+ * Trait <code>Map</code> may only be used for
+ * accessing elements from map implementations. Two different extensions
+ * of trait <code>Map</code> in the package <code>scala.collections.mutable</code>
+ * and <code>scala.collections.immutable</code> provide functionality for
+ * adding new key/value mappings to a map. The trait in the first package is
+ * implemented by maps that are modified destructively, whereas the trait in
+ * the second package is used by functional map implementations that rely on
+ * immutable data structures.
*
- * @author Matthias Zenger
- * @version 1.0, 08/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 08/07/2003
*/
trait Map[A, +B] with PartialFunction[A, B]
with Iterable[Pair[A, B]]
with StructuralEquality[Map[A, B]]{
- /** Compute the number of key-to-value mappings.
+ /**
+ * Compute the number of key-to-value mappings.
*
- * @returns the number of mappings
+ * @return the number of mappings
*/
def size: Int;
- /** Check if this map maps <code>key</code> to a value and return the
- * value if it exists.
+ /**
+ * Check if this map maps <code>key</code> to a value and return the
+ * value if it exists.
*
- * @param key the key of the mapping of interest
- * @returns the value of the mapping, if it exists
+ * @param key the key of the mapping of interest
+ * @return the value of the mapping, if it exists
*/
def get(key: A): Option[B];
- /** Is this an empty map?
+ /**
+ * Is this an empty map?
*
- * @returns true, iff the map is empty.
+ * @return true, iff the map is empty.
*/
def isEmpty: Boolean = (size == 0);
- /** Retrieve the value which is associated with the given key. This
- * method throws an exception if there is no mapping from the given
- * key to a value.
+ /**
+ * Retrieve the value which is associated with the given key. This
+ * method throws an exception if there is no mapping from the given
+ * key to a value.
*
- * @param key the key
- * @returns the value associated with the given key.
+ * @param key the key
+ * @return the value associated with the given key.
*/
def apply(key: A): B = get(key) match {
case None => error("key not found")
case Some(value) => value
}
- /** Is the given key mapped to a value by this map?
+ /**
+ * Is the given key mapped to a value by this map?
*
- * @param key the key
- * @returns true, iff there is a mapping for key in this map
+ * @param key the key
+ * @return true, iff there is a mapping for key in this map
*/
def contains(key: A): Boolean = get(key) match {
case None => false
case Some(_) => true
}
- /** Does this map contain a mapping from the given key to a value?
+ /**
+ * Does this map contain a mapping from the given key to a value?
*
- * @param key the key
- * @returns true, iff there is a mapping for key in this map
+ * @param key the key
+ * @return true, iff there is a mapping for key in this map
*/
def isDefinedAt(key: A) = contains(key);
- /** Creates an iterator for all keys.
+ /**
+ * Creates an iterator for all keys.
*
- * @returns an iterator over all keys.
+ * @return an iterator over all keys.
*/
def keys: Iterator[A] = new Iterator[A] {
val iter = Map.this.elements;
@@ -87,9 +96,10 @@ trait Map[A, +B] with PartialFunction[A, B]
def next = iter.next._1;
}
- /** Creates an iterator for a contained values.
+ /**
+ * Creates an iterator for a contained values.
*
- * @returns an iterator over all values.
+ * @return an iterator over all values.
*/
def values: Iterator[B] = new Iterator[B] {
val iter = Map.this.elements;
@@ -97,10 +107,11 @@ trait Map[A, +B] with PartialFunction[A, B]
def next = iter.next._2;
}
- /** Executes the given function for all (key, value) pairs
- * contained in this map.
+ /**
+ * Executes the given function for all (key, value) pairs
+ * contained in this map.
*
- * @param f the function to execute.
+ * @param f the function to execute.
*/
def foreach(f: (A, B) => Unit) = {
val iter = elements;
@@ -110,32 +121,35 @@ trait Map[A, +B] with PartialFunction[A, B]
}
}
- /** Applies the given predicate to all (key, value) mappings
+ /**
+ * Applies the given predicate to all (key, value) mappings
* contained in this map and returns true if this predicate
* yields true for all mappings.
*
* @param p the predicate
- * @returns true, iff p yields true for all mappings.
+ * @return true, iff p yields true for all mappings.
*/
def forall(p: (A, B) => Boolean): Boolean = elements.forall {
case Pair(key, value) => p(key, value)
}
- /** Applies the given predicate to all (key, value) mappings
- * contained in this map and returns true if there is at least
- * one mapping for which this predicate yields true.
+ /**
+ * Applies the given predicate to all (key, value) mappings
+ * contained in this map and returns true if there is at least
+ * one mapping for which this predicate yields true.
*
- * @param p the predicate
- * @returns true, iff there is at least one mapping for which
- * p yields true.
+ * @param p the predicate
+ * @return true, iff there is at least one mapping for which
+ * p yields true.
*/
def exists(p: (A, B) => Boolean): Boolean = elements.exists {
case Pair(key, value) => p(key, value)
}
- /** Creates a list of all (key, value) mappings.
+ /**
+ * Creates a list of all (key, value) mappings.
*
- * @returns the list of all mappings
+ * @return the list of all mappings
*/
def toList: List[Pair[A, B]] = {
var res: List[Pair[A, B]] = Nil;
@@ -143,11 +157,12 @@ trait Map[A, +B] with PartialFunction[A, B]
res;
}
- /** Compares two maps structurally; i.e. checks if all mappings
- * contained in this map are also contained in the other map,
- * and vice versa.
+ /**
+ * Compares two maps structurally; i.e. checks if all mappings
+ * contained in this map are also contained in the other map,
+ * and vice versa.
*
- * @returns true, iff both maps contain exactly the same mappings.
+ * @return true, iff both maps contain exactly the same mappings.
*/
override def ===[C >: Map[A, B]](that: C): Boolean =
that.isInstanceOf[Map[A, B]] &&
@@ -160,9 +175,10 @@ trait Map[A, +B] with PartialFunction[A, B]
}
}};
- /** Creates a string representation for this map.
+ /**
+ * Creates a string representation for this map.
*
- * @returns a string showing all mappings
+ * @return a string showing all mappings
*/
override def toString() =
if (size == 0)
@@ -176,4 +192,5 @@ trait Map[A, +B] with PartialFunction[A, B]
}
res;
} + "}";
+
}
diff --git a/sources/scala/collection/immutable/GBTree.scala b/sources/scala/collection/immutable/GBTree.scala
index a30405a9c9..edceffa535 100755
--- a/sources/scala/collection/immutable/GBTree.scala
+++ b/sources/scala/collection/immutable/GBTree.scala
@@ -4,12 +4,14 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
-** =====================================================================*/
+\* */
+
+// $Id$
+
/* General Balanced Trees - highly efficient functional dictionaries.
**
** This is a scala version of gb_trees.erl which is
-** copyrighted (C) 1999-2001 by Sven-Olof Nyström, and Richard Carlsson
+** copyrighted (C) 1999-2001 by Sven-Olof Nyström, and Richard Carlsson
**
** An efficient implementation of Prof. Arne Andersson's General
** Balanced Trees. These have no storage overhead compared to plain
@@ -43,19 +45,21 @@ object GBTree {
def Empty[A <: Ord[A], B] = new GBTree[A, B];
}
-/** General Balanced Trees - highly efficient functional dictionaries.
-**
-** An efficient implementation of Prof. Arne Andersson's General
-** Balanced Trees. These have no storage overhead compared to plain
-** unbalanced binary trees, and their performance is in general better
-** than AVL trees.
-** <p>
-** I make no attempt to balance trees after deletions. Since deletions
-** don't increase the height of a tree, I figure this is OK.
-**
-** @author Erik Stenman
-** @version 1.0, 10/07/2003
-*/
+/**
+ * General Balanced Trees - highly efficient functional dictionaries.
+ *
+ * An efficient implementation of Prof. Arne Andersson's General
+ * Balanced Trees. These have no storage overhead compared to plain
+ * unbalanced binary trees, and their performance is in general better
+ * than AVL trees.
+ * <p>
+ * I make no attempt to balance trees after deletions. Since deletions
+ * don't increase the height of a tree, I figure this is OK.
+ *
+ * @author Erik Stenman
+ * @version 1.0, 10/07/2003
+ */
+
/* Data structure:
** - Size - the number of elements in the tree.
** - Tree, which is composed of nodes of the form:
@@ -71,10 +75,13 @@ object GBTree {
class GBTree[A <: Ord[A], B]() with scala.collection.immutable.Map[A, B, GBTree[A,B]] {
private type TREE = Tree[A,B];
- /** - size: returns the number of nodes in the tree as an integer.
- ** Returns 0 (zero) if the tree is empty.
- **/
+ /**
+ * Returns the number of nodes in the tree as an integer.
+ *
+ * @return Returns 0 (zero) if the tree is empty.
+ */
def size = 0;
+
protected val tree:TREE = Nil[A,B]();
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -90,17 +97,19 @@ class GBTree[A <: Ord[A], B]() with scala.collection.immutable.Map[A, B, GBTree[
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
- /** Checks if the tree is empty.
+ /**
+ * Checks if the tree is empty.
*
- * @returns true, iff there is no element in the tree.
+ * @return true, iff there is no element in the tree.
*/
override def isEmpty = size == 0;
- /** Looks up the key in the tree;
- ** @returns Option.Some(v),
- ** or Option.None if the key is not present.
- **
- **/
+ /**
+ * Looks up the key in the tree;
+ *
+ * @return Option.Some(v),
+ * or Option.None if the key is not present.
+ */
def get(key:A) = get_1(key, tree);
/* Ord is an arithmetic total order, so we should not
@@ -120,7 +129,8 @@ class GBTree[A <: Ord[A], B]() with scala.collection.immutable.Map[A, B, GBTree[
case Nil() => None;
}
- /* This is a specialized version of `get'.
+ /**
+ * This is a specialized version of `get'.
*/
override def contains(key:A) = is_defined_1(key, tree);
@@ -134,13 +144,13 @@ class GBTree[A <: Ord[A], B]() with scala.collection.immutable.Map[A, B, GBTree[
case Nil() => false
}
-
-
- /** Retreives the value stored with the <code>key</code>
- ** in the tree. Assumes that the key is present in the tree.
- ** @returns the value stored with the <code>key</code>.
- ** @throws "key not found".
- **/
+ /**
+ * Retrieves the value stored with the <code>key</code>
+ * in the tree. Assumes that the key is present in the tree.
+ *
+ * @return the value stored with the <code>key</code>.
+ * @throws "key not found".
+ */
override def apply(key:A):B = apply_1(key, tree);
private def apply_1(key:A,t:Tree[A,B]):B =
@@ -180,15 +190,17 @@ class GBTree[A <: Ord[A], B]() with scala.collection.immutable.Map[A, B, GBTree[
- /** Inserts the key <code>key</code>
- ** with value <code>value</code> into the tree; returns
- ** the new tree.
- ** Assumes that the key is *not* present in the tree.
- ** @returns tree:GBTree[A,B].
- ** @throws GBTree.KeyExists(key)
- **/
+ /**
+ * Inserts the key <code>key</code>
+ * with value <code>value</code> into the tree; returns
+ * the new tree.
+ * Assumes that the key is *not* present in the tree.
+ *
+ * @return tree:GBTree[A,B].
+ * @throws GBTree.KeyExists(key)
+ */
def insert(key:A, value:B):GBTree[A,B] = {
- val s1 = size+1;
+ val s1 = size + 1;
val ITree(t1) = insert_1(key, value, tree, pow(s1, p));
mkGBTree(s1,t1);
@@ -311,8 +323,6 @@ class GBTree[A <: Ord[A], B]() with scala.collection.immutable.Map[A, B, GBTree[
}
-
-
def delete_any(key:A):GBTree[A,B] =
if(contains(key)) delete(key)
else this;
diff --git a/sources/scala/collection/immutable/Queue.scala b/sources/scala/collection/immutable/Queue.scala
index 8a525ab19d..d8158da5e2 100644
--- a/sources/scala/collection/immutable/Queue.scala
+++ b/sources/scala/collection/immutable/Queue.scala
@@ -4,23 +4,24 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala.collection.immutable;
-/** <code>Queue</code> objects implement data structures that allow to
- * insert and retrieve elements in a first-in-first-out (FIFO) manner.
+/**
+ * <code>Queue</code> objects implement data structures that allow to
+ * insert and retrieve elements in a first-in-first-out (FIFO) manner.
*
- * @author Erik Stenman
- * @version 1.0, 08/07/2003
+ * @author Erik Stenman
+ * @version 1.0, 08/07/2003
*/
-
object Queue {
val Empty:Queue[All] = new Queue();
}
-class Queue[+A](elem: A*)extends Seq[A]
+class Queue[+A](elem: A*) extends Seq[A]
with StructuralEquality[Queue[A]] {
protected val in:List[A] = Nil;
protected val out:List[A] = itToList(elem.elements);
@@ -37,66 +38,75 @@ class Queue[+A](elem: A*)extends Seq[A]
};
}
- /** Returns the <code>n</code>-th element of this queue.
- * The first element is at position 0.
- * @param n index of the element to return
- * @return the element at position <code>n</code> in this list.
- * @throws java.lang.RuntimeException if the list is too short.
- */
+ /**
+ * Returns the <code>n</code>-th element of this queue.
+ * The first element is at position 0.
+ *
+ * @param n index of the element to return
+ * @return the element at position <code>n</code> in this list.
+ * @throws java.lang.RuntimeException if the list is too short.
+ */
def apply(n: Int): A =
if (n < out.length) out.apply(n)
else in.reverse.apply(n - out.length);
- /** Returns the elements in the list as an iterator
+ /**
+ * Returns the elements in the list as an iterator
*/
def elements: Iterator[A] = (out:::(in.reverse)).elements;
- /** Checks if the queue is empty.
+ /**
+ * Checks if the queue is empty.
*
- * @returns true, iff there is no element in the queue.
+ * @return true, iff there is no element in the queue.
*/
def isEmpty: Boolean = (in.isEmpty && out.isEmpty);
- /** Returns the length of the queue.
+ /**
+ * Returns the length of the queue.
*/
def length = in.length + out.length;
- /** Creates a new queue with element added at the end
- * of the old queue.
+ /**
+ * Creates a new queue with element added at the end
+ * of the old queue.
*
- * @param elem the element to insert
+ * @param elem the element to insert
*/
def +[B >: A](elem: B) = mkQueue(elem::in,out);
- /** Returns a new queue with all all elements provided by
- * an <code>Iterable</code> object added at the end of
- * the queue.
- * The elements are prepended in the order they
- * are given out by the iterator.
+ /**
+ * Returns a new queue with all all elements provided by
+ * an <code>Iterable</code> object added at the end of
+ * the queue.
+ * The elements are prepended in the order they
+ * are given out by the iterator.
*
- * @param iter an iterable object
+ * @param iter an iterable object
*/
def +[B >: A](iter: Iterable[B]) = {
var q:List[B] = in;
iter.elements.foreach(e => q = (e::q));
- mkQueue(q,out);
+ mkQueue(q, out);
}
- /** Returns a new queue with all elements added.
+ /**
+ * Returns a new queue with all elements added.
*
- * @param elems the elements to add.
+ * @param elems the elements to add.
*/
def enqueue [B >: A](elems: B*) = (this + elems);
- /** Returns a tuple with the first element in the queue,
- * and a new queue with this element removed.
+ /**
+ * Returns a tuple with the first element in the queue,
+ * and a new queue with this element removed.
*
- * @returns the first element of the queue.
+ * @return the first element of the queue.
*/
def dequeue:Pair[A,Queue[A]] = {
- var newOut:List[A]=Nil;
- var newIn:List[A]=Nil;
+ var newOut:List[A] = Nil;
+ var newIn:List[A] = Nil;
if (out.isEmpty) {
newOut = in.reverse;
newIn = Nil;
@@ -107,13 +117,14 @@ class Queue[+A](elem: A*)extends Seq[A]
if (newOut.isEmpty)
error("queue empty");
else
- Pair(newOut.head,mkQueue(newIn,newOut.tail));
+ Pair(newOut.head, mkQueue(newIn, newOut.tail));
}
- /** Returns the first element in the queue, or throws an error if there
- * is no element contained in the queue.
+ /**
+ * Returns the first element in the queue, or throws an error if there
+ * is no element contained in the queue.
*
- * @returns the first element.
+ * @return the first element.
*/
def front: A =
if (out.isEmpty) {
@@ -121,7 +132,8 @@ class Queue[+A](elem: A*)extends Seq[A]
} else
out.head;
- /** Returns a string representation of this queue. The resulting string
+ /**
+ * Returns a string representation of this queue. The resulting string
* begins with the string <code>start</code> and is finished by the string
* <code>end</code>. Inside, the string representations of elements (w.r.t.
* the method <code>toString()</code>) are separated by the string
@@ -129,6 +141,7 @@ class Queue[+A](elem: A*)extends Seq[A]
* <p>
* Ex: <br>
* <code>Queue(1, 2, 3).mkString("(", "; ", ")") = "(1; 2; 3)"</code>
+ *
* @param start starting string.
* @param sep separator string.
* @param end ending string.
@@ -137,14 +150,16 @@ class Queue[+A](elem: A*)extends Seq[A]
def mkString(start: String, sep: String, end: String): String =
(out ::: (in.reverse)).mkString(start,sep,end);
- /** Returns a string representation of this queue.
+ /**
+ * Returns a string representation of this queue.
*/
override def toString() = (out ::: (in.reverse)).mkString("Queue(", ",", ")");
- /** Compares two queues for equality by comparing
- * each element in the queues.
+ /**
+ * Compares two queues for equality by comparing
+ * each element in the queues.
*
- * @returns true, iff the two queues are structurally equal.
+ * @return true, iff the two queues are structurally equal.
*/
override def equals(o: Any): Boolean = o match {
case q: Queue[Any] =>
@@ -168,6 +183,5 @@ class Queue[+A](elem: A*)extends Seq[A]
case _ => false; /* o is not a queue: not equal to this. */
}
-}
-
+}
diff --git a/sources/scala/collection/immutable/Stack.scala b/sources/scala/collection/immutable/Stack.scala
index 6f12460b9d..5ba966a6b9 100644
--- a/sources/scala/collection/immutable/Stack.scala
+++ b/sources/scala/collection/immutable/Stack.scala
@@ -4,9 +4,10 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala.collection.immutable;
@@ -14,41 +15,46 @@ object Stack {
def Empty[A] = new Stack[A];
}
-/** This class implements immutable stacks using a list-based data
- * structure. Instances of <code>Stack</code> represent
- * empty stacks; they can be either created by calling the constructor
- * directly, or by applying the function <code>Stack.Empty</code>.
+/**
+ * This class implements immutable stacks using a list-based data
+ * structure. Instances of <code>Stack</code> represent
+ * empty stacks; they can be either created by calling the constructor
+ * directly, or by applying the function <code>Stack.Empty</code>.
*
- * @author Matthias Zenger
- * @version 1.0, 10/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 10/07/2003
*/
class Stack[+A] with Seq[A] with StructuralEquality[Stack[A]] {
- /** Checks if this stack is empty.
+ /**
+ * Checks if this stack is empty.
*
- * @returns true, iff there is no element on the stack.
+ * @return true, iff there is no element on the stack.
*/
def isEmpty: Boolean = true;
- /** Returns the size of this stack.
+ /**
+ * Returns the size of this stack.
*
- * @returns the stack size.
+ * @return the stack size.
*/
def length: Int = 0;
- /** Push an element on the stack.
+ /**
+ * Push an element on the stack.
*
- * @param elem the element to push on the stack.
- * @returns the stack with the new element on top.
+ * @param elem the element to push on the stack.
+ * @return the stack with the new element on top.
*/
def +[B >: A](elem: B): Stack[B] = new Node(elem);
- /** Push all elements provided by the given iterable object onto
- * the stack. The last element returned by the iterable object
- * will be on top of the new stack.
+ /**
+ * Push all elements provided by the given iterable object onto
+ * the stack. The last element returned by the iterable object
+ * will be on top of the new stack.
*
- * @param elems the iterable object.
- * @returns the stack with the new elements on top.
+ * @param elems the iterable object.
+ * @return the stack with the new elements on top.
*/
def +[B >: A](elems: Iterable[B]): Stack[B] = {
var res: Stack[B] = this;
@@ -56,53 +62,60 @@ class Stack[+A] with Seq[A] with StructuralEquality[Stack[A]] {
res;
}
- /** Push a sequence of elements onto the stack. The last element
- * of the sequence will be on top of the new stack.
+ /**
+ * Push a sequence of elements onto the stack. The last element
+ * of the sequence will be on top of the new stack.
*
- * @param elems the element sequence.
- * @returns the stack with the new elements on top.
+ * @param elems the element sequence.
+ * @return the stack with the new elements on top.
*/
def push[B >: A](elems: B*): Stack[B] = this + elems;
- /** Returns the top element of the stack. An error is signaled if
- * there is no element on the stack.
+ /**
+ * Returns the top element of the stack. An error is signaled if
+ * there is no element on the stack.
*
- * @returns the top element.
+ * @return the top element.
*/
def top: A = error("no element on stack");
- /** Removes the top element from the stack.
+ /**
+ * Removes the top element from the stack.
*
- * @returns the new stack without the former top element.
+ * @return the new stack without the former top element.
*/
def pop: Stack[A] = error("no element on stack");
- /** Returns the n-th element of this stack. The top element has index
- * 0, elements below are indexed with increasing numbers.
+ /**
+ * Returns the n-th element of this stack. The top element has index
+ * 0, elements below are indexed with increasing numbers.
*
- * @param n the index number.
- * @returns the n-th element on the stack.
+ * @param n the index number.
+ * @return the n-th element on the stack.
*/
def apply(n: Int): A = error("no element on stack");
- /** Returns an iterator over all elements on the stack. The iterator
- * issues elements in the reversed order they were inserted into the
- * stack (LIFO order).
+ /**
+ * Returns an iterator over all elements on the stack. The iterator
+ * issues elements in the reversed order they were inserted into the
+ * stack (LIFO order).
*
- * @returns an iterator over all stack elements.
+ * @return an iterator over all stack elements.
*/
def elements: Iterator[A] = toList.elements;
- /** Creates a list of all stack elements in LIFO order.
+ /**
+ * Creates a list of all stack elements in LIFO order.
*
- * @returns the created list.
+ * @return the created list.
*/
def toList: List[A] = Nil;
- /** Compares this stack with the given object.
+ /**
+ * Compares this stack with the given object.
*
- * @returns true, iff the two stacks are equal; i.e. they contain the
- * same elements in the same order.
+ * @return true, iff the two stacks are equal; i.e. they contain the
+ * same elements in the same order.
*/
override def equals(obj: Any): Boolean =
if (obj.isInstanceOf[Stack[A]])
@@ -110,9 +123,10 @@ class Stack[+A] with Seq[A] with StructuralEquality[Stack[A]] {
else
false;
- /** Returns the hash code for this stack.
+ /**
+ * Returns the hash code for this stack.
*
- * @returns the hash code of the stack.
+ * @return the hash code of the stack.
*/
override def hashCode(): Int = 0;
@@ -129,4 +143,5 @@ class Stack[+A] with Seq[A] with StructuralEquality[Stack[A]] {
override def toList: List[B] = elem :: Stack.this.toList;
override def hashCode(): Int = elem.hashCode() + Stack.this.hashCode();
}
+
}
diff --git a/sources/scala/collection/mutable/Buffer.scala b/sources/scala/collection/mutable/Buffer.scala
index 487c493276..8a6ee778d8 100644
--- a/sources/scala/collection/mutable/Buffer.scala
+++ b/sources/scala/collection/mutable/Buffer.scala
@@ -4,30 +4,58 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala.collection.mutable;
-/** Buffers are used to create sequences of elements incrementally by
- * appending or prepending new elements. It is also possible to
- * access and modify elements in a random access fashion via the
- * index of the element in the sequence.
+/**
+ * Buffers are used to create sequences of elements incrementally by
+ * appending or prepending new elements. It is also possible to
+ * access and modify elements in a random access fashion via the
+ * index of the element in the sequence.
*
- * @author Matthias Zenger
- * @version 1.0, 08/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 08/07/2003
*/
class Buffer[A] with MutableList[A] with StructuralEquality[Buffer[A]] {
+ /**
+ * ..
+ *
+ * @param elem
+ */
def prepend(elem: A) = prependElem(elem);
+ /**
+ * ..
+ *
+ * @param elems
+ */
def append(elems: A*) = (this += elems);
+ /**
+ * ..
+ *
+ * @param elem
+ */
def +=(elem: A) = appendElem(elem);
+ /**
+ * ..
+ *
+ * @param iter
+ */
def +=(iter: Iterable[A]) = iter.elements.foreach(e => appendElem(e));
+ /**
+ * ..
+ *
+ * @param n
+ * @param newelem
+ */
def update(n: Int, newelem: A): Unit = {
var elem = first;
var i = n;
@@ -40,6 +68,12 @@ class Buffer[A] with MutableList[A] with StructuralEquality[Buffer[A]] {
elem.elem = newelem;
}
+ /**
+ * ..
+ *
+ * @param n
+ * @param newelem
+ */
def insert(n: Int, newelem: A): Unit = {
if (n == 0)
prepend(newelem);
@@ -59,6 +93,11 @@ class Buffer[A] with MutableList[A] with StructuralEquality[Buffer[A]] {
}
}
+ /**
+ * ..
+ *
+ * @param n
+ */
def remove(n: Int): A = {
val old = apply(n);
if (n >= len)
@@ -84,11 +123,15 @@ class Buffer[A] with MutableList[A] with StructuralEquality[Buffer[A]] {
old;
}
+ /**
+ * Clears the buffer contents
+ */
def clear: Unit = reset;
- /** Checks if two buffers are structurally identical.
+ /**
+ * Checks if two buffers are structurally identical.
*
- * @returns true, iff both buffers contain the same sequence of elements.
+ * @return true, iff both buffers contain the same sequence of elements.
*/
override def ===[B >: Buffer[A]](that: B) =
that.isInstanceOf[Buffer[A]] &&
@@ -96,4 +139,5 @@ class Buffer[A] with MutableList[A] with StructuralEquality[Buffer[A]] {
elements.zip(other.elements).forall {
case Pair(thiselem, thatelem) => thiselem == thatelem;
}};
+
}
diff --git a/sources/scala/collection/mutable/Queue.scala b/sources/scala/collection/mutable/Queue.scala
index 6810a9910d..55e36b1512 100644
--- a/sources/scala/collection/mutable/Queue.scala
+++ b/sources/scala/collection/mutable/Queue.scala
@@ -4,50 +4,57 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala.collection.mutable;
-/** <code>Queue</code> objects implement data structures that allow to
- * insert and retrieve elements in a first-in-first-out (FIFO) manner.
+/**
+ * <code>Queue</code> objects implement data structures that allow to
+ * insert and retrieve elements in a first-in-first-out (FIFO) manner.
*
- * @author Matthias Zenger
- * @version 1.0, 08/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 08/07/2003
*/
class Queue[A] with MutableList[A] {
- /** Checks if the queue is empty.
+ /**
+ * Checks if the queue is empty.
*
- * @returns true, iff there is no element in the queue.
+ * @return true, iff there is no element in the queue.
*/
def isEmpty: Boolean = (first == null);
- /** Inserts a single element at the end of the queue.
+ /**
+ * Inserts a single element at the end of the queue.
*
- * @param elem the element to insert
+ * @param elem the element to insert
*/
def +=(elem: A) = appendElem(elem);
- /** Adds all elements provided by an <code>Iterable</code> object
- * at the end of the queue. The elements are prepended in the order they
- * are given out by the iterator.
+ /**
+ * Adds all elements provided by an <code>Iterable</code> object
+ * at the end of the queue. The elements are prepended in the order they
+ * are given out by the iterator.
*
- * @param iter an iterable object
+ * @param iter an iterable object
*/
def +=(iter: Iterable[A]) = iter.elements.foreach(e => appendElem(e));
- /** Adds all elements to the queue.
+ /**
+ * Adds all elements to the queue.
*
- * @param elems the elements to add.
+ * @param elems the elements to add.
*/
def enqueue(elems: A*): Unit = (this += elems);
- /** Returns the first element in the queue, and removes this element
- * from the queue.
+ /**
+ * Returns the first element in the queue, and removes this element
+ * from the queue.
*
- * @returns the first element of the queue.
+ * @return the first element of the queue.
*/
def dequeue: A = {
if (first == null)
@@ -59,21 +66,24 @@ class Queue[A] with MutableList[A] {
}
}
- /** Returns the first element in the queue, or throws an error if there
- * is no element contained in the queue.
+ /**
+ * Returns the first element in the queue, or throws an error if there
+ * is no element contained in the queue.
*
- * @returns the first element.
+ * @return the first element.
*/
def front: A = first.elem;
- /** Removes all elements from the queue. After this operation is completed,
- * the queue will be empty.
+ /**
+ * Removes all elements from the queue. After this operation is completed,
+ * the queue will be empty.
*/
def clear: Unit = reset;
- /** Checks if two queues are structurally identical.
+ /**
+ * Checks if two queues are structurally identical.
*
- * @returns true, iff both queues contain the same sequence of elements.
+ * @return true, iff both queues contain the same sequence of elements.
*/
override def equals(that: Any): Boolean =
that.isInstanceOf[Queue[A]] &&
@@ -82,16 +92,19 @@ class Queue[A] with MutableList[A] {
case Pair(thiselem, thatelem) => thiselem == thatelem;
}};
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable queues as keys in hash tables.
+ /**
+ * The hashCode method always yields an error, since it is not
+ * safe to use mutable queues as keys in hash tables.
*
- * @returns never.
+ * @return never.
*/
override def hashCode(): Int = error("unsuitable as hash key");
- /** Returns a textual representation of a queue as a string.
+ /**
+ * Returns a textual representation of a queue as a string.
*
- * @returns the string representation of this queue.
+ * @return the string representation of this queue.
*/
override def toString() = toList.mkString("Queue(", ", ", ")");
+
}
diff --git a/sources/scala/collection/mutable/Stack.scala b/sources/scala/collection/mutable/Stack.scala
index 4851421767..8c04763a99 100644
--- a/sources/scala/collection/mutable/Stack.scala
+++ b/sources/scala/collection/mutable/Stack.scala
@@ -4,83 +4,95 @@
** __\ \/ /__/ __ |/ /__/ __ | **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
-** $Id$
\* */
+// $Id$
+
package scala.collection.mutable;
-/** A stack implements a data structure which allows to store and retrieve
- * objects in a last-in-first-out (LIFO) fashion.
+/**
+ * A stack implements a data structure which allows to store and retrieve
+ * objects in a last-in-first-out (LIFO) fashion.
*
- * @author Matthias Zenger
- * @version 1.0, 08/07/2003
+ * @author Matthias Zenger
+ * @version 1.0, 08/07/2003
*/
class Stack[A] with MutableList[A] {
- /** Checks if the stack is empty.
+ /**
+ * Checks if the stack is empty.
*
- * @returns true, iff there is no element on the stack
+ * @return true, iff there is no element on the stack
*/
def isEmpty: Boolean = (first == null);
- /** Pushes a single element on top of the stack.
+ /**
+ * Pushes a single element on top of the stack.
*
- * @param elem the element to push onto the stack
+ * @param elem the element to push onto the stack
*/
def +=(elem: A): Unit = prependElem(elem);
- /** Pushes all elements provided by an <code>Iterable</code> object
- * on top of the stack. The elements are pushed in the order they
- * are given out by the iterator.
+ /**
+ * Pushes all elements provided by an <code>Iterable</code> object
+ * on top of the stack. The elements are pushed in the order they
+ * are given out by the iterator.
*
- * @param iter an iterable object
+ * @param iter an iterable object
*/
def +=(iter: Iterable[A]): Unit = iter.elements.foreach(e => prependElem(e));
- /** Pushes a sequence of elements on top of the stack. The first element
- * is pushed first, etc.
+ /**
+ * Pushes a sequence of elements on top of the stack. The first element
+ * is pushed first, etc.
*
- * @param elems a sequence of elements
+ * @param elems a sequence of elements
*/
def push(elems: A*): Unit = (this += elems);
- /** Returns the top element of the stack. This method will not remove
- * the element from the stack. An error is signaled if there is no
- * element on the stack.
+ /**
+ * Returns the top element of the stack. This method will not remove
+ * the element from the stack. An error is signaled if there is no
+ * element on the stack.
*
- * @returns the top element
+ * @return the top element
*/
def top: A = if (first == null) error("stack empty"); else first.elem;
- /** Removes the top element from the stack.
+ /**
+ * Removes the top element from the stack.
*/
def pop: Unit = if (first != null) { first = first.next; }
- /** Removes all elements from the stack. After this operation completed,
- * the stack will be empty.
+ /**
+ * Removes all elements from the stack. After this operation completed,
+ * the stack will be empty.
*/
def clear: Unit = reset;
- /** Returns an iterator over all elements on the stack. This iterator
- * is stable with respect to state changes in the stack object; i.e.
- * such changes will not be reflected in the iterator. The iterator
- * issues elements in the order they were inserted into the stack
- * (FIFO order).
+ /**
+ * Returns an iterator over all elements on the stack. This iterator
+ * is stable with respect to state changes in the stack object; i.e.
+ * such changes will not be reflected in the iterator. The iterator
+ * issues elements in the order they were inserted into the stack
+ * (FIFO order).
*
- * @returns an iterator over all stack elements.
+ * @return an iterator over all stack elements.
*/
override def elements: Iterator[A] = toList.elements;
- /** Creates a list of all stack elements in FIFO order.
+ /**
+ * Creates a list of all stack elements in FIFO order.
*
- * @returns the created list.
+ * @return the created list.
*/
override def toList: List[A] = super[MutableList].toList.reverse;
- /** Checks if two stacks are structurally identical.
+ /**
+ * Checks if two stacks are structurally identical.
*
- * @returns true, iff both stacks contain the same sequence of elements.
+ * @return true, iff both stacks contain the same sequence of elements.
*/
override def equals(that: Any): Boolean =
that.isInstanceOf[Stack[A]] &&
@@ -89,16 +101,19 @@ class Stack[A] with MutableList[A] {
case Pair(thiselem, thatelem) => thiselem == thatelem;
}};
- /** The hashCode method always yields an error, since it is not
- * safe to use mutable stacks as keys in hash tables.
+ /**
+ * The hashCode method always yields an error, since it is not
+ * safe to use mutable stacks as keys in hash tables.
*
- * @returns never.
+ * @return never.
*/
override def hashCode(): Int = error("unsuitable as hash key");
- /** Returns a textual representation of a stack as a string.
+ /**
+ * Returns a textual representation of a stack as a string.
*
- * @returns the string representation of this stack.
+ * @return the string representation of this stack.
*/
override def toString() = toList.mkString("Stack(", ", ", ")");
+
}