EmptyList<E> class

An empty list that doesn't allow adding-operations. Removing-operations (like remove, clear, retainWhere, ...) are ok, because the don't modify the contents of an empty list.

Inheritance

Constructors

EmptyList()
const

Properties

first ↔ E
Throws a StateError; because there is no such element.
read / write, inherited-getter
last ↔ E
Throws a StateError; because there is no such element.
read / write, inherited-getter
length ↔ int
Returns 0.
read / write, inherited-getter
reversed → Iterable<E>
Returns an Iterable of the objects in this list in reverse order.
read-only
hashCode → int
The hash code for this object.
read-only, inherited
isEmpty → bool
Returns true if there are no elements in this collection. [...]
read-only, inherited
isNotEmpty → bool
Returns true if there is at least one element in this collection. [...]
read-only, inherited
iterator → Iterator<E>
Returns an empty iterator.
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited
single → E
Throws a StateError; because there is no such element.
read-only, inherited

Methods

add(E value) → void
Throws an UnsupportedError; operations that add to the collection are disallowed.
addAll(Iterable<E> iterable) → void
Throws an UnsupportedError; operations that add to the collection are disallowed.
asMap() → Map<int, E>
According to the documentation of Map.asMap the resulting map has to be unmodifiable so a const {} is returned. This is choosen over a const EmptyMap() because the word "unmodifiable" is linked to the expectation that remove-operations (and such) will fail instead of be handled gracefully.
cast<R>() → List<R>
Returns itself; because this is already an empty iterable.
override
clear() → void
Does nothing; because this collection is already empty.
fillRange(int start, int end, [ E fillValue ]) → void
Throws an exception if start and end don't define the empty range (are both 0).
getRange(int start, int end) → Iterable<E>
Returns an empty iterable if start and end define the empty range (are both 0). Throws a RangeError elsewise.
indexOf(E element, [ int start = 0 ]) → int
Returns the first index of element in this list. [...]
indexWhere(bool test(E element), [ int start = 0 ]) → int
Returns the first index in the list that satisfies the provided test. [...]
insert(int index, E element) → void
Throws an UnsupportedError; operations that add to the collection are disallowed.
insertAll(int index, Iterable<E> iterable) → void
Throws an UnsupportedError; operations that add to the collection are disallowed.
lastIndexOf(E element, [ int start ]) → int
Returns the last index of element in this list. [...]
lastIndexWhere(bool test(E element), [ int start ]) → int
Returns the last index in the list that satisfies the provided test. [...]
remove(Object value) → bool
Always returns false; because value is guaranteed not to be contained in an empty collection.
removeAt(int index) → E
Throws an RangeError; because this list is empty.
removeLast() → E
[].removeLast() throws a RangeError so this implementation throws a RangeError.
removeRange(int start, int end) → void
Throws an exception if start and end don't define the empty range (are both 0).
removeWhere(bool test(E element)) → void
Changes nothing because this list is already empty.
replaceRange(int start, int end, Iterable<E> replacement) → void
Throws an exception if start and end don't define the empty range (are both 0).
retainWhere(bool test(E element)) → void
Removes all objects from this list that fail to satisfy test. [...]
setAll(int index, Iterable<E> iterable) → void
Throws an UnsupportedError; operations that add to the collection are disallowed.
setRange(int start, int end, Iterable<E> iterable, [ int skipCount = 0 ]) → void
Copies the objects of iterable, skipping skipCount objects first, into the range start, inclusive, to end, exclusive, of the list. [...]
shuffle([Random random ]) → void
Shuffles the elements of this list randomly.
sort([int compare(E a, E b) ]) → void
Sorts this list according to the order specified by the compare function. [...]
sublist(int start, [ int end ]) → List<E>
Returns a new list containing the elements between start and end. [...]
any(bool f(E element)) → bool
Checks whether any element of this iterable satisfies test. [...]
inherited
contains(Object element) → bool
Returns true if the collection contains an element equal to element. [...]
inherited
elementAt(int index) → E
Throws a RangeError.
inherited
every(bool f(E element)) → bool
Returns true; because an empty iterable doesn't have an element for which the predicate could return false.
inherited
expand<T>(Iterable<T> f(E element)) → Iterable<T>
Returns itself; because this is already an empty iterable. So there is nothing to expand.
inherited
firstWhere(bool test(E element), { E orElse() }) → E
Returns the result of orElse if such a function is provided. Throws an StateError otherwise.
inherited
fold<T>(T initialValue, T combine(T previousValue, E element)) → T
Returns initialValue; because there is nothing to combine.
inherited
followedBy(Iterable<E> other) → Iterable<E>
Returns other; because this Iterator is empty.
inherited
forEach(void f(E element)) → void
Applies the function f to each element of this collection in iteration order.
inherited
join([String separator = "" ]) → String
Returns an empty string.
inherited
lastWhere(bool test(E element), { E orElse() }) → E
Returns the result of orElse if such a function is provided. Throws an StateError otherwise.
inherited
map<T>(T f(E e)) → Iterable<T>
Returns itself; because an empty iterable is an empty iterable and i can't create type information with a const constructor anyway.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
reduce(E combine(E value, E element)) → E
Throws a StateError; because there is no element available.
inherited
singleWhere(bool test(E element), { E orElse() }) → E
Throws a StateError; because there is no such element.
inherited
skip(int count) → Iterable<E>
Throws a RangeError if count is negative. Returns itself otherwise; because this is already an empty iterable.
inherited
skipWhile(bool test(E value)) → Iterable<E>
Returns itself; because this is already an empty iterable.
inherited
take(int count) → Iterable<E>
Throws a RangeError if count is negative. Returns itself otherwise; because this is already an empty iterable.
inherited
takeWhile(bool test(E value)) → Iterable<E>
Returns itself; because this is already an empty iterable.
inherited
toList({bool growable: true }) → List<E>
If growable is true (which is the default) new List.from(this, growable: true) is returned, otherwise an const EmptyList() which is more efficient than new List(0)
inherited
toSet() → Set<E>
The documentation says nothing about the behaviour of the resulting set, so an empty standard set is returned (new Set()) to which new elements can be added.
inherited
toString() → String
Returns a string representation of this object.
inherited
where(bool f(E element)) → Iterable<E>
Returns itself; because this is already an empty iterable.
inherited
whereType<T>() → Iterable<T>
Returns itself; because this is already an empty iterable.
inherited

Operators

operator +(List<E> other) → List<E>
Returns the concatenation of this list and other. [...]
operator [](int index) → E
Returns the object at the given index in the list or throws a RangeError if index is out of bounds.
operator []=(int index, E value) → void
Throws an UnsupportedError; operations that add to the collection are disallowed.
operator ==(dynamic other) → bool
The equality operator.
inherited