QueueList<E>.from constructor

QueueList<E>.from(Iterable<E> source)

Create a queue initially containing the elements of source.

Implementation

factory QueueList.from(Iterable<E> source) {
  if (source is List) {
    int length = source.length;
    QueueList<E> queue = new QueueList(length + 1);
    assert(queue._table.length > length);
    var sourceList = source;
    queue._table.setRange(0, length, sourceList, 0);
    queue._tail = length;
    return queue;
  } else {
    return new QueueList<E>()..addAll(source);
  }
}