| 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]. |
| 11 * |
| 12 * It is generally not allowed to modify the queue (add or remove entries) while |
| 13 * an operation on the queue is being performed, for example during a call to |
| 14 * [forEach]. |
| 15 * Modifying the queue while it is being iterated will most likely break the |
| 16 * iteration. |
| 17 * This goes both for using the [iterator] directly, or for iterating an |
| 18 * `Iterable` returned by a method like [map] or [where]. |
| 11 */ | 19 */ |
| 12 abstract class Queue<E> implements Iterable<E>, EfficientLength { | 20 abstract class Queue<E> implements Iterable<E>, EfficientLength { |
| 13 | 21 |
| 14 /** | 22 /** |
| 15 * Creates a queue. | 23 * Creates a queue. |
| 16 */ | 24 */ |
| 17 factory Queue() = ListQueue<E>; | 25 factory Queue() = ListQueue<E>; |
| 18 | 26 |
| 19 /** | 27 /** |
| 20 * Creates a queue with the elements of [other]. The order in | 28 * Creates a queue with the elements of [other]. The order in |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 _queue._checkModification(_modificationCount); | 698 _queue._checkModification(_modificationCount); |
| 691 if (_position == _end) { | 699 if (_position == _end) { |
| 692 _current = null; | 700 _current = null; |
| 693 return false; | 701 return false; |
| 694 } | 702 } |
| 695 _current = _queue._table[_position]; | 703 _current = _queue._table[_position]; |
| 696 _position = (_position + 1) & (_queue._table.length - 1); | 704 _position = (_position + 1) & (_queue._table.length - 1); |
| 697 return true; | 705 return true; |
| 698 } | 706 } |
| 699 } | 707 } |
| OLD | NEW |