| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 queue._table.setRange(0, length, sourceList, 0); | 380 queue._table.setRange(0, length, sourceList, 0); |
| 381 queue._tail = length; | 381 queue._tail = length; |
| 382 return queue; | 382 return queue; |
| 383 } else { | 383 } else { |
| 384 return new ListQueue<E>()..addAll(source); | 384 return new ListQueue<E>()..addAll(source); |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 | 387 |
| 388 // Iterable interface. | 388 // Iterable interface. |
| 389 | 389 |
| 390 Iterator<E> get iterator => new _ListQueueIterator(this); | 390 Iterator<E> get iterator => new _ListQueueIterator<E>(this); |
| 391 | 391 |
| 392 void forEach(void action (E element)) { | 392 void forEach(void action (E element)) { |
| 393 int modificationCount = _modificationCount; | 393 int modificationCount = _modificationCount; |
| 394 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { | 394 for (int i = _head; i != _tail; i = (i + 1) & (_table.length - 1)) { |
| 395 action(_table[i]); | 395 action(_table[i]); |
| 396 _checkModification(modificationCount); | 396 _checkModification(modificationCount); |
| 397 } | 397 } |
| 398 } | 398 } |
| 399 | 399 |
| 400 bool get isEmpty => _head == _tail; | 400 bool get isEmpty => _head == _tail; |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 699 _queue._checkModification(_modificationCount); | 699 _queue._checkModification(_modificationCount); |
| 700 if (_position == _end) { | 700 if (_position == _end) { |
| 701 _current = null; | 701 _current = null; |
| 702 return false; | 702 return false; |
| 703 } | 703 } |
| 704 _current = _queue._table[_position]; | 704 _current = _queue._table[_position]; |
| 705 _position = (_position + 1) & (_queue._table.length - 1); | 705 _position = (_position + 1) & (_queue._table.length - 1); |
| 706 return true; | 706 return true; |
| 707 } | 707 } |
| 708 } | 708 } |
| OLD | NEW |