Cons<A> final
final class Cons<A> extends IList<A>The non-empty case of IList, containing a head element and a tail.
Inheritance
Object → IList<A> → Cons<A>
Available Extensions
- IListConcurrencyOps<A>
- IListEitherOps<A, B>
- IListIOOps<A>
- IListNestedOps<A>
- IListNullableOps<A>
- IListOptionOps<A>
- IListResourceOps<A>
- IListTuple2Ops<T1, T2>
- IListTuple2UnzipOps<A, B>
- IListTuple3Ops<T1, T2, T3>
- IListTuple3UnzipOps<A, B, C>
- IListTuple4Ops<T1, T2, T3, T4>
- IListTuple5Ops<T1, T2, T3, T4, T5>
- IOIListOps<A>
- ResourceIListOps<A>
- RibsIterableTuple2Ops<A, B>
- RIterableDoubleOps
- RIterableIntOps
- RIterableNested2Ops<A>
- RIterableTuple2Ops<A, B>
Constructors
Cons()
Cons(A head, IList<A> next)Implementation
Cons(this.head, this.next);Properties
hashCode no setter inherited
int get hashCodeThe hash code for this object.
A hash code is a single integer which represents the state of the object that affects operator == comparisons.
All objects have hash codes. The default hash code implemented by Object represents only the identity of the object, the same way as the default operator == implementation only considers objects equal if they are identical (see identityHashCode).
If operator == is overridden to use the object state instead, the hash code must also be changed to represent that state, otherwise the object cannot be used in hash based data structures like the default Set and Map implementations.
Hash codes must be the same for objects that are equal to each other according to operator ==. The hash code of an object should only change if the object changes in a way that affects equality. There are no further requirements for the hash codes. They need not be consistent between executions of the same program and there are no distribution guarantees.
Objects that are not equal are allowed to have the same hash code. It is even technically allowed that all instances have the same hash code, but if clashes happen too often, it may reduce the efficiency of hash-based data structures like HashSet or HashMap.
If a subclass overrides hashCode, it should override the operator == operator as well to maintain consistency.
Inherited from IList.
Implementation
@override
int get hashCode => MurmurHash3.listHash(this);head final
final A headReturns the first element of this collection, or throws if it is empty.
Implementation
@override
final A head;headOption no setter override
Option<A> get headOptionReturns the first element of this collection as a Some if non-empty. If this collction is empty, None is returned.
Implementation
@override
Option<A> get headOption => Some(head);init no setter inherited
IList<A> get initReturns all elements from this collection except the last. If this collection is empty, an empty collection is returned.
Inherited from IList.
Implementation
@override
IList<A> get init => super.init.toIList();inits no setter inherited
Returns an iterator of all potential tails of this collection, starting with the entire collection and ending with an empty one.
Inherited from IList.
Implementation
@override
RIterator<IList<A>> get inits => super.inits.map((i) => i.toIList());isEmpty no setter inherited
bool get isEmptyWhether this collection contains no elements.
Inherited from IList.
Implementation
@override
bool get isEmpty => this is Nil;isNotEmpty no setter inherited
bool get isNotEmptyWhether this collection contains at least one element.
Inherited from RIterableOnce.
Implementation
bool get isNotEmpty => !isEmpty;isTraversableAgain no setter inherited
bool get isTraversableAgainWhether this collection can be traversed more than once.
Always false for a bare RIterableOnce; overridden to true by RIterable and its subtypes.
Inherited from RIterableOnce.
Implementation
bool get isTraversableAgain => false;iterator no setter inherited
RIterator<A> get iteratorReturns an RIterator over the elements of this collection.
Inherited from IList.
Implementation
@override
RIterator<A> get iterator => _IListIterator(this);knownSize no setter inherited
int get knownSizeReturns the number of elements in this collection, if that number is already known. If not, -1 is returned.
Inherited from RIterableOnce.
Implementation
int get knownSize => -1;last no setter inherited
A get lastReturns the last element of this collection, or throws if it is empty.
Inherited from RIterable.
Implementation
A get last {
final it = iterator;
var lst = it.next();
while (it.hasNext) {
lst = it.next();
}
return lst;
}lastOption no setter inherited
Option<A> get lastOptionReturns the last element of this collection as a Some, or None if this collection is empty.
Inherited from RIterable.
Implementation
Option<A> get lastOption {
if (isEmpty) {
return none();
} else {
final it = iterator;
var last = it.next();
while (it.hasNext) {
last = it.next();
}
return Some(last);
}
}length no setter inherited
int get lengthThe number of elements in this sequence.
Inherited from IList.
Implementation
@override
int get length {
var these = this;
var len = 0;
while (!these.isEmpty) {
len += 1;
these = these.tail;
}
return len;
}nonEmpty no setter inherited
bool get nonEmptyWhether this collection contains at least one element.
Inherited from RIterableOnce.
Implementation
bool get nonEmpty => !isEmpty;runtimeType no setter inherited
Type get runtimeTypeA representation of the runtime type of the object.
Inherited from Object.
Implementation
external Type get runtimeType;size no setter inherited
int get sizeReturns the number of elements in this collection.
Inherited from RSeq.
Implementation
@override
int get size => length;tail no setter override
IList<A> get tailReturns a new collection with the first element removed. If this collection is empty, an empty collection is returned.
Implementation
@override
IList<A> get tail => next;tails no setter inherited
Returns an iterator of all potential tails of this collection, starting with the entire collection and ending with an empty one.
Inherited from IList.
Implementation
@override
RIterator<IList<A>> get tails => RIterator.iterate(
this,
(c) => c.tail,
).takeWhile((a) => a.nonEmpty).concat(RIterator.single(Nil<A>()));Methods
appended() inherited
IList<A> appended(A elem)Returns a new Seq, with the given elem added to the end.
Inherited from IList.
Implementation
@override
IList<A> appended(A elem) {
final b = builder<A>();
b.addAll(this);
b.addOne(elem);
return b.toIList();
}appendedAll() inherited
IList<A> appendedAll(RIterableOnce<A> suffix)Returns a new Seq, with elems added to the end.
Inherited from IList.
Implementation
@override
IList<A> appendedAll(RIterableOnce<A> suffix) => switch (suffix) {
final IList<A> xs => xs.prependedAll(this),
_ => builder<A>().addAll(this).addAll(suffix).toIList(),
};canEqual() inherited
bool canEqual(Object other)Inherited from RSeq.
Implementation
bool canEqual(Object other) => true;collect() inherited
Returns a new collection by applying f to each element an only keeping results of type Some.
Inherited from IList.
Implementation
@override
IList<B> collect<B>(Function1<A, Option<B>> f) {
final nilB = Nil<B>();
if (isEmpty) {
return nilB;
} else {
var rest = this;
Cons<B>? h;
// Special case for first element
while (h == null) {
f(rest.head).foreach((x) => h = Cons(x, nilB));
rest = rest.tail;
if (rest.isEmpty) return h ?? nilB;
}
var t = h;
// Remaining elements
while (rest.nonEmpty) {
f(rest.head).foreach((x) {
final nx = Cons(x, nilB);
t!.next = nx;
t = nx;
});
rest = rest.tail;
}
return h ?? nilB;
}
}collectFirst() inherited
Applies f to each element of this collection, returning the first element that results in a Some, if any.
Inherited from RIterableOnce.
Implementation
Option<B> collectFirst<B>(Function1<A, Option<B>> f) {
final it = iterator;
while (it.hasNext) {
final x = f(it.next());
if (x.isDefined) return x;
}
return none();
}combinations() inherited
Returns an Iterator that will produce all combinations of elements from this sequence of size n in order.
Given the list [1, 2, 2, 2], combinations of size 2 would result in [1, 2] and [2, 2]. Note that [2, 1] would not be included since combinations are taken from element in order.
Also note from the example above, [1, 2] would only be included once even though there are technically 3 ways to generate a combination of [1, 2], only one will be included in the result since the other 2 are duplicates.
Inherited from IList.
Implementation
@override
RIterator<IList<A>> combinations(int n) => super.combinations(n).map((a) => a.toIList());concat() inherited
IList<A> concat(RIterableOnce<A> suffix)Returns a copy of this collection, with elems added to the end.
Inherited from IList.
Implementation
@override
IList<A> concat(RIterableOnce<A> suffix) => appendedAll(suffix);contains() inherited
bool contains(A elem)Returns true, if any element of this collection equals elem.
Inherited from IList.
Implementation
@override
bool contains(A elem) {
var these = this;
while (!these.isEmpty) {
if (these.head == elem) return true;
these = these.tail;
}
return false;
}containsSlice() inherited
bool containsSlice(RSeq<A> that)Returns true if that is contained in this collection, in order.
Inherited from RSeq.
Implementation
bool containsSlice(RSeq<A> that) => indexOfSlice(that).isDefined;copyToArray() inherited
int copyToArray(Array<A> xs, [int start = 0, int? n])Copies elements into xs starting at start, writing at most n elements (or all remaining capacity when n is omitted).
Returns the number of elements actually copied.
Inherited from RIterableOnce.
Implementation
int copyToArray(Array<A> xs, [int start = 0, int? n]) {
final it = iterator;
final end = start + min(n ?? Integer.maxValue, xs.length - start);
var i = start;
while (i < end && it.hasNext) {
xs[i] = it.next();
i += 1;
}
return i - start;
}corresponds() inherited
bool corresponds<B>(RSeq<B> that, bool Function(A, B) p)Returns true if this collection has the same size as that and each corresponding element from this and that satisfies the given predicate p.
Inherited from RSeq.
Implementation
@override
bool corresponds<B>(RSeq<B> that, Function2<A, B, bool> p) {
final i = iterator;
final j = that.iterator;
while (i.hasNext && j.hasNext) {
if (!p(i.next(), j.next())) return false;
}
return !i.hasNext && !j.hasNext;
}count() inherited
int count(bool Function(A) p)Return the number of elements in this collection that satisfy the given predicate.
Inherited from RIterableOnce.
Implementation
int count(Function1<A, bool> p) {
var res = 0;
final it = iterator;
while (it.hasNext) {
if (p(it.next())) res += 1;
}
return res;
}deleteFirst() inherited
Option<Record> deleteFirst(bool Function(A) p)Removes the first element satisfying p and returns it paired with the remaining list. Returns None if no element matches.
Inherited from IList.
Implementation
Option<(A, IList<A>)> deleteFirst(Function1<A, bool> p) {
if (isEmpty) {
return none();
} else {
final b = builder<A>();
A? found;
var these = this;
while (these.nonEmpty && found == null) {
final hd = these.head;
if (p(hd)) {
found = hd;
b.addAll(these.tail);
} else {
b.addOne(hd);
}
these = these.tail;
}
if (found != null) {
return Some((found, b.toIList()));
} else {
return none();
}
}
}diff() inherited
Returns a new collection with the difference of this and that, i.e. all elements that appear in only this collection.
Inherited from IList.
Implementation
@override
IList<A> diff(RSeq<A> that) => super.diff(that).toIList();distinct() inherited
IList<A> distinct()Returns a new collection where every element is distinct according to equality.
Inherited from IList.
Implementation
@override
IList<A> distinct() => super.distinct().toIList();distinctBy() inherited
IList<A> distinctBy<B>(B Function(A) f)Returns a new collection where every element is distinct according to the application of f to each element.
Inherited from IList.
Implementation
@override
IList<A> distinctBy<B>(Function1<A, B> f) => super.distinctBy(f).toIList();drop() inherited
IList<A> drop(int n)Returns a new collection with the first n elements removed.
Inherited from IList.
Implementation
@override
IList<A> drop(int n) {
var l = this;
var i = n;
while (l.nonEmpty && i > 0) {
l = l.tail;
i -= 1;
}
return l;
}dropRight() inherited
IList<A> dropRight(int n)Return a new collection with the last n elements removed.
Inherited from IList.
Implementation
@override
IList<A> dropRight(int n) {
if (isEmpty) {
return this;
} else {
final lead = iterator.drop(n);
final it = iterator;
final res = builder<A>();
while (lead.hasNext) {
res.addOne(it.next());
lead.next();
}
return res.toIList();
}
}dropWhile() inherited
IList<A> dropWhile(bool Function(A) p)Returns a new collection with leading elements satisfying p removed.
Inherited from IList.
Implementation
@override
IList<A> dropWhile(Function1<A, bool> p) {
var s = this;
while (s.nonEmpty && p(s.head)) {
s = s.tail;
}
return s;
}endsWith() inherited
bool endsWith(RIterable<A> that)Returns true if the end of this collection has the same elements in order as that. Otherwise, false is returned.
Inherited from RSeq.
Implementation
bool endsWith(RIterable<A> that) {
if (that.isEmpty) {
return true;
} else {
final i = iterator.drop(length - that.size);
final j = that.iterator;
while (i.hasNext && j.hasNext) {
if (i.next() != j.next()) return false;
}
return !j.hasNext;
}
}exists() inherited
bool exists(bool Function(A) p)Returns true if any element of this collection satisfies the given predicate, false if no elements satisfy it.
Inherited from IList.
Implementation
@override
bool exists(Function1<A, bool> p) {
var these = this;
while (!these.isEmpty) {
if (p(these.head)) return true;
these = these.tail;
}
return false;
}filter() inherited
IList<A> filter(bool Function(A) p)Returns a new collection containing only elements that satisfy p.
Inherited from IList.
Implementation
@override
IList<A> filter(Function1<A, bool> p) => _filterCommon(p, false);filterNot() inherited
IList<A> filterNot(bool Function(A) p)Returns a new collection containing only elements that do not satisfy p.
Inherited from IList.
Implementation
@override
IList<A> filterNot(Function1<A, bool> p) => _filterCommon(p, true);find() inherited
Option<A> find(bool Function(A) p)Returns the first element from this collection that satisfies the given predicate p. If no element satisfies p, None is returned.
Inherited from IList.
Implementation
@override
Option<A> find(Function1<A, bool> p) {
var these = this;
while (!these.isEmpty) {
if (p(these.head)) return Some(these.head);
these = these.tail;
}
return none();
}findLast() inherited
Option<A> findLast(bool Function(A) p)Returns the last element satisfying p as Some, or None if none.
Inherited from RSeq.
Implementation
Option<A> findLast(Function1<A, bool> p) {
final it = reverseIterator();
while (it.hasNext) {
final elem = it.next();
if (p(elem)) return Some(elem);
}
return none();
}flatMap() inherited
IList<B> flatMap<B>(RIterableOnce<B> Function(A) f)Returns a new collection by applying f to each element and concatenating the results.
Inherited from IList.
Implementation
@override
IList<B> flatMap<B>(Function1<A, RIterableOnce<B>> f) {
var rest = this;
Cons<B>? h;
Cons<B>? t;
final nilB = Nil<B>();
while (rest.nonEmpty) {
final it = f(rest.head).iterator;
while (it.hasNext) {
final nx = Cons(it.next(), nilB);
if (t == null) {
h = nx;
} else {
t.next = nx;
}
t = nx;
}
rest = rest.tail;
}
return h ?? nilB;
}fold() inherited
A fold(A init, A Function(A, A) op)Alias for foldLeft with a same-type accumulator.
Inherited from RIterable.
Implementation
A fold(A init, Function2<A, A, A> op) => foldLeft(init, op);foldLeft() inherited
B foldLeft<B>(B z, B Function(B, A) op)Returns a summary value by applying op to all elements of this collection, moving from left to right. The fold uses a seed value of z.
Inherited from IList.
Implementation
@override
B foldLeft<B>(B z, Function2<B, A, B> op) {
var res = z;
var current = this;
while (current is Cons) {
res = op(res, current.head);
current = (current as Cons<A>).next;
}
return res;
}foldRight() inherited
B foldRight<B>(B z, B Function(A, B) op)Returns a summary value by applying op to all elements of this collection, moving from right to left. The fold uses a seed value of z.
Inherited from IList.
Implementation
@override
B foldRight<B>(B z, Function2<A, B, B> op) {
var acc = z;
var these = this;
while (these.nonEmpty) {
acc = op(these.head, acc);
these = these.tail;
}
return acc;
}forall() inherited
bool forall(bool Function(A) p)Returns true if all elements of this collection satisfy the given predicate, false if any elements do not.
Inherited from IList.
Implementation
@override
bool forall(Function1<A, bool> p) {
var these = this;
while (!these.isEmpty) {
if (!p(these.head)) return false;
these = these.tail;
}
return true;
}foreach() inherited
void foreach<U>(U Function(A) f)Applies f to each element of this collection, discarding any resulting values.
Inherited from RIterableOnce.
Implementation
void foreach<U>(Function1<A, U> f) {
final it = iterator;
while (it.hasNext) {
f(it.next());
}
}groupBy() inherited
Partitions all elements of this collection by applying f to each element and accumulating duplicate keys in the returned IMap.
Inherited from IList.
Implementation
@override
IMap<K, IList<A>> groupBy<K>(Function1<A, K> f) => super.groupBy(f).mapValues((a) => a.toIList());grouped() inherited
Returns a new iterator where each element is a collection of size elements from the original collection. The last element may contain less than size elements.
Inherited from IList.
Implementation
@override
RIterator<IList<A>> grouped(int size) => super.grouped(size).map((a) => a.toIList());groupMap() inherited
Creates a new map by generating a key-value pair for each elements of this collection using key and f. Any elements that generate the same key will have the resulting values accumulated in the returned map.
Inherited from IList.
Implementation
@override
IMap<K, IList<B>> groupMap<K, B>(Function1<A, K> key, Function1<A, B> f) =>
super.groupMap(key, f).mapValues((a) => a.toIList());groupMapReduce() inherited
IMap<K, B> groupMapReduce<K, B>(
K Function(A) key,
B Function(A) f,
B Function(B, B) reduce,
)Partitions all elements of this collection by applying key to each element. Additionally f is applied to each element to generate a value. If multiple values are generating for the same key, those values will be combined using reduce.
Inherited from RIterable.
Implementation
IMap<K, B> groupMapReduce<K, B>(
Function1<A, K> key,
Function1<A, B> f,
Function2<B, B, B> reduce,
) {
final m = <K, B>{};
foreach((elem) {
m.update(key(elem), (b) => reduce(b, f(elem)), ifAbsent: () => f(elem));
});
return IMap.fromDart(m);
}indexOf() inherited
Option<int> indexOf(A elem, [int from = 0])Returns the first index, if any, where the element at that index equals elem. If no index contains elem, None is returned.
Inherited from RSeq.
Implementation
Option<int> indexOf(A elem, [int from = 0]) => indexWhere((a) => a == elem, from);indexOfSlice() inherited
Finds the first index in this collection where the next sequence of elements is equal to that. If that cannot be found in this collection, None is returned.
Inherited from RSeq.
Implementation
Option<int> indexOfSlice(RSeq<A> that, [int from = 0]) {
if (that.isEmpty && from == 0) {
return const Some(0);
} else {
final l = knownSize;
final tl = that.knownSize;
if (l >= 0 && tl >= 0) {
final clippedFrom = max(0, from);
if (from > l) {
return none();
} else if (tl < 1) {
return Some(clippedFrom);
} else if (l < tl) {
return none();
} else {
return _kmpSearch(this, clippedFrom, l, that, 0, tl, true);
}
} else {
var i = from;
var s = drop(i);
while (s.nonEmpty) {
if (s.startsWith(that)) return Some(i);
i += 1;
s = s.tail;
}
return none();
}
}
}indexWhere() inherited
Option<int> indexWhere(bool Function(A) p, [int from = 0])Returns the index of the first element that satisfies the predicate p. If no element satisfies, None is returned.
Inherited from RSeq.
Implementation
Option<int> indexWhere(Function1<A, bool> p, [int from = 0]) => iterator.indexWhere(p, from);indices() inherited
Range indices()Returns a range of all indices of this sequence
Will force evaluation.
Inherited from RSeq.
Implementation
Range indices() => Range.exclusive(0, length);insertAt() inherited
IList<A> insertAt(int idx, A elem)Returns a new list with elem inserted at idx.
Throws RangeError if idx is out of [0, length].
Inherited from IList.
Implementation
IList<A> insertAt(int idx, A elem) {
if (0 <= idx && idx <= length) {
return splitAt(idx)((before, after) => before.concat(after.prepended(elem)));
} else {
throw RangeError('$idx is out of bounds (min 0, max $length)');
}
}intersect() inherited
Returns a new collection with the intersection of this and that, i.e. all elements that appear in both collections.
Inherited from IList.
Implementation
@override
IList<A> intersect(RSeq<A> that) {
if (isEmpty || that.isEmpty) {
return Nil<A>();
} else {
final occ = _occCounts(that);
final b = builder<A>();
foreach((x) {
final count = occ[x] ?? -1;
if (count > 0) {
b.addOne(x);
if (count == 1) {
occ.remove(x);
} else {
occ[x] = count - 1;
}
}
});
return b.toIList();
}
}intersperse() inherited
IList<A> intersperse(A x)Returns a new collection with sep inserted between each element.
Inherited from IList.
Implementation
@override
IList<A> intersperse(A x) => super.intersperse(x).toIList();isDefinedAt() inherited
bool isDefinedAt(int idx)Returns true if this collection has an element at the given idx.
Inherited from RSeq.
Implementation
bool isDefinedAt(int idx) => 0 <= idx && idx < size;lastIndexOf() inherited
Option<int> lastIndexOf(A elem, [int end = 2147483647])Returns the last index, if any, where the element at that index equals elem. If no index contains elem, None is returned.
Inherited from RSeq.
Implementation
Option<int> lastIndexOf(A elem, [int end = 2147483647]) => lastIndexWhere((a) => a == elem, end);lastIndexOfSlice() inherited
Finds the last index in this collection where the next sequence of elements is equal to that. If that cannot be found in this collection, None is returned.
Inherited from RSeq.
Implementation
Option<int> lastIndexOfSlice(RSeq<A> that, [int end = 2147483647]) {
final l = length;
final tl = that.length;
final clippedL = min(l - tl, end);
if (end < 0) {
return none();
} else if (tl < 1) {
return Some(clippedL);
} else if (l < tl) {
return none();
} else {
return _kmpSearch(this, 0, clippedL + tl, that, 0, tl, false);
}
}lastIndexWhere() inherited
Option<int> lastIndexWhere(bool Function(A) p, [int end = 2147483647])Returns the index of the last element that satisfies the predicate p. If no element satisfies, None is returned.
Inherited from RSeq.
Implementation
Option<int> lastIndexWhere(Function1<A, bool> p, [int end = 2147483647]) {
var i = length - 1;
final it = reverseIterator();
while (it.hasNext) {
final elem = it.next();
if (i < end && p(elem)) return Some(i);
i -= 1;
}
return none();
}lift() inherited
Option<A> lift(int ix)Returns the element at index ix as a Some. If ix is outside the range of this collection, None is returned.
Inherited from RSeq.
Implementation
Option<A> lift(int ix) => Option.when(() => isDefinedAt(ix), () => this[ix]);map() inherited
IList<B> map<B>(B Function(A) f)Returns a new collection by applying f to each element.
Inherited from IList.
Implementation
@override
IList<B> map<B>(Function1<A, B> f) {
final nilB = Nil<B>();
if (this is Nil) {
return nilB;
} else {
final h = Cons(f(head), nilB);
var t = h;
var rest = tail;
while (rest is! Nil) {
final nx = Cons(f(rest.head), nilB);
t.next = nx;
t = nx;
rest = rest.tail;
}
return h;
}
}maxByOption() inherited
Finds the largest element in this collection by applying f to each element and using the given Order to find the greatest.
If this collection is empty, None is returned.
Inherited from RIterableOnce.
Implementation
Option<A> maxByOption<B>(Function1<A, B> f, Order<B> order) => _minMaxByOption(f, order.max);maxOption() inherited
Finds the largest element in this collection according to the given Order.
If this collection is empty, None is returned.
Inherited from RIterableOnce.
Implementation
Option<A> maxOption(Order<A> order) => switch (knownSize) {
0 => none(),
_ => _reduceOptionIterator(iterator, order.max),
};minByOption() inherited
Finds the smallest element in this collection by applying f to each element and using the given Order to find the greatest.
If this collection is empty, None is returned.
Inherited from RIterableOnce.
Implementation
Option<A> minByOption<B>(Function1<A, B> f, Order<B> order) => _minMaxByOption(f, order.min);minOption() inherited
Finds the largest element in this collection according to the given Order.
If this collection is empty, None is returned.
Inherited from RIterableOnce.
Implementation
Option<A> minOption(Order<A> order) => switch (knownSize) {
0 => none(),
_ => _reduceOptionIterator(iterator, order.min),
};mkString() inherited
String mkString({String? start, String? sep, String? end})Returns a String by using each elements toString(), adding sep between each element. If start is defined, it will be prepended to the resulting string. If end is defined, it will be appended to the resulting string.
Inherited from RIterableOnce.
Implementation
String mkString({String? start, String? sep, String? end}) {
if (knownSize == 0) {
return '${start ?? ""}${end ?? ""}';
} else {
return _mkStringImpl(StringBuffer(), start ?? '', sep ?? '', end ?? '');
}
}noSuchMethod() inherited
dynamic noSuchMethod(Invocation invocation)Invoked when a nonexistent method or property is accessed.
A dynamic member invocation can attempt to call a member which doesn't exist on the receiving object. Example:
dynamic object = 1;
object.add(42); // Statically allowed, run-time errorThis invalid code will invoke the noSuchMethod method of the integer 1 with an Invocation representing the .add(42) call and arguments (which then throws).
Classes can override noSuchMethod to provide custom behavior for such invalid dynamic invocations.
A class with a non-default noSuchMethod invocation can also omit implementations for members of its interface. Example:
class MockList<T> implements List<T> {
noSuchMethod(Invocation invocation) {
log(invocation);
super.noSuchMethod(invocation); // Will throw.
}
}
void main() {
MockList().add(42);
}This code has no compile-time warnings or errors even though the MockList class has no concrete implementation of any of the List interface methods. Calls to List methods are forwarded to noSuchMethod, so this code will log an invocation similar to Invocation.method(#add, [42]) and then throw.
If a value is returned from noSuchMethod, it becomes the result of the original invocation. If the value is not of a type that can be returned by the original invocation, a type error occurs at the invocation.
The default behavior is to throw a NoSuchMethodError.
Inherited from Object.
Implementation
@pragma("vm:entry-point")
@pragma("wasm:entry-point")
external dynamic noSuchMethod(Invocation invocation);padTo() inherited
IList<A> padTo(int len, A elem)Returns a new collection with a length of at least len.
If this collection is shorter than len, the returned collection will have size len and elem will be used for each new element needed to reach that size.
If this collection is already at least len in size, this collection will be returned.
Inherited from IList.
Implementation
@override
IList<A> padTo(int len, A elem) {
if (len > size) {
final b = builder<A>();
var diff = len - size;
b.addAll(this);
while (diff > 0) {
b.addOne(elem);
diff -= 1;
}
return b.toIList();
} else {
return this;
}
}partition() inherited
Record partition(bool Function(A) p)Returns 2 collections as a tuple where the first tuple element will be a collection of elements that satisfy the given predicate p. The second item of the returned tuple will be elements that do not satisfy p.
Inherited from IList.
Implementation
@override
(IList<A>, IList<A>) partition(Function1<A, bool> p) {
final yes = builder<A>();
final no = builder<A>();
var these = this;
while (these.nonEmpty) {
if (p(these.head)) {
yes.addOne(these.head);
} else {
no.addOne(these.head);
}
these = these.tail;
}
return (yes.toIList(), no.toIList());
}partitionMap() inherited
Record partitionMap<A1, A2>(Either<A1, A2> Function(A) f)Applies f to each element of this collection and returns a separate collection for all applications resulting in a Left and Right respectively.
Inherited from IList.
Implementation
@override
(IList<A1>, IList<A2>) partitionMap<A1, A2>(Function1<A, Either<A1, A2>> f) {
final l = builder<A1>();
final r = builder<A2>();
var these = this;
while (these.nonEmpty) {
f(these.head).fold(
(x1) => l.addOne(x1),
(x2) => r.addOne(x2),
);
these = these.tail;
}
return (l.toIList(), r.toIList());
}patch() inherited
IList<A> patch(int from, RIterableOnce<A> other, int replaced)Returns a new collection with replaced elements starting at from replaced by the elements of other.
Inherited from IList.
Implementation
@override
IList<A> patch(int from, RIterableOnce<A> other, int replaced) {
final b = builder<A>();
var i = 0;
final it = iterator;
while (i < from && it.hasNext) {
b.addOne(it.next());
i += 1;
}
b.addAll(other);
i = replaced;
while (i > 0 && it.hasNext) {
it.next();
i -= 1;
}
while (it.hasNext) {
b.addOne(it.next());
}
return b.toIList();
}permutations() inherited
Returns an Iterator that will emit all possible permutations of the elements in this collection.
Note that only distinct permutations are emitted. Given the example [1, 2, 2, 2] the permutations will only include [1, 2, 2, 2] once, even though there are 3 different way to generate that permutation.
Inherited from IList.
Implementation
@override
RIterator<IList<A>> permutations() => super.permutations().map((a) => a.toIList());prepended() inherited
IList<A> prepended(A elem)Returns a new collection with elem added to the beginning.
Inherited from IList.
Implementation
@override
IList<A> prepended(A elem) => Cons(elem, this);prependedAll() inherited
IList<A> prependedAll(RIterableOnce<A> prefix)Returns a new collection with all elems added to the beginning.
Inherited from IList.
Implementation
@override
IList<A> prependedAll(RIterableOnce<A> prefix) {
if (prefix is IList<A>) {
if (isEmpty) {
return prefix;
} else if (prefix.isEmpty) {
return this;
} else {
final result = Cons(prefix.head, this);
var curr = result;
var that = prefix.tail;
while (!that.isEmpty) {
final temp = Cons(that.head, this);
curr.next = temp;
curr = temp;
that = that.tail;
}
return result;
}
} else if (prefix.knownSize == 0) {
return this;
} else if (prefix is ListBuffer<A> && isEmpty) {
return prefix.toIList();
} else {
final iter = prefix.iterator;
if (iter.hasNext) {
final result = Cons(iter.next(), this);
var curr = result;
while (iter.hasNext) {
final temp = Cons(iter.next(), this);
curr.next = temp;
curr = temp;
}
return result;
} else {
return this;
}
}
}reduce() inherited
A reduce(A Function(A, A) op)Reduces this collection to a single value by applying op left to right.
Throws if the collection is empty.
Inherited from RIterableOnce.
Implementation
A reduce(Function2<A, A, A> op) => reduceLeft(op);reduceLeft() inherited
A reduceLeft(A Function(A, A) op)Reduces from left to right. Throws if empty.
Inherited from RIterableOnce.
Implementation
A reduceLeft(Function2<A, A, A> op) => switch (this) {
final IndexedSeq<A> seq when seq.length > 0 => _foldl(seq, 1, seq[0], op),
_ when knownSize == 0 => throw UnsupportedError('empty.reduceLeft'),
_ => _reduceLeftIterator(() => throw UnsupportedError('empty.reduceLeft'), op),
};reduceLeftOption() inherited
Option<A> reduceLeftOption(A Function(A, A) op)Returns a summary values of all elements of this collection by applying f to each element, moving left to right.
If this collection is empty, None will be returned.
Inherited from RIterableOnce.
Implementation
Option<A> reduceLeftOption(Function2<A, A, A> op) => switch (knownSize) {
0 => none(),
_ => _reduceOptionIterator(iterator, op),
};reduceOption() inherited
Option<A> reduceOption(A Function(A, A) op)Returns a summary values of all elements of this collection by applying f to each element, moving left to right.
If this collection is empty, None will be returned.
Inherited from RIterableOnce.
Implementation
Option<A> reduceOption(Function2<A, A, A> op) => reduceLeftOption(op);reduceRight() inherited
A reduceRight(A Function(A, A) op)Reduces from right to left. Throws if empty.
Inherited from RIterableOnce.
Implementation
A reduceRight(Function2<A, A, A> op) => switch (this) {
final IndexedSeq<A> seq when seq.length > 0 => _foldr(seq, op),
_ when knownSize == 0 => throw UnsupportedError('empty.reduceLeft'),
_ => _reversed().reduceLeft((x, y) => op(y, x)),
};reduceRightOption() inherited
Option<A> reduceRightOption(A Function(A, A) op)Returns a summary values of all elements of this collection by applying f to each element, moving right to left.
If this collection is empty, None will be returned.
Inherited from RIterableOnce.
Implementation
Option<A> reduceRightOption(Function2<A, A, A> op) => switch (knownSize) {
-1 => _reduceOptionIterator(_reversed().iterator, (x, y) => op(y, x)),
0 => none(),
_ => Some(reduceRight(op)),
};removeAt() inherited
IList<A> removeAt(int idx)Returns a new collection with the element at idx removed.
Throws RangeError if idx is out of bounds.
Inherited from IList.
Implementation
@override
IList<A> removeAt(int idx) => super.removeAt(idx).toIList();removeFirst() inherited
IList<A> removeFirst(bool Function(A) p)Returns a new list with the first element satisfying p removed.
Returns this list unchanged if no element matches.
Inherited from IList.
Implementation
IList<A> removeFirst(Function1<A, bool> p) => indexWhere(p).fold(() => this, removeAt);reverse() inherited
IList<A> reverse()Returns a new collection with the order of the elements reversed.
Inherited from IList.
Implementation
@override
IList<A> reverse() {
IList<A> result = Nil<A>();
var these = this;
while (!these.isEmpty) {
result = Cons(these.head, result);
these = these.tail;
}
return result;
}reverseIterator() inherited
RIterator<A> reverseIterator()Returns an iterator that will emit all elements in this collection, in reverse order.
Inherited from RSeq.
Implementation
RIterator<A> reverseIterator() => reverse().iterator;sameElements() inherited
bool sameElements(RIterable<A> that)Returns true if this collection has the same elements, in the same order, as that.
Inherited from RSeq.
Implementation
bool sameElements(RIterable<A> that) {
final thisKnownSize = knownSize;
final thatKnownSize = that.knownSize;
final knownDifference =
thisKnownSize != -1 && thatKnownSize != -1 && thisKnownSize != thatKnownSize;
return !knownDifference && iterator.sameElements(that);
}scan() inherited
IList<B> scan<B>(B z, B Function(B, A) op)Alias for scanLeft.
Inherited from IList.
Implementation
@override
IList<B> scan<B>(B z, Function2<B, A, B> op) => scanLeft(z, op);scanLeft() inherited
IList<B> scanLeft<B>(B z, B Function(B, A) op)Returns a new collection of running totals starting with z.
The first element of the result is z; each subsequent element is the result of applying op to the previous total and the next element.
Inherited from IList.
Implementation
@override
IList<B> scanLeft<B>(B z, Function2<B, A, B> op) => super.scanLeft(z, op).toIList();scanRight() inherited
IList<B> scanRight<B>(B z, B Function(A, B) op)Returns a new collection of running totals starting with z, traversing from right to left.
Inherited from IList.
Implementation
@override
IList<B> scanRight<B>(B z, Function2<A, B, B> op) => super.scanRight(z, op).toIList();segmentLength() inherited
int segmentLength(bool Function(A) p, [int from = 0])Returns the length of the longest prefix starting at from where every element satisfies p.
Inherited from RSeq.
Implementation
int segmentLength(Function1<A, bool> p, [int from = 0]) {
var i = 0;
final it = iterator.drop(from);
while (it.hasNext && p(it.next())) {
i += 1;
}
return i;
}slice() inherited
IList<A> slice(int from, int until)Returns a new collection containing elements in the range [from, until).
Inherited from IList.
Implementation
@override
IList<A> slice(int from, int until) {
final lo = max(from, 0);
if (until <= lo || isEmpty) {
return Nil<A>();
} else {
return drop(lo).take(until - lo);
}
}sliding() inherited
Returns an iterator where elements are fixed size chunks of size n of the original collection. Each chunk is calculated by sliding a 'window' of size n over the original collection, moving the window step elements at a time.
Inherited from IList.
Implementation
@override
RIterator<IList<A>> sliding(int size, [int step = 1]) =>
super.sliding(size, step).map((a) => a.toIList());sortBy() inherited
Returns a new collection that is sorted according to order after applying f to each element in this collection.
Inherited from IList.
Implementation
@override
IList<A> sortBy<B>(Order<B> order, Function1<A, B> f) => super.sortBy(order, f).toIList();sorted() inherited
Returns a new collection that is sorted according to order.
Inherited from IList.
Implementation
@override
IList<A> sorted(Order<A> order) => super.sorted(order).toIList();sortWith() inherited
IList<A> sortWith(bool Function(A, A) lt)Returns a new collection sorted using the provided function lt which is used to determine if one element is less than the other.
Inherited from IList.
Implementation
@override
IList<A> sortWith(Function2<A, A, bool> lt) => super.sortWith(lt).toIList();span() inherited
Record span(bool Function(A) p)Returns two collections: elements before and starting from the first element that does not satisfy p.
Inherited from IList.
Implementation
@override
(IList<A>, IList<A>) span(Function1<A, bool> p) {
final b = builder<A>();
var these = this;
while (!these.isEmpty && p(these.head)) {
b.addOne(these.head);
these = these.tail;
}
return (b.toIList(), these);
}splitAt() inherited
Record splitAt(int n)Returns two collections: the first n elements and the remainder.
Inherited from IList.
Implementation
@override
(IList<A>, IList<A>) splitAt(int n) {
final b = builder<A>();
var i = 0;
var these = this;
while (!these.isEmpty && i < n) {
i += 1;
b.addOne(these.head);
these = these.tail;
}
return (b.toIList(), these);
}startsWith() inherited
bool startsWith(RIterableOnce<A> that, [int offset = 0])Returns true if the beginning of this collection corresponds with that.
Inherited from RSeq.
Implementation
bool startsWith(RIterableOnce<A> that, [int offset = 0]) {
final i = iterator.drop(offset);
final j = that.iterator;
while (j.hasNext && i.hasNext) {
if (i.next() != j.next()) return false;
}
return !j.hasNext;
}take() inherited
IList<A> take(int n)Returns a new collection containing only the first n elements.
Inherited from IList.
Implementation
@override
IList<A> take(int n) {
final nilA = Nil<A>();
if (isEmpty || n <= 0) return nilA;
final h = Cons(head, nilA);
var t = h;
var rest = tail;
var i = 1;
if (rest.isEmpty) return this;
while (i < n) {
if (rest.isEmpty) return this;
i += 1;
final nx = Cons(rest.head, nilA);
t.next = nx;
t = nx;
rest = rest.tail;
}
return h;
}takeRight() inherited
IList<A> takeRight(int n)Returns a new collection with the last n elements of this collection. If n is greater than the size of this collection, the original collection is returned.
Inherited from IList.
Implementation
@override
IList<A> takeRight(int n) {
if (isEmpty || n <= 0) return Nil<A>();
var lead = drop(n);
var lag = this;
while (lead.nonEmpty) {
lead = lead.tail;
lag = lag.tail;
}
return lag;
}takeWhile() inherited
IList<A> takeWhile(bool Function(A) p)Returns a new collection of leading elements that satisfy p.
Inherited from IList.
Implementation
@override
IList<A> takeWhile(Function1<A, bool> p) {
final b = builder<A>();
var these = this;
while (!these.isEmpty && p(these.head)) {
b.addOne(these.head);
these = these.tail;
}
return b.toIList();
}tapEach() inherited
IList<A> tapEach<U>(U Function(A) f)Applies f to each element in this collection, discarding any results and returns this collection.
Inherited from IList.
Implementation
@override
IList<A> tapEach<U>(Function1<A, U> f) {
foreach(f);
return this;
}toIList() inherited
IList<A> toIList()Returns an IList with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
IList<A> toIList() => IList.from(this);toIndexedSeq() inherited
IndexedSeq<A> toIndexedSeq()Returns an IndexedSeq with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
IndexedSeq<A> toIndexedSeq() => IndexedSeq.from(this);toISet() inherited
ISet<A> toISet()Returns an ISet with the same elements as this collection, duplicates removed.
Inherited from RIterableOnce.
Implementation
ISet<A> toISet() => ISet.from(this);toIVector() inherited
IVector<A> toIVector()Returns an IVector with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
IVector<A> toIVector() => IVector.from(this);toList() inherited
List<A> toList({bool growable = true})Returns a new List with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
List<A> toList({bool growable = true}) {
if (growable) {
final it = iterator;
final res = List<A>.empty(growable: true);
while (it.hasNext) {
res.add(it.next());
}
return res;
} else {
final it = iterator;
return List.generate(size, (_) => it.next());
}
}toNel() inherited
Option<NonEmptyIList<A>> toNel()Converts this list to a NonEmptyIList, returning None if it is empty.
Inherited from IList.
Implementation
Option<NonEmptyIList<A>> toNel() => NonEmptyIList.from(this);toSeq() inherited
RSeq<A> toSeq()Returns a RSeq with the same elements as this collection.
Inherited from IList.
Implementation
@override
RSeq<A> toSeq() => this;toString() inherited
String toString()A string representation of this object.
Some classes have a default textual representation, often paired with a static parse function (like int.parse). These classes will provide the textual representation as their string representation.
Other classes have no meaningful textual representation that a program will care about. Such classes will typically override toString to provide useful information when inspecting the object, mainly for debugging or logging.
Inherited from IList.
Implementation
@override
String toString() => 'IList${mkString(start: '(', sep: ', ', end: ')')}';traverseEither() inherited
Applies f to each element of this RSeq and collects the results into a new collection. If Left is encountered for any element, that result is returned and any additional elements will not be evaluated.
Inherited from IList.
Implementation
@override
Either<B, IList<C>> traverseEither<B, C>(Function1<A, Either<B, C>> f) =>
super.traverseEither(f).map(IList.from);traverseOption() inherited
Applies f to each element of this RSeq and collects the results into a new collection. If None is encountered for any element, that result is returned and any additional elements will not be evaluated.
Inherited from IList.
Implementation
@override
Option<IList<B>> traverseOption<B>(Function1<A, Option<B>> f) =>
super.traverseOption(f).map((a) => a.toIList());uncons() inherited
B uncons<B>(B Function(Option<Record>) f)Deconstructs the list by passing Some((head, tail)) to f when non-empty, or None when empty.
Inherited from IList.
Implementation
B uncons<B>(Function1<Option<(A, IList<A>)>, B> f) {
if (isEmpty) {
return f(none());
} else {
return f(Some((head, tail)));
}
}updated() inherited
IList<A> updated(int index, A elem)Returns a new collection with the element at index replaced by elem.
Throws RangeError if index is out of bounds.
Inherited from IList.
Implementation
@override
IList<A> updated(int index, A elem) {
var i = 0;
var current = this;
final prefix = builder<A>();
while (i < index && current.nonEmpty) {
i += 1;
prefix.addOne(current.head);
current = current.tail;
}
if (i == index && current.nonEmpty) {
return prefix.prependToList(Cons(elem, current.tail));
} else {
throw RangeError('$index is out of bounds (min 0, max ${length - 1})');
}
}zip() inherited
IList<Record> zip<B>(RIterableOnce<B> that)Returns a new collection that combines corresponding elements from this collection and that as a tuple. The length of the returned collection will be the minimum of this collections size and the size of that.
Inherited from IList.
Implementation
@override
IList<(A, B)> zip<B>(RIterableOnce<B> that) {
final b = builder<(A, B)>();
final it1 = iterator;
final it2 = that.iterator;
while (it1.hasNext && it2.hasNext) {
b.addOne((it1.next(), it2.next()));
}
return b.toIList();
}zipAll() inherited
IList<Record> zipAll<B>(RIterableOnce<B> that, A thisElem, B thatElem)Returns a new collection that combines corresponding elements from this collection and that as a tuple. The length of the returned collection will be the maximum of this collections size and thes size of that. If this collection is shorter than that, thisElem will be used to fill in the resulting collection. If that is shorter, thatElem will be used to will in the resulting collection.
Inherited from IList.
Implementation
@override
IList<(A, B)> zipAll<B>(
RIterableOnce<B> that,
A thisElem,
B thatElem,
) => super.zipAll(that, thisElem, thatElem).toIList();zipWithIndex() inherited
IList<Record> zipWithIndex()Return a new collection with each element of this collection paired with it's respective index.
Inherited from IList.
Implementation
@override
IList<(A, int)> zipWithIndex() {
final b = builder<(A, int)>();
var i = 0;
final it = iterator;
while (it.hasNext) {
b.addOne((it.next(), i));
i += 1;
}
return b.toIList();
}Extension Methods
dropWhileN() extension
IList<Record> dropWhileN(bool Function(T1, T2, T3, T4) p)Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
IList<(T1, T2, T3, T4)> dropWhileN(Function4<T1, T2, T3, T4, bool> p) => dropWhile(p.tupled);dropWhileN() extension
IList<Record> dropWhileN(bool Function(T1, T2, T3) p)Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
IList<(T1, T2, T3)> dropWhileN(Function3<T1, T2, T3, bool> p) => dropWhile(p.tupled);dropWhileN() extension
IList<Record> dropWhileN(bool Function(T1, T2, T3, T4, T5) p)Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
IList<(T1, T2, T3, T4, T5)> dropWhileN(Function5<T1, T2, T3, T4, T5, bool> p) =>
dropWhile(p.tupled);dropWhileN() extension
IList<Record> dropWhileN(bool Function(T1, T2) p)Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
IList<(T1, T2)> dropWhileN(Function2<T1, T2, bool> p) => dropWhile(p.tupled);filterN() extension
IList<Record> filterN(bool Function(T1, T2, T3) p)Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
IList<(T1, T2, T3)> filterN(Function3<T1, T2, T3, bool> p) => filter(p.tupled);filterN() extension
IList<Record> filterN(bool Function(T1, T2) p)Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
IList<(T1, T2)> filterN(Function2<T1, T2, bool> p) => filter(p.tupled);filterN() extension
IList<Record> filterN(bool Function(T1, T2, T3, T4) p)Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
IList<(T1, T2, T3, T4)> filterN(Function4<T1, T2, T3, T4, bool> p) => filter(p.tupled);filterN() extension
IList<Record> filterN(bool Function(T1, T2, T3, T4, T5) p)Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
IList<(T1, T2, T3, T4, T5)> filterN(Function5<T1, T2, T3, T4, T5, bool> p) => filter(p.tupled);filterNotN() extension
IList<Record> filterNotN(bool Function(T1, T2, T3, T4, T5) p)Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
IList<(T1, T2, T3, T4, T5)> filterNotN(Function5<T1, T2, T3, T4, T5, bool> p) =>
filterNot(p.tupled);filterNotN() extension
IList<Record> filterNotN(bool Function(T1, T2) p)Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
IList<(T1, T2)> filterNotN(Function2<T1, T2, bool> p) => filterNot(p.tupled);filterNotN() extension
IList<Record> filterNotN(bool Function(T1, T2, T3, T4) p)Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
IList<(T1, T2, T3, T4)> filterNotN(Function4<T1, T2, T3, T4, bool> p) => filterNot(p.tupled);filterNotN() extension
IList<Record> filterNotN(bool Function(T1, T2, T3) p)Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
IList<(T1, T2, T3)> filterNotN(Function3<T1, T2, T3, bool> p) => filterNot(p.tupled);flatMapN() extension
Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
IList<T6> flatMapN<T6>(Function5<T1, T2, T3, T4, T5, IList<T6>> f) => flatMap(f.tupled);flatMapN() extension
Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
IList<T4> flatMapN<T4>(Function3<T1, T2, T3, IList<T4>> f) => flatMap(f.tupled);flatMapN() extension
Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
IList<T5> flatMapN<T5>(Function4<T1, T2, T3, T4, IList<T5>> f) => flatMap(f.tupled);flatMapN() extension
Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
IList<T3> flatMapN<T3>(Function2<T1, T2, IList<T3>> f) => flatMap(f.tupled);flatten() extension
RIterable<A> flatten()Concatenates all inner iterables into a single IList.
Available on RIterable<A>, provided by the RIterableNested2Ops<A> extension
Implementation
RIterable<A> flatten() {
final it = iterator;
final b = IList.builder<A>();
while (it.hasNext) {
b.addAll(it.next());
}
return b.toIList();
}flatten() extension
IList<A> flatten()Combines all nested lists into one list using concatenation.
Available on IList<A>, provided by the IListNestedOps<A> extension
Implementation
IList<A> flatten() => foldLeft(nil<A>(), (z, a) => z.concat(a));flatTraverseIO() extension
Applies f to each element of this list and collects the results into a new list that is flattened using concatenation. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> flatTraverseIO<B>(Function1<A, IO<IList<B>>> f) =>
traverseIO(f).map((a) => a.flatten());flatTraverseResource() extension
Applies f to each element of this list and collects the results into a new list that is flattened using concatenation. Resources are allocated sequentially.
Available on IList<A>, provided by the ResourceIListOps<A> extension
Implementation
Resource<IList<B>> flatTraverseResource<B>(Function1<A, Resource<IList<B>>> f) =>
traverseResource(f).map((a) => a.flatten());foreachN() extension
void foreachN(void Function(T1, T2, T3, T4, T5) f)Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
void foreachN(Function5<T1, T2, T3, T4, T5, void> f) => foreach(f.tupled);foreachN() extension
void foreachN(void Function(T1, T2, T3, T4) f)Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
void foreachN(Function4<T1, T2, T3, T4, void> f) => foreach(f.tupled);foreachN() extension
void foreachN(void Function(T1, T2) f)Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
void foreachN(Function2<T1, T2, void> f) => foreach(f.tupled);foreachN() extension
void foreachN(void Function(T1, T2, T3) f)Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
void foreachN(Function3<T1, T2, T3, void> f) => foreach(f.tupled);mapN() extension
IList<T5> mapN<T5>(T5 Function(T1, T2, T3, T4) f)Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
IList<T5> mapN<T5>(Function4<T1, T2, T3, T4, T5> f) => map(f.tupled);mapN() extension
IList<T4> mapN<T4>(T4 Function(T1, T2, T3) f)Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
IList<T4> mapN<T4>(Function3<T1, T2, T3, T4> f) => map(f.tupled);mapN() extension
IList<T6> mapN<T6>(T6 Function(T1, T2, T3, T4, T5) f)Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
IList<T6> mapN<T6>(Function5<T1, T2, T3, T4, T5, T6> f) => map(f.tupled);mapN() extension
IList<T3> mapN<T3>(T3 Function(T1, T2) f)Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
IList<T3> mapN<T3>(Function2<T1, T2, T3> f) => map(f.tupled);noNulls() extension
IList<A> noNulls()Returns a new list with all null elements removed.
Available on IList<A>, provided by the IListNullableOps<A> extension
Implementation
IList<A> noNulls() => foldLeft(nil(), (acc, elem) => elem == null ? acc : acc.appended(elem));parSequence() extension
Alias for parTraverseIO, using identity as the function parameter.
Available on IList<A>, provided by the IListIOOps<A> extension
Implementation
IO<IList<A>> parSequence() => parTraverseIO(identity);parSequence() extension
Alias for parTraverseResource, using identity as the function parameter.
Available on IList<A>, provided by the IListResourceOps<A> extension
Implementation
Resource<IList<A>> parSequence() => parTraverseResource(identity);parSequence_() extension
Alias for parTraverseIO_, using identity as the function parameter.
Available on IList<A>, provided by the IListIOOps<A> extension
Implementation
IO<Unit> parSequence_() => parTraverseIO_(identity);parSequence_() extension
Alias for parTraverseResource_, using identity as the function parameter.
Available on IList<A>, provided by the IListResourceOps<A> extension
Implementation
Resource<Unit> parSequence_() => parTraverseResource_(identity);parTraverseIO() extension
Asynchronously applies f to each element of this list and collects the results into a new list. If an error or cancelation is encountered for any element, that result is returned and all other elements will be canceled if possible.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> parTraverseIO<B>(Function1<A, IO<B>> f) {
IO<IList<B>> result = IO.pure(nil());
foreach((elem) {
result = IO.both(result, f(elem)).map((t) => t((acc, b) => acc.prepended(b)));
});
return result.map((a) => a.reverse());
}parTraverseIO_() extension
Asynchronously applies f to each element of this list, discarding any results. If an error or cancelation is encountered for any element, that result is returned and all other elements will be canceled if possible.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<Unit> parTraverseIO_<B>(Function1<A, IO<B>> f) {
IO<Unit> result = IO.pure(Unit());
foreach((elem) {
result = IO.both(result, f(elem)).map((t) => t((acc, b) => Unit()));
});
return result;
}parTraverseION() extension
Maps f over the list concurrently, running at most n tasks at a time.
Available on IList<A>, provided by the IListConcurrencyOps<A> extension
Implementation
IO<IList<B>> parTraverseION<B>(int n, IO<B> Function(A) f) {
if (n <= 0) throw ArgumentError("Concurrency limit 'n' must be > 0");
return Semaphore.permits(
n,
).flatMap((sem) => parTraverseIO((a) => sem.permit().use((_) => f(a))));
}parTraverseResource() extension
Asynchronously applies f to each element of this list and collects the results into a new list. Resources are allocated in parallel; if any allocation fails, all others are released.
Available on IList<A>, provided by the ResourceIListOps<A> extension
Implementation
Resource<IList<B>> parTraverseResource<B>(Function1<A, Resource<B>> f) {
Resource<IList<B>> result = Resource.pure(nil());
foreach((elem) {
result = Resource.both(result, f(elem)).map((t) => t((acc, b) => acc.prepended(b)));
});
return result.map((a) => a.reverse());
}parTraverseResource_() extension
Asynchronously applies f to each element of this list, discarding any results. Resources are allocated in parallel; if any allocation fails, all others are released.
Available on IList<A>, provided by the ResourceIListOps<A> extension
Implementation
Resource<Unit> parTraverseResource_<B>(Function1<A, Resource<B>> f) {
Resource<Unit> result = Resource.pure(Unit());
foreach((elem) {
result = Resource.both(result, f(elem)).map((t) => t((acc, b) => Unit()));
});
return result;
}product() extension
int product()Returns the product of all elements in this list
Available on RIterableOnce<A>, provided by the RIterableIntOps extension
Implementation
int product() {
var p = 1;
final it = iterator;
while (it.hasNext) {
p *= it.next();
}
return p;
}product() extension
double product()Returns the product of all elements in this list
Available on RIterableOnce<A>, provided by the RIterableDoubleOps extension
Implementation
double product() {
var p = 1.0;
final it = iterator;
while (it.hasNext) {
p *= it.next();
}
return p;
}sequence() extension
Accumulates all elements in this list as one Either. If any element is a Left, that Left is returned immediately. If all elements are Right, the entire list of right values is returned wrapped in a Right.
Available on IList<A>, provided by the IListEitherOps<A, B> extension
Implementation
Either<A, IList<B>> sequence() => traverseEither(identity);sequence() extension
Alias for traverseIO, using identity as the function parameter.
Available on IList<A>, provided by the IListIOOps<A> extension
Implementation
IO<IList<A>> sequence() => traverseIO(identity);sequence() extension
Accumulates all elements in this list as one Option. If any element is a None, None will be returned. If all elements are Some, then the entire list is returned, wrapped in a Some.
Available on IList<A>, provided by the IListOptionOps<A> extension
Implementation
Option<IList<A>> sequence() => traverseOption(identity);sequence() extension
Alias for traverseResource, using identity as the function parameter.
Available on IList<A>, provided by the IListResourceOps<A> extension
Implementation
Resource<IList<A>> sequence() => traverseResource(identity);sequence_() extension
Alias for traverseResource_, using identity as the function parameter.
Available on IList<A>, provided by the IListResourceOps<A> extension
Implementation
Resource<Unit> sequence_() => traverseResource_(identity);sequence_() extension
Alias for traverseIO_, using identity as the function parameter.
Available on IList<A>, provided by the IListIOOps<A> extension
Implementation
IO<Unit> sequence_() => traverseIO_(identity);sum() extension
double sum()Returns the sum of all elements in this list
Available on RIterableOnce<A>, provided by the RIterableDoubleOps extension
Implementation
double sum() {
var s = 0.0;
final it = iterator;
while (it.hasNext) {
s += it.next();
}
return s;
}sum() extension
int sum()Returns the sum of all elements in this list
Available on RIterableOnce<A>, provided by the RIterableIntOps extension
Implementation
int sum() {
var s = 0;
final it = iterator;
while (it.hasNext) {
s += it.next();
}
return s;
}takeWhileN() extension
IList<Record> takeWhileN(bool Function(T1, T2, T3, T4, T5) p)Available on IList<A>, provided by the IListTuple5Ops<T1, T2, T3, T4, T5> extension
Implementation
IList<(T1, T2, T3, T4, T5)> takeWhileN(Function5<T1, T2, T3, T4, T5, bool> p) =>
takeWhile(p.tupled);takeWhileN() extension
IList<Record> takeWhileN(bool Function(T1, T2) p)Available on IList<A>, provided by the IListTuple2Ops<T1, T2> extension
Implementation
IList<(T1, T2)> takeWhileN(Function2<T1, T2, bool> p) => takeWhile(p.tupled);takeWhileN() extension
IList<Record> takeWhileN(bool Function(T1, T2, T3) p)Available on IList<A>, provided by the IListTuple3Ops<T1, T2, T3> extension
Implementation
IList<(T1, T2, T3)> takeWhileN(Function3<T1, T2, T3, bool> p) => takeWhile(p.tupled);takeWhileN() extension
IList<Record> takeWhileN(bool Function(T1, T2, T3, T4) p)Available on IList<A>, provided by the IListTuple4Ops<T1, T2, T3, T4> extension
Implementation
IList<(T1, T2, T3, T4)> takeWhileN(Function4<T1, T2, T3, T4, bool> p) => takeWhile(p.tupled);toIMap() extension
IMap<A, B> toIMap()Creates a new IMap where element tuple element of this list is used to create a key and value respectively.
Available on RIterable<A>, provided by the RIterableTuple2Ops<A, B> extension
Implementation
IMap<A, B> toIMap() => IMap.from(this);traverseFilterIO() extension
Applies f to each element of this list and collects the results into a new list. Any results from f that are None are discarded from the resulting list. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> traverseFilterIO<B>(Function1<A, IO<Option<B>>> f) => traverseIO(f).map(
(opts) => opts.foldLeft(
IList.empty<B>(),
(acc, elem) => elem.fold(() => acc, (elem) => acc.appended(elem)),
),
);traverseFilterResource() extension
Applies f to each element of this list and collects the results into a new list. Any results from f that are None are discarded from the resulting list. Resources are allocated sequentially.
Available on IList<A>, provided by the ResourceIListOps<A> extension
Implementation
Resource<IList<B>> traverseFilterResource<B>(Function1<A, Resource<Option<B>>> f) =>
traverseResource(f).map(
(opts) => opts.foldLeft(
IList.empty<B>(),
(acc, elem) => elem.fold(() => acc, (elem) => acc.appended(elem)),
),
);traverseIO() extension
Applies f to each element of this list and collects the results into a new list. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<IList<B>> traverseIO<B>(Function1<A, IO<B>> f) {
IO<IList<B>> result = IO.pure(nil());
foreach((elem) {
result = result.flatMap((l) => f(elem).map((b) => l.prepended(b)));
});
return result.map((a) => a.reverse());
}traverseIO_() extension
Applies f to each element of this list, discarding any results. If an error or cancelation is encountered for any element, that result is returned and any additional elements will not be evaluated.
Available on IList<A>, provided by the IOIListOps<A> extension
Implementation
IO<Unit> traverseIO_<B>(Function1<A, IO<B>> f) {
var result = IO.pure(Unit());
foreach((elem) {
result = result.flatMap((l) => f(elem).map((b) => Unit()));
});
return result;
}traverseResource() extension
Applies f to each element of this list and collects the results into a new list. Resources are allocated sequentially; if any allocation fails, previously allocated resources are released.
Available on IList<A>, provided by the ResourceIListOps<A> extension
Implementation
Resource<IList<B>> traverseResource<B>(Function1<A, Resource<B>> f) {
Resource<IList<B>> result = Resource.pure(nil());
foreach((elem) {
result = result.flatMap((l) => f(elem).map((b) => l.prepended(b)));
});
return result.map((a) => a.reverse());
}traverseResource_() extension
Applies f to each element of this list, discarding any results. Resources are allocated sequentially; if any allocation fails, previously allocated resources are released.
Available on IList<A>, provided by the ResourceIListOps<A> extension
Implementation
Resource<Unit> traverseResource_<B>(Function1<A, Resource<B>> f) {
var result = Resource.pure(Unit());
foreach((elem) {
result = result.flatMap((_) => f(elem).voided());
});
return result;
}unNone() extension
IList<A> unNone()Returns a new list with all None elements removed.
Available on IList<A>, provided by the IListOptionOps<A> extension
Implementation
IList<A> unNone() => foldLeft(nil(), (acc, elem) => elem.fold(() => acc, (a) => acc.appended(a)));unzip() extension
Record unzip()Returns 3 new lists as a tuple. The first list is all the first items from each tuple element of this list. The second list is all the second items from each tuple element of this list. The third list is all the third items from each tuple element of this list.
Available on IList<A>, provided by the IListTuple3UnzipOps<A, B, C> extension
Implementation
(IList<A>, IList<B>, IList<C>) unzip() => foldLeft(
(nil<A>(), nil<B>(), nil<C>()),
(acc, abc) => (acc.$1.appended(abc.$1), acc.$2.appended(abc.$2), acc.$3.appended(abc.$3)),
);unzip() extension
Record unzip()Returns 2 new lists as a tuple. The first list is all the first items from each tuple element of this list. The second list is all the second items from each tuple element of this list.
Available on IList<A>, provided by the IListTuple2UnzipOps<A, B> extension
Implementation
(IList<A>, IList<B>) unzip() =>
foldLeft((nil<A>(), nil<B>()), (acc, ab) => (acc.$1.appended(ab.$1), acc.$2.appended(ab.$2)));unzip() extension
Record unzip()Returns 2 new lists as a tuple. The first list is all the Left items from each element of this list. The second list is all the Right items from each element of this list.
Available on IList<A>, provided by the IListEitherOps<A, B> extension
Implementation
(IList<A>, IList<B>) unzip() {
final a1s = List<A>.empty(growable: true);
final a2s = List<B>.empty(growable: true);
foreach((elem) => elem.fold((a1) => a1s.add(a1), (a2) => a2s.add(a2)));
return (ilist(a1s), ilist(a2s));
}unzip() extension
Record unzip()Splits a collection of pairs into two separate collections.
Available on RIterable<A>, provided by the RibsIterableTuple2Ops<A, B> extension
Implementation
(RIterable<A>, RIterable<B>) unzip() => (
views.Map(this, (a) => a.$1),
views.Map(this, (a) => a.$2),
);Operators
operator ==() inherited
bool operator ==(Object other)The equality operator.
The default behavior for all Objects is to return true if and only if this object and other are the same object.
Override this method to specify a different equality relation on a class. The overriding method must still be an equivalence relation. That is, it must be:
Total: It must return a boolean for all arguments. It should never throw.
Reflexive: For all objects
o,o == omust be true.Symmetric: For all objects
o1ando2,o1 == o2ando2 == o1must either both be true, or both be false.Transitive: For all objects
o1,o2, ando3, ifo1 == o2ando2 == o3are true, theno1 == o3must be true.
The method should also be consistent over time, so whether two objects are equal should only change if at least one of the objects was modified.
If a subclass overrides the equality operator, it should override the hashCode method as well to maintain consistency.
Inherited from IList.
Implementation
@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
} else if (other is IList) {
var a = this;
var b = other;
while (a.nonEmpty && b.nonEmpty && a.head == b.head) {
a = a.tail;
b = b.tail;
}
return a.isEmpty && b.isEmpty;
} else {
return super == other;
}
}operator inherited
A operator [](int idx)Returns the element at index idx.
Inherited from IList.
Implementation
@override
A operator [](int idx) {
if (idx < 0) throw RangeError.index(idx, 'Invalid IList index: $idx');
final skipped = drop(idx);
if (skipped.isEmpty) throw RangeError.index(idx, this);
return skipped.head;
}