W3cubDocs

/Dart 2

DoubleLinkedQueue<E>.from constructor

DoubleLinkedQueue<E>.from(Iterable elements)

Creates a double-linked queue containing all elements.

The element order in the queue is as if the elements were added using addLast in the order provided by elements.iterator.

All the elements should be instances of E. The elements iterable itself may have any element type, so this constructor can be used to down-cast a Queue, for example as:

Queue<SuperType> superQueue = ...;
Queue<SubType> subQueue =
    new DoubleLinkedQueue<SubType>.from(superQueue.whereType<SubType>());

Implementation

factory DoubleLinkedQueue.from(Iterable elements) {
  Queue<E> list = new DoubleLinkedQueue<E>();
  for (final e in elements) {
    list.addLast(e);
  }
  return list;
}

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-collection/DoubleLinkedQueue/DoubleLinkedQueue.from.html