Chromium Code Reviews| Index: lib/compiler/implementation/util/link_implementation.dart |
| diff --git a/lib/compiler/implementation/util/link_implementation.dart b/lib/compiler/implementation/util/link_implementation.dart |
| index a237a307a12f92ac39e9f09a45101096b4434d21..1331f2e970be92f7a10e53a726c57d57aee31f65 100644 |
| --- a/lib/compiler/implementation/util/link_implementation.dart |
| +++ b/lib/compiler/implementation/util/link_implementation.dart |
| @@ -70,6 +70,11 @@ class LinkTail<T> implements EmptyLink<T> { |
| bool isEmpty() => true; |
| void forEach(void f(T element)) {} |
| + |
| + bool equals(other) { |
| + if (other is !Link<T>) return false; |
| + return other.isEmpty(); |
| + } |
| } |
| class LinkEntry<T> implements Link<T> { |
| @@ -134,6 +139,19 @@ class LinkEntry<T> implements Link<T> { |
| f(link.head); |
| } |
| } |
| + |
| + bool equals(other) { |
| + if (other is !Link<T>) return false; |
|
ngeoffray
2012/09/05 12:50:40
Making it recursive looks easier to understand. Bu
karlklose
2012/09/06 11:04:02
I will keep it as it is.
|
| + Link<T> myElements = this; |
| + while (!myElements.isEmpty() && !other.isEmpty()) { |
| + if (myElements.head != other.head) { |
| + return false; |
| + } |
| + myElements = myElements.tail; |
| + other = other.tail; |
| + } |
| + return myElements.isEmpty() && other.isEmpty(); |
| + } |
| } |
| class LinkBuilderImplementation<T> implements LinkBuilder<T> { |