ArrayChunks<T> class
final
Returns an iterator over N elements of the iterator at a time.
The chunks do not overlap. If N does not divide the length of the iterator, then the last up to N-1 elements will
be omitted and can be retrieved from the .intoRemainder()
function of the iterator.
Constructors
-
ArrayChunks(Iterator<
T> _iterator, int _chunkSize)
Properties
-
current
→ Arr<
T> -
The current element.
no setteroverride
-
first
→ Arr<
T> -
The first element.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- isEmpty → bool
-
Whether this collection has no elements.
no setterinherited
- isNotEmpty → bool
-
Whether this collection has at least one element.
no setterinherited
-
iterator
→ Iterator<
Arr< T> > -
A new
Iterator
that allows iterating the elements of thisIterable
.no setteroverride -
last
→ Arr<
T> -
The last element.
no setterinherited
- length → int
-
The number of elements in this Iterable.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
single
→ Arr<
T> -
Checks that this iterable has only one element, and returns that element.
no setterinherited
Methods
-
advanceBy(
int n) → Result< (), int> -
Advances the iterator by n elements.
The iterator will have been advanced by n elements when Ok(()) is returned, or a Err(k)
where k is remaining number of steps that could not be advanced because the iterator ran out.
inherited
-
all(
bool f(Arr< T> )) → bool -
inherited
-
any(
bool test(Arr< T> element)) → bool -
Checks whether any element of this iterable satisfies
test
.inherited -
arrayChunks(
int size) → ArrayChunks< Arr< T> > -
Returns an iterator over N elements of the iterator at a time.
The chunks do not overlap. If N does not divide the length of the iterator, then the last up to N-1 elements will
be omitted and can be retrieved from the
.intoRemainder()
function of the iterator.inherited -
cast<
U> () → Iter< U> -
Casts this Iter
inherited
-
chain(
Iterator< Arr< other) → Chain<T> >Arr< T> > -
Takes two iterators and creates a new iterator over both in sequence.
inherited
-
clone(
) → ArrayChunks< T> -
An iterator which is a "clone" of the original iterator. Iterating through the original or the clone will not affect the other.
Do not modify the original collection the original Iterable is based on while iterating. See Clone for more information.
override
-
cmpBy<
U> (Iterator< U> other, int f(Arr<T> , U)) → int -
Lexicographically compares the elements of this Iterator with those of another with respect to the specified comparison function.
Less = -1
Equal = 0
Greater = 1
inherited
-
collectArr(
) → Arr< Arr< T> > -
inherited
-
collectList(
) → List< Arr< T> > -
inherited
-
collectSet(
) → Set< Arr< T> > -
inherited
-
contains(
Object? element) → bool -
Whether the collection contains an element equal to
element
.inherited -
count(
) → int -
Counting the number of iterations and returning it.
inherited
-
cycle(
) → Cycle< Arr< T> > -
Creates an iterator which repeats the elements of the original iterator endlessly.
inherited
-
elementAt(
int index) → Arr< T> -
Returns the
index
th element.inherited -
enumerate(
) → Iter< (int, Arr< T> )> -
Creates an iterator which gives the current iteration count as well as the next value.
inherited
-
eq<
U> (Iterator< U> other) → bool -
Determines if the elements of this Iterator are equal to those of another using "==".
inherited
-
eqBy<
U> (Iterator< U> other, bool f(Arr<T> , U)) → bool -
Determines if the elements of this Iterator are equal to those of another with respect to the specified equality function.
inherited
-
every(
bool test(Arr< T> element)) → bool -
Checks whether every element of this iterable satisfies
test
.inherited -
expand<
U> (Iterable< U> f(Arr<T> )) → Iter<U> -
Expands each element of this Iter into zero or more elements.
inherited
-
filter(
bool f(Arr< T> )) → Iter<Arr< T> > -
Creates an iterator which uses a closure to determine if an element should be yielded.
inherited
-
filterMap<
U extends Object> (Option< U> f(Arr<T> )) → Iter<U> -
Creates an iterator that both filters and maps.
The returned iterator yields only the values for which the supplied closure returns Some(value).
inherited
-
find(
bool f(Arr< T> )) → Option<Arr< T> > -
Searches for an element of an iterator that satisfies a predicate.
inherited
-
findMap<
U extends Object> (Option< U> f(Arr<T> )) → Option<U> -
Applies the function to the elements of iterator and returns the first non-none result.
inherited
-
firstWhere(
bool test(Arr< T> element), {Arr<T> orElse()?}) → Arr<T> -
The first element that satisfies the given predicate
test
.inherited -
flatMap<
U> (Iterator< U> f(Arr<T> )) → FlatMap<Arr< T> , U> -
Creates an iterator that works like map, but flattens nested structure.
inherited
-
fold<
T> (T initialValue, T combine(T previousValue, Arr< T> element)) → T -
Reduces a collection to a single value by iteratively combining each
element of the collection with an existing value
inherited
-
followedBy(
Iterable< Arr< other) → Iter<T> >Arr< T> > -
Creates the lazy concatenation of this Iterator and
other
inherited -
forEach(
void action(Arr< T> element)) → void -
Invokes
action
on each element of this iterable in iteration order.inherited -
inspect(
void f(Arr< T> )) → Iter<Arr< T> > -
Does something with each element of an iterator, passing the value on.
inherited
-
intersperse(
Arr< T> element) → Iter<Arr< T> > -
Creates a new iterator which places a separator between adjacent items of the original iterator.
Similar to join with strings.
inherited
-
intersperseWith(
Arr< T> f()) → Iter<Arr< T> > -
Creates a new iterator which places an item generated by separator between adjacent items of the original iterator.
The closure will be called each time to generate the separator.
inherited
-
intoRemainder(
) → Option< Iter< T> > - Returns an iterator over the remaining elements of the original iterator that are not going to be returned by this iterator. Therefore, the returned iterator will yield at most N-1 elements. i.e. Will return None If the iterator has been completely consumed or all the chunks have not yet been cosumed.
-
isPartitioned(
bool f(Arr< T> )) → bool -
Checks if the elements of this iterator are partitioned according to the given predicate, such that all those that return true precede all those that return false.
inherited
-
isSortedBy(
int f(Arr< T> , Arr<T> )) → bool -
Checks if the elements of this iterator are sorted by f.
That is, for each element f(a,b) and its following element f(b,c), f(a,b) <= f(b,c) must hold. If the iterator yields exactly zero or one element, true is returned.
negative if a < b
zero if a == b
positive if a > b
inherited
-
isSortedByKey<
U extends Comparable< (U> >U f(Arr< T> )) → bool -
Checks if the elements of this iterator are sorted by a key.
That is, for each element f(a) and its following element f(b), f(a) <= f(b) must hold. If the iterator yields exactly zero or one element, true is returned.
negative if a < b
zero if a == b
positive if a > b
inherited
-
join(
[String separator = ""]) → String -
Converts each element to a String and concatenates the strings.
inherited
-
lastOrOption(
) → Option< Arr< T> > -
Consumes the iterator and returns the last element.
inherited
-
lastWhere(
bool test(Arr< T> element), {Arr<T> orElse()?}) → Arr<T> -
The last element that satisfies the given predicate
test
.inherited -
map<
U> (U f(Arr< T> )) → Iter<U> -
Maps each element of this Iter to a new Iter
inherited
-
mapWhile<
U extends Object> (Option< U> f(Arr<T> )) → Iter<U> -
Creates an iterator that both yields elements based on a predicate and maps.
It will call this closure on each element of the iterator, and yield elements while it returns Some(_).
inherited
-
mapWindows<
U> (int size, U f(Arr< Arr< )) → Iter<T> >U> -
Calls the given function f for each contiguous window of
size
over self and returns an iterator over the outputs of f e.g.1, 2, 3, 4
with size 2 will yield windows of1, 2
,2, 3
,3, 4
inherited -
maxBy(
int f(Arr< T> , Arr<T> )) → Option<Arr< T> > -
Returns the element that gives the maximum value with respect to the specified comparison function.
inherited
-
maxByKey<
U extends Comparable< (U> >U f(Arr< T> )) → Option<Arr< T> > -
Returns the element that gives the maximum value from the specified function.
inherited
-
minBy(
int f(Arr< T> , Arr<T> )) → Option<Arr< T> > -
Returns the element that gives the minimum value with respect to the specified comparison function.
inherited
-
minByKey<
U extends Comparable< (U> >U f(Arr< T> )) → Option<Arr< T> > -
Returns the element that gives the minimum value from the specified function.
inherited
-
moveNext(
) → bool -
Advances the iterator to the next element of the iteration.
override
-
next(
) → Option< Arr< T> > -
If the iterator is empty, returns None. Otherwise, returns the next value wrapped in Some.
inherited
-
nextChunk(
int size) → Result< Arr< Arr< , Iter<T> >Arr< >T> > -
Returns the next n elements of the iterator as an Arr,
If there are not enough elements to fill the array then Err is returned containing an iterator over the remaining elements.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nth(
int n) → Option< Arr< T> > -
Returns the nth element of the iterator.
Like most indexing operations, the count starts from zero, so nth(0) returns the first value, nth(1) the second, and so on.
nth() will return None if n is greater than or equal to the length of the iterator.
inherited
-
partition(
bool f(Arr< T> )) → (List<Arr< , List<T> >Arr< )T> > -
Consumes an iterator, creating two collections from it.
partition() returns a pair, all of the elements for which it returned true, and all of the elements for which it returned false.
inherited
-
partitionInPlace(
bool f(Arr< T> )) → int -
Reorders the elements of this iterator in-place according to the given predicate,
such that all those that return true precede all those that return false.
Returns the number of true elements found.
The relative order of partitioned items is not maintained.
inherited
-
peekable(
) → Peekable< Arr< T> > -
Creates an iterator which can use the "peek" to look at the next element of the iterator without consuming it.
inherited
-
position(
bool f(Arr< T> )) → Option<int> -
Searches for an element in an iterator, returning its index.
inherited
-
reduce(
Arr< T> combine(Arr<T> value, Arr<T> element)) → Arr<T> -
Reduces a collection to a single value by iteratively combining elements
of the collection using the provided function.
inherited
-
rev(
) → Iter< Arr< T> > -
Reverses the iterable
inherited
-
rposition(
bool f(Arr< T> )) → Option<int> -
Searches for an element in an iterator from the right, returning its index.
Recommended to use with a list, as it is more efficient, otherwise use position.
inherited
-
scan<
U extends Object> (U initial, Option< U> f(U, Arr<T> )) → Iter<U> -
An iterator which, like fold, holds internal state, but unlike fold, produces a new iterator.
On iteration, the closure will be applied to each element of the iterator and the return value from the closure.
The closure can return Some(value) to yield value, or None to end the iteration.
inherited
-
singleWhere(
bool test(Arr< T> element), {Arr<T> orElse()?}) → Arr<T> -
The single element that satisfies
test
.inherited -
skip(
int count) → Iter< Arr< T> > -
Consumes and skips the first
count
elements.inherited -
skipWhile(
bool f(Arr< T> )) → Iter<Arr< T> > -
Consumes and skips elements while
f
is true and returns the rest.inherited -
stepBy(
int step) → Iter< Arr< T> > -
Creates an iterator starting at the same point, but stepping by the given amount at each iteration.
inherited
-
take(
int count) → Iter< Arr< T> > -
Takes the first
count
elements from the Iter.inherited -
takeWhile(
bool f(Arr< T> )) → Iter<Arr< T> > -
TTakes the first count elements from the Iter while
f
is true.inherited -
toList(
{bool growable = true}) → List< Arr< T> > -
Creates a List containing the elements of this Iterable.
inherited
-
toSet(
) → Set< Arr< T> > -
Creates a Set containing the same elements as this iterable.
inherited
-
toString(
) → String -
Returns a string representation of (some of) the elements of
this
.inherited -
where(
bool f(Arr< T> )) → Iter<Arr< T> > -
Creates an Iter where all the elements satisfy the predicate
f
.inherited -
whereType<
U> () → Iter< U> -
Creates an Iter where all the elements are of Type U.
inherited
-
zip<
U> (Iterator< U> other) → Zip<Arr< T> , U> -
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited