Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:collection
  3. Queue<E> class
Queue
description

Queue<E> classabstractinterface

AQueue is a collection that can be manipulated at both ends. Onecan iterate over the elements of a queue throughforEach or withanIterator.

It is generally not allowed to modify the queue (add or remove entries)while an operation in the queue is being performed, for example during acall toforEach.Modifying the queue while it is being iterated will most likely break theiteration.This goes both for using theiterator directly, or for iterating anIterable returned by a method likemap orwhere.

Example:

final queue = Queue<int>(); // ListQueue() by defaultprint(queue.runtimeType); // ListQueue// Adding items to queuequeue.addAll([1, 2, 3]);queue.addFirst(0);queue.addLast(10);print(queue); // {0, 1, 2, 3, 10}// Removing items from queuequeue.removeFirst();queue.removeLast();print(queue); // {1, 2, 3}
Implemented types
Implementers
Available extensions

Constructors

Queue()
Creates a queue.
factory
Queue.from(Iterableelements)
Creates a queue containing allelements.
factory
Queue.of(Iterable<E>elements)
Creates a queue fromelements.
factory

Properties

first→ E
The first element.
no setterinherited
firstOrNull→ T?

Available onIterable<T>, provided by theIterableExtensions extension

The first element of this iterator, ornull if the iterable is empty.
no setter
hashCodeint
The hash code for this object.
no setterinherited
indexedIterable<(int,T)>

Available onIterable<T>, provided by theIterableExtensions extension

Pairs of elements of the indices and elements of this iterable.
no setter
isEmptybool
Whether this collection has no elements.
no setterinherited
isNotEmptybool
Whether this collection has at least one element.
no setterinherited
iteratorIterator<E>
A newIterator that allows iterating the elements of thisIterable.
no setterinherited
last→ E
The last element.
no setterinherited
lastOrNull→ T?

Available onIterable<T>, provided by theIterableExtensions extension

The last element of this iterable, ornull if the iterable is empty.
no setter
lengthint
The number of elements in thisIterable.
no setterinherited
nonNullsIterable<T>

Available onIterable<T?>, provided by theNullableIterableExtensions extension

The non-null elements of this iterable.
no setter
runtimeTypeType
A representation of the runtime type of the object.
no setterinherited
single→ E
Checks that this iterable has only one element, and returns that element.
no setterinherited
singleOrNull→ T?

Available onIterable<T>, provided by theIterableExtensions extension

The single element of this iterator, ornull.
no setter
waitFuture<List<T>>

Available onIterable<Future<T>>, provided by theFutureIterable extension

Waits for futures in parallel.
no setter

Methods

add(Evalue)→ void
Addsvalue at the end of the queue.
addAll(Iterable<E>iterable)→ void
Adds all elements ofiterable at the end of the queue. Thelength of the queue is extended by the length ofiterable.
addFirst(Evalue)→ void
Addsvalue at the beginning of the queue.
addLast(Evalue)→ void
Addsvalue at the end of the queue.
any(booltest(Eelement))bool
Checks whether any element of this iterable satisfiestest.
inherited
asNameMap()Map<String,T>

Available onIterable<T>, provided by theEnumByName extension

Creates a map from the names of enum values to the values.
byName(Stringname)→ T

Available onIterable<T>, provided by theEnumByName extension

Finds the enum value in this list with namename.
cast<R>()Queue<R>
Provides a view of this queue as a queue ofR instances, if necessary.
override
clear()→ void
Removes all elements in the queue. The size of the queue becomes zero.
contains(Object?element)bool
Whether the collection contains an element equal toelement.
inherited
elementAt(intindex)→ E
Returns theindexth element.
inherited
elementAtOrNull(intindex)→ T?

Available onIterable<T>, provided by theIterableExtensions extension

The element at positionindex of this iterable, ornull.
every(booltest(Eelement))bool
Checks whether every element of this iterable satisfiestest.
inherited
expand<T>(Iterable<T>toElements(Eelement))Iterable<T>
Expands each element of thisIterable into zero or more elements.
inherited
firstWhere(booltest(Eelement), {EorElse()?})→ E
The first element that satisfies the given predicatetest.
inherited
fold<T>(TinitialValue,Tcombine(TpreviousValue,Eelement))→ T
Reduces a collection to a single value by iteratively combining eachelement of the collection with an existing value
inherited
followedBy(Iterable<E>other)Iterable<E>
Creates the lazy concatenation of this iterable andother.
inherited
forEach(voidaction(Eelement))→ void
Invokesaction on each element of this iterable in iteration order.
inherited
join([Stringseparator =""])String
Converts each element to aString and concatenates the strings.
inherited
lastWhere(booltest(Eelement), {EorElse()?})→ E
The last element that satisfies the given predicatetest.
inherited
map<T>(TtoElement(Ee))Iterable<T>
The current elements of this iterable modified bytoElement.
inherited
noSuchMethod(Invocationinvocation)→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(Ecombine(Evalue,Eelement))→ E
Reduces a collection to a single value by iteratively combining elementsof the collection using the provided function.
inherited
remove(Object?value)bool
Removes a single instance ofvalue from the queue.
removeFirst()→ E
Removes and returns the first element of this queue.
removeLast()→ E
Removes and returns the last element of the queue.
removeWhere(booltest(Eelement))→ void
Removes all elements matched bytest from the queue.
retainWhere(booltest(Eelement))→ void
Removes all elements not matched bytest from the queue.
singleWhere(booltest(Eelement), {EorElse()?})→ E
The single element that satisfiestest.
inherited
skip(intcount)Iterable<E>
Creates anIterable that provides all but the firstcount elements.
inherited
skipWhile(booltest(Evalue))Iterable<E>
Creates anIterable that skips leading elements whiletest is satisfied.
inherited
take(intcount)Iterable<E>
Creates a lazy iterable of thecount first elements of this iterable.
inherited
takeWhile(booltest(Evalue))Iterable<E>
Creates a lazy iterable of the leading elements satisfyingtest.
inherited
toList({boolgrowable =true})List<E>
Creates aList containing the elements of thisIterable.
inherited
toSet()Set<E>
Creates aSet containing the same elements as this iterable.
inherited
toString()String
A string representation of this object.
inherited
where(booltest(Eelement))Iterable<E>
Creates a new lazyIterable with all elements that satisfy thepredicatetest.
inherited
whereType<T>()Iterable<T>
Creates a new lazyIterable with all elements that have typeT.
inherited

Operators

operator ==(Objectother)bool
The equality operator.
inherited

Static Methods

castFrom<S,T>(Queue<S>source)Queue<T>
Adaptssource to be aQueue<T>.
override
  1. Dart
  2. dart:collection
  3. Queue<E> class
dart:collection library

[8]ページ先頭

©2009-2025 Movatter.jp