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

Side by Side Diff: test/generated_sdk/lib/collection/collection.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 // 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 * Classes and utilities that supplement the collection support in dart:core. 6 * Classes and utilities that supplement the collection support in dart:core.
7 */ 7 */
8 library dart.collection; 8 library dart.collection;
9 9
10 import 'dart:_internal'; 10 import 'dart:_internal';
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 int length = JS('int', '#.length', bucket); 359 int length = JS('int', '#.length', bucket);
360 for (int i = 0; i < length; i += 2) { 360 for (int i = 0; i < length; i += 2) {
361 if (identical(JS('var', '#[#]', bucket, i), key)) return i; 361 if (identical(JS('var', '#[#]', bucket, i), key)) return i;
362 } 362 }
363 return -1; 363 return -1;
364 } 364 }
365 } 365 }
366 class _CustomHashMap<K, V> extends _HashMap<K, V> { 366 class _CustomHashMap<K, V> extends _HashMap<K, V> {
367 final _Equality<K> _equals; 367 final _Equality<K> _equals;
368 final _Hasher<K> _hashCode; 368 final _Hasher<K> _hashCode;
369 final _Predicate _validKey; 369 final _Predicate<Object> _validKey;
370 _CustomHashMap(this._equals, this._hashCode, bool validKey(potentialKey)) 370 _CustomHashMap(this._equals, this._hashCode,
371 bool validKey(Object potentialKey))
371 : _validKey = (validKey != null) ? validKey : ((v) => v is K); 372 : _validKey = (validKey != null) ? validKey : ((v) => v is K);
372 373
373 V operator[](Object key) { 374 V operator[](Object key) {
374 if (!_validKey(key)) return null; 375 if (!_validKey(key)) return null;
375 return super._get(key); 376 return super._get(key);
376 } 377 }
377 378
378 void operator[]=(K key, V value) { 379 void operator[]=(K key, V value) {
379 super._set(key, value); 380 super._set(key, value);
380 } 381 }
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
781 for (int i = 0; i < length; i++) { 782 for (int i = 0; i < length; i++) {
782 LinkedHashMapCell cell = JS('var', '#[#]', bucket, i); 783 LinkedHashMapCell cell = JS('var', '#[#]', bucket, i);
783 if (identical(cell._key, key)) return i; 784 if (identical(cell._key, key)) return i;
784 } 785 }
785 return -1; 786 return -1;
786 } 787 }
787 } 788 }
788 class _LinkedCustomHashMap<K, V> extends _LinkedHashMap<K, V> { 789 class _LinkedCustomHashMap<K, V> extends _LinkedHashMap<K, V> {
789 final _Equality<K> _equals; 790 final _Equality<K> _equals;
790 final _Hasher<K> _hashCode; 791 final _Hasher<K> _hashCode;
791 final _Predicate _validKey; 792 final _Predicate<Object> _validKey;
792 _LinkedCustomHashMap(this._equals, this._hashCode, 793 _LinkedCustomHashMap(this._equals, this._hashCode,
793 bool validKey(potentialKey)) 794 bool validKey(Object potentialKey))
794 : _validKey = (validKey != null) ? validKey : ((v) => v is K); 795 : _validKey = (validKey != null) ? validKey : ((v) => v is K);
795 796
796 V operator[](Object key) { 797 V operator[](Object key) {
797 if (!_validKey(key)) return null; 798 if (!_validKey(key)) return null;
798 return super._get(key); 799 return super._get(key);
799 } 800 }
800 801
801 void operator[]=(K key, V value) { 802 void operator[]=(K key, V value) {
802 super._set(key, value); 803 super._set(key, value);
803 } 804 }
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1180 int length = JS('int', '#.length', bucket); 1181 int length = JS('int', '#.length', bucket);
1181 for (int i = 0; i < length; i++) { 1182 for (int i = 0; i < length; i++) {
1182 if (identical(JS('var', '#[#]', bucket, i), element)) return i; 1183 if (identical(JS('var', '#[#]', bucket, i), element)) return i;
1183 } 1184 }
1184 return -1; 1185 return -1;
1185 } 1186 }
1186 } 1187 }
1187 class _CustomHashSet<E> extends _HashSet<E> { 1188 class _CustomHashSet<E> extends _HashSet<E> {
1188 _Equality<E> _equality; 1189 _Equality<E> _equality;
1189 _Hasher<E> _hasher; 1190 _Hasher<E> _hasher;
1190 _Predicate _validKey; 1191 _Predicate<Object> _validKey;
1191 _CustomHashSet(this._equality, this._hasher, bool validKey(potentialKey)) 1192 _CustomHashSet(this._equality, this._hasher,
1193 bool validKey(Object potentialKey))
1192 : _validKey = (validKey != null) ? validKey : ((x) => x is E); 1194 : _validKey = (validKey != null) ? validKey : ((x) => x is E);
1193 1195
1194 Set<E> _newSet() => new _CustomHashSet<E>(_equality, _hasher, _validKey); 1196 Set<E> _newSet() => new _CustomHashSet<E>(_equality, _hasher, _validKey);
1195 1197
1196 int _findBucketIndex(var bucket, var element) { 1198 int _findBucketIndex(var bucket, var element) {
1197 if (bucket == null) return -1; 1199 if (bucket == null) return -1;
1198 int length = JS('int', '#.length', bucket); 1200 int length = JS('int', '#.length', bucket);
1199 for (int i = 0; i < length; i++) { 1201 for (int i = 0; i < length; i++) {
1200 if (_equality(JS('var', '#[#]', bucket, i), element)) return i; 1202 if (_equality(JS('var', '#[#]', bucket, i), element)) return i;
1201 } 1203 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 for (int i = 0; i < length; i++) { 1583 for (int i = 0; i < length; i++) {
1582 LinkedHashSetCell cell = JS('var', '#[#]', bucket, i); 1584 LinkedHashSetCell cell = JS('var', '#[#]', bucket, i);
1583 if (identical(cell._element, element)) return i; 1585 if (identical(cell._element, element)) return i;
1584 } 1586 }
1585 return -1; 1587 return -1;
1586 } 1588 }
1587 } 1589 }
1588 class _LinkedCustomHashSet<E> extends _LinkedHashSet<E> { 1590 class _LinkedCustomHashSet<E> extends _LinkedHashSet<E> {
1589 _Equality<E> _equality; 1591 _Equality<E> _equality;
1590 _Hasher<E> _hasher; 1592 _Hasher<E> _hasher;
1591 _Predicate _validKey; 1593 _Predicate<Object> _validKey;
1592 _LinkedCustomHashSet(this._equality, this._hasher, 1594 _LinkedCustomHashSet(this._equality, this._hasher,
1593 bool validKey(potentialKey)) 1595 bool validKey(Object potentialKey))
1594 : _validKey = (validKey != null) ? validKey : ((x) => x is E); 1596 : _validKey = (validKey != null) ? validKey : ((x) => x is E);
1595 1597
1596 Set<E> _newSet() => 1598 Set<E> _newSet() =>
1597 new _LinkedCustomHashSet<E>(_equality, _hasher, _validKey); 1599 new _LinkedCustomHashSet<E>(_equality, _hasher, _validKey);
1598 1600
1599 int _findBucketIndex(var bucket, var element) { 1601 int _findBucketIndex(var bucket, var element) {
1600 if (bucket == null) return -1; 1602 if (bucket == null) return -1;
1601 int length = JS('int', '#.length', bucket); 1603 int length = JS('int', '#.length', bucket);
1602 for (int i = 0; i < length; i++) { 1604 for (int i = 0; i < length; i++) {
1603 LinkedHashSetCell cell = JS('var', '#[#]', bucket, i); 1605 LinkedHashSetCell cell = JS('var', '#[#]', bucket, i);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 } else if (_cell == null) { 1674 } else if (_cell == null) {
1673 _current = null; 1675 _current = null;
1674 return false; 1676 return false;
1675 } else { 1677 } else {
1676 _current = _cell._element; 1678 _current = _cell._element;
1677 _cell = _cell._next; 1679 _cell = _cell._next;
1678 return true; 1680 return true;
1679 } 1681 }
1680 } 1682 }
1681 } 1683 }
OLDNEW
« no previous file with comments | « test/dart_codegen/expect/collection/splay_tree.dart ('k') | test/generated_sdk/lib/collection/hash_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698