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

Side by Side Diff: test/dart_codegen/expect/collection/splay_tree.dart

Issue 1122313002: Typing fixes to eliminate casts/dcalls (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Rebase Created 5 years, 7 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
OLDNEW
1 part of dart.collection; 1 part of dart.collection;
2 typedef bool _Predicate<T>(T value); 2 typedef bool _Predicate<T>(T value);
3 class _SplayTreeNode<K> {final K key; 3 class _SplayTreeNode<K> {final K key;
4 _SplayTreeNode<K> left; 4 _SplayTreeNode<K> left;
5 _SplayTreeNode<K> right; 5 _SplayTreeNode<K> right;
6 _SplayTreeNode(K this.key); 6 _SplayTreeNode(K this.key);
7 } 7 }
8 class _SplayTreeMapNode<K, V> extends _SplayTreeNode<K> {V value; 8 class _SplayTreeMapNode<K, V> extends _SplayTreeNode<K> {V value;
9 _SplayTreeMapNode(K key, V this.value) : super(key); 9 _SplayTreeMapNode(K key, V this.value) : super(key);
10 } 10 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 _root = _splayMax(_root); 137 _root = _splayMax(_root);
138 return _root; 138 return _root;
139 } 139 }
140 void _clear() { 140 void _clear() {
141 _root = null; 141 _root = null;
142 _count = 0; 142 _count = 0;
143 _modificationCount++; 143 _modificationCount++;
144 } 144 }
145 } 145 }
146 class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> {Comparator <K> _comparator; 146 class SplayTreeMap<K, V> extends _SplayTree<K> implements Map<K, V> {Comparator <K> _comparator;
147 _Predicate _validKey; 147 _Predicate<Object> _validKey;
148 SplayTreeMap([int compare(K key1, K key2), bool isValidKey(potentialKey)]) : _c omparator = ((__x12) => DEVC$RT.cast(__x12, dynamic, DEVC$RT.type((Comparator<K> _) { 148 SplayTreeMap([int compare(K key1, K key2), bool isValidKey(Object potentialKey) ]) : _comparator = ((__x12) => DEVC$RT.cast(__x12, dynamic, DEVC$RT.type((Compar ator<K> _) {
149 } 149 }
150 ), "CompositeCast", """line 264, column 23 of dart:collection/splay_tree.dart: " "", __x12 is Comparator<K>, false))((compare == null) ? Comparable.compare : com pare), _validKey = (isValidKey != null) ? isValidKey : ((v) => v is K); 150 ), "CompositeCast", """line 265, column 23 of dart:collection/splay_tree.dart: " "", __x12 is Comparator<K>, false))((compare == null) ? Comparable.compare : com pare), _validKey = (isValidKey != null) ? isValidKey : ((v) => v is K);
151 factory SplayTreeMap.from(Map other, [int compare(K key1, K key2), bool isValid Key(potentialKey)]) { 151 factory SplayTreeMap.from(Map other, [int compare(K key1, K key2), bool isValid Key(Object potentialKey)]) {
152 SplayTreeMap<K, V> result = new SplayTreeMap<K, V>(); 152 SplayTreeMap<K, V> result = new SplayTreeMap<K, V>();
153 other.forEach((k, v) { 153 other.forEach((k, v) {
154 result[k] = DEVC$RT.cast(v, dynamic, V, "CompositeCast", """line 274, column 40 of dart:collection/splay_tree.dart: """, v is V, false); 154 result[k] = DEVC$RT.cast(v, dynamic, V, "CompositeCast", """line 275, column 40 of dart:collection/splay_tree.dart: """, v is V, false);
155 } 155 }
156 ); 156 );
157 return result; 157 return result;
158 } 158 }
159 factory SplayTreeMap.fromIterable(Iterable iterable, { 159 factory SplayTreeMap.fromIterable(Iterable iterable, {
160 K key(element), V value(element), int compare(K key1, K key2), bool isValidKey(p otentialKey)} 160 K key(element), V value(element), int compare(K key1, K key2), bool isValidKey(O bject potentialKey)}
161 ) { 161 ) {
162 SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey); 162 SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey);
163 Maps._fillMapWithMappedIterable(map, iterable, key, value); 163 Maps._fillMapWithMappedIterable(map, iterable, key, value);
164 return map; 164 return map;
165 } 165 }
166 factory SplayTreeMap.fromIterables(Iterable<K> keys, Iterable<V> values, [int c ompare(K key1, K key2), bool isValidKey(potentialKey)]) { 166 factory SplayTreeMap.fromIterables(Iterable<K> keys, Iterable<V> values, [int c ompare(K key1, K key2), bool isValidKey(Object potentialKey)]) {
167 SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey); 167 SplayTreeMap<K, V> map = new SplayTreeMap<K, V>(compare, isValidKey);
168 Maps._fillMapWithIterables(map, keys, values); 168 Maps._fillMapWithIterables(map, keys, values);
169 return map; 169 return map;
170 } 170 }
171 int _compare(K key1, K key2) => _comparator(key1, key2); 171 int _compare(K key1, K key2) => _comparator(key1, key2);
172 SplayTreeMap._internal(); 172 SplayTreeMap._internal();
173 V operator [](Object key) { 173 V operator [](Object key) {
174 if (key == null) throw new ArgumentError(key); 174 if (key == null) throw new ArgumentError(key);
175 if (!_validKey(key)) return null; 175 if (!_validKey(key)) return null;
176 if (_root != null) { 176 if (_root != null) {
177 int comp = _splay(DEVC$RT.cast(key, Object, K, "CompositeCast", """line 327, col umn 25 of dart:collection/splay_tree.dart: """, key is K, false)); 177 int comp = _splay(DEVC$RT.cast(key, Object, K, "CompositeCast", """line 328, col umn 25 of dart:collection/splay_tree.dart: """, key is K, false));
178 if (comp == 0) { 178 if (comp == 0) {
179 _SplayTreeMapNode mapRoot = DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) { 179 _SplayTreeMapNode mapRoot = DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) {
180 } 180 }
181 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 181 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
182 } 182 }
183 ), "AssignmentCast", """line 329, column 37 of dart:collection/splay_tree.dart: """, _root is _SplayTreeMapNode<dynamic, dynamic>, true); 183 ), "AssignmentCast", """line 330, column 37 of dart:collection/splay_tree.dart: """, _root is _SplayTreeMapNode<dynamic, dynamic>, true);
184 return DEVC$RT.cast(mapRoot.value, dynamic, V, "CompositeCast", """line 330, co lumn 16 of dart:collection/splay_tree.dart: """, mapRoot.value is V, false); 184 return DEVC$RT.cast(mapRoot.value, dynamic, V, "CompositeCast", """line 331, co lumn 16 of dart:collection/splay_tree.dart: """, mapRoot.value is V, false);
185 } 185 }
186 } 186 }
187 return null; 187 return null;
188 } 188 }
189 V remove(Object key) { 189 V remove(Object key) {
190 if (!_validKey(key)) return null; 190 if (!_validKey(key)) return null;
191 _SplayTreeMapNode mapRoot = ((__x13) => DEVC$RT.cast(__x13, DEVC$RT.type((_Spla yTreeNode<dynamic> _) { 191 _SplayTreeMapNode mapRoot = ((__x13) => DEVC$RT.cast(__x13, DEVC$RT.type((_Spla yTreeNode<dynamic> _) {
192 } 192 }
193 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 193 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
194 } 194 }
195 ), "AssignmentCast", """line 338, column 33 of dart:collection/splay_tree.dart: """, __x13 is _SplayTreeMapNode<dynamic, dynamic>, true))(_remove(DEVC$RT.cast(k ey, Object, K, "CompositeCast", """line 338, column 41 of dart:collection/splay_ tree.dart: """, key is K, false))); 195 ), "AssignmentCast", """line 339, column 33 of dart:collection/splay_tree.dart: """, __x13 is _SplayTreeMapNode<dynamic, dynamic>, true))(_remove(DEVC$RT.cast(k ey, Object, K, "CompositeCast", """line 339, column 41 of dart:collection/splay_ tree.dart: """, key is K, false)));
196 if (mapRoot != null) return DEVC$RT.cast(mapRoot.value, dynamic, V, "CompositeC ast", """line 339, column 33 of dart:collection/splay_tree.dart: """, mapRoot.va lue is V, false); 196 if (mapRoot != null) return DEVC$RT.cast(mapRoot.value, dynamic, V, "CompositeC ast", """line 340, column 33 of dart:collection/splay_tree.dart: """, mapRoot.va lue is V, false);
197 return null; 197 return null;
198 } 198 }
199 void operator []=(K key, V value) { 199 void operator []=(K key, V value) {
200 if (key == null) throw new ArgumentError(key); 200 if (key == null) throw new ArgumentError(key);
201 int comp = _splay(key); 201 int comp = _splay(key);
202 if (comp == 0) { 202 if (comp == 0) {
203 _SplayTreeMapNode mapRoot = DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) { 203 _SplayTreeMapNode mapRoot = DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) {
204 } 204 }
205 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 205 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
206 } 206 }
207 ), "AssignmentCast", """line 349, column 35 of dart:collection/splay_tree.dart: """, _root is _SplayTreeMapNode<dynamic, dynamic>, true); 207 ), "AssignmentCast", """line 350, column 35 of dart:collection/splay_tree.dart: """, _root is _SplayTreeMapNode<dynamic, dynamic>, true);
208 mapRoot.value = value; 208 mapRoot.value = value;
209 return;} 209 return;}
210 _addNewRoot(new _SplayTreeMapNode<K, dynamic>(key, value), comp); 210 _addNewRoot(new _SplayTreeMapNode<K, dynamic>(key, value), comp);
211 } 211 }
212 V putIfAbsent(K key, V ifAbsent()) { 212 V putIfAbsent(K key, V ifAbsent()) {
213 if (key == null) throw new ArgumentError(key); 213 if (key == null) throw new ArgumentError(key);
214 int comp = _splay(key); 214 int comp = _splay(key);
215 if (comp == 0) { 215 if (comp == 0) {
216 _SplayTreeMapNode mapRoot = DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) { 216 _SplayTreeMapNode mapRoot = DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) {
217 } 217 }
218 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 218 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
219 } 219 }
220 ), "AssignmentCast", """line 361, column 35 of dart:collection/splay_tree.dart: """, _root is _SplayTreeMapNode<dynamic, dynamic>, true); 220 ), "AssignmentCast", """line 362, column 35 of dart:collection/splay_tree.dart: """, _root is _SplayTreeMapNode<dynamic, dynamic>, true);
221 return DEVC$RT.cast(mapRoot.value, dynamic, V, "CompositeCast", """line 362, co lumn 14 of dart:collection/splay_tree.dart: """, mapRoot.value is V, false); 221 return DEVC$RT.cast(mapRoot.value, dynamic, V, "CompositeCast", """line 363, co lumn 14 of dart:collection/splay_tree.dart: """, mapRoot.value is V, false);
222 } 222 }
223 int modificationCount = _modificationCount; 223 int modificationCount = _modificationCount;
224 int splayCount = _splayCount; 224 int splayCount = _splayCount;
225 V value = ifAbsent(); 225 V value = ifAbsent();
226 if (modificationCount != _modificationCount) { 226 if (modificationCount != _modificationCount) {
227 throw new ConcurrentModificationError(this); 227 throw new ConcurrentModificationError(this);
228 } 228 }
229 if (splayCount != _splayCount) { 229 if (splayCount != _splayCount) {
230 comp = _splay(key); 230 comp = _splay(key);
231 assert (comp != 0);} 231 assert (comp != 0);}
(...skipping 10 matching lines...) Expand all
242 return (_root == null); 242 return (_root == null);
243 } 243 }
244 bool get isNotEmpty => !isEmpty; 244 bool get isNotEmpty => !isEmpty;
245 void forEach(void f(K key, V value)) { 245 void forEach(void f(K key, V value)) {
246 Iterator<_SplayTreeNode<K>> nodes = new _SplayTreeNodeIterator<K>(this); 246 Iterator<_SplayTreeNode<K>> nodes = new _SplayTreeNodeIterator<K>(this);
247 while (nodes.moveNext()) { 247 while (nodes.moveNext()) {
248 _SplayTreeMapNode<K, V> node = DEVC$RT.cast(nodes.current, DEVC$RT.type((_SplayT reeNode<K> _) { 248 _SplayTreeMapNode<K, V> node = DEVC$RT.cast(nodes.current, DEVC$RT.type((_SplayT reeNode<K> _) {
249 } 249 }
250 ), DEVC$RT.type((_SplayTreeMapNode<K, V> _) { 250 ), DEVC$RT.type((_SplayTreeMapNode<K, V> _) {
251 } 251 }
252 ), "CompositeCast", """line 393, column 38 of dart:collection/splay_tree.dart: " "", nodes.current is _SplayTreeMapNode<K, V>, false); 252 ), "CompositeCast", """line 394, column 38 of dart:collection/splay_tree.dart: " "", nodes.current is _SplayTreeMapNode<K, V>, false);
253 f(node.key, node.value); 253 f(node.key, node.value);
254 } 254 }
255 } 255 }
256 int get length { 256 int get length {
257 return _count; 257 return _count;
258 } 258 }
259 void clear() { 259 void clear() {
260 _clear(); 260 _clear();
261 } 261 }
262 bool containsKey(Object key) { 262 bool containsKey(Object key) {
263 return _validKey(key) && _splay(DEVC$RT.cast(key, Object, K, "CompositeCast", "" "line 407, column 37 of dart:collection/splay_tree.dart: """, key is K, false)) == 0; 263 return _validKey(key) && _splay(DEVC$RT.cast(key, Object, K, "CompositeCast", "" "line 408, column 37 of dart:collection/splay_tree.dart: """, key is K, false)) == 0;
264 } 264 }
265 bool containsValue(Object value) { 265 bool containsValue(Object value) {
266 bool found = false; 266 bool found = false;
267 int initialSplayCount = _splayCount; 267 int initialSplayCount = _splayCount;
268 bool visit(_SplayTreeMapNode node) { 268 bool visit(_SplayTreeMapNode node) {
269 while (node != null) { 269 while (node != null) {
270 if (node.value == value) return true; 270 if (node.value == value) return true;
271 if (initialSplayCount != _splayCount) { 271 if (initialSplayCount != _splayCount) {
272 throw new ConcurrentModificationError(this); 272 throw new ConcurrentModificationError(this);
273 } 273 }
274 if (node.right != null && visit(DEVC$RT.cast(node.right, DEVC$RT.type((_SplayTr eeNode<dynamic> _) { 274 if (node.right != null && visit(DEVC$RT.cast(node.right, DEVC$RT.type((_SplayTr eeNode<dynamic> _) {
275 } 275 }
276 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 276 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
277 } 277 }
278 ), "ImplicitCast", """line 419, column 41 of dart:collection/splay_tree.dart: "" ", node.right is _SplayTreeMapNode<dynamic, dynamic>, true))) return true; 278 ), "ImplicitCast", """line 420, column 41 of dart:collection/splay_tree.dart: "" ", node.right is _SplayTreeMapNode<dynamic, dynamic>, true))) return true;
279 node = DEVC$RT.cast(node.left, DEVC$RT.type((_SplayTreeNode<dynamic> _) { 279 node = DEVC$RT.cast(node.left, DEVC$RT.type((_SplayTreeNode<dynamic> _) {
280 } 280 }
281 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 281 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
282 } 282 }
283 ), "ImplicitCast", """line 420, column 16 of dart:collection/splay_tree.dart: "" ", node.left is _SplayTreeMapNode<dynamic, dynamic>, true); 283 ), "ImplicitCast", """line 421, column 16 of dart:collection/splay_tree.dart: "" ", node.left is _SplayTreeMapNode<dynamic, dynamic>, true);
284 } 284 }
285 return false; 285 return false;
286 } 286 }
287 return visit(DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) { 287 return visit(DEVC$RT.cast(_root, DEVC$RT.type((_SplayTreeNode<K> _) {
288 } 288 }
289 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 289 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
290 } 290 }
291 ), "ImplicitCast", """line 424, column 18 of dart:collection/splay_tree.dart: "" ", _root is _SplayTreeMapNode<dynamic, dynamic>, true)); 291 ), "ImplicitCast", """line 425, column 18 of dart:collection/splay_tree.dart: "" ", _root is _SplayTreeMapNode<dynamic, dynamic>, true));
292 } 292 }
293 Iterable<K> get keys => new _SplayTreeKeyIterable<K>(this); 293 Iterable<K> get keys => new _SplayTreeKeyIterable<K>(this);
294 Iterable<V> get values => new _SplayTreeValueIterable<K, V>(this); 294 Iterable<V> get values => new _SplayTreeValueIterable<K, V>(this);
295 String toString() { 295 String toString() {
296 return Maps.mapToString(this); 296 return Maps.mapToString(this);
297 } 297 }
298 K firstKey() { 298 K firstKey() {
299 if (_root == null) return null; 299 if (_root == null) return null;
300 return DEVC$RT.cast(_first.key, dynamic, K, "CompositeCast", """line 440, colum n 12 of dart:collection/splay_tree.dart: """, _first.key is K, false); 300 return DEVC$RT.cast(_first.key, dynamic, K, "CompositeCast", """line 441, colum n 12 of dart:collection/splay_tree.dart: """, _first.key is K, false);
301 } 301 }
302 K lastKey() { 302 K lastKey() {
303 if (_root == null) return null; 303 if (_root == null) return null;
304 return DEVC$RT.cast(_last.key, dynamic, K, "CompositeCast", """line 448, column 12 of dart:collection/splay_tree.dart: """, _last.key is K, false); 304 return DEVC$RT.cast(_last.key, dynamic, K, "CompositeCast", """line 449, column 12 of dart:collection/splay_tree.dart: """, _last.key is K, false);
305 } 305 }
306 K lastKeyBefore(K key) { 306 K lastKeyBefore(K key) {
307 if (key == null) throw new ArgumentError(key); 307 if (key == null) throw new ArgumentError(key);
308 if (_root == null) return null; 308 if (_root == null) return null;
309 int comp = _splay(key); 309 int comp = _splay(key);
310 if (comp < 0) return _root.key; 310 if (comp < 0) return _root.key;
311 _SplayTreeNode<K> node = _root.left; 311 _SplayTreeNode<K> node = _root.left;
312 if (node == null) return null; 312 if (node == null) return null;
313 while (node.right != null) { 313 while (node.right != null) {
314 node = node.right; 314 node = node.right;
(...skipping 30 matching lines...) Expand all
345 else { 345 else {
346 _workList.add(tree._root); 346 _workList.add(tree._root);
347 } 347 }
348 } 348 }
349 T get current { 349 T get current {
350 if (_currentNode == null) return null; 350 if (_currentNode == null) return null;
351 return _getValue(DEVC$RT.cast(_currentNode, DEVC$RT.type((_SplayTreeNode<dynami c> _) { 351 return _getValue(DEVC$RT.cast(_currentNode, DEVC$RT.type((_SplayTreeNode<dynami c> _) {
352 } 352 }
353 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) { 353 ), DEVC$RT.type((_SplayTreeMapNode<dynamic, dynamic> _) {
354 } 354 }
355 ), "ImplicitCast", """line 544, column 22 of dart:collection/splay_tree.dart: "" ", _currentNode is _SplayTreeMapNode<dynamic, dynamic>, true)); 355 ), "ImplicitCast", """line 545, column 22 of dart:collection/splay_tree.dart: "" ", _currentNode is _SplayTreeMapNode<dynamic, dynamic>, true));
356 } 356 }
357 void _findLeftMostDescendent(_SplayTreeNode node) { 357 void _findLeftMostDescendent(_SplayTreeNode node) {
358 while (node != null) { 358 while (node != null) {
359 _workList.add(node); 359 _workList.add(node);
360 node = node.left; 360 node = node.left;
361 } 361 }
362 } 362 }
363 void _rebuildWorkList(_SplayTreeNode currentNode) { 363 void _rebuildWorkList(_SplayTreeNode currentNode) {
364 assert (!_workList.isEmpty); _workList.clear(); 364 assert (!_workList.isEmpty); _workList.clear();
365 if (currentNode == null) { 365 if (currentNode == null) {
(...skipping 23 matching lines...) Expand all
389 } 389 }
390 class _SplayTreeKeyIterable<K> extends IterableBase<K> implements EfficientLeng th {_SplayTree<K> _tree; 390 class _SplayTreeKeyIterable<K> extends IterableBase<K> implements EfficientLeng th {_SplayTree<K> _tree;
391 _SplayTreeKeyIterable(this._tree); 391 _SplayTreeKeyIterable(this._tree);
392 int get length => _tree._count; 392 int get length => _tree._count;
393 bool get isEmpty => _tree._count == 0; 393 bool get isEmpty => _tree._count == 0;
394 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree); 394 Iterator<K> get iterator => new _SplayTreeKeyIterator<K>(_tree);
395 Set<K> toSet() { 395 Set<K> toSet() {
396 var setOrMap = _tree; 396 var setOrMap = _tree;
397 SplayTreeSet<K> set = new SplayTreeSet<K>(DEVC$RT.cast(setOrMap._comparator, dy namic, DEVC$RT.type((__CastType14<K> _) { 397 SplayTreeSet<K> set = new SplayTreeSet<K>(DEVC$RT.cast(setOrMap._comparator, dy namic, DEVC$RT.type((__CastType14<K> _) {
398 } 398 }
399 ), "CompositeCast", """line 609, column 29 of dart:collection/splay_tree.dart: " "", setOrMap._comparator is __CastType14<K>, false), DEVC$RT.cast(setOrMap._vali dKey, dynamic, __CastType17, "CompositeCast", """line 609, column 51 of dart:col lection/splay_tree.dart: """, setOrMap._validKey is __CastType17, false)); 399 ), "CompositeCast", """line 610, column 29 of dart:collection/splay_tree.dart: " "", setOrMap._comparator is __CastType14<K>, false), DEVC$RT.cast(setOrMap._vali dKey, dynamic, __CastType17, "CompositeCast", """line 610, column 51 of dart:col lection/splay_tree.dart: """, setOrMap._validKey is __CastType17, false));
400 set._count = _tree._count; 400 set._count = _tree._count;
401 set._root = set._copyNode(_tree._root); 401 set._root = set._copyNode(_tree._root);
402 return set; 402 return set;
403 } 403 }
404 } 404 }
405 class _SplayTreeValueIterable<K, V> extends IterableBase<V> implements Efficien tLength {SplayTreeMap<K, V> _map; 405 class _SplayTreeValueIterable<K, V> extends IterableBase<V> implements Efficien tLength {SplayTreeMap<K, V> _map;
406 _SplayTreeValueIterable(this._map); 406 _SplayTreeValueIterable(this._map);
407 int get length => _map._count; 407 int get length => _map._count;
408 bool get isEmpty => _map._count == 0; 408 bool get isEmpty => _map._count == 0;
409 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map); 409 Iterator<V> get iterator => new _SplayTreeValueIterator<K, V>(_map);
410 } 410 }
411 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K> {_SplayTreeKeyIter ator(_SplayTree<K> map) : super(map); 411 class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K> {_SplayTreeKeyIter ator(_SplayTree<K> map) : super(map);
412 K _getValue(_SplayTreeNode node) => DEVC$RT.cast(node.key, dynamic, K, "Composi teCast", """line 627, column 39 of dart:collection/splay_tree.dart: """, node.ke y is K, false); 412 K _getValue(_SplayTreeNode node) => DEVC$RT.cast(node.key, dynamic, K, "Composi teCast", """line 628, column 39 of dart:collection/splay_tree.dart: """, node.ke y is K, false);
413 } 413 }
414 class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<V> {_SplayTreeVa lueIterator(SplayTreeMap<K, V> map) : super(map); 414 class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<V> {_SplayTreeVa lueIterator(SplayTreeMap<K, V> map) : super(map);
415 V _getValue(_SplayTreeMapNode node) => DEVC$RT.cast(node.value, dynamic, V, "Co mpositeCast", """line 632, column 42 of dart:collection/splay_tree.dart: """, no de.value is V, false); 415 V _getValue(_SplayTreeMapNode node) => DEVC$RT.cast(node.value, dynamic, V, "Co mpositeCast", """line 633, column 42 of dart:collection/splay_tree.dart: """, no de.value is V, false);
416 } 416 }
417 class _SplayTreeNodeIterator<K> extends _SplayTreeIterator<_SplayTreeNode<K>> { _SplayTreeNodeIterator(_SplayTree<K> tree) : super(tree); 417 class _SplayTreeNodeIterator<K> extends _SplayTreeIterator<_SplayTreeNode<K>> { _SplayTreeNodeIterator(_SplayTree<K> tree) : super(tree);
418 _SplayTreeNodeIterator.startAt(_SplayTree<K> tree, var startKey) : super.startA t(tree, startKey); 418 _SplayTreeNodeIterator.startAt(_SplayTree<K> tree, var startKey) : super.startA t(tree, startKey);
419 _SplayTreeNode<K> _getValue(_SplayTreeNode node) => DEVC$RT.cast(node, DEVC$RT. type((_SplayTreeNode<dynamic> _) { 419 _SplayTreeNode<K> _getValue(_SplayTreeNode node) => DEVC$RT.cast(node, DEVC$RT. type((_SplayTreeNode<dynamic> _) {
420 } 420 }
421 ), DEVC$RT.type((_SplayTreeNode<K> _) { 421 ), DEVC$RT.type((_SplayTreeNode<K> _) {
422 } 422 }
423 ), "CompositeCast", """line 640, column 55 of dart:collection/splay_tree.dart: " "", node is _SplayTreeNode<K>, false); 423 ), "CompositeCast", """line 641, column 55 of dart:collection/splay_tree.dart: " "", node is _SplayTreeNode<K>, false);
424 } 424 }
425 class SplayTreeSet<E> extends _SplayTree<E> with IterableMixin<E>, SetMixin<E> {Comparator _comparator; 425 class SplayTreeSet<E> extends _SplayTree<E> with IterableMixin<E>, SetMixin<E> {Comparator<E> _comparator;
426 _Predicate _validKey; 426 _Predicate<Object> _validKey;
427 SplayTreeSet([int compare(E key1, E key2), bool isValidKey(potentialKey)]) : _c omparator = (compare == null) ? Comparable.compare : compare, _validKey = (isVal idKey != null) ? isValidKey : ((v) => v is E); 427 SplayTreeSet([int compare(E key1, E key2), bool isValidKey(Object potentialKey) ]) : _comparator = ((__x19) => DEVC$RT.cast(__x19, dynamic, DEVC$RT.type((Compar ator<E> _) {
428 factory SplayTreeSet.from(Iterable elements, [int compare(E key1, E key2), bool isValidKey(potentialKey)]) { 428 }
429 ), "CompositeCast", """line 691, column 23 of dart:collection/splay_tree.dart: " "", __x19 is Comparator<E>, false))((compare == null) ? Comparable.compare : com pare), _validKey = (isValidKey != null) ? isValidKey : ((v) => v is E);
430 factory SplayTreeSet.from(Iterable elements, [int compare(E key1, E key2), bool isValidKey(Object potentialKey)]) {
429 SplayTreeSet<E> result = new SplayTreeSet<E>(compare, isValidKey); 431 SplayTreeSet<E> result = new SplayTreeSet<E>(compare, isValidKey);
430 for (final E element in DEVC$RT.cast(elements, DEVC$RT.type((Iterable<dynamic> _) { 432 for (final E element in DEVC$RT.cast(elements, DEVC$RT.type((Iterable<dynamic> _) {
431 } 433 }
432 ), DEVC$RT.type((Iterable<E> _) { 434 ), DEVC$RT.type((Iterable<E> _) {
433 } 435 }
434 ), "CompositeCast", """line 703, column 29 of dart:collection/splay_tree.dart: " "", elements is Iterable<E>, false)) { 436 ), "CompositeCast", """line 705, column 29 of dart:collection/splay_tree.dart: " "", elements is Iterable<E>, false)) {
435 result.add(element); 437 result.add(element);
436 } 438 }
437 return result; 439 return result;
438 } 440 }
439 int _compare(E e1, E e2) => _comparator(e1, e2); 441 int _compare(E e1, E e2) => _comparator(e1, e2);
440 Iterator<E> get iterator => new _SplayTreeKeyIterator<E>(this); 442 Iterator<E> get iterator => new _SplayTreeKeyIterator<E>(this);
441 int get length => _count; 443 int get length => _count;
442 bool get isEmpty => _root == null; 444 bool get isEmpty => _root == null;
443 bool get isNotEmpty => _root != null; 445 bool get isNotEmpty => _root != null;
444 E get first { 446 E get first {
445 if (_count == 0) throw IterableElementError.noElement(); 447 if (_count == 0) throw IterableElementError.noElement();
446 return DEVC$RT.cast(_first.key, dynamic, E, "CompositeCast", """line 721, colum n 12 of dart:collection/splay_tree.dart: """, _first.key is E, false); 448 return DEVC$RT.cast(_first.key, dynamic, E, "CompositeCast", """line 723, colum n 12 of dart:collection/splay_tree.dart: """, _first.key is E, false);
447 } 449 }
448 E get last { 450 E get last {
449 if (_count == 0) throw IterableElementError.noElement(); 451 if (_count == 0) throw IterableElementError.noElement();
450 return DEVC$RT.cast(_last.key, dynamic, E, "CompositeCast", """line 726, column 12 of dart:collection/splay_tree.dart: """, _last.key is E, false); 452 return DEVC$RT.cast(_last.key, dynamic, E, "CompositeCast", """line 728, column 12 of dart:collection/splay_tree.dart: """, _last.key is E, false);
451 } 453 }
452 E get single { 454 E get single {
453 if (_count == 0) throw IterableElementError.noElement(); 455 if (_count == 0) throw IterableElementError.noElement();
454 if (_count > 1) throw IterableElementError.tooMany(); 456 if (_count > 1) throw IterableElementError.tooMany();
455 return _root.key; 457 return _root.key;
456 } 458 }
457 bool contains(Object object) { 459 bool contains(Object object) {
458 return _validKey(object) && _splay(DEVC$RT.cast(object, Object, E, "CompositeCas t", """line 737, column 40 of dart:collection/splay_tree.dart: """, object is E, false)) == 0; 460 return _validKey(object) && _splay(DEVC$RT.cast(object, Object, E, "CompositeCas t", """line 739, column 40 of dart:collection/splay_tree.dart: """, object is E, false)) == 0;
459 } 461 }
460 bool add(E element) { 462 bool add(E element) {
461 int compare = _splay(element); 463 int compare = _splay(element);
462 if (compare == 0) return false; 464 if (compare == 0) return false;
463 _addNewRoot(new _SplayTreeNode<E>(element), compare); 465 _addNewRoot(new _SplayTreeNode<E>(element), compare);
464 return true; 466 return true;
465 } 467 }
466 bool remove(Object object) { 468 bool remove(Object object) {
467 if (!_validKey(object)) return false; 469 if (!_validKey(object)) return false;
468 return _remove(DEVC$RT.cast(object, Object, E, "CompositeCast", """line 749, co lumn 20 of dart:collection/splay_tree.dart: """, object is E, false)) != null; 470 return _remove(DEVC$RT.cast(object, Object, E, "CompositeCast", """line 751, co lumn 20 of dart:collection/splay_tree.dart: """, object is E, false)) != null;
469 } 471 }
470 void addAll(Iterable<E> elements) { 472 void addAll(Iterable<E> elements) {
471 for (E element in elements) { 473 for (E element in elements) {
472 int compare = _splay(element); 474 int compare = _splay(element);
473 if (compare != 0) { 475 if (compare != 0) {
474 _addNewRoot(new _SplayTreeNode<E>(element), compare); 476 _addNewRoot(new _SplayTreeNode<E>(element), compare);
475 } 477 }
476 } 478 }
477 } 479 }
478 void removeAll(Iterable<Object> elements) { 480 void removeAll(Iterable<Object> elements) {
479 for (Object element in elements) { 481 for (Object element in elements) {
480 if (_validKey(element)) _remove(DEVC$RT.cast(element, Object, E, "CompositeCast" , """line 763, column 39 of dart:collection/splay_tree.dart: """, element is E, false)); 482 if (_validKey(element)) _remove(DEVC$RT.cast(element, Object, E, "CompositeCast" , """line 765, column 39 of dart:collection/splay_tree.dart: """, element is E, false));
481 } 483 }
482 } 484 }
483 void retainAll(Iterable<Object> elements) { 485 void retainAll(Iterable<Object> elements) {
484 SplayTreeSet<E> retainSet = new SplayTreeSet<E>(DEVC$RT.cast(_comparator, DEVC$R T.type((Comparator<dynamic> _) { 486 SplayTreeSet<E> retainSet = new SplayTreeSet<E>(_comparator, _validKey);
485 }
486 ), DEVC$RT.type((__CastType19<E> _) {
487 }
488 ), "CompositeCast", """line 769, column 53 of dart:collection/splay_tree.dart: " "", _comparator is __CastType19<E>, false), _validKey);
489 int modificationCount = _modificationCount; 487 int modificationCount = _modificationCount;
490 for (Object object in elements) { 488 for (Object object in elements) {
491 if (modificationCount != _modificationCount) { 489 if (modificationCount != _modificationCount) {
492 throw new ConcurrentModificationError(this); 490 throw new ConcurrentModificationError(this);
493 } 491 }
494 if (_validKey(object) && _splay(DEVC$RT.cast(object, Object, E, "CompositeCast" , """line 777, column 39 of dart:collection/splay_tree.dart: """, object is E, f alse)) == 0) retainSet.add(_root.key); 492 if (_validKey(object) && _splay(DEVC$RT.cast(object, Object, E, "CompositeCast" , """line 779, column 39 of dart:collection/splay_tree.dart: """, object is E, f alse)) == 0) retainSet.add(_root.key);
495 } 493 }
496 if (retainSet._count != _count) { 494 if (retainSet._count != _count) {
497 _root = retainSet._root; 495 _root = retainSet._root;
498 _count = retainSet._count; 496 _count = retainSet._count;
499 _modificationCount++; 497 _modificationCount++;
500 } 498 }
501 } 499 }
502 E lookup(Object object) { 500 E lookup(Object object) {
503 if (!_validKey(object)) return null; 501 if (!_validKey(object)) return null;
504 int comp = _splay(DEVC$RT.cast(object, Object, E, "CompositeCast", """line 789, column 23 of dart:collection/splay_tree.dart: """, object is E, false)); 502 int comp = _splay(DEVC$RT.cast(object, Object, E, "CompositeCast", """line 791, column 23 of dart:collection/splay_tree.dart: """, object is E, false));
505 if (comp != 0) return null; 503 if (comp != 0) return null;
506 return _root.key; 504 return _root.key;
507 } 505 }
508 Set<E> intersection(Set<Object> other) { 506 Set<E> intersection(Set<Object> other) {
509 Set<E> result = new SplayTreeSet<E>(DEVC$RT.cast(_comparator, DEVC$RT.type((Comp arator<dynamic> _) { 507 Set<E> result = new SplayTreeSet<E>(_comparator, _validKey);
510 }
511 ), DEVC$RT.type((__CastType19<E> _) {
512 }
513 ), "CompositeCast", """line 795, column 41 of dart:collection/splay_tree.dart: " "", _comparator is __CastType19<E>, false), _validKey);
514 for (E element in this) { 508 for (E element in this) {
515 if (other.contains(element)) result.add(element); 509 if (other.contains(element)) result.add(element);
516 } 510 }
517 return result; 511 return result;
518 } 512 }
519 Set<E> difference(Set<Object> other) { 513 Set<E> difference(Set<Object> other) {
520 Set<E> result = new SplayTreeSet<E>(DEVC$RT.cast(_comparator, DEVC$RT.type((Comp arator<dynamic> _) { 514 Set<E> result = new SplayTreeSet<E>(_comparator, _validKey);
521 }
522 ), DEVC$RT.type((__CastType19<E> _) {
523 }
524 ), "CompositeCast", """line 803, column 41 of dart:collection/splay_tree.dart: " "", _comparator is __CastType19<E>, false), _validKey);
525 for (E element in this) { 515 for (E element in this) {
526 if (!other.contains(element)) result.add(element); 516 if (!other.contains(element)) result.add(element);
527 } 517 }
528 return result; 518 return result;
529 } 519 }
530 Set<E> union(Set<E> other) { 520 Set<E> union(Set<E> other) {
531 return _clone()..addAll(other); 521 return _clone()..addAll(other);
532 } 522 }
533 SplayTreeSet<E> _clone() { 523 SplayTreeSet<E> _clone() {
534 var set = new SplayTreeSet<E>(DEVC$RT.cast(_comparator, DEVC$RT.type((Comparator <dynamic> _) { 524 var set = new SplayTreeSet<E>(_comparator, _validKey);
535 }
536 ), DEVC$RT.type((__CastType19<E> _) {
537 }
538 ), "CompositeCast", """line 815, column 35 of dart:collection/splay_tree.dart: " "", _comparator is __CastType19<E>, false), _validKey);
539 set._count = _count; 525 set._count = _count;
540 set._root = _copyNode(_root); 526 set._root = _copyNode(_root);
541 return set; 527 return set;
542 } 528 }
543 _SplayTreeNode<E> _copyNode(_SplayTreeNode<E> node) { 529 _SplayTreeNode<E> _copyNode(_SplayTreeNode<E> node) {
544 if (node == null) return null; 530 if (node == null) return null;
545 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left)..right = _c opyNode(node.right); 531 return new _SplayTreeNode<E>(node.key)..left = _copyNode(node.left)..right = _c opyNode(node.right);
546 } 532 }
547 void clear() { 533 void clear() {
548 _clear(); 534 _clear();
549 } 535 }
550 Set<E> toSet() => _clone(); 536 Set<E> toSet() => _clone();
551 String toString() => IterableBase.iterableToFullString(this, '{', '}'); 537 String toString() => IterableBase.iterableToFullString(this, '{', '}');
552 } 538 }
553 typedef int __CastType14<K>(K __u15, K __u16); 539 typedef int __CastType14<K>(K __u15, K __u16);
554 typedef bool __CastType17(dynamic __u18); 540 typedef bool __CastType17(Object __u18);
555 typedef int __CastType19<E>(E __u20, E __u21);
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/collection/set.dart ('k') | test/generated_sdk/lib/collection/collection.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698