OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 part of dart.collection; | 5 part of dart.collection; |
6 | 6 |
7 /** | 7 /** |
8 * A [Queue] is a collection that can be manipulated at both ends. One | 8 * A [Queue] is a collection that can be manipulated at both ends. One |
9 * can iterate over the elements of a queue through [forEach] or with | 9 * can iterate over the elements of a queue through [forEach] or with |
10 * an [Iterator]. | 10 * an [Iterator]. |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
550 result.addLast(element as Object/*=E*/); | 550 result.addLast(element as Object/*=E*/); |
551 } | 551 } |
552 return result; | 552 return result; |
553 } | 553 } |
554 } | 554 } |
555 | 555 |
556 // Iterable interface. | 556 // Iterable interface. |
557 | 557 |
558 Iterator<E> get iterator => new _ListQueueIterator<E>(this); | 558 Iterator<E> get iterator => new _ListQueueIterator<E>(this); |
559 | 559 |
560 void forEach(void action(E element)) { | 560 void forEach(void f(E element)) { |
Lasse Reichstein Nielsen
2017/05/31 12:30:22
I'd actually prefer to change the original to "act
| |
561 int modificationCount = _modificationCount; | 561 int modificationCount = _modificationCount; |
562 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { | 562 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { |
563 action(_table[i]); | 563 f(_table[i]); |
564 _checkModification(modificationCount); | 564 _checkModification(modificationCount); |
565 } | 565 } |
566 } | 566 } |
567 | 567 |
568 bool get isEmpty => _head == _tail; | 568 bool get isEmpty => _head == _tail; |
569 | 569 |
570 int get length => (_tail - _head) & (_table.length - 1); | 570 int get length => (_tail - _head) & (_table.length - 1); |
571 | 571 |
572 E get first { | 572 E get first { |
573 if (_head == _tail) throw IterableElementError.noElement(); | 573 if (_head == _tail) throw IterableElementError.noElement(); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 _queue._checkModification(_modificationCount); | 872 _queue._checkModification(_modificationCount); |
873 if (_position == _end) { | 873 if (_position == _end) { |
874 _current = null; | 874 _current = null; |
875 return false; | 875 return false; |
876 } | 876 } |
877 _current = _queue._table[_position]; | 877 _current = _queue._table[_position]; |
878 _position = (_position + 1) & (_queue._table.length - 1); | 878 _position = (_position + 1) & (_queue._table.length - 1); |
879 return true; | 879 return true; |
880 } | 880 } |
881 } | 881 } |
OLD | NEW |