On this page
ListQueue.from factory constructor
ListQueue.from(Create a ListQueue
containing all elements
.
The elements are added to the queue, as by addLast, in the order given by elements.iterator
.
All elements
should be assignable to E
.
Source
factory ListQueue.from(Iterable elements) {
if (elements is List) {
int length = elements.length;
ListQueue<E> queue = new ListQueue<E>(length + 1);
assert(queue._table.length > length);
for (int i = 0; i < length; i++) {
queue._table[i] = elements[i] as Object/*=E*/;
}
queue._tail = length;
return queue;
} else {
int capacity = _INITIAL_CAPACITY;
if (elements is EfficientLengthIterable) {
capacity = elements.length;
}
ListQueue<E> result = new ListQueue<E>(capacity);
for (final element in elements) {
result.addLast(element as Object/*=E*/);
}
return result;
}
}
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-collection/ListQueue/ListQueue.from.html