Namespace goog.iter
code »Classes
|
Type Definitions
No description.
Global Functions
code »goog.iter.accumulate ( iterable ) ⇒ !goog.iter.Iterator.<number>
Creates an iterator that returns running totals from the numbers in
iterable
. For example, the array [1, 2, 3, 4, 5]
yields
1 -> 3 -> 6 -> 10 -> 15
.
!goog.iter.Iterator.<number>
iterable
. For example, the array [1, 2, 3, 4, 5]
yields
1 -> 3 -> 6 -> 10 -> 15
.Parameters |
---|
|
Returns |
|
Takes zero or more iterables and returns one iterator that will iterate over
them in the order chained.
Parameters |
---|
|
Returns |
|
Takes a single iterable containing zero or more iterables and returns one
iterator that will iterate over each one in the order given.
Parameters |
---|
|
Returns |
iterable . |
Creates an iterator that returns combinations of elements from
iterable
.
Combinations are obtained by taking the goog.iter#permutations of
iterable
and filtering those whose elements appear in the order they
are encountered in iterable
. For example, the 3-length combinations
of [0,1,2,3]
are [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]
.
iterable
.
Combinations are obtained by taking the goog.iter#permutations of
iterable
and filtering those whose elements appear in the order they
are encountered in iterable
. For example, the 3-length combinations
of [0,1,2,3]
are [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]
.Parameters |
---|
|
Returns |
iterable . |
Creates an iterator that returns combinations of elements from
iterable
, with repeated elements possible.
Combinations are obtained by taking the Cartesian product of length
iterables and filtering those whose elements appear in the order they are
encountered in iterable
. For example, the 2-length combinations of
[1,2,3]
are [[1,1], [1,2], [1,3], [2,2], [2,3], [3,3]]
.
iterable
, with repeated elements possible.
Combinations are obtained by taking the Cartesian product of length
iterables and filtering those whose elements appear in the order they are
encountered in iterable
. For example, the 2-length combinations of
[1,2,3]
are [[1,1], [1,2], [1,3], [2,2], [2,3], [3,3]]
.Parameters |
---|
|
Returns |
iterable . |
Creates an iterator that filters iterable
based on a series of
selectors
. On each call to next()
, one item is taken from
both the iterable
and selectors
iterators. If the item from
selectors
evaluates to true, the item from iterable
is given.
Otherwise, it is skipped. Once either iterable
or selectors
is exhausted, subsequent calls to next()
will throw
goog.iter.StopIteration
.
iterable
based on a series of
selectors
. On each call to next()
, one item is taken from
both the iterable
and selectors
iterators. If the item from
selectors
evaluates to true, the item from iterable
is given.
Otherwise, it is skipped. Once either iterable
or selectors
is exhausted, subsequent calls to next()
will throw
goog.iter.StopIteration
.Parameters |
---|
|
Returns |
|
Creates an iterator that is advanced count
steps ahead. Consumed
values are silently discarded. If count
is greater than the number
of elements in iterable
, an empty iterator is returned. Subsequent
calls to next()
will throw goog.iter.StopIteration
.
count
steps ahead. Consumed
values are silently discarded. If count
is greater than the number
of elements in iterable
, an empty iterator is returned. Subsequent
calls to next()
will throw goog.iter.StopIteration
.Parameters |
---|
|
Returns |
|
code »goog.iter.count ( opt_start, opt_step ) ⇒ !goog.iter.Iterator.<number>
Creates an iterator that counts indefinitely from a starting value.
!goog.iter.Iterator.<number>
Create an iterator to cycle over the iterable's elements indefinitely.
For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ...
Parameters |
---|
|
Returns |
iterable . |
Builds a new iterator that iterates over the original, but skips elements as
long as a supplied function returns true.
Parameters |
---|
|
Returns |
f is true. |
Creates an iterator that returns arrays containing a count and an element
obtained from the given iterable
.
iterable
.Parameters |
---|
|
Returns |
|
Iterates over two iterables and returns true if they contain the same
sequence of elements and have the same length.
Parameters |
---|
|
Returns |
|
Goes through the values in the iterator. Calls f for each of these and if any
of them returns false this returns false (without checking the rest). If all
return true this will return true.
Parameters |
---|
|
Returns |
|
Calls a function for every element in the iterator, and if the function
returns true adds the element to a new iterator.
Parameters |
---|
|
Returns |
|
Calls a function for every element in the iterator, and if the function
returns false adds the element to a new iterator.
Parameters |
---|
|
Returns |
|
Calls a function for each element in the iterator with the element of the
iterator passed as argument.
Parameters |
---|
|
Creates an iterator that returns arrays containing elements from the
iterable
grouped by a key value. For iterables with repeated
elements (i.e. sorted according to a particular key function), this function
has a uniq
-like effect. For example, grouping the array:
[A, B, B, C, C, A]
produces
[A, [A]], [B, [B, B]], [C, [C, C]], [A, [A]]
.
iterable
grouped by a key value. For iterables with repeated
elements (i.e. sorted according to a particular key function), this function
has a uniq
-like effect. For example, grouping the array:
[A, B, B, C, C, A]
produces
[A, [A]], [B, [B, B]], [C, [C, C]], [A, [A]]
.Parameters |
---|
|
Returns |
|
Checks an array for duplicate elements.
Parameters |
---|
|
Returns |
|
Joins the values in a iterator with a delimiter.
Parameters |
---|
|
Returns |
|
Creates an iterator that returns the first limitSize
elements from an
iterable. If this number is greater than the number of elements in the
iterable, all the elements are returned.
limitSize
elements from an
iterable. If this number is greater than the number of elements in the
iterable, all the elements are returned.Parameters |
---|
|
Returns |
limitSize elements. |
For every element in the iterator call a function and return a new iterator
with that value.
Parameters |
---|
|
Returns |
|
Advances the iterator to the next position, returning the given default value
instead of throwing an exception if the iterator has no more entries.
Parameters |
---|
|
Returns |
|
Creates an iterator that returns permutations of elements in
iterable
.
Permutations are obtained by taking the Cartesian product of
opt_length
iterables and filtering out those with repeated
elements. For example, the permutations of [1,2,3]
are
[[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]
.
iterable
.
Permutations are obtained by taking the Cartesian product of
opt_length
iterables and filtering out those with repeated
elements. For example, the permutations of [1,2,3]
are
[[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]
.Parameters |
---|
|
Returns |
iterable . |
Cartesian product of zero or more sets. Gives an iterator that gives every
combination of one element chosen from each set. For example,
([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]).
Parameters |
---|
|
Returns |
|
code »goog.iter.range ( startOrStop, opt_stop, opt_step ) ⇒ !goog.iter.Iterator.<number>
Creates a new iterator that returns the values in a range. This function
can take 1, 2 or 3 arguments:
range(5) same as range(0, 5, 1)
range(2, 5) same as range(2, 5, 1)
!goog.iter.Iterator.<number>
Parameters |
---|
|
Returns |
|
Passes every element of an iterator into a function and accumulates the
result.
Parameters |
---|
|
Returns |
|
Creates an iterator that returns the same object or value repeatedly.
Parameters |
---|
|
Returns |
|
Creates an iterator that returns a range of elements from an iterable.
Similar to goog.array#slice but does not support negative indexes.
Parameters |
---|
|
Returns |
|
Goes through the values in the iterator. Calls f for each of these, and if
any of them returns true, this returns true (without checking the rest). If
all return false this will return false.
Parameters |
---|
|
Returns |
|
Gives an iterator that gives the result of calling the given function
f
with the arguments taken from the next element from
iterable
(the elements are expected to also be iterables).
Similar to goog.iter#map but allows the function to accept multiple
arguments from the iterable.
f
with the arguments taken from the next element from
iterable
(the elements are expected to also be iterables).
Similar to goog.iter#map but allows the function to accept multiple
arguments from the iterable.Parameters |
---|
|
Returns |
|
Builds a new iterator that iterates over the original, but only as long as a
supplied function returns true.
Parameters |
---|
|
Returns |
|
Returns an array of iterators each of which can iterate over the values in
iterable
without advancing the others.
iterable
without advancing the others.Parameters |
---|
|
Returns |
|
Converts the iterator to an array
Parameters |
---|
|
Returns |
|
Returns an iterator that knows how to iterate over the values in the object.
Parameters |
---|
|
Returns |
iterable . |
Creates an iterator that returns arrays containing the ith elements from the
provided iterables. The returned arrays will be the same size as the number
of iterables given in var_args
. Once the shortest iterable is
exhausted, subsequent calls to next()
will throw
goog.iter.StopIteration
.
var_args
. Once the shortest iterable is
exhausted, subsequent calls to next()
will throw
goog.iter.StopIteration
.Parameters |
---|
|
Returns |
|
Creates an iterator that returns arrays containing the ith elements from the
provided iterables. The returned arrays will be the same size as the number
of iterables given in var_args
. Shorter iterables will be extended
with fillValue
. Once the longest iterable is exhausted, subsequent
calls to next()
will throw goog.iter.StopIteration
.
var_args
. Shorter iterables will be extended
with fillValue
. Once the longest iterable is exhausted, subsequent
calls to next()
will throw goog.iter.StopIteration
.Parameters |
---|
|
Returns |
|