| 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 /** | 5 /** |
| 6 * A [Queue] is a collection that can be manipulated at both ends. One | 6 * A [Queue] is a collection that can be manipulated at both ends. One |
| 7 * can iterate over the elements of a queue through [forEach] or with | 7 * can iterate over the elements of a queue through [forEach] or with |
| 8 * an [Iterator]. | 8 * an [Iterator]. |
| 9 */ | 9 */ |
| 10 abstract class Queue<E> extends Collection<E> { | 10 abstract class Queue<E> extends Collection<E> { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 DoubleLinkedQueueEntry<E> lastEntry() { | 222 DoubleLinkedQueueEntry<E> lastEntry() { |
| 223 return _sentinel.previousEntry(); | 223 return _sentinel.previousEntry(); |
| 224 } | 224 } |
| 225 | 225 |
| 226 DoubleLinkedQueueEntry<E> firstEntry() { | 226 DoubleLinkedQueueEntry<E> firstEntry() { |
| 227 return _sentinel.nextEntry(); | 227 return _sentinel.nextEntry(); |
| 228 } | 228 } |
| 229 | 229 |
| 230 int get length { | 230 int get length { |
| 231 int counter = 0; | 231 int counter = 0; |
| 232 forEach(void _(E element) { counter++; }); | 232 forEach((E element) { counter++; }); |
| 233 return counter; | 233 return counter; |
| 234 } | 234 } |
| 235 | 235 |
| 236 bool get isEmpty { | 236 bool get isEmpty { |
| 237 return (identical(_sentinel._next, _sentinel)); | 237 return (identical(_sentinel._next, _sentinel)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 void clear() { | 240 void clear() { |
| 241 _sentinel._next = _sentinel; | 241 _sentinel._next = _sentinel; |
| 242 _sentinel._previous = _sentinel; | 242 _sentinel._previous = _sentinel; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 | 330 |
| 331 E next() { | 331 E next() { |
| 332 if (!hasNext) { | 332 if (!hasNext) { |
| 333 throw new StateError("No more elements"); | 333 throw new StateError("No more elements"); |
| 334 } | 334 } |
| 335 _currentEntry = _currentEntry._next; | 335 _currentEntry = _currentEntry._next; |
| 336 return _currentEntry.element; | 336 return _currentEntry.element; |
| 337 } | 337 } |
| 338 } | 338 } |
| OLD | NEW |