Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: lib/compiler/implementation/util/link_implementation.dart

Issue 10917290: DartType equals converted to operator == and tested. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class LinkIterator<T> implements Iterator<T> { 5 class LinkIterator<T> implements Iterator<T> {
6 Link<T> current; 6 Link<T> current;
7 LinkIterator(Link<T> this.current); 7 LinkIterator(Link<T> this.current);
8 bool hasNext() => !current.isEmpty(); 8 bool hasNext() => !current.isEmpty();
9 T next() { 9 T next() {
10 T result = current.head; 10 T result = current.head;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 if (from.isEmpty()) return this; 64 if (from.isEmpty()) return this;
65 return this.prepend(from.head).reversePrependAll(from.tail); 65 return this.prepend(from.head).reversePrependAll(from.tail);
66 } 66 }
67 67
68 List toList() => const []; 68 List toList() => const [];
69 69
70 bool isEmpty() => true; 70 bool isEmpty() => true;
71 71
72 void forEach(void f(T element)) {} 72 void forEach(void f(T element)) {}
73 73
74 bool equals(other) { 74 bool operator ==(other) {
75 if (other is !Link<T>) return false; 75 if (other is !Link<T>) return false;
76 return other.isEmpty(); 76 return other.isEmpty();
77 } 77 }
78 } 78 }
79 79
80 class LinkEntry<T> implements Link<T> { 80 class LinkEntry<T> implements Link<T> {
81 final T head; 81 final T head;
82 Link<T> tail; 82 Link<T> tail;
83 83
84 LinkEntry(T this.head, Link<T> this.tail); 84 LinkEntry(T this.head, Link<T> this.tail);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 133 }
134 return list; 134 return list;
135 } 135 }
136 136
137 void forEach(void f(T element)) { 137 void forEach(void f(T element)) {
138 for (Link<T> link = this; !link.isEmpty(); link = link.tail) { 138 for (Link<T> link = this; !link.isEmpty(); link = link.tail) {
139 f(link.head); 139 f(link.head);
140 } 140 }
141 } 141 }
142 142
143 bool equals(other) { 143 bool operator ==(other) {
144 if (other is !Link<T>) return false; 144 if (other is !Link<T>) return false;
145 Link<T> myElements = this; 145 Link<T> myElements = this;
146 while (!myElements.isEmpty() && !other.isEmpty()) { 146 while (!myElements.isEmpty() && !other.isEmpty()) {
147 if (myElements.head != other.head) { 147 if (myElements.head != other.head) {
148 return false; 148 return false;
149 } 149 }
150 myElements = myElements.tail; 150 myElements = myElements.tail;
151 other = other.tail; 151 other = other.tail;
152 } 152 }
153 return myElements.isEmpty() && other.isEmpty(); 153 return myElements.isEmpty() && other.isEmpty();
(...skipping 20 matching lines...) Expand all
174 length++; 174 length++;
175 LinkEntry<T> entry = new LinkEntry<T>(t, null); 175 LinkEntry<T> entry = new LinkEntry<T>(t, null);
176 if (head === null) { 176 if (head === null) {
177 head = entry; 177 head = entry;
178 } else { 178 } else {
179 lastLink.tail = entry; 179 lastLink.tail = entry;
180 } 180 }
181 lastLink = entry; 181 lastLink = entry;
182 } 182 }
183 } 183 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698