summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2009-06-16 15:26:45 +0000
committerPaul Phillips <paulp@improving.org>2009-06-16 15:26:45 +0000
commit4788fee88e2cee8b072193bd11e4fe29c0ec8988 (patch)
tree7397b18af583e2ec2a1a284305ad9a7b62f36004 /src
parente41d30ba4a308baa8260a6957b7a0207c4035326 (diff)
downloadscala-4788fee88e2cee8b072193bd11e4fe29c0ec8988.tar.gz
scala-4788fee88e2cee8b072193bd11e4fe29c0ec8988.tar.bz2
scala-4788fee88e2cee8b072193bd11e4fe29c0ec8988.zip
made Hashable use a Seq instead of List.
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/util/Hashable.scala12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/library/scala/util/Hashable.scala b/src/library/scala/util/Hashable.scala
index 88d3b72fbd..348c3c0b96 100644
--- a/src/library/scala/util/Hashable.scala
+++ b/src/library/scala/util/Hashable.scala
@@ -8,7 +8,7 @@
package scala.util
/** A convenience trait for simplifying hashCode creation.
- * Mix this into a class and define val hashValues = List(x1, x2, ...)
+ * Mix this into a class and define val hashValues = Seq(x1, x2, ...)
* and your hashCode will be derived from those values. If you define
* equals in terms of equalHashValues then your hashCode and equals
* methods will never be out of sync. Something like:
@@ -23,29 +23,29 @@ package scala.util
abstract trait Hashable extends AnyRef
{
import Hashable._
- protected def hashValues: List[Any] // in an ideal universe this would be more like List[Hashable]
+ protected def hashValues: Seq[Any] // in an ideal universe this would be more like Seq[Hashable]
protected def hashSeed: Int = 0
override def hashCode: Int =
(hashValues map calculateHashCode).foldLeft(hashSeed)((x, y) => x * 41 + y)
protected def equalHashValues(other: Any) = other match {
- case x: Hashable => hashValues == x.hashValues
+ case x: Hashable => hashValues sameElements x.hashValues
case _ => false
}
}
abstract trait StrictHashable extends Hashable
{
- protected def hashValues: List[Hashable]
+ protected def hashValues: Seq[Hashable]
}
object Hashable
{
- /** This implicit is for StrictHashable's benefit, so your hashValues list
+ /** This implicit is for StrictHashable's benefit, so your hashValues Seq
* can contain both explicitly Hashable classes and value types.
*/
implicit def anyVal2Hashable(x: AnyVal): Hashable =
- new Hashable { protected def hashValues = List(x) }
+ new Hashable { protected def hashValues = Seq(x) }
private def calculateHashCode(x: Any) = x match {
case null => 0