| 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 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 return list; | 603 return list; |
| 604 } | 604 } |
| 605 | 605 |
| 606 // Collection interface. | 606 // Collection interface. |
| 607 | 607 |
| 608 void add(E value) { | 608 void add(E value) { |
| 609 _add(value); | 609 _add(value); |
| 610 } | 610 } |
| 611 | 611 |
| 612 void addAll(Iterable<E> elements) { | 612 void addAll(Iterable<E> elements) { |
| 613 if (elements is List/*<E>*/) { | 613 if (elements is List<E>) { |
| 614 List<E> list = elements; | 614 List<E> list = elements; |
| 615 int addCount = list.length; | 615 int addCount = list.length; |
| 616 int length = this.length; | 616 int length = this.length; |
| 617 if (length + addCount >= _table.length) { | 617 if (length + addCount >= _table.length) { |
| 618 _preGrow(length + addCount); | 618 _preGrow(length + addCount); |
| 619 // After preGrow, all elements are at the start of the list. | 619 // After preGrow, all elements are at the start of the list. |
| 620 _table.setRange(length, length + addCount, list, 0); | 620 _table.setRange(length, length + addCount, list, 0); |
| 621 _tail += addCount; | 621 _tail += addCount; |
| 622 } else { | 622 } else { |
| 623 // Adding addCount elements won't reach _head. | 623 // Adding addCount elements won't reach _head. |
| (...skipping 248 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 |