diff options
author | michelou <michelou@epfl.ch> | 2007-01-10 10:15:19 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-01-10 10:15:19 +0000 |
commit | 8b51007563c84fee9ebdfc503aee984c83172d71 (patch) | |
tree | 4220029627aea362f9ebf45ad956b498a60a4e98 /src | |
parent | b6df86923f800794fc718b471bccde271af9fe96 (diff) | |
download | scala-8b51007563c84fee9ebdfc503aee984c83172d71.tar.gz scala-8b51007563c84fee9ebdfc503aee984c83172d71.tar.bz2 scala-8b51007563c84fee9ebdfc503aee984c83172d71.zip |
minor changes in collection/*.scala
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/collection/BitSet.scala | 47 | ||||
-rw-r--r-- | src/library/scala/collection/Map.scala | 39 | ||||
-rw-r--r-- | src/library/scala/collection/Set.scala | 37 |
3 files changed, 75 insertions, 48 deletions
diff --git a/src/library/scala/collection/BitSet.scala b/src/library/scala/collection/BitSet.scala index 17ecd1fa6c..374ad1fb71 100644 --- a/src/library/scala/collection/BitSet.scala +++ b/src/library/scala/collection/BitSet.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -31,7 +31,10 @@ abstract class BitSet extends Set[Int] { /** number of bits in this bitset */ def size: Int - /** @return true if bit i is set */ + /** + * @param i ... + * @return <code>true</code> if bit <code>i</code> is set. + */ def contains(i: Int): Boolean = (i < capacity) && ((arr(offset(i)) & mask(i)) != 0) @@ -62,11 +65,12 @@ abstract class BitSet extends Set[Int] { newarr } - /** - * Checks if two bitsets are structurally identical. - * Uses accelerated (32 x faster) check if the other set is a BitSet + /** Checks if two bitsets are structurally identical. + * Uses accelerated (32 x faster) check if the other set is a BitSet * - * @return true, iff both bitsets contain the same elements. + * @param other ... + * @return <code>true</code>, iff both bitsets contain the same + * elements. */ override def equals(other: Any): Boolean = other match { case that: BitSet => @@ -88,12 +92,12 @@ abstract class BitSet extends Set[Int] { h } - /** - * Checks if this set is a subset of set <code>that</code>. - * Uses accelerated (32 x faster) check if the other set is a BitSet + /** Checks if this set is a subset of set <code>that</code>. + * Uses accelerated (32 x faster) check if the other set is a BitSet * - * @param that another set. - * @return true, iff the other set is a superset of this set. + * @param other another set. + * @return <code>true</code>, iff the other set is a superset of + * this set. */ override def subsetOf(other: Set[Int]): Boolean = other match { case that: BitSet => @@ -108,16 +112,29 @@ abstract class BitSet extends Set[Int] { super.subsetOf(other) } - /** @return the number of Int cells needed to store <code>n</code> bits */ + /** + * @param n the number of bits to be stored. + * @return the number of <code>Int</code> cells needed to store + * <code>n</code> bits. + */ protected final def memsize(n: Int): Int = offset(n + 31) - /** @return the number of bits represented by <code>n</code> words */ + /** + * @param n ... + * @return the number of bits represented by <code>n</code> words. + */ protected final def nbits(n: Int): Int = n << 5 - /** @return the position in the array where the bit resides */ + /** + * @param n ... + * @return the position in the array where the bit resides. + */ protected final def offset(n: Int): Int = n >>> 5 - /** @return a mask with 1 at the position of the bit */ + /** + * @param n ... + * @return a mask with 1 at the position of the bit. + */ protected final def mask(n: Int): Int = 1 << (n & 0x1F) } diff --git a/src/library/scala/collection/Map.scala b/src/library/scala/collection/Map.scala index feb9b2caf0..c02c195086 100644 --- a/src/library/scala/collection/Map.scala +++ b/src/library/scala/collection/Map.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -14,20 +14,22 @@ package scala.collection import Predef._ -//import Predef.NoSuchElementException - -/** This class defines the interface of collections that unambiguously map - * keys to values (i.e. a key is mapped to at least one value). - * Class <code>Map</code> may only be used for accessing elements from map - * implementations. Two different extensions of class <code>Map</code> in - * the package <code><a href="mutable$content.html" target="contentFrame"> - * scala.collection.mutable</a></code> - * and <code><a href="immutable$content.html" target="contentFrame"> - * scala.collection.immutable</a></code> provide functionality for - * adding new key/value mappings to a map. The class in the first package is - * implemented by maps that are modified destructively, whereas the class in - * the second package is used by functional map implementations that rely on - * immutable data structures. +/** <p> + * This class defines the interface of collections that unambiguously map + * keys to values (i.e. a key is mapped to at least one value). + * </p> + * <p> + * Class <code>Map</code> may only be used for accessing elements from map + * implementations. Two different extensions of class <code>Map</code> in + * the package <code><a href="mutable$content.html" target="contentFrame"> + * scala.collection.mutable</a></code> + * and <code><a href="immutable$content.html" target="contentFrame"> + * scala.collection.immutable</a></code> provide functionality for + * adding new key/value mappings to a map. The class in the first package is + * implemented by maps that are modified destructively, whereas the class in + * the second package is used by functional map implementations that rely on + * immutable data structures. + * </p> * * @author Matthias Zenger * @author Martin Odersky @@ -97,9 +99,9 @@ trait Map[A, +B] extends PartialFunction[A, B] with Iterable[Pair[A, B]] { /** @return the keys of this map as a set. */ def keySet = new Set[A] { - def size = Map.this.size; - def contains(key : A) = Map.this.contains(key); - def elements = Map.this.elements.map(._1); + def size = Map.this.size + def contains(key : A) = Map.this.contains(key) + def elements = Map.this.elements.map(._1) } /** Creates an iterator for a contained values. @@ -152,4 +154,5 @@ trait Map[A, +B] extends PartialFunction[A, B] with Iterable[Pair[A, B]] { */ def default(key: A): B = throw new NoSuchElementException("key not found: " + key) + } diff --git a/src/library/scala/collection/Set.scala b/src/library/scala/collection/Set.scala index 951b6616aa..66e9b3b4a4 100644 --- a/src/library/scala/collection/Set.scala +++ b/src/library/scala/collection/Set.scala @@ -1,6 +1,6 @@ /* __ *\ ** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2006, LAMP/EPFL ** +** / __/ __// _ | / / / _ | (c) 2003-2007, LAMP/EPFL ** ** __\ \/ /__/ __ |/ /__/ __ | ** ** /____/\___/_/ |_/____/_/ | | ** ** |/ ** @@ -12,18 +12,23 @@ package scala.collection -/** This class defines the interface of collections that do not contain - * duplicate elements. Class <code>Set</code> may only be used for - * accessing elements from set implementations. Two different extensions - * of class <code>Set</code> in the package - * <code><a href="mutable$content.html" target="contentFrame"> - * scala.collection.mutable</a></code> and - * <code><a href="immutable$content.html" target="contentFrame"> - * scala.collection.immutable</a></code> provide functionality for - * adding new elements to a set. The class in the first package is implemented - * by sets the are modified destructively, whereas the class in the second - * package is used by functional set implementations that rely on immutable - * data structures. +/** <p> + * This class defines the interface of collections that do not contain + * duplicate elements. + * </p> + * <p> + * Class <code>Set</code> may only be used for accessing elements + * from set implementations. Two different extensions + * of class <code>Set</code> in the package + * <code><a href="mutable$content.html" target="contentFrame"> + * scala.collection.mutable</a></code> and + * <code><a href="immutable$content.html" target="contentFrame"> + * scala.collection.immutable</a></code> provide functionality for adding + * new elements to a set. The class in the first package is implemented + * by sets the are modified destructively, whereas the class in the second + * package is used by functional set implementations that rely on immutable + * data structures. + * </p> * * @author Matthias Zenger * @author Martin Odersky @@ -40,13 +45,14 @@ trait Set[A] extends (A => Boolean) with Iterable[A] { /** Checks if this set contains element <code>elem</code>. * * @param elem the element to check for membership. - * @return <code>true</code> iff <code>elem</code> is contained ini + * @return <code>true</code> iff <code>elem</code> is contained in * this set. */ def contains(elem: A): Boolean /** This method allows sets to be interpreted as predicates. - * It returns true, iff this set contains element <code>elem</code>. + * It returns <code>true</code>, iff this set contains element + * <code>elem</code>. * * @param elem the element to check for membership. * @return <code>true</code> iff <code>elem</code> is contained in @@ -93,4 +99,5 @@ trait Set[A] extends (A => Boolean) with Iterable[A] { * @return a string showing all elements of this set. */ override def toString(): String = mkString("{", ", ", "}") + } |