Dart Documentationdart.pkg.collection.wrappersDelegatingQueue<E>

DelegatingQueue<E> class

Creates a Queue that delegates all operations to a base queue.

This class can be used hide non-Queue methods of a queue object, or it can be extended to add extra functionality on top of an existing queue object.

class DelegatingQueue<E> extends DelegatingIterable<E> implements Queue<E> {
 DelegatingQueue(Queue<E> queue) : super(queue);

 Queue<E> get _baseQueue => _base;

 void add(E value) {
   _baseQueue.add(value);
 }

 void addAll(Iterable<E> iterable) {
   _baseQueue.addAll(iterable);
 }

 void addFirst(E value) {
   _baseQueue.addFirst(value);
 }

 void addLast(E value) {
   _baseQueue.addLast(value);
 }

 void clear() {
   _baseQueue.clear();
 }

 bool remove(Object object) => _baseQueue.remove(object);

 void removeWhere(bool test(E element)) { _baseQueue.removeWhere(test); }

 void retainWhere(bool test(E element)) { _baseQueue.retainWhere(test); }

 E removeFirst() => _baseQueue.removeFirst();

 E removeLast() => _baseQueue.removeLast();
}

Extends

DelegatingIterable<E> > DelegatingQueue<E>

Implements

Queue<E>

Constructors

new DelegatingQueue(Queue<E> queue) #

Create a wrapper that forwards operations to base.

docs inherited from DelegatingIterable<E>
DelegatingQueue(Queue<E> queue) : super(queue);

Properties

final E first #

inherited from DelegatingIterable

Returns the first element.

If this is empty throws a StateError. Otherwise this method is equivalent to this.elementAt(0)

docs inherited from Iterable<E>
E get first => _base.first;

final bool isEmpty #

inherited from DelegatingIterable

Returns true if there is no element in this collection.

docs inherited from Iterable<E>
bool get isEmpty => _base.isEmpty;

final bool isNotEmpty #

inherited from DelegatingIterable

Returns true if there is at least one element in this collection.

docs inherited from Iterable<E>
bool get isNotEmpty => _base.isNotEmpty;

final Iterator<E> iterator #

inherited from DelegatingIterable

Returns an Iterator that iterates over this Iterable object.

docs inherited from Iterable<E>
Iterator<E> get iterator => _base.iterator;

final E last #

inherited from DelegatingIterable

Returns the last element.

If this is empty throws a StateError.

docs inherited from Iterable<E>
E get last => _base.last;

final int length #

inherited from DelegatingIterable

Returns the number of elements in this.

Counting all elements may be involve running through all elements and can therefore be slow.

docs inherited from Iterable<E>
int get length => _base.length;

final E single #

inherited from DelegatingIterable

Returns the single element in this.

If this is empty or has more than one element throws a StateError.

docs inherited from Iterable<E>
E get single => _base.single;

Methods

void add(E value) #

Adds value at the end of the queue.

docs inherited from Queue<E>
void add(E value) {
 _baseQueue.add(value);
}

void addAll(Iterable<E> iterable) #

Adds all elements of iterable at the end of the queue. The length of the queue is extended by the length of iterable.

docs inherited from Queue<E>
void addAll(Iterable<E> iterable) {
 _baseQueue.addAll(iterable);
}

void addFirst(E value) #

Adds value at the beginning of the queue.

docs inherited from Queue<E>
void addFirst(E value) {
 _baseQueue.addFirst(value);
}

void addLast(E value) #

Adds value at the end of the queue.

docs inherited from Queue<E>
void addLast(E value) {
 _baseQueue.addLast(value);
}

bool any(bool test(E element)) #

inherited from DelegatingIterable

Returns true if one element of this collection satisfies the predicate test. Returns false otherwise.

docs inherited from Iterable<E>
bool any(bool test(E element)) => _base.any(test);

void clear() #

Removes all elements in the queue. The size of the queue becomes zero.

docs inherited from Queue<E>
void clear() {
 _baseQueue.clear();
}

bool contains(Object element) #

inherited from DelegatingIterable

Returns true if the collection contains an element equal to element.

docs inherited from Iterable<E>
bool contains(Object element) => _base.contains(element);

E elementAt(int index) #

inherited from DelegatingIterable

Returns the indexth element.

If this has fewer than index elements throws a RangeError.

Note: if this does not have a deterministic iteration order then the function may simply return any element without any iteration if there are at least index elements in this.

docs inherited from Iterable<E>
E elementAt(int index) => _base.elementAt(index);

bool every(bool test(E element)) #

inherited from DelegatingIterable

Returns true if every elements of this collection satisify the predicate test. Returns false otherwise.

docs inherited from Iterable<E>
bool every(bool test(E element)) => _base.every(test);

Iterable expand(Iterable f(E element)) #

inherited from DelegatingIterable

Expands each element of this Iterable into zero or more elements.

The resulting Iterable runs through the elements returned by f for each element of this, in order.

The returned Iterable is lazy, and calls f for each element of this every time it's iterated.

docs inherited from Iterable<E>
Iterable expand(Iterable f(E element)) => _base.expand(f);

E firstWhere(bool test(E element), {E orElse()}) #

inherited from DelegatingIterable

Returns the first element that satisfies the given predicate test.

If none matches, the result of invoking the orElse function is returned. By default, when orElse is null, a StateError is thrown.

docs inherited from Iterable<E>
E firstWhere(bool test(E element), {E orElse()}) =>
   _base.firstWhere(test, orElse: orElse);

dynamic fold(initialValue, combine(previousValue, E element)) #

inherited from DelegatingIterable

Reduces a collection to a single value by iteratively combining each element of the collection with an existing value using the provided function.

Use initialValue as the initial value, and the function combine to create a new value from the previous one and an element.

Example of calculating the sum of an iterable:

iterable.fold(0, (prev, element) => prev + element);
docs inherited from Iterable<E>
fold(initialValue, combine(previousValue, E element)) =>
   _base.fold(initialValue, combine);

void forEach(void f(E element)) #

inherited from DelegatingIterable

Applies the function f to each element of this collection.

docs inherited from Iterable<E>
void forEach(void f(E element)) => _base.forEach(f);

String join([String separator = ""]) #

inherited from DelegatingIterable

Converts each element to a String and concatenates the strings.

Converts each element to a String by calling Object.toString on it. Then concatenates the strings, optionally separated by the separator string.

docs inherited from Iterable<E>
String join([String separator = ""]) => _base.join(separator);

E lastWhere(bool test(E element), {E orElse()}) #

inherited from DelegatingIterable

Returns the last element that satisfies the given predicate test.

If none matches, the result of invoking the orElse function is returned. By default, when orElse is null, a StateError is thrown.

docs inherited from Iterable<E>
E lastWhere(bool test(E element), {E orElse()}) =>
   _base.lastWhere(test, orElse: orElse);

Iterable map(f(E element)) #

inherited from DelegatingIterable

Returns a lazy Iterable where each element e of this is replaced by the result of f(e).

This method returns a view of the mapped elements. As long as the returned Iterable is not iterated over, the supplied function f will not be invoked. The transformed elements will not be cached. Iterating multiple times over the the returned Iterable will invoke the supplied function f multiple times on the same element.

docs inherited from Iterable<E>
Iterable map(f(E element)) => _base.map(f);

E reduce(E combine(E value, E element)) #

inherited from DelegatingIterable

Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.

Example of calculating the sum of an iterable:

iterable.reduce((value, element) => value + element);
docs inherited from Iterable<E>
E reduce(E combine(E value, E element)) => _base.reduce(combine);

bool remove(Object object) #

Remove a single instance of value from the queue.

Returns true if a value was removed, or false if the queue contained no element equal to value.

docs inherited from Queue<E>
bool remove(Object object) => _baseQueue.remove(object);

E removeFirst() #

Removes and returns the first element of this queue. Throws an StateError exception if this queue is empty.

docs inherited from Queue<E>
E removeFirst() => _baseQueue.removeFirst();

E removeLast() #

Removes and returns the last element of the queue. Throws an StateError exception if this queue is empty.

docs inherited from Queue<E>
E removeLast() => _baseQueue.removeLast();

void removeWhere(bool test(E element)) #

Removes all elements matched by test from the queue.

The test function must not throw or modify the queue.

docs inherited from Queue<E>
void removeWhere(bool test(E element)) { _baseQueue.removeWhere(test); }

void retainWhere(bool test(E element)) #

Removes all elements not matched by test from the queue.

The test function must not throw or modify the queue.

docs inherited from Queue<E>
void retainWhere(bool test(E element)) { _baseQueue.retainWhere(test); }

E singleWhere(bool test(E element)) #

inherited from DelegatingIterable

Returns the single element that satisfies test. If no or more than one element match then a StateError is thrown.

docs inherited from Iterable<E>
E singleWhere(bool test(E element)) => _base.singleWhere(test);

Iterable<E> skip(int n) #

inherited from DelegatingIterable

Returns an Iterable that skips the first n elements.

If this has fewer than n elements, then the resulting Iterable is empty.

It is an error if n is negative.

docs inherited from Iterable<E>
Iterable<E> skip(int n) => _base.skip(n);

Iterable<E> skipWhile(bool test(E value)) #

inherited from DelegatingIterable

Returns an Iterable that skips elements while test is satisfied.

The filtering happens lazily. Every new Iterator of the returned Iterable iterates over all elements of this.

As long as the iterator's elements satisfy test they are discarded. Once an element does not satisfy the test the iterator stops testing and uses every later element unconditionally. That is, the elements of the returned Iterable are the elements of this starting from the first element that does not satisfy test.

docs inherited from Iterable<E>
Iterable<E> skipWhile(bool test(E value)) => _base.skipWhile(test);

Iterable<E> take(int n) #

inherited from DelegatingIterable

Returns an Iterable with at most n elements.

The returned Iterable may contain fewer than n elements, if this contains fewer than n elements.

It is an error if n is negative.

docs inherited from Iterable<E>
Iterable<E> take(int n) => _base.take(n);

Iterable<E> takeWhile(bool test(E value)) #

inherited from DelegatingIterable

Returns an Iterable that stops once test is not satisfied anymore.

The filtering happens lazily. Every new Iterator of the returned Iterable starts iterating over the elements of this.

When the iterator encounters an element e that does not satisfy test, it discards e and moves into the finished state. That is, it does not get or provide any more elements.

docs inherited from Iterable<E>
Iterable<E> takeWhile(bool test(E value)) => _base.takeWhile(test);

List<E> toList({bool growable: true}) #

inherited from DelegatingIterable

Creates a List containing the elements of this Iterable.

The elements are in iteration order. The list is fixed-length if growable is false.

docs inherited from Iterable<E>
List<E> toList({bool growable: true}) => _base.toList(growable: growable);

Set<E> toSet() #

inherited from DelegatingIterable

Creates a Set containing the elements of this Iterable.

docs inherited from Iterable<E>
Set<E> toSet() => _base.toSet();

Iterable<E> where(bool test(E element)) #

inherited from DelegatingIterable

Returns a lazy Iterable with all elements that satisfy the predicate test.

This method returns a view of the mapped elements. As long as the returned Iterable is not iterated over, the supplied function test will not be invoked. Iterating will not cache results, and thus iterating multiple times over the returned Iterable will invoke the supplied function test multiple times on the same element.

docs inherited from Iterable<E>
Iterable<E> where(bool test(E element)) => _base.where(test);