Dart by Example: Queue
1. import 'dart:collection';
3. main() {
4. // Queues are optimized for adding to the head or tail
5. // Items cannot be accessed by their index.
6. var q = new Queue.from([300, 200, 100, 500]);
8. // Queues implement Iterable:
9. print(q.takeWhile((i) => i > 100));
11. // Consuming a queue
12. while(q.first > 100) {
13. q.removeFirst();
14. }
15. print(q);
16. }
1. $ dart queue.dart
2. (300, 200)
3. {100, 500}
