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

Side by Side Diff: corelib/src/implementation/splay_tree.dart

Issue 8400038: Use strict equality when comparing with null, especially when null is a default value. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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
« no previous file with comments | « corelib/src/implementation/promise_implementation.dart ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * A node in a splay tree. It holds the key, the value and the left 6 * A node in a splay tree. It holds the key, the value and the left
7 * and right children in the tree. 7 * and right children in the tree.
8 */ 8 */
9 class SplayTreeNode<K, V> { 9 class SplayTreeNode<K, V> {
10 SplayTreeNode(K k, V v) { 10 SplayTreeNode(K k, V v) {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 bool isEmpty() { 175 bool isEmpty() {
176 // assert(!((_root === null) && (_count != 0))); 176 // assert(!((_root === null) && (_count != 0)));
177 // assert(!((_count == 0) && (_root !== null))); 177 // assert(!((_count == 0) && (_root !== null)));
178 return (_root === null); 178 return (_root === null);
179 } 179 }
180 180
181 void forEach(void f(K key, V value)) { 181 void forEach(void f(K key, V value)) {
182 List<SplayTreeNode<K, V>> list = new List<SplayTreeNode<K, V>>(); 182 List<SplayTreeNode<K, V>> list = new List<SplayTreeNode<K, V>>();
183 SplayTreeNode<K, V> current = _root; 183 SplayTreeNode<K, V> current = _root;
184 while (current != null) { 184 while (current !== null) {
185 if (current.left != null) { 185 if (current.left !== null) {
186 list.add(current); 186 list.add(current);
187 current = current.left; 187 current = current.left;
188 } else { 188 } else {
189 f(current.key, current.value); 189 f(current.key, current.value);
190 while (current.right == null) { 190 while (current.right === null) {
191 if (list.isEmpty()) return; 191 if (list.isEmpty()) return;
192 current = list.removeLast(); 192 current = list.removeLast();
193 f(current.key, current.value); 193 f(current.key, current.value);
194 } 194 }
195 current = current.right; 195 current = current.right;
196 } 196 }
197 } 197 }
198 } 198 }
199 199
200 int get length() { 200 int get length() {
(...skipping 27 matching lines...) Expand all
228 forEach((K k, V v) { list.add(k); }); 228 forEach((K k, V v) { list.add(k); });
229 return list; 229 return list;
230 } 230 }
231 231
232 Collection<V> getValues() { 232 Collection<V> getValues() {
233 List<V> list = new List<V>(); 233 List<V> list = new List<V>();
234 forEach((K k, V v) { list.add(v); }); 234 forEach((K k, V v) { list.add(v); });
235 return list; 235 return list;
236 } 236 }
237 } 237 }
OLDNEW
« no previous file with comments | « corelib/src/implementation/promise_implementation.dart ('k') | runtime/bin/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698