OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Patch file for dart:collection classes. | 5 // Patch file for dart:collection classes. |
6 import 'dart:_foreign_helper' show JS; | 6 import 'dart:_foreign_helper' show JS; |
7 import 'dart:_js_helper' show | 7 import 'dart:_js_helper' show |
8 fillLiteralMap, InternalMap, NoInline, NoSideEffects, NoThrows, patch, | 8 fillLiteralMap, InternalMap, NoInline, NoSideEffects, NoThrows, patch, |
9 JsLinkedHashMap, LinkedHashMapCell, LinkedHashMapKeyIterable, | 9 JsLinkedHashMap, LinkedHashMapCell, LinkedHashMapKeyIterable, |
10 LinkedHashMapKeyIterator; | 10 LinkedHashMapKeyIterator; |
(...skipping 413 matching lines...) Loading... |
424 int length = JS('int', '#.length', bucket); | 424 int length = JS('int', '#.length', bucket); |
425 for (int i = 0; i < length; i += 2) { | 425 for (int i = 0; i < length; i += 2) { |
426 if (_equals(JS('var', '#[#]', bucket, i), key)) return i; | 426 if (_equals(JS('var', '#[#]', bucket, i), key)) return i; |
427 } | 427 } |
428 return -1; | 428 return -1; |
429 } | 429 } |
430 | 430 |
431 String toString() => Maps.mapToString(this); | 431 String toString() => Maps.mapToString(this); |
432 } | 432 } |
433 | 433 |
434 class _HashMapKeyIterable<E> extends Iterable<E> implements EfficientLength { | 434 class _HashMapKeyIterable<E> extends EfficientLengthIterable<E> { |
435 final _HashMap/*<E, dynamic>*/ _map; | 435 final _HashMap/*<E, dynamic>*/ _map; |
436 _HashMapKeyIterable(this._map); | 436 _HashMapKeyIterable(this._map); |
437 | 437 |
438 int get length => _map._length; | 438 int get length => _map._length; |
439 bool get isEmpty => _map._length == 0; | 439 bool get isEmpty => _map._length == 0; |
440 | 440 |
441 Iterator<E> get iterator { | 441 Iterator<E> get iterator { |
442 return new _HashMapKeyIterator<E>(_map, _map._computeKeys()); | 442 return new _HashMapKeyIterator<E>(_map, _map._computeKeys()); |
443 } | 443 } |
444 | 444 |
(...skipping 187 matching lines...) Loading... |
632 // Value cycles after 2^30 modifications so that modification counts are | 632 // Value cycles after 2^30 modifications so that modification counts are |
633 // always unboxed (Smi) values. Modification detection will be missed if you | 633 // always unboxed (Smi) values. Modification detection will be missed if you |
634 // make exactly some multiple of 2^30 modifications between advances of an | 634 // make exactly some multiple of 2^30 modifications between advances of an |
635 // iterator. | 635 // iterator. |
636 _modifications = (_modifications + 1) & 0x3ffffff; | 636 _modifications = (_modifications + 1) & 0x3ffffff; |
637 } | 637 } |
638 | 638 |
639 String toString() => Maps.mapToString(this); | 639 String toString() => Maps.mapToString(this); |
640 } | 640 } |
641 | 641 |
642 class _Es6MapIterable<E> extends Iterable<E> | 642 class _Es6MapIterable<E> extends EfficientLengthIterable<E> { |
643 implements EfficientLength { | |
644 final _map; | 643 final _map; |
645 final bool _isKeys; | 644 final bool _isKeys; |
646 | 645 |
647 _Es6MapIterable(this._map, this._isKeys); | 646 _Es6MapIterable(this._map, this._isKeys); |
648 | 647 |
649 int get length => _map.length; | 648 int get length => _map.length; |
650 bool get isEmpty => _map.isEmpty; | 649 bool get isEmpty => _map.isEmpty; |
651 | 650 |
652 Iterator<E> get iterator => | 651 Iterator<E> get iterator => |
653 new _Es6MapIterator<E>(_map, _map._modifications, _isKeys); | 652 new _Es6MapIterator<E>(_map, _map._modifications, _isKeys); |
(...skipping 969 matching lines...) Loading... |
1623 } else if (_cell == null) { | 1622 } else if (_cell == null) { |
1624 _current = null; | 1623 _current = null; |
1625 return false; | 1624 return false; |
1626 } else { | 1625 } else { |
1627 _current = _cell._element; | 1626 _current = _cell._element; |
1628 _cell = _cell._next; | 1627 _cell = _cell._next; |
1629 return true; | 1628 return true; |
1630 } | 1629 } |
1631 } | 1630 } |
1632 } | 1631 } |
OLD | NEW |