LabeledList<E> class

An implementation of list that accepts an optional label with every element added to the list.

Available Extensions

Constructors

LabeledList()
An implementation of list that accepts an optional label with every element added to the list.
LabeledList.empty({bool growable = false})
Constructs a new empty LabeledList.
LabeledList.filled(int length, E fill, {Iterable<String?>? labels, bool growable = false})
Constructs a new LabeledList of the given length with fill for every element.
LabeledList.from(Iterable<E> elements, {Iterable<String?>? labels, bool growable = true})
Constructs a new LabeledList from elements.
LabeledList.generate(int length, Generator<E> generator, {Iterable<String?>? labels, bool growable = true})
Generates a LabeledList of values, as returned by generator.
LabeledList.of(Iterable<E> elements, {Iterable<String?>? labels, bool growable = true})
Constructs a new LabeledList containing all elements.
LabeledList.unmodifiable(Iterable<E> elements, {Iterable<String?>? labels})
Constructs an unmodifiable LabeledList of elements.

Properties

elements List<E>
The underlying List containing all of the elements in this list.
finalinherited
first ↔ E
The first element.
getter/setter pairinherited
growable bool
If true, this list is growable; otherwise, this is a fixed-length list.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Whether this collection has no elements.
no setterinherited
isNotEmpty bool
Whether this collection has at least one element.
no setterinherited
iterator Iterator<E>
A new Iterator that allows iterating the elements of this Iterable.
no setterinherited
labels List<String?>
Returns a list containing all of the labels mapped to this list.
no setter
last ↔ E
The last element.
getter/setter pairinherited
length int
The number of objects in this list.
getter/setter pairinherited-getter
reversed Iterable<E>
An Iterable of the objects in this list in reverse order.
no setterinherited
runtimeType Type
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

Methods

add(E value, {String? label}) → void
Adds value to the end of this list, extending the length by one.
addAll(Iterable<E> iterable, {Iterable<String?>? labels}) → void
Appends all objects of iterable to the end of this list.
any(Test<E> test) bool
Checks whether any element of this iterable satisfies test.
inherited
asMap() Map<int, E>
An unmodifiable Map view of this list.
inherited
cast<R>({bool? growable}) LabeledList<R>
Returns a view of this list as a list of R instances.
override
clear() → void
Removes all objects from this list; the length of the list becomes zero.
inherited
contains(Object? element) bool
Whether the collection contains an element equal to element.
inherited
elementAt(int index) → E
Returns the indexth element.
inherited
every(Test<E> test) bool
Checks whether every element of this iterable satisfies test.
inherited
expand<T>(Expand<T, E> f) Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
fillRange(int start, int end, [E? fillValue]) → void
Overwrites a range of elements with fillValue.
inherited
firstWhere(Test<E> test, {OrElse<E>? orElse}) → E
The first element that satisfies the given predicate test.
inherited
fold<T>(T initialValue, Fold<T, E> combine) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<E> other, {bool labeled = false, bool? growable}) Iterable<E>
Creates the lazy concatenation of this iterable and other.
forEach(ForEach<E> f) → void
Invokes action on each element of this iterable in iteration order.
inherited
getLabel(E element) String?
Returns the label associated with element.
getLabelAt(int index) String?
Returns the label associated with the element at index.
getRange(int start, int end) Iterable<E>
Creates an Iterable that iterates over a range of elements.
inherited
hasLabel(String label) bool
Returns true if this list contains an element labeled as label.
hasLabelAt(int index) bool
Returns true if the element at index has a label.
indexOf(E element, [int start = 0]) int
The first index of element in this list.
inherited
indexOfLabel(String label) int
Returns the index of the element associated with label.
indexWhere(Test<E> test, [int start = 0]) int
The first index in the list that satisfies the provided test.
inherited
insert(int index, E element, {String? label}) → void
Inserts element at position index in this list.
insertAll(int index, Iterable<E> iterable, {Iterable<String?>? labels}) → void
Inserts all objects of iterable at position index in this list.
join([String separator = '']) String
Converts each element to a String and concatenates the strings.
inherited
lastIndexOf(E element, [int? start]) int
The last index of element in this list.
inherited
lastIndexWhere(Test<E> test, [int? start]) int
The last index in the list that satisfies the provided test.
inherited
lastWhere(Test<E> test, {OrElse<E>? orElse}) → E
The last element that satisfies the given predicate test.
inherited
map<T>(Mapper<T, E> f, {bool labeled = false, bool? growable}) Iterable<T>
The current elements of this iterable modified by toElement.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(Combine<E> combine) → E
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
remove(Object? value) bool
Removes the first occurrence of value from this list.
removeAt(int index) → E
Removes the object at position index from this list.
removeByLabel(String label) → E
Removes the element associated with label from the list.
removeLabelWhere(Test<E> test) → void
Sets the label of every element that pass the test to null.
removeLast() → E
Removes and returns the last object in this list.
removeRange(int start, int end) → void
Removes a range of elements from the list.
removeWhere(Test<E> test) → void
Removes all objects from this list that satisfy test.
replaceRange(int start, int end, Iterable<E> replacement) → void
Replaces a range of elements with the elements of replacements.
inherited
retainWhere(Test<E> test) → void
Removes all objects from this list that fail to satisfy test.
setAll(int index, Iterable<E> iterable) → void
Overwrites elements with the objects of iterable.
inherited
setLabel(E element, String? label) → void
Sets the label associated with element.
setLabelAt(int index, String? label) → void
Sets the label associated with the element at index.
setRange(int start, int end, Iterable<E> iterable, [int skipCount = 0]) → void
Writes some elements of iterable into a range of this list.
inherited
shuffle([Random? random]) → void
Shuffles the elements of this list randomly.
inherited
singleWhere(Test<E> test, {OrElse<E>? orElse}) → E
The single element that satisfies test.
inherited
skip(int count, {bool labeled = false, bool? growable}) Iterable<E>
Creates an Iterable that provides all but the first count elements.
skipWhile(Test<E> test, {bool labeled = false, bool? growable}) Iterable<E>
Creates an Iterable that skips leading elements while test is satisfied.
sort([Compare<E>? compare]) → void
Sorts this list according to the order specified by the compare function.
inherited
sublist(int start, [int? end]) LabeledList<E>
Returns a new list containing the elements between start and end.
take(int count, {bool labeled = false, bool? growable}) Iterable<E>
Creates a lazy iterable of the count first elements of this iterable.
takeWhile(Test<E> test, {bool labeled = false, bool? growable}) Iterable<E>
Creates a lazy iterable of the leading elements satisfying test.
toList({bool growable = true}) List<E>
Creates a List containing the elements of this Iterable.
inherited
toMap() Map<String, E>
Returns the list as a map, with the labels as keys, and the elements as values.
toSet() Set<E>
Creates a Set containing the same elements as this iterable.
inherited
toString() String
A string representation of this object.
inherited
where(Test<E> test, {bool labeled = false, bool? growable}) Iterable<E>
Creates a new lazy Iterable with all elements that satisfy the predicate test.
whereType<T>({bool labeled = false, bool? growable}) Iterable<T>
Creates a new lazy Iterable with all elements that have type T.

Operators

operator +(List<E> other) List<E>
Returns the concatenation of this list and other.
inherited
operator ==(Object other) bool
The equality operator.
inherited
operator [](Object identifier) → E
Returns the value associated with identifier.
operator []=(Object identifier, E value) → void
Sets the value assocaited with identifier to value.

Static Methods

castFrom<S, T>(List<S> source, {Iterable<String?>? labels, bool growable = true}) LabeledList<T>
Adapts source to be a LabeledList<T>.
override