OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 // Efficient JavaScript based implementation of a linked hash map used as a | 5 // Efficient JavaScript based implementation of a linked hash map used as a |
6 // backing map for constant maps and the [LinkedHashMap] patch | 6 // backing map for constant maps and the [LinkedHashMap] patch |
7 | 7 |
8 part of dart._js_helper; | 8 part of dart._js_helper; |
9 | 9 |
10 // DDC-specific, just use Object-backed maps | 10 // DDC-specific, just use Object-backed maps |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 class LinkedHashMapCell<K, V> { | 375 class LinkedHashMapCell<K, V> { |
376 final dynamic/*=K*/ hashMapCellKey; | 376 final dynamic/*=K*/ hashMapCellKey; |
377 dynamic/*=V*/ hashMapCellValue; | 377 dynamic/*=V*/ hashMapCellValue; |
378 | 378 |
379 LinkedHashMapCell/*<K, V>*/ _next; | 379 LinkedHashMapCell/*<K, V>*/ _next; |
380 LinkedHashMapCell/*<K, V>*/ _previous; | 380 LinkedHashMapCell/*<K, V>*/ _previous; |
381 | 381 |
382 LinkedHashMapCell(this.hashMapCellKey, this.hashMapCellValue); | 382 LinkedHashMapCell(this.hashMapCellKey, this.hashMapCellValue); |
383 } | 383 } |
384 | 384 |
385 class LinkedHashMapKeyIterable<E> extends Iterable<E> | 385 class LinkedHashMapKeyIterable<E> extends EfficientLengthIterable<E> { |
386 implements EfficientLength { | |
387 final dynamic/*=JsLinkedHashMap<E, dynamic>*/ _map; | 386 final dynamic/*=JsLinkedHashMap<E, dynamic>*/ _map; |
388 LinkedHashMapKeyIterable(this._map); | 387 LinkedHashMapKeyIterable(this._map); |
389 | 388 |
390 int get length => _map._length; | 389 int get length => _map._length; |
391 bool get isEmpty => _map._length == 0; | 390 bool get isEmpty => _map._length == 0; |
392 | 391 |
393 Iterator<E> get iterator { | 392 Iterator<E> get iterator { |
394 return new LinkedHashMapKeyIterator<E>(_map, _map._modifications); | 393 return new LinkedHashMapKeyIterator<E>(_map, _map._modifications); |
395 } | 394 } |
396 | 395 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } else if (_cell == null) { | 428 } else if (_cell == null) { |
430 _current = null; | 429 _current = null; |
431 return false; | 430 return false; |
432 } else { | 431 } else { |
433 _current = _cell.hashMapCellKey; | 432 _current = _cell.hashMapCellKey; |
434 _cell = _cell._next; | 433 _cell = _cell._next; |
435 return true; | 434 return true; |
436 } | 435 } |
437 } | 436 } |
438 } | 437 } |
OLD | NEW |