blob: 9765ae1f1eff276d0593aeb60ab61e3322bd475e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* __ *\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2009, LAMP/EPFL **
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\___/_/ |_/____/_/ | | **
** |/ **
\* */
// $Id$
package scala.collection.mutable
/** This class implements single linked lists where both the head (<code>elem</code>)
* and the tail (<code>next</code>) are mutable.
*
* @author Matthias Zenger
* @version 1.0, 08/07/2003
*/
@serializable
class LinkedList[A](var elem: A, var next: LinkedList[A])
extends SingleLinkedList[A, LinkedList[A]]
{
/** Compares two lists structurally; i.e. checks if all elements
* contained in this list are also contained in the other list,
* and vice versa.
*
* @param that the other list
* @return <code>true</code> iff both lists contain exactly the
* same mappings.
*/
override def equals(obj: Any): Boolean = obj match {
case that: LinkedList[_] => this.toList equals that.toList
case _ => false
}
/** A hash method compatible with <code>equals</code>
*/
override def hashCode(): Int =
(0 /: elements) ((hash, kv) => hash + kv.hashCode)
override protected def stringPrefix: String = "LinkedList"
}
|