goog.iter
Functions
accumulate( iterable ) → goog.iter.Iterator<number>
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
.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
| ||||
See Also | http://docs.python.org/3.2/library/itertools.html#itertools.accumulate |
chain<VALUE>( ...var_args ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Takes zero or more iterables and returns one iterator that will iterate over them in the order chained.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
chainFromIterable<VALUE>( iterable ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
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 |
| ||||
See Also |
combinations<VALUE>( iterable, length ) → goog.iter.Iterator<Array<(VALUE|null)>>
goog.iter.Iterator<Array<(VALUE|null)>>
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]]
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.combinations |
combinationsWithReplacement<VALUE>( iterable, length ) → goog.iter.Iterator<Array<(VALUE|null)>>
goog.iter.Iterator<Array<(VALUE|null)>>
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]]
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also |
compress<VALUE>( iterable, selectors ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
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 return
goog.iter.ES6_ITERATOR_DONE
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.compress |
consume<VALUE>( iterable, count ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
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 return goog.iter.ES6_ITERATOR_DONE
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
count( opt_start, opt_step ) → goog.iter.Iterator<number>
goog.iter.Iterator<number>
Creates an iterator that counts indefinitely from a starting value.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.count |
createEs6IteratorYield<VALUE>( value ) → IIterableResult<(VALUE|null)>
IIterableResult<(VALUE|null)>
Wraps a VALUE in the ES6 Iterator protocol's IIterableResult container, including the compiler-mandated 'done' key, set to false.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
cycle<VALUE>( iterable ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
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 |
| ||||
See Also | : http://docs.python.org/library/itertools.html#itertools.cycle. |
dropWhile<THIS, VALUE>( iterable, f, opt_obj ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Builds a new iterator that iterates over the original, but skips elements as long as a supplied function returns true.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
enumerate<VALUE>( iterable, opt_start ) → goog.iter.Iterator<Array<?>>
goog.iter.Iterator<Array<?>>
Creates an iterator that returns arrays containing a count and an element
obtained from the given iterable
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also |
equals<VALUE>( iterable1, iterable2, opt_equalsFn ) → boolean
boolean
Iterates over two iterables and returns true if they contain the same sequence of elements and have the same length.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
every<THIS, VALUE>( iterable, f, opt_obj ) → boolean
boolean
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 |
|
filter<THIS, VALUE>( iterable, f, opt_obj ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Calls a function for every element in the iterator, and if the function returns true adds the element to a new iterator.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
filterFalse<THIS, VALUE>( iterable, f, opt_obj ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Calls a function for every element in the iterator, and if the function returns false adds the element to a new iterator.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
forEach<THIS, VALUE>( iterable, f, opt_obj ) → void
void
Calls a function for each element in the iterator with the element of the iterator passed as argument.
Parameters |
|
---|
groupBy<KEY, VALUE>( iterable, opt_keyFunc ) → goog.iter.Iterator<Array<?>>
goog.iter.Iterator<Array<?>>
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]]
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.groupby |
join<VALUE>( iterable, deliminator ) → string
string
limit<VALUE>( iterable, limitSize ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | <http://goo.gl/V0sihp Inspired by the limit iterator in Guava.> |
map<THIS, VALUE, RESULT>( iterable, f, opt_obj ) → goog.iter.Iterator<(RESULT|null)>
goog.iter.Iterator<(RESULT|null)>
For every element in the iterator call a function and return a new iterator with that value.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
nextOrValue<VALUE>( iterable, defaultValue ) → VALUE
VALUE
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 |
|
permutations<VALUE>( iterable, opt_length ) → goog.iter.Iterator<Array<(VALUE|null)>>
goog.iter.Iterator<Array<(VALUE|null)>>
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]]
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.permutations |
product<VALUE>( ...var_args ) → goog.iter.Iterator<Array<(VALUE|null)>>
goog.iter.Iterator<Array<(VALUE|null)>>
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 |
| ||||
See Also | http://docs.python.org/library/itertools.html#itertools.product |
range( startOrStop, opt_stop, opt_step ) → goog.iter.Iterator<number>
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)
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
reduce<THIS, VALUE, RVALUE>( iterable, f, val, opt_obj ) → RVALUE
RVALUE
Passes every element of an iterator into a function and accumulates the result.
Parameters |
| ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
repeat<VALUE>( value ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Creates an iterator that returns the same object or value repeatedly.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
slice<VALUE>( iterable, start, opt_end ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
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 |
|
some<THIS, VALUE>( iterable, f, opt_obj ) → boolean
boolean
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 |
|
starMap<THIS, RESULT>( iterable, f, opt_obj ) → goog.iter.Iterator<(RESULT|null)>
goog.iter.Iterator<(RESULT|null)>
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.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
takeWhile<THIS, VALUE>( iterable, f, opt_obj ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Builds a new iterator that iterates over the original, but only as long as a supplied function returns true.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
tee<VALUE>( iterable, opt_num ) → Array<(goog.iter.Iterator<(VALUE|null)>|null)>
Array<(goog.iter.Iterator<(VALUE|null)>|null)>
Returns an array of iterators each of which can iterate over the values in
iterable
without advancing the others.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.tee |
toArray<VALUE>( iterable ) → Array<(VALUE|null)>
Array<(VALUE|null)>
toIterator<VALUE>( iterable ) → goog.iter.Iterator<(VALUE|null)>
goog.iter.Iterator<(VALUE|null)>
Returns an iterator that knows how to iterate over the values in the object.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
zip<VALUE>( ...var_args ) → goog.iter.Iterator<Array<(VALUE|null)>>
goog.iter.Iterator<Array<(VALUE|null)>>
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 return
goog.iter.ES6_ITERATOR_DONE
.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
| ||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.izip |
zipLongest<VALUE>( fillValue, ...var_args ) → goog.iter.Iterator<Array<(VALUE|null)>>
goog.iter.Iterator<Array<(VALUE|null)>>
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 return goog.iter.ES6_ITERATOR_DONE
.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
| ||||||||
See Also | http://docs.python.org/2/library/itertools.html#itertools.izip_longest |
Properties
ES6_ITERATOR_DONE → IIterableResult<?>
IIterableResult<?>
An ES6 Iteration protocol result indicating iteration has completed for an iterator.
Iterable → ({length: number}|{__iterator__: ?})
({length: number}|{__iterator__: ?})
No information.