QueueList<E>.from constructor

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

Create a queue initially containing the elements of source.

Implementation

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