MQueue<A>
A mutable FIFO queue backed by ArrayDeque.
Use enqueue / enqueueAll to add elements at the back and dequeue to remove from the front. front peeks at the head without removing it.
final q = MQueue<int>();
q.enqueue(1).enqueue(2);
q.dequeue(); // 1
q.front; // 2Inheritance
Object → ArrayDeque<A> → MQueue<A>
Available Extensions
Constructors
MQueue()
Implementation
MQueue([super.size = ArrayDeque.DefaultInitialSize]);Properties
array read / write inherited
Inherited from ArrayDeque.
Implementation
@protected
Array<A> array;end read / write inherited
Inherited from ArrayDeque.
Implementation
@protected
int end;front no setter
Returns the front element without removing it.
Implementation
A get front => head;hashCode no setter inherited
The 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 RSeq.
Implementation
@override
int get hashCode => MurmurHash3.seqHash(this);head no setter inherited
Returns the first element of this collection, or throws if it is empty.
Inherited from RIterable.
Implementation
A get head => iterator.next();headOption no setter inherited
Returns the first element of this collection as a Some if non-empty. If this collction is empty, None is returned.
Inherited from RIterable.
Implementation
Option<A> get headOption {
final it = iterator;
return Option.when(() => it.hasNext, () => it.next());
}init no setter inherited
Returns all elements from this collection except the last. If this collection is empty, an empty collection is returned.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> get init => from(super.init);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 ArrayDeque.
Implementation
@override
RIterator<ArrayDeque<A>> get inits => super.inits.map(from);isEmpty no setter inherited
Whether this collection contains no elements.
Inherited from ArrayDeque.
Implementation
@override
bool get isEmpty => start == end;isNotEmpty no setter inherited
Whether this collection contains at least one element.
Inherited from RIterableOnce.
Implementation
bool get isNotEmpty => !isEmpty;isTraversableAgain no setter inherited
Whether 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
Returns an RIterator over the elements of this collection.
Inherited from ArrayDeque.
Implementation
@override
RIterator<A> get iterator => _ArrayDequeIterator(this, 0, () => 0);knownSize no setter inherited
Returns the number of elements in this collection, if that number is already known. If not, -1 is returned.
Inherited from ArrayDeque.
Implementation
@override
int get knownSize => length;last no setter inherited
Returns 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
Returns 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
The number of elements in this sequence.
Inherited from ArrayDeque.
Implementation
@override
int get length => _endMinus(start);nonEmpty no setter inherited
Whether this collection contains at least one element.
Inherited from RIterableOnce.
Implementation
bool get nonEmpty => !isEmpty;runtimeType no setter inherited
A representation of the runtime type of the object.
Inherited from Object.
Implementation
external Type get runtimeType;size no setter inherited
Returns the number of elements in this collection.
Inherited from RSeq.
Implementation
@override
int get size => length;start read / write inherited
Inherited from ArrayDeque.
Implementation
@protected
int start;tail no setter inherited
Returns a new collection with the first element removed. If this collection is empty, an empty collection is returned.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> get tail => from(super.tail);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 ArrayDeque.
Implementation
@override
RIterator<ArrayDeque<A>> get tails => super.tails.map(from);Methods
addAll() inherited
Appends all elems and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> addAll(RIterableOnce<A> elems) {
final srcLength = elems.knownSize;
if (srcLength > 0) {
_ensureSize(srcLength + length);
elems.iterator.foreach(_appendAssumingCapacity);
} else {
elems.iterator.foreach(addOne);
}
return this;
}addOne() inherited
Appends elem and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> addOne(A elem) {
_ensureSize(length + 1);
return _appendAssumingCapacity(elem);
}append() inherited
Alias for addOne.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> append(A elem) => from(super.append(elem));appendAll() inherited
Alias for addAll.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> appendAll(RIterableOnce<A> elems) => from(super.appendAll(elems));appended() inherited
Returns a new Seq, with the given elem added to the end.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> appended(A elem) => from(super.appended(elem));appendedAll() inherited
Returns a new Seq, with elems added to the end.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> appendedAll(RIterableOnce<A> suffix) => from(super.appendedAll(suffix));canEqual() inherited
Inherited from IndexedSeq.
Implementation
@override
bool canEqual(Object other) => switch (other) {
final RSeq<A> that => length == that.length && super.canEqual(that),
_ => super.canEqual(other),
};clear() inherited
Removes all elements from this buffer.
Inherited from ArrayDeque.
Implementation
@override
void clear() {
while (nonEmpty) {
_removeHeadAssumingNonEmpty();
}
}collect() inherited
Returns a new collection by applying f to each element an only keeping results of type Some.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<B> collect<B>(Function1<A, Option<B>> f) => from(super.collect(f));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 ArrayDeque.
Implementation
@override
RIterator<ArrayDeque<A>> combinations(int n) => super.combinations(n).map(from);concat() inherited
Returns a copy of this collection, with elems added to the end.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> concat(covariant RIterableOnce<A> suffix) => from(super.concat(suffix));contains() inherited
Returns true, if any element of this collection equals elem.
Inherited from RSeq.
Implementation
bool contains(A elem) => exists((a) => a == elem);containsSlice() inherited
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
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
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 RIterableOnce.
Implementation
bool corresponds<B>(
covariant RIterable<B> that,
Function2<A, B, bool> p,
) {
final a = iterator;
final b = that.iterator;
while (a.hasNext && b.hasNext) {
if (!p(a.next(), b.next())) return false;
}
return !a.hasNext && !b.hasNext;
}count() inherited
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;
}dequeue()
Removes and returns the front element. Throws if empty.
Implementation
A dequeue() => removeHead();dequeueAll()
Removes and returns all elements satisfying p.
Implementation
RSeq<A> dequeueAll(Function1<A, bool> p) => removeAll(p);dequeueFirst()
Removes and returns the first element satisfying p, or None if none.
Implementation
Option<A> dequeueFirst(Function1<A, bool> p) => removeFirst(p);dequeueWhile()
Removes and returns all leading elements satisfying p.
Implementation
RSeq<A> dequeueWhile(Function1<A, bool> p) => removeHeadWhile(p);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 ArrayDeque.
Implementation
@override
ArrayDeque<A> diff(RSeq<A> that) => from(super.diff(that));distinct() inherited
Returns a new collection where every element is distinct according to equality.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> distinct() => from(super.distinct());distinctBy() inherited
Returns a new collection where every element is distinct according to the application of f to each element.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> distinctBy<B>(Function1<A, B> f) => from(super.distinctBy(f));drop() inherited
Returns a new collection with the first n elements removed.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> drop(int n) => from(super.drop(n));dropInPlace() inherited
Removes the first n elements in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> dropInPlace(int n) => from(super.dropInPlace(n));dropRight() inherited
Return a new collection with the last n elements removed.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> dropRight(int n) => from(super.dropRight(n));dropRightInPlace() inherited
Removes the last n elements in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> dropRightInPlace(int n) => from(super.dropRightInPlace(n));dropWhile() inherited
Returns a new collection with leading elements satisfying p removed.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> dropWhile(Function1<A, bool> p) => from(super.dropWhile(p));dropWhileInPlace() inherited
Removes leading elements satisfying p in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> dropWhileInPlace(Function1<A, bool> p) => from(super.dropWhileInPlace(p));endsWith() inherited
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;
}
}enqueue()
Adds elem at the back of the queue and returns this.
Implementation
MQueue<A> enqueue(A elem) {
super.addOne(elem);
return this;
}enqueueAll()
Adds all elems at the back of the queue and returns this.
Implementation
MQueue<A> enqueueAll(RIterableOnce<A> elems) {
super.addAll(elems);
return this;
}exists() inherited
Returns true if any element of this collection satisfies the given predicate, false if no elements satisfy it.
Inherited from RIterableOnce.
Implementation
bool exists(Function1<A, bool> p) {
var res = false;
final it = iterator;
while (!res && it.hasNext) {
res = p(it.next());
}
return res;
}filter() inherited
Returns a new collection containing only elements that satisfy p.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> filter(Function1<A, bool> p) {
return from(super.filter(p));
}filterNot() inherited
Returns a new collection containing only elements that do not satisfy p.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> filterNot(Function1<A, bool> p) => from(super.filterNot(p));find() inherited
Returns the first element from this collection that satisfies the given predicate p. If no element satisfies p, None is returned.
Inherited from RIterableOnce.
Implementation
Option<A> find(Function1<A, bool> p) {
final it = iterator;
while (it.hasNext) {
final a = it.next();
if (p(a)) return Some(a);
}
return none();
}findLast() inherited
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
Returns a new collection by applying f to each element and concatenating the results.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<B> flatMap<B>(covariant Function1<A, RIterableOnce<B>> f) => from(super.flatMap(f));fold() inherited
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
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 RIterableOnce.
Implementation
B foldLeft<B>(B z, Function2<B, A, B> op) {
var result = z;
final it = iterator;
while (it.hasNext) {
result = op(result, it.next());
}
return result;
}foldRight() inherited
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 RIterableOnce.
Implementation
B foldRight<B>(B z, Function2<A, B, B> op) => _reversed().foldLeft(z, (b, a) => op(a, b));forall() inherited
Returns true if all elements of this collection satisfy the given predicate, false if any elements do not.
Inherited from RIterableOnce.
Implementation
bool forall(Function1<A, bool> p) {
var res = true;
final it = iterator;
while (res && it.hasNext) {
res = p(it.next());
}
return res;
}foreach() inherited
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 ArrayDeque.
Implementation
@override
IMap<K, ArrayDeque<A>> groupBy<K>(Function1<A, K> f) => super.groupBy(f).mapValues(from);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 ArrayDeque.
Implementation
@override
RIterator<ArrayDeque<A>> grouped(int size) => super.grouped(size).map(from);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 ArrayDeque.
Implementation
@override
IMap<K, ArrayDeque<B>> groupMap<K, B>(Function1<A, K> key, Function1<A, B> f) =>
super.groupMap(key, f).mapValues(from);groupMapReduce() inherited
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
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
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
Returns a range of all indices of this sequence
Will force evaluation.
Inherited from RSeq.
Implementation
Range indices() => Range.exclusive(0, length);insert() inherited
Inserts elem at position idx, shifting later elements right.
Inherited from ArrayDeque.
Implementation
@override
void insert(int idx, A elem) {
_requireBounds(idx, length + 1);
final n = length;
if (idx == 0) {
prepend(elem);
} else if (idx == n) {
addOne(elem);
} else {
final finalLength = n + 1;
if (_mustGrow(finalLength)) {
final array2 = ArrayDeque.alloc<A>(finalLength);
_copySliceToArray(0, array2, 0, idx);
array2[idx] = elem;
_copySliceToArray(idx, array2, idx + 1, n);
_reset(array2, 0, finalLength);
} else if (n <= idx * 2) {
var i = n - 1;
while (i >= idx) {
_set(i + 1, _get(i));
i -= 1;
}
end = _endPlus(1);
i += 1;
_set(i, elem);
} else {
var i = 0;
while (i < idx) {
_set(i - 1, _get(i));
i += 1;
}
start = _startMinus(1);
_set(i, elem);
}
}
}insertAll() inherited
Inserts all elems starting at position idx.
Inherited from ArrayDeque.
Implementation
@override
void insertAll(int idx, RIterableOnce<A> elems) {
_requireBounds(idx, length + 1);
final n = length;
if (idx == 0) {
prependAll(elems);
} else if (idx == n) {
addAll(elems);
} else {
final RIterator<A> it;
final int srcLength;
if (elems.knownSize >= 0) {
it = elems.iterator;
srcLength = elems.knownSize;
} else {
final indexed = IndexedSeq.from(elems);
it = indexed.iterator;
srcLength = indexed.size;
}
if (it.nonEmpty) {
final finalLength = srcLength + n;
// Either we resize right away or move prefix left or suffix right
if (_mustGrow(finalLength)) {
final array2 = ArrayDeque.alloc<A>(finalLength);
_copySliceToArray(0, array2, 0, idx);
final copied = it.copyToArray(array2, idx);
assert(copied == srcLength);
_copySliceToArray(idx, array2, idx + srcLength, n);
_reset(array2, 0, finalLength);
} else if (2 * idx >= n) {
// Cheaper to shift the suffix right
var i = n - 1;
while (i >= idx) {
_set(i + srcLength, _get(i));
i -= 1;
}
end = _endPlus(srcLength);
while (it.hasNext) {
i += 1;
_set(i, it.next());
}
} else {
// Cheaper to shift prefix left
var i = 0;
while (i < idx) {
_set(i - srcLength, _get(i));
i += 1;
}
start = _startMinus(srcLength);
while (it.hasNext) {
_set(i, it.next());
i += 1;
}
}
}
}
}intersect() inherited
Returns a new collection with the intersection of this and that, i.e. all elements that appear in both collections.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> intersect(RSeq<A> that) => from(super.intersect(that));intersperse() inherited
Returns a new collection with sep inserted between each element.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> intersperse(A x) => from(super.intersperse(x));isDefinedAt() inherited
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
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
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
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
Returns a new collection by applying f to each element.
Inherited from RSeq.
Implementation
@override
RSeq<B> map<B>(Function1<A, B> f) => seqviews.Map(this, f).toSeq();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
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
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
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 ArrayDeque.
Implementation
@override
ArrayDeque<A> padTo(int len, A elem) => from(super.padTo(len, elem));padToInPlace() inherited
Appends elem until length equals len, then returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> padToInPlace(int len, A elem) => from(super.padToInPlace(len, elem));partition() inherited
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 ArrayDeque.
Implementation
@override
(ArrayDeque<A>, ArrayDeque<A>) partition(Function1<A, bool> p) {
final (a, b) = super.partition(p);
return (from(a), from(b));
}partitionMap() inherited
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 ArrayDeque.
Implementation
@override
(ArrayDeque<A1>, ArrayDeque<A2>) partitionMap<A1, A2>(Function1<A, Either<A1, A2>> f) {
final (a, b) = super.partitionMap(f);
return (from(a), from(b));
}patch() inherited
Returns a new collection with replaced elements starting at from replaced by the elements of other.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> patch(int from, RIterableOnce<A> other, int replaced) =>
ArrayDeque.from(super.patch(from, other, replaced));patchInPlace() inherited
Replaces replaced elements starting at from with patch in place.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> patchInPlace(int from, RIterableOnce<A> patch, int replaced) {
final replaced0 = min(max(replaced, 0), length);
final i = min(max(from, 0), length);
var j = 0;
final iter = patch.iterator;
while (iter.hasNext && j < replaced0 && i + j < length) {
update(i + j, iter.next());
j += 1;
}
if (iter.hasNext) {
insertAll(i + j, iter);
} else if (j < replaced0) {
removeN(i + j, min(replaced0 - j, length - i - j));
}
return this;
}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 IndexedSeq.
Implementation
@override
RIterator<IndexedSeq<A>> permutations() => super.permutations().map((a) => a.toIndexedSeq());prepend() inherited
Prepends elem and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> prepend(A elem) {
_ensureSize(length + 1);
return _prependAssumingCapacity(elem);
}prependAll() inherited
Prepends all elems and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> prependAll(RIterableOnce<A> elems) {
final it = elems.iterator;
if (it.nonEmpty) {
final n = length;
final srcLength = elems.knownSize;
if (srcLength < 0) {
return prependAll(it.toIndexedSeq());
} else if (_mustGrow(srcLength + n)) {
final finalLength = srcLength + n;
final array2 = ArrayDeque.alloc<A>(finalLength);
final copied = it.copyToArray(array2);
assert(copied == srcLength);
_copySliceToArray(0, array2, srcLength, n);
_reset(array2, 0, finalLength);
} else {
var i = 0;
while (i < srcLength) {
_set(i - srcLength, it.next());
i += 1;
}
start = _startMinus(srcLength);
}
}
return this;
}prepended() inherited
Returns a new collection with elem added to the beginning.
Inherited from IndexedSeq.
Implementation
@override
IndexedSeq<A> prepended(A elem) => super.prepended(elem).toIndexedSeq();prependedAll() inherited
Returns a new collection with all elems added to the beginning.
Inherited from IndexedSeq.
Implementation
@override
IndexedSeq<A> prependedAll(RIterableOnce<A> prefix) => super.prependedAll(prefix).toIndexedSeq();reduce() inherited
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
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
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
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
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
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)),
};remove() inherited
Removes and returns the element at idx.
Inherited from ArrayDeque.
Implementation
@override
A remove(int idx) {
final elem = this[idx];
removeN(idx, 1);
return elem;
}removeAll() inherited
Removes and returns all elements satisfying p in FIFO order.
Inherited from ArrayDeque.
Implementation
RSeq<A> removeAll(Function1<A, bool> p) {
final elems = IVector.builder<A>();
while (nonEmpty) {
elems.addOne(_removeHeadAssumingNonEmpty());
}
return elems.result();
}removeAt() inherited
Returns a new collection with the element at idx removed.
Throws RangeError if idx is out of bounds.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> removeAt(int idx) => from(super.removeAt(idx));removeFirst() inherited
Removes the first element satisfying p at or after from and returns Some(element), or None if no such element exists.
Inherited from ArrayDeque.
Implementation
Option<A> removeFirst(Function1<A, bool> p, [int from = 0]) => indexWhere(p, from).map(remove);removeHead() inherited
Removes and returns the first element.
Throws UnsupportedError if this deque is empty.
Inherited from ArrayDeque.
Implementation
A removeHead({bool resizeInternalRepr = false}) {
if (isEmpty) {
throw UnsupportedError('ArrayDeque.removeHead: empty');
} else {
return _removeHeadAssumingNonEmpty();
}
}removeHeadOption() inherited
Removes and returns the first element wrapped in Some, or returns None when empty.
Inherited from ArrayDeque.
Implementation
Option<A> removeHeadOption({bool resizeInternalRepr = false}) {
if (isEmpty) {
return const None();
} else {
return Some(_removeHeadAssumingNonEmpty());
}
}removeHeadWhile() inherited
Removes and returns all leading elements satisfying p.
Inherited from ArrayDeque.
Implementation
RSeq<A> removeHeadWhile(Function1<A, bool> p) {
final elems = IVector.builder<A>();
while (headOption.exists(p)) {
elems.addOne(_removeHeadAssumingNonEmpty());
}
return elems.result();
}removeLast() inherited
Removes and returns the last element.
Throws UnsupportedError if this deque is empty.
Inherited from ArrayDeque.
Implementation
A removeLast({bool resizeInternalRepr = false}) {
if (isEmpty) {
throw UnsupportedError('ArrayDeque.removeLast: empty');
} else {
return _removeLastAssumingNonEmpty();
}
}removeLastOption() inherited
Removes and returns the last element wrapped in Some, or returns None when empty.
Inherited from ArrayDeque.
Implementation
Option<A> removeLastOption({bool resizeInternalRepr = false}) {
if (isEmpty) {
return const None();
} else {
return Some(_removeLastAssumingNonEmpty());
}
}removeN() inherited
Removes count elements starting at idx.
Inherited from ArrayDeque.
Implementation
@override
void removeN(int idx, int count) {
if (count > 0) {
_requireBounds(idx);
final n = length;
final removals = min(n - idx, count);
final finalLength = n - removals;
final suffixStart = idx + removals;
// If we know we can resize after removing, do it right away using arrayCopy
// Else, choose the shorter: either move the prefix (0 until idx) right OR the suffix (idx+removals until n) left
if (_shouldShrink(finalLength)) {
final array2 = ArrayDeque.alloc<A>(finalLength);
_copySliceToArray(0, array2, 0, idx);
_copySliceToArray(suffixStart, array2, idx, n);
_reset(array2, 0, finalLength);
} else if (2 * idx <= finalLength) {
// Cheaper to move the prefix right
var i = suffixStart - 1;
while (i >= removals) {
_set(i, _get(i - removals));
i -= 1;
}
while (i >= 0) {
_set(i, null);
i -= 1;
}
start = _startPlus(removals);
} else {
// Cheaper to move the suffix left
var i = idx;
while (i < finalLength) {
_set(i, _get(i + removals));
i += 1;
}
while (i < n) {
_set(i, null);
i += 1;
}
end = _endMinus(removals);
}
} else if (count < 0) {
throw ArgumentError("removing negative number of elements: $count");
}
}reverse() inherited
Returns a new collection with the order of the elements reversed.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> reverse() {
final n = length;
final arr = alloc<A>(n);
var i = 0;
while (i < n) {
arr[i] = this[n - i - 1];
i += 1;
}
return ArrayDeque.internal(arr, 0, n);
}reverseIterator() inherited
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
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
Alias for scanLeft.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<B> scan<B>(B z, Function2<B, A, B> op) => from(super.scan(z, op));scanLeft() inherited
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 ArrayDeque.
Implementation
@override
ArrayDeque<B> scanLeft<B>(B z, Function2<B, A, B> op) => from(super.scanLeft(z, op));scanRight() inherited
Returns a new collection of running totals starting with z, traversing from right to left.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<B> scanRight<B>(B z, Function2<A, B, B> op) => from(super.scanRight(z, op));segmentLength() inherited
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
Returns a new collection containing elements in the range [from, until).
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> slice(int from, int until) => ArrayDeque.from(super.slice(from, until));sliceInPlace() inherited
Keeps only the elements in [start, end) in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> sliceInPlace(int start, int end) => from(super.sliceInPlace(start, end));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 ArrayDeque.
Implementation
@override
RIterator<ArrayDeque<A>> sliding(int size, [int step = 1]) => super.sliding(size, step).map(from);sortBy() inherited
Returns a new collection that is sorted according to order after applying f to each element in this collection.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> sortBy<B>(Order<B> order, Function1<A, B> f) => from(super.sortBy(order, f));sorted() inherited
Returns a new collection that is sorted according to order.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> sorted(Order<A> order) => from(super.sorted(order));sortWith() inherited
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 ArrayDeque.
Implementation
@override
ArrayDeque<A> sortWith(Function2<A, A, bool> lt) => from(super.sortWith(lt));span() inherited
Returns two collections: elements before and starting from the first element that does not satisfy p.
Inherited from ArrayDeque.
Implementation
@override
(ArrayDeque<A>, ArrayDeque<A>) span(Function1<A, bool> p) {
final (a, b) = super.span(p);
return (from(a), from(b));
}splitAt() inherited
Returns two collections: the first n elements and the remainder.
Inherited from RSeq.
Implementation
@override
(RSeq<A>, RSeq<A>) splitAt(int n) => super.splitAt(n)((a, b) => (a.toSeq(), b.toSeq()));startsWith() inherited
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;
}subtractOne() inherited
Removes the first occurrence of x and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> subtractOne(A x) => from(super.subtractOne(x));take() inherited
Returns a new collection containing only the first n elements.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> take(int n) => from(super.take(n));takeInPlace() inherited
Keeps only the first n elements in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> takeInPlace(int n) => from(super.takeInPlace(n));takeRight() inherited
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 ArrayDeque.
Implementation
@override
ArrayDeque<A> takeRight(int n) => from(super.takeRight(n));takeRightInPlace() inherited
Keeps only the last n elements in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> takeRightInPlace(int n) => from(super.takeRightInPlace(n));takeWhile() inherited
Returns a new collection of leading elements that satisfy p.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> takeWhile(Function1<A, bool> p) => from(super.takeWhile(p));takeWhileInPlace() inherited
Keeps only the leading elements satisfying p in place and returns this.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> takeWhileInPlace(Function1<A, bool> p) => from(super.takeWhileInPlace(p));tapEach() inherited
Applies f to each element in this collection, discarding any results and returns this collection.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> tapEach<U>(Function1<A, U> f) => from(super.tapEach(f));toIList() inherited
Returns an IList with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
IList<A> toIList() => IList.from(this);toIndexedSeq() inherited
Returns an IndexedSeq with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
IndexedSeq<A> toIndexedSeq() => IndexedSeq.from(this);toISet() inherited
Returns an ISet with the same elements as this collection, duplicates removed.
Inherited from RIterableOnce.
Implementation
ISet<A> toISet() => ISet.from(this);toIVector() inherited
Returns an IVector with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
IVector<A> toIVector() => IVector.from(this);toList() inherited
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());
}
}toSeq() inherited
Returns a RSeq with the same elements as this collection.
Inherited from RIterableOnce.
Implementation
RSeq<A> toSeq() => RSeq.from(this);toString() inherited
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 RIterable.
Implementation
@override
String toString() => 'Iterable${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 ArrayDeque.
Implementation
@override
Either<B, ArrayDeque<C>> traverseEither<B, C>(Function1<A, Either<B, C>> f) =>
super.traverseEither(f).map(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 ArrayDeque.
Implementation
@override
Option<ArrayDeque<B>> traverseOption<B>(Function1<A, Option<B>> f) =>
super.traverseOption(f).map(from);trimToSize() inherited
Shrinks the internal array to exactly fit the current number of elements.
Inherited from ArrayDeque.
Implementation
void trimToSize() => _resize(length);update() inherited
Replaces the element at idx with elem.
Inherited from ArrayDeque.
Implementation
void update(int idx, A elem) {
_requireBounds(idx);
_set(idx, elem);
}updated() inherited
Returns a new collection with the element at index replaced by elem.
Throws RangeError if index is out of bounds.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<A> updated(int index, A elem) => from(super.updated(index, elem));zip() inherited
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 ArrayDeque.
Implementation
@override
ArrayDeque<(A, B)> zip<B>(RIterableOnce<B> that) => from(super.zip(that));zipAll() inherited
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 ArrayDeque.
Implementation
@override
ArrayDeque<(A, B)> zipAll<B>(RIterableOnce<B> that, A thisElem, B thatElem) =>
from(super.zipAll(that, thisElem, thatElem));zipWithIndex() inherited
Return a new collection with each element of this collection paired with it's respective index.
Inherited from ArrayDeque.
Implementation
@override
ArrayDeque<(A, int)> zipWithIndex() => from(super.zipWithIndex());Extension Methods
flatten() extension
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();
}product() extension
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;
}product() extension
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;
}sum() extension
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
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;
}toIMap() extension
Creates a new IMap where each 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);unzip() extension
Available on IndexedSeq<A>, provided by the IndexedSeqTuple2Ops<A, B> extension
Implementation
(IndexedSeq<A>, IndexedSeq<B>) unzip() => (
iseqviews.Map(this, (a) => a.$1),
iseqviews.Map(this, (a) => a.$2),
);unzip() extension
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
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 RSeq.
Implementation
@override
bool operator ==(Object other) {
return identical(this, other) ||
switch (other) {
final RSeq<A> that => canEqual(that) && sameElements(that),
_ => false,
};
}operator []() inherited
Returns the element at index idx.
Inherited from ArrayDeque.
Implementation
@override
A operator [](int idx) {
_requireBounds(idx);
return _get(idx);
}Static Methods
empty() override
Returns an empty MQueue.
Implementation
static MQueue<A> empty<A>() => MQueue<A>();from() override
Creates an MQueue from a RIterableOnce, preserving order.
Implementation
static MQueue<A> from<A>(RIterableOnce<A> source) {
if (source is MQueue<A>) {
return source;
} else if (source is ArrayDeque<A>) {
return MQueue._internal(source.array, source.start, source.end);
} else {
final array = ArrayDeque.alloc<A>(source.size);
final copied = source.copyToArray(array);
return MQueue._internal(array, 0, copied);
}
}