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

Side by Side Diff: lib/coreimpl/splay_tree.dart

Issue 11267018: Make getKeys, getValues getters (keys, values). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update status files with co19 issue number. Created 8 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 | « lib/coreimpl/maps.dart ('k') | lib/html/dart2js/html_dart2js.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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 this.key, V this.value); 10 SplayTreeNode(K this.key, V this.value);
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 bool containsValue(V value) { 215 bool containsValue(V value) {
216 bool found = false; 216 bool found = false;
217 bool visit(SplayTreeNode node) { 217 bool visit(SplayTreeNode node) {
218 if (node === null) return false; 218 if (node === null) return false;
219 if (node.value == value) return true; 219 if (node.value == value) return true;
220 return visit(node.left) || visit(node.right); 220 return visit(node.left) || visit(node.right);
221 } 221 }
222 return visit(_root); 222 return visit(_root);
223 } 223 }
224 224
225 Collection<K> getKeys() { 225 Collection<K> get keys {
226 List<K> list = new List<K>(); 226 List<K> list = new List<K>();
227 forEach((K k, V v) { list.add(k); }); 227 forEach((K k, V v) { list.add(k); });
228 return list; 228 return list;
229 } 229 }
230 230
231 Collection<V> getValues() { 231 Collection<V> get values {
232 List<V> list = new List<V>(); 232 List<V> list = new List<V>();
233 forEach((K k, V v) { list.add(v); }); 233 forEach((K k, V v) { list.add(v); });
234 return list; 234 return list;
235 } 235 }
236 236
237 String toString() { 237 String toString() {
238 return Maps.mapToString(this); 238 return Maps.mapToString(this);
239 } 239 }
240 240
241 /** 241 /**
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (node.key.compareTo(key) > 0) { 297 if (node.key.compareTo(key) > 0) {
298 return visit(node.left, node.key); 298 return visit(node.left, node.key);
299 } 299 }
300 if (node.key.compareTo(key) <= 0) { 300 if (node.key.compareTo(key) <= 0) {
301 return visit(node.right, ifEmpty); 301 return visit(node.right, ifEmpty);
302 } 302 }
303 } 303 }
304 return visit(_root, null); 304 return visit(_root, null);
305 } 305 }
306 } 306 }
OLDNEW
« no previous file with comments | « lib/coreimpl/maps.dart ('k') | lib/html/dart2js/html_dart2js.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698