1 line
147 KiB
JavaScript
1 line
147 KiB
JavaScript
["^ ","~:resource-id",["~:shadow.build.classpath/resource","goog/iter/iter.js"],"~:js","goog.provide(\"goog.iter\");\ngoog.provide(\"goog.iter.Iterable\");\ngoog.provide(\"goog.iter.Iterator\");\ngoog.require(\"goog.array\");\ngoog.require(\"goog.asserts\");\ngoog.require(\"goog.debug\");\ngoog.require(\"goog.functions\");\ngoog.require(\"goog.math\");\ngoog.iter.Iterable;\ngoog.iter.Iterator = function() {\n};\ngoog.iter.Iterator.prototype.next = function() {\n return goog.iter.ES6_ITERATOR_DONE;\n};\ngoog.iter.ES6_ITERATOR_DONE = goog.debug.freeze({done:true, value:undefined});\ngoog.iter.createEs6IteratorYield = function(value) {\n return {value, done:false};\n};\ngoog.iter.Iterator.prototype.__iterator__ = function(opt_keys) {\n return this;\n};\ngoog.iter.toIterator = function(iterable) {\n if (iterable instanceof goog.iter.Iterator) {\n return iterable;\n }\n if (typeof iterable.__iterator__ == \"function\") {\n return iterable.__iterator__(false);\n }\n if (goog.isArrayLike(iterable)) {\n const like = iterable;\n let i = 0;\n const newIter = new goog.iter.Iterator();\n newIter.next = function() {\n while (true) {\n if (i >= like.length) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n if (!(i in like)) {\n i++;\n continue;\n }\n return goog.iter.createEs6IteratorYield(like[i++]);\n }\n };\n return newIter;\n }\n throw new Error(\"Not implemented\");\n};\ngoog.iter.forEach = function(iterable, f, opt_obj) {\n if (goog.isArrayLike(iterable)) {\n goog.array.forEach(iterable, f, opt_obj);\n } else {\n const iterator = goog.iter.toIterator(iterable);\n while (true) {\n const {done, value} = iterator.next();\n if (done) {\n return;\n }\n f.call(opt_obj, value, undefined, iterator);\n }\n }\n};\ngoog.iter.filter = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n const newIter = new goog.iter.Iterator();\n newIter.next = function() {\n while (true) {\n const {done, value} = iterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n if (f.call(opt_obj, value, undefined, iterator)) {\n return goog.iter.createEs6IteratorYield(value);\n }\n }\n };\n return newIter;\n};\ngoog.iter.filterFalse = function(iterable, f, opt_obj) {\n return goog.iter.filter(iterable, goog.functions.not(f), opt_obj);\n};\ngoog.iter.range = function(startOrStop, opt_stop, opt_step) {\n let start = 0;\n let stop = startOrStop;\n let step = opt_step || 1;\n if (arguments.length > 1) {\n start = startOrStop;\n stop = +opt_stop;\n }\n if (step == 0) {\n throw new Error(\"Range step argument must not be zero\");\n }\n const newIter = new goog.iter.Iterator();\n newIter.next = function() {\n if (step > 0 && start >= stop || step < 0 && start <= stop) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const rv = start;\n start += step;\n return goog.iter.createEs6IteratorYield(rv);\n };\n return newIter;\n};\ngoog.iter.join = function(iterable, deliminator) {\n return goog.iter.toArray(iterable).join(deliminator);\n};\ngoog.iter.map = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n const newIter = new goog.iter.Iterator();\n newIter.next = function() {\n const {done, value} = iterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const mappedVal = f.call(opt_obj, value, undefined, iterator);\n return goog.iter.createEs6IteratorYield(mappedVal);\n };\n return newIter;\n};\ngoog.iter.reduce = function(iterable, f, val, opt_obj) {\n let rval = val;\n goog.iter.forEach(iterable, function(val) {\n rval = f.call(opt_obj, rval, val);\n });\n return rval;\n};\ngoog.iter.some = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n while (true) {\n const {done, value} = iterator.next();\n if (done) {\n return false;\n }\n if (f.call(opt_obj, value, undefined, iterator)) {\n return true;\n }\n }\n};\ngoog.iter.every = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n while (true) {\n const {done, value} = iterator.next();\n if (done) {\n return true;\n }\n if (!f.call(opt_obj, value, undefined, iterator)) {\n return false;\n }\n }\n};\ngoog.iter.chain = function(var_args) {\n return goog.iter.chainFromIterable(arguments);\n};\ngoog.iter.chainFromIterable = function(iterable) {\n const iteratorOfIterators = goog.iter.toIterator(iterable);\n const iter = new goog.iter.Iterator();\n let current = null;\n iter.next = function() {\n while (true) {\n if (current == null) {\n const it = iteratorOfIterators.next();\n if (it.done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const value = it.value;\n current = goog.iter.toIterator(value);\n }\n const it = current.next();\n if (it.done) {\n current = null;\n continue;\n }\n const value = it.value;\n return goog.iter.createEs6IteratorYield(value);\n }\n };\n return iter;\n};\ngoog.iter.dropWhile = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n const newIter = new goog.iter.Iterator();\n let dropping = true;\n newIter.next = function() {\n while (true) {\n const {done, value} = iterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n if (dropping && f.call(opt_obj, value, undefined, iterator)) {\n continue;\n } else {\n dropping = false;\n }\n return goog.iter.createEs6IteratorYield(value);\n }\n };\n return newIter;\n};\ngoog.iter.takeWhile = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n const iter = new goog.iter.Iterator();\n iter.next = function() {\n const {done, value} = iterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n if (f.call(opt_obj, value, undefined, iterator)) {\n return goog.iter.createEs6IteratorYield(value);\n }\n return goog.iter.ES6_ITERATOR_DONE;\n };\n return iter;\n};\ngoog.iter.toArray = function(iterable) {\n if (goog.isArrayLike(iterable)) {\n return goog.array.toArray(iterable);\n }\n iterable = goog.iter.toIterator(iterable);\n const array = [];\n goog.iter.forEach(iterable, function(val) {\n array.push(val);\n });\n return array;\n};\ngoog.iter.equals = function(iterable1, iterable2, opt_equalsFn) {\n const fillValue = {};\n const pairs = goog.iter.zipLongest(fillValue, iterable1, iterable2);\n const equalsFn = opt_equalsFn || goog.array.defaultCompareEquality;\n return goog.iter.every(pairs, function(pair) {\n return equalsFn(pair[0], pair[1]);\n });\n};\ngoog.iter.nextOrValue = function(iterable, defaultValue) {\n const iterator = goog.iter.toIterator(iterable);\n const {done, value} = iterator.next();\n if (done) {\n return defaultValue;\n }\n return value;\n};\ngoog.iter.product = function(var_args) {\n const someArrayEmpty = Array.prototype.some.call(arguments, function(arr) {\n return !arr.length;\n });\n if (someArrayEmpty || !arguments.length) {\n return new goog.iter.Iterator();\n }\n const iter = new goog.iter.Iterator();\n const arrays = arguments;\n let indices = goog.array.repeat(0, arrays.length);\n iter.next = function() {\n if (indices) {\n const retVal = goog.array.map(indices, function(valueIndex, arrayIndex) {\n return arrays[arrayIndex][valueIndex];\n });\n for (let i = indices.length - 1; i >= 0; i--) {\n goog.asserts.assert(indices);\n if (indices[i] < arrays[i].length - 1) {\n indices[i]++;\n break;\n }\n if (i == 0) {\n indices = null;\n break;\n }\n indices[i] = 0;\n }\n return goog.iter.createEs6IteratorYield(retVal);\n }\n return goog.iter.ES6_ITERATOR_DONE;\n };\n return iter;\n};\ngoog.iter.cycle = function(iterable) {\n const baseIterator = goog.iter.toIterator(iterable);\n const cache = [];\n let cacheIndex = 0;\n const iter = new goog.iter.Iterator();\n let useCache = false;\n iter.next = function() {\n let returnElement = null;\n if (!useCache) {\n const it = baseIterator.next();\n if (it.done) {\n if (goog.array.isEmpty(cache)) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n useCache = true;\n } else {\n cache.push(it.value);\n return it;\n }\n }\n returnElement = cache[cacheIndex];\n cacheIndex = (cacheIndex + 1) % cache.length;\n return goog.iter.createEs6IteratorYield(returnElement);\n };\n return iter;\n};\ngoog.iter.count = function(opt_start, opt_step) {\n let counter = opt_start || 0;\n const step = opt_step !== undefined ? opt_step : 1;\n const iter = new goog.iter.Iterator();\n iter.next = function() {\n const returnValue = counter;\n counter += step;\n return goog.iter.createEs6IteratorYield(returnValue);\n };\n return iter;\n};\ngoog.iter.repeat = function(value) {\n const iter = new goog.iter.Iterator();\n iter.next = function() {\n return goog.iter.createEs6IteratorYield(value);\n };\n return iter;\n};\ngoog.iter.accumulate = function(iterable) {\n const iterator = goog.iter.toIterator(iterable);\n let total = 0;\n const iter = new goog.iter.Iterator();\n iter.next = function() {\n const {done, value} = iterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n total += value;\n return goog.iter.createEs6IteratorYield(total);\n };\n return iter;\n};\ngoog.iter.zip = function(var_args) {\n const args = arguments;\n const iter = new goog.iter.Iterator();\n if (args.length > 0) {\n const iterators = goog.array.map(args, goog.iter.toIterator);\n let allDone = false;\n iter.next = function() {\n if (allDone) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const arr = [];\n for (let i = 0, iterator; iterator = iterators[i++];) {\n const it = iterator.next();\n if (it.done) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n arr.push(it.value);\n }\n return goog.iter.createEs6IteratorYield(arr);\n };\n }\n return iter;\n};\ngoog.iter.zipLongest = function(fillValue, var_args) {\n const args = Array.prototype.slice.call(arguments, 1);\n const iter = new goog.iter.Iterator();\n if (args.length > 0) {\n const iterators = goog.array.map(args, goog.iter.toIterator);\n let allDone = false;\n iter.next = function() {\n if (allDone) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n let iteratorsHaveValues = false;\n const arr = [];\n for (let i = 0, iterator; iterator = iterators[i++];) {\n const it = iterator.next();\n if (it.done) {\n arr.push(fillValue);\n continue;\n }\n arr.push(it.value);\n iteratorsHaveValues = true;\n }\n if (!iteratorsHaveValues) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n return goog.iter.createEs6IteratorYield(arr);\n };\n }\n return iter;\n};\ngoog.iter.compress = function(iterable, selectors) {\n const valueIterator = goog.iter.toIterator(iterable);\n const selectorIterator = goog.iter.toIterator(selectors);\n const iter = new goog.iter.Iterator();\n let allDone = false;\n iter.next = function() {\n if (allDone) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n while (true) {\n const valIt = valueIterator.next();\n if (valIt.done) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const selectorIt = selectorIterator.next();\n if (selectorIt.done) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const val = valIt.value;\n const selectorVal = selectorIt.value;\n if (selectorVal) {\n return goog.iter.createEs6IteratorYield(val);\n }\n }\n };\n return iter;\n};\ngoog.iter.GroupByIterator_ = function(iterable, opt_keyFunc) {\n this.iterator = goog.iter.toIterator(iterable);\n this.keyFunc = opt_keyFunc || goog.functions.identity;\n this.targetKey;\n this.currentKey;\n this.currentValue;\n};\ngoog.inherits(goog.iter.GroupByIterator_, goog.iter.Iterator);\ngoog.iter.GroupByIterator_.prototype.next = function() {\n while (this.currentKey == this.targetKey) {\n const it = this.iterator.next();\n if (it.done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n this.currentValue = it.value;\n this.currentKey = this.keyFunc(this.currentValue);\n }\n this.targetKey = this.currentKey;\n return goog.iter.createEs6IteratorYield([this.currentKey, this.groupItems_(this.targetKey)]);\n};\ngoog.iter.GroupByIterator_.prototype.groupItems_ = function(targetKey) {\n const arr = [];\n while (this.currentKey == targetKey) {\n arr.push(this.currentValue);\n const it = this.iterator.next();\n if (it.done) {\n break;\n }\n this.currentValue = it.value;\n this.currentKey = this.keyFunc(this.currentValue);\n }\n return arr;\n};\ngoog.iter.groupBy = function(iterable, opt_keyFunc) {\n return new goog.iter.GroupByIterator_(iterable, opt_keyFunc);\n};\ngoog.iter.starMap = function(iterable, f, opt_obj) {\n const iterator = goog.iter.toIterator(iterable);\n const iter = new goog.iter.Iterator();\n iter.next = function() {\n const it = iterator.next();\n if (it.done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const args = goog.iter.toArray(it.value);\n const value = f.apply(opt_obj, [].concat(args, undefined, iterator));\n return goog.iter.createEs6IteratorYield(value);\n };\n return iter;\n};\ngoog.iter.tee = function(iterable, opt_num) {\n const iterator = goog.iter.toIterator(iterable);\n const num = typeof opt_num === \"number\" ? opt_num : 2;\n const buffers = goog.array.map(goog.array.range(num), function() {\n return [];\n });\n function addNextIteratorValueToBuffers() {\n const {done, value} = iterator.next();\n if (done) {\n return false;\n }\n for (let i = 0, buffer; buffer = buffers[i++];) {\n buffer.push(value);\n }\n return true;\n }\n function createIterator(buffer) {\n const iter = new goog.iter.Iterator();\n iter.next = function() {\n if (goog.array.isEmpty(buffer)) {\n const added = addNextIteratorValueToBuffers();\n if (!added) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n }\n goog.asserts.assert(!goog.array.isEmpty(buffer));\n return goog.iter.createEs6IteratorYield(buffer.shift());\n };\n return iter;\n }\n return goog.array.map(buffers, createIterator);\n};\ngoog.iter.enumerate = function(iterable, opt_start) {\n return goog.iter.zip(goog.iter.count(opt_start), iterable);\n};\ngoog.iter.limit = function(iterable, limitSize) {\n goog.asserts.assert(goog.math.isInt(limitSize) && limitSize >= 0);\n const iterator = goog.iter.toIterator(iterable);\n const iter = new goog.iter.Iterator();\n let remaining = limitSize;\n iter.next = function() {\n if (remaining-- > 0) {\n return iterator.next();\n }\n return goog.iter.ES6_ITERATOR_DONE;\n };\n return iter;\n};\ngoog.iter.consume = function(iterable, count) {\n goog.asserts.assert(goog.math.isInt(count) && count >= 0);\n const iterator = goog.iter.toIterator(iterable);\n while (count-- > 0) {\n goog.iter.nextOrValue(iterator, null);\n }\n return iterator;\n};\ngoog.iter.slice = function(iterable, start, opt_end) {\n goog.asserts.assert(goog.math.isInt(start) && start >= 0);\n let iterator = goog.iter.consume(iterable, start);\n if (typeof opt_end === \"number\") {\n goog.asserts.assert(goog.math.isInt(opt_end) && opt_end >= start);\n iterator = goog.iter.limit(iterator, opt_end - start);\n }\n return iterator;\n};\ngoog.iter.hasDuplicates_ = function(arr) {\n const deduped = [];\n goog.array.removeDuplicates(arr, deduped);\n return arr.length != deduped.length;\n};\ngoog.iter.permutations = function(iterable, opt_length) {\n const elements = goog.iter.toArray(iterable);\n const length = typeof opt_length === \"number\" ? opt_length : elements.length;\n const sets = goog.array.repeat(elements, length);\n const product = goog.iter.product.apply(undefined, sets);\n return goog.iter.filter(product, function(arr) {\n return !goog.iter.hasDuplicates_(arr);\n });\n};\ngoog.iter.combinations = function(iterable, length) {\n const elements = goog.iter.toArray(iterable);\n const indexes = goog.iter.range(elements.length);\n const indexIterator = goog.iter.permutations(indexes, length);\n const sortedIndexIterator = goog.iter.filter(indexIterator, function(arr) {\n return goog.array.isSorted(arr);\n });\n const iter = new goog.iter.Iterator();\n function getIndexFromElements(index) {\n return elements[index];\n }\n iter.next = function() {\n const {done, value} = sortedIndexIterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n return goog.iter.createEs6IteratorYield(goog.array.map(value, getIndexFromElements));\n };\n return iter;\n};\ngoog.iter.combinationsWithReplacement = function(iterable, length) {\n const elements = goog.iter.toArray(iterable);\n const indexes = goog.array.range(elements.length);\n const sets = goog.array.repeat(indexes, length);\n const indexIterator = goog.iter.product.apply(undefined, sets);\n const sortedIndexIterator = goog.iter.filter(indexIterator, function(arr) {\n return goog.array.isSorted(arr);\n });\n const iter = new goog.iter.Iterator();\n function getIndexFromElements(index) {\n return elements[index];\n }\n iter.next = function() {\n const {done, value} = sortedIndexIterator.next();\n if (done) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n return goog.iter.createEs6IteratorYield(goog.array.map(value, getIndexFromElements));\n };\n return iter;\n};\n","~:source","/**\n * @license\n * Copyright The Closure Library Authors.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/**\n * @fileoverview Python style iteration utilities.\n */\n\n\ngoog.provide('goog.iter');\ngoog.provide('goog.iter.Iterable');\ngoog.provide('goog.iter.Iterator');\n\ngoog.require('goog.array');\ngoog.require('goog.asserts');\ngoog.require('goog.debug');\ngoog.require('goog.functions');\ngoog.require('goog.math');\n\n\n/**\n * @typedef {{length:number}|{__iterator__}}\n */\ngoog.iter.Iterable;\n\n\n/**\n * Class/interface for iterators.\n * @constructor\n * @template VALUE\n * @implements {Iterator<VALUE>}\n * @deprecated Use objects implementing JavaScript iterable protocol introduced\n * in ES6.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\n */\ngoog.iter.Iterator = function() {};\n\n\n/**\n * Returns the next value of the iteration as an an ES6 IIterableResult.\n * @return {!IIterableResult<VALUE>}\n * @override\n */\ngoog.iter.Iterator.prototype.next = function() {\n 'use strict';\n return goog.iter.ES6_ITERATOR_DONE;\n};\n\n\n/**\n * An ES6 Iteration protocol result indicating iteration has completed for an\n * iterator.\n * @const {!IIterableResult<?>}\n */\ngoog.iter.ES6_ITERATOR_DONE = goog.debug.freeze({done: true, value: undefined});\n\n\n/**\n * Wraps a VALUE in the ES6 Iterator protocol's IIterableResult container,\n * including the compiler-mandated 'done' key, set to false.\n * @param {VALUE} value\n * @return {!IIterableResult<VALUE>} An ES6 Iteration Protocol compatible result\n * object, indicating iteration is not done.\n * @template VALUE\n */\ngoog.iter.createEs6IteratorYield = function(value) {\n return {value, done: false};\n};\n\n\n/**\n * Returns the `Iterator` object itself. This is used to implement\n * the iterator protocol in JavaScript 1.7\n * @param {boolean=} opt_keys Whether to return the keys or values. Default is\n * to only return the values. This is being used by the for-in loop (true)\n * and the for-each-in loop (false). Even though the param gives a hint\n * about what the iterator will return there is no guarantee that it will\n * return the keys when true is passed.\n * @return {!goog.iter.Iterator<VALUE>} The object itself.\n */\ngoog.iter.Iterator.prototype.__iterator__ = function(opt_keys) {\n 'use strict';\n return this;\n};\n\n\n/**\n * Returns an iterator that knows how to iterate over the values in the object.\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable If the\n * object is an iterator it will be returned as is. If the object has an\n * `__iterator__` method that will be called to get the value\n * iterator. If the object is an array-like object we create an iterator\n * for that.\n * @return {!goog.iter.Iterator<VALUE>} An iterator that knows how to iterate\n * over the values in `iterable`.\n * @template VALUE\n */\ngoog.iter.toIterator = function(iterable) {\n 'use strict';\n if (iterable instanceof goog.iter.Iterator) {\n return iterable;\n }\n if (typeof iterable.__iterator__ == 'function') {\n return /** @type {{__iterator__:function(this:?, boolean=)}} */ (iterable)\n .__iterator__(false);\n }\n if (goog.isArrayLike(iterable)) {\n const like = /** @type {!IArrayLike<number|string>} */ (iterable);\n let i = 0;\n const newIter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n newIter.next = function() {\n 'use strict';\n while (true) {\n if (i >= like.length) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n // Don't include deleted elements.\n if (!(i in like)) {\n i++;\n continue;\n }\n return goog.iter.createEs6IteratorYield(like[i++]);\n }\n };\n\n return newIter;\n }\n\n\n // TODO(arv): Should we fall back on goog.structs.getValues()?\n throw new Error('Not implemented');\n};\n\n\n/**\n * Calls a function for each element in the iterator with the element of the\n * iterator passed as argument.\n *\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * to iterate over. If the iterable is an object `toIterator` will be\n * called on it.\n * @param {function(this:THIS,VALUE,?,!goog.iter.Iterator<VALUE>)} f\n * The function to call for every element. This function takes 3 arguments\n * (the element, undefined, and the iterator) and the return value is\n * irrelevant. The reason for passing undefined as the second argument is\n * so that the same function can be used in {@see goog.array.forEach} as\n * well as others. The third parameter is of type \"number\" for\n * arraylike objects, undefined, otherwise.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @template THIS, VALUE\n */\ngoog.iter.forEach = function(iterable, f, opt_obj) {\n 'use strict';\n if (goog.isArrayLike(iterable)) {\n // NOTES: this passes the index number to the second parameter\n // of the callback contrary to the documentation above.\n goog.array.forEach(\n /** @type {IArrayLike<?>} */ (iterable), f, opt_obj);\n } else {\n const iterator = goog.iter.toIterator(iterable);\n while (true) {\n const {done, value} = iterator.next();\n if (done) return;\n f.call(opt_obj, value, undefined, iterator);\n }\n }\n};\n\n\n/**\n * Calls a function for every element in the iterator, and if the function\n * returns true adds the element to a new iterator.\n *\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * to iterate over.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\n * The function to call for every element. This function takes 3 arguments\n * (the element, undefined, and the iterator) and should return a boolean.\n * If the return value is true the element will be included in the returned\n * iterator. If it is false the element is not included.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator in which only elements\n * that passed the test are present.\n * @template THIS, VALUE\n */\ngoog.iter.filter = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n const newIter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n newIter.next = function() {\n 'use strict';\n while (true) {\n const {done, value} = iterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n if (f.call(opt_obj, value, undefined, iterator)) {\n return goog.iter.createEs6IteratorYield(value);\n }\n }\n };\n\n return newIter;\n};\n\n\n/**\n * Calls a function for every element in the iterator, and if the function\n * returns false adds the element to a new iterator.\n *\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * to iterate over.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\n * The function to call for every element. This function takes 3 arguments\n * (the element, undefined, and the iterator) and should return a boolean.\n * If the return value is false the element will be included in the returned\n * iterator. If it is true the element is not included.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator in which only elements\n * that did not pass the test are present.\n * @template THIS, VALUE\n */\ngoog.iter.filterFalse = function(iterable, f, opt_obj) {\n 'use strict';\n return goog.iter.filter(iterable, goog.functions.not(f), opt_obj);\n};\n\n\n/**\n * Creates a new iterator that returns the values in a range. This function\n * can take 1, 2 or 3 arguments:\n * <pre>\n * range(5) same as range(0, 5, 1)\n * range(2, 5) same as range(2, 5, 1)\n * </pre>\n *\n * @param {number} startOrStop The stop value if only one argument is provided.\n * The start value if 2 or more arguments are provided. If only one\n * argument is used the start value is 0.\n * @param {number=} opt_stop The stop value. If left out then the first\n * argument is used as the stop value.\n * @param {number=} opt_step The number to increment with between each call to\n * next. This can be negative.\n * @return {!goog.iter.Iterator<number>} A new iterator that returns the values\n * in the range.\n */\ngoog.iter.range = function(startOrStop, opt_stop, opt_step) {\n 'use strict';\n let start = 0;\n let stop = startOrStop;\n let step = opt_step || 1;\n if (arguments.length > 1) {\n start = startOrStop;\n stop = +opt_stop;\n }\n if (step == 0) {\n throw new Error('Range step argument must not be zero');\n }\n\n const newIter =\n /** @type {!goog.iter.Iterator<number>} */ (new goog.iter.Iterator());\n /**\n * @return {!IIterableResult<number>}\n * @override\n */\n newIter.next = function() {\n 'use strict';\n if (step > 0 && start >= stop || step < 0 && start <= stop) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n const rv = start;\n start += step;\n return goog.iter.createEs6IteratorYield(rv);\n };\n\n return newIter;\n};\n\n\n/**\n * Joins the values in a iterator with a delimiter.\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * to get the values from.\n * @param {string} deliminator The text to put between the values.\n * @return {string} The joined value string.\n * @template VALUE\n */\ngoog.iter.join = function(iterable, deliminator) {\n 'use strict';\n return goog.iter.toArray(iterable).join(deliminator);\n};\n\n\n/**\n * For every element in the iterator call a function and return a new iterator\n * with that value.\n *\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterator to iterate over.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):RESULT} f\n * The function to call for every element. This function takes 3 arguments\n * (the element, undefined, and the iterator) and should return a new value.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {!goog.iter.Iterator<RESULT>} A new iterator that returns the\n * results of applying the function to each element in the original\n * iterator.\n * @template THIS, VALUE, RESULT\n */\ngoog.iter.map = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n const newIter =\n /** @type {!goog.iter.Iterator<RESULT>} */ (new goog.iter.Iterator());\n /**\n * @return {!IIterableResult<RESULT>}\n * @override\n */\n newIter.next = function() {\n 'use strict';\n const {done, value} = iterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n const mappedVal = f.call(opt_obj, value, undefined, iterator);\n return goog.iter.createEs6IteratorYield(mappedVal);\n };\n\n return newIter;\n};\n\n\n/**\n * Passes every element of an iterator into a function and accumulates the\n * result.\n *\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable<VALUE>} iterable The\n * iterator to iterate over.\n * @param {function(this:THIS,RVALUE,VALUE):RVALUE} f The function to call for\n * every element. This function takes 2 arguments (the function's previous\n * result or the initial value, and the value of the current element).\n * function(previousValue, currentElement) : newValue.\n * @param {RVALUE} val The initial value to pass into the function on the first\n * call.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * f.\n * @return {RVALUE} Result of evaluating f repeatedly across the values of\n * the iterator.\n * @template THIS, VALUE, RVALUE\n */\ngoog.iter.reduce = function(iterable, f, val, opt_obj) {\n 'use strict';\n let rval = val;\n goog.iter.forEach(iterable, function(val) {\n 'use strict';\n rval = f.call(opt_obj, rval, val);\n });\n return rval;\n};\n\n\n/**\n * Goes through the values in the iterator. Calls f for each of these, and if\n * any of them returns true, this returns true (without checking the rest). If\n * all return false this will return false.\n *\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * object.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\n * The function to call for every value. This function takes 3 arguments\n * (the value, undefined, and the iterator) and should return a boolean.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {boolean} true if any value passes the test.\n * @template THIS, VALUE\n */\ngoog.iter.some = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n\n while (true) {\n const {done, value} = iterator.next();\n if (done) return false;\n if (f.call(opt_obj, value, undefined, iterator)) {\n return true;\n }\n }\n};\n\n\n/**\n * Goes through the values in the iterator. Calls f for each of these and if any\n * of them returns false this returns false (without checking the rest). If all\n * return true this will return true.\n *\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * object.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\n * The function to call for every value. This function takes 3 arguments\n * (the value, undefined, and the iterator) and should return a boolean.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {boolean} true if every value passes the test.\n * @template THIS, VALUE\n */\ngoog.iter.every = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n\n while (true) {\n const {done, value} = iterator.next();\n if (done) return true;\n if (!f.call(opt_obj, value, undefined, iterator)) {\n return false;\n }\n }\n};\n\n\n/**\n * Takes zero or more iterables and returns one iterator that will iterate over\n * them in the order chained.\n * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any\n * number of iterable objects.\n * @return {!goog.iter.Iterator<VALUE>} Returns a new iterator that will\n * iterate over all the given iterables' contents.\n * @template VALUE\n */\ngoog.iter.chain = function(var_args) {\n 'use strict';\n return goog.iter.chainFromIterable(arguments);\n};\n\n\n/**\n * Takes a single iterable containing zero or more iterables and returns one\n * iterator that will iterate over each one in the order given.\n * @see https://goo.gl/5NRp5d\n * @param {goog.iter.Iterator<?>|goog.iter.Iterable} iterable The iterable of\n * iterables to chain.\n * @return {!goog.iter.Iterator<VALUE>} Returns a new iterator that will\n * iterate over all the contents of the iterables contained within\n * `iterable`.\n * @template VALUE\n */\ngoog.iter.chainFromIterable = function(iterable) {\n 'use strict';\n const iteratorOfIterators = goog.iter.toIterator(iterable);\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n let current = null;\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n while (true) {\n if (current == null) {\n const it = iteratorOfIterators.next();\n if (it.done) return goog.iter.ES6_ITERATOR_DONE;\n const value = /** @type {!goog.iter.Iterator<VALUE>} */ (it.value);\n current = goog.iter.toIterator(value);\n }\n const it = current.next();\n if (it.done) {\n // If the child iterator is out of values, set current to null which\n // triggers iterating over the parent above.\n current = null;\n continue;\n }\n const value = /** @type {VALUE} */ (it.value);\n return goog.iter.createEs6IteratorYield(value);\n }\n };\n\n return iter;\n};\n\n\n/**\n * Builds a new iterator that iterates over the original, but skips elements as\n * long as a supplied function returns true.\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * object.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\n * The function to call for every value. This function takes 3 arguments\n * (the value, undefined, and the iterator) and should return a boolean.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that drops elements from\n * the original iterator as long as `f` is true.\n * @template THIS, VALUE\n */\ngoog.iter.dropWhile = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n\n const newIter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n let dropping = true;\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n newIter.next = function() {\n 'use strict';\n while (true) {\n const {done, value} = iterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n if (dropping && f.call(opt_obj, value, undefined, iterator)) {\n continue;\n } else {\n dropping = false;\n }\n return goog.iter.createEs6IteratorYield(value);\n }\n };\n\n return newIter;\n};\n\n\n/**\n * Builds a new iterator that iterates over the original, but only as long as a\n * supplied function returns true.\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * object.\n * @param {\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\n * The function to call for every value. This function takes 3 arguments\n * (the value, undefined, and the iterator) and should return a boolean.\n * @param {THIS=} opt_obj This is used as the 'this' object in f when called.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that keeps elements in\n * the original iterator as long as the function is true.\n * @template THIS, VALUE\n */\ngoog.iter.takeWhile = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n const {done, value} = iterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n if (f.call(opt_obj, value, undefined, iterator)) {\n return goog.iter.createEs6IteratorYield(value);\n }\n return goog.iter.ES6_ITERATOR_DONE;\n };\n\n return iter;\n};\n\n\n/**\n * Converts the iterator to an array\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\n * to convert to an array.\n * @return {!Array<VALUE>} An array of the elements the iterator iterates over.\n * @template VALUE\n */\ngoog.iter.toArray = function(iterable) {\n 'use strict';\n // Fast path for array-like.\n if (goog.isArrayLike(iterable)) {\n return goog.array.toArray(/** @type {!IArrayLike<?>} */ (iterable));\n }\n iterable = goog.iter.toIterator(iterable);\n const array = [];\n goog.iter.forEach(iterable, function(val) {\n 'use strict';\n array.push(val);\n });\n return array;\n};\n\n\n/**\n * Iterates over two iterables and returns true if they contain the same\n * sequence of elements and have the same length.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable1 The first\n * iterable object.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable2 The second\n * iterable object.\n * @param {function(VALUE,VALUE):boolean=} opt_equalsFn Optional comparison\n * function.\n * Should take two arguments to compare, and return true if the arguments\n * are equal. Defaults to {@link goog.array.defaultCompareEquality} which\n * compares the elements using the built-in '===' operator.\n * @return {boolean} true if the iterables contain the same sequence of elements\n * and have the same length.\n * @template VALUE\n */\ngoog.iter.equals = function(iterable1, iterable2, opt_equalsFn) {\n 'use strict';\n const fillValue = {};\n const pairs = goog.iter.zipLongest(fillValue, iterable1, iterable2);\n const equalsFn = opt_equalsFn || goog.array.defaultCompareEquality;\n return goog.iter.every(pairs, function(pair) {\n 'use strict';\n return equalsFn(pair[0], pair[1]);\n });\n};\n\n\n/**\n * Advances the iterator to the next position, returning the given default value\n * instead of throwing an exception if the iterator has no more entries.\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterable\n * object.\n * @param {VALUE} defaultValue The value to return if the iterator is empty.\n * @return {VALUE} The next item in the iteration, or defaultValue if the\n * iterator was empty.\n * @template VALUE\n */\ngoog.iter.nextOrValue = function(iterable, defaultValue) {\n 'use strict';\n const iterator = /** @type {!goog.iter.Iterator<VALUE>} */ (\n goog.iter.toIterator(iterable));\n const {done, value} = iterator.next();\n if (done) return defaultValue;\n return value;\n};\n\n\n/**\n * Cartesian product of zero or more sets. Gives an iterator that gives every\n * combination of one element chosen from each set. For example,\n * ([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]).\n * @see http://docs.python.org/library/itertools.html#itertools.product\n * @param {...!IArrayLike<VALUE>} var_args Zero or more sets, as\n * arrays.\n * @return {!goog.iter.Iterator<!Array<VALUE>>} An iterator that gives each\n * n-tuple (as an array).\n * @template VALUE\n */\ngoog.iter.product = function(var_args) {\n 'use strict';\n const someArrayEmpty = Array.prototype.some.call(arguments, function(arr) {\n 'use strict';\n return !arr.length;\n });\n\n // An empty set in a cartesian product gives an empty set.\n if (someArrayEmpty || !arguments.length) {\n return /** @type {!goog.iter.Iterator<!Array<VALUE>>} */ (\n new goog.iter.Iterator());\n }\n\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n const arrays = arguments;\n\n // The first indices are [0, 0, ...]\n /** @type {?Array<number>} */\n let indices = goog.array.repeat(0, arrays.length);\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n if (indices) {\n const retVal = goog.array.map(indices, function(valueIndex, arrayIndex) {\n 'use strict';\n return arrays[arrayIndex][valueIndex];\n });\n\n // Generate the next-largest indices for the next call.\n // Increase the rightmost index. If it goes over, increase the next\n // rightmost (like carry-over addition).\n for (let i = indices.length - 1; i >= 0; i--) {\n // Assertion prevents compiler warning below.\n goog.asserts.assert(indices);\n if (indices[i] < arrays[i].length - 1) {\n indices[i]++;\n break;\n }\n\n // We're at the last indices (the last element of every array), so\n // the iteration is over on the next call.\n if (i == 0) {\n indices = null;\n break;\n }\n // Reset the index in this column and loop back to increment the\n // next one.\n indices[i] = 0;\n }\n return goog.iter.createEs6IteratorYield(retVal);\n }\n\n return goog.iter.ES6_ITERATOR_DONE;\n };\n\n\n return iter;\n};\n\n\n/**\n * Create an iterator to cycle over the iterable's elements indefinitely.\n * For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ...\n * @see: http://docs.python.org/library/itertools.html#itertools.cycle.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable object.\n * @return {!goog.iter.Iterator<VALUE>} An iterator that iterates indefinitely\n * over the values in `iterable`.\n * @template VALUE\n */\ngoog.iter.cycle = function(iterable) {\n 'use strict';\n const baseIterator = /** @type {!goog.iter.Iterator<VALUE>} */ (\n goog.iter.toIterator(iterable));\n\n // We maintain a cache to store the iterable elements as we iterate\n // over them. The cache is used to return elements once we have\n // iterated over the iterable once.\n const cache = [];\n let cacheIndex = 0;\n\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n // This flag is set after the iterable is iterated over once\n let useCache = false;\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n let returnElement = null;\n\n // Pull elements off the original iterator if not using cache\n if (!useCache) {\n const it = baseIterator.next();\n if (it.done) {\n if (goog.array.isEmpty(cache)) {\n return goog.iter.ES6_ITERATOR_DONE;\n }\n // set useCache to true after we've exhausted the inner iterator and\n // there is at least one element in the cache.\n useCache = true;\n // Fallthrough to using the cache immediately.\n } else {\n cache.push(it.value);\n return it;\n }\n }\n\n returnElement = cache[cacheIndex];\n cacheIndex = (cacheIndex + 1) % cache.length;\n\n return goog.iter.createEs6IteratorYield(returnElement);\n };\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that counts indefinitely from a starting value.\n * @see http://docs.python.org/2/library/itertools.html#itertools.count\n * @param {number=} opt_start The starting value. Default is 0.\n * @param {number=} opt_step The number to increment with between each call to\n * next. Negative and floating point numbers are allowed. Default is 1.\n * @return {!goog.iter.Iterator<number>} A new iterator that returns the values\n * in the series.\n */\ngoog.iter.count = function(opt_start, opt_step) {\n 'use strict';\n let counter = opt_start || 0;\n const step = (opt_step !== undefined) ? opt_step : 1;\n const iter =\n /** @type {!goog.iter.Iterator<number>} */ (new goog.iter.Iterator());\n\n /**\n * @return {!IIterableResult<number>}\n * @override @see {!goog.iter.Iterator}\n */\n iter.next = function() {\n 'use strict';\n const returnValue = counter;\n counter += step;\n return goog.iter.createEs6IteratorYield(returnValue);\n };\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that returns the same object or value repeatedly.\n * @param {VALUE} value Any object or value to repeat.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that returns the\n * repeated value.\n * @template VALUE\n */\ngoog.iter.repeat = function(value) {\n 'use strict';\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n return goog.iter.createEs6IteratorYield(value);\n };\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that returns running totals from the numbers in\n * `iterable`. For example, the array {@code [1, 2, 3, 4, 5]} yields\n * {@code 1 -> 3 -> 6 -> 10 -> 15}.\n * @see http://docs.python.org/3.2/library/itertools.html#itertools.accumulate\n * @param {!goog.iter.Iterator<number>|!goog.iter.Iterable} iterable The\n * iterable of numbers to accumulate.\n * @return {!goog.iter.Iterator<number>} A new iterator that returns the\n * numbers in the series.\n */\ngoog.iter.accumulate = function(iterable) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n let total = 0;\n const iter =\n /** @type {!goog.iter.Iterator<number>} */ (new goog.iter.Iterator());\n\n /**\n * @return {!IIterableResult<number>}\n * @override @see {!goog.iter.Iterator}\n */\n iter.next = function() {\n 'use strict';\n const {done, value} = iterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n total += value;\n return goog.iter.createEs6IteratorYield(total);\n };\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that returns arrays containing the ith elements from the\n * provided iterables. The returned arrays will be the same size as the number\n * of iterables given in `var_args`. Once the shortest iterable is\n * exhausted, subsequent calls to `next()` will return\n * `goog.iter.ES6_ITERATOR_DONE`.\n * @see http://docs.python.org/2/library/itertools.html#itertools.izip\n * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any\n * number of iterable objects.\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator that returns\n * arrays of elements from the provided iterables.\n * @template VALUE\n */\ngoog.iter.zip = function(var_args) {\n 'use strict';\n const args = arguments;\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n if (args.length > 0) {\n const iterators = goog.array.map(args, goog.iter.toIterator);\n let allDone = false;\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n if (allDone) return goog.iter.ES6_ITERATOR_DONE;\n\n const arr = [];\n for (let i = 0, iterator; iterator = iterators[i++];) {\n const it = /** @type {!IIterableResult<VALUE>} */ (iterator.next());\n if (it.done) {\n // One of the iterators being zipped is done, so set allDone and\n // return.\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n arr.push(it.value);\n }\n return goog.iter.createEs6IteratorYield(arr);\n };\n }\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that returns arrays containing the ith elements from the\n * provided iterables. The returned arrays will be the same size as the number\n * of iterables given in `var_args`. Shorter iterables will be extended\n * with `fillValue`. Once the longest iterable is exhausted, subsequent\n * calls to `next()` will return `goog.iter.ES6_ITERATOR_DONE`.\n * @see http://docs.python.org/2/library/itertools.html#itertools.izip_longest\n * @param {VALUE} fillValue The object or value used to fill shorter iterables.\n * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any\n * number of iterable objects.\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator that returns\n * arrays of elements from the provided iterables.\n * @template VALUE\n */\ngoog.iter.zipLongest = function(fillValue, var_args) {\n 'use strict';\n const args = Array.prototype.slice.call(arguments, 1);\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n if (args.length > 0) {\n const iterators = goog.array.map(args, goog.iter.toIterator);\n\n let allDone = false; // set to true once all iterators are empty.\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n if (allDone) return goog.iter.ES6_ITERATOR_DONE;\n\n let iteratorsHaveValues = false;\n const arr = [];\n for (let i = 0, iterator; iterator = iterators[i++];) {\n const it = /** @type {!IIterableResult<VALUE>} */ (iterator.next());\n if (it.done) {\n // If this iterator is empty, others might not be, so use the\n // fillValue.\n arr.push(fillValue);\n continue;\n }\n arr.push(it.value);\n iteratorsHaveValues = true;\n }\n\n if (!iteratorsHaveValues) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n return goog.iter.createEs6IteratorYield(arr);\n };\n }\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that filters `iterable` based on a series of\n * `selectors`. On each call to `next()`, one item is taken from\n * both the `iterable` and `selectors` iterators. If the item from\n * `selectors` evaluates to true, the item from `iterable` is given.\n * Otherwise, it is skipped. Once either `iterable` or `selectors`\n * is exhausted, subsequent calls to `next()` will return\n * `goog.iter.ES6_ITERATOR_DONE`.\n * @see http://docs.python.org/2/library/itertools.html#itertools.compress\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to filter.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} selectors An\n * iterable of items to be evaluated in a boolean context to determine if\n * the corresponding element in `iterable` should be included in the\n * result.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that returns the\n * filtered values.\n * @template VALUE\n */\ngoog.iter.compress = function(iterable, selectors) {\n 'use strict';\n const valueIterator = goog.iter.toIterator(iterable);\n const selectorIterator = goog.iter.toIterator(selectors);\n\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n let allDone = false;\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n if (allDone) return goog.iter.ES6_ITERATOR_DONE;\n\n while (true) {\n const valIt = valueIterator.next();\n if (valIt.done) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n\n const selectorIt = selectorIterator.next();\n if (selectorIt.done) {\n allDone = true;\n return goog.iter.ES6_ITERATOR_DONE;\n }\n\n const val = valIt.value;\n const selectorVal = selectorIt.value;\n if (selectorVal) return goog.iter.createEs6IteratorYield(val);\n }\n };\n\n return iter;\n};\n\n\n\n/**\n * Implements the `goog.iter.groupBy` iterator.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to group.\n * @param {function(VALUE): KEY=} opt_keyFunc Optional function for\n * determining the key value for each group in the `iterable`. Default\n * is the identity function.\n * @constructor\n * @extends {goog.iter.Iterator<!Array<?>>}\n * @template KEY, VALUE\n * @private\n */\ngoog.iter.GroupByIterator_ = function(iterable, opt_keyFunc) {\n 'use strict';\n /**\n * The iterable to group, coerced to an iterator.\n * @type {!goog.iter.Iterator}\n */\n this.iterator = goog.iter.toIterator(iterable);\n\n /**\n * A function for determining the key value for each element in the iterable.\n * If no function is provided, the identity function is used and returns the\n * element unchanged.\n * @type {function(VALUE): KEY}\n */\n this.keyFunc = opt_keyFunc || goog.functions.identity;\n\n /**\n * The target key for determining the start of a group.\n * @type {KEY}\n */\n this.targetKey;\n\n /**\n * The current key visited during iteration.\n * @type {KEY}\n */\n this.currentKey;\n\n /**\n * The current value being added to the group.\n * @type {VALUE}\n */\n this.currentValue;\n};\ngoog.inherits(goog.iter.GroupByIterator_, goog.iter.Iterator);\n\n\n/**\n * @return {!IIterableResult<!Array<?>>}\n * @override\n */\ngoog.iter.GroupByIterator_.prototype.next = function() {\n 'use strict';\n while (this.currentKey == this.targetKey) {\n const it = this.iterator.next();\n if (it.done) return goog.iter.ES6_ITERATOR_DONE;\n this.currentValue = it.value;\n this.currentKey = this.keyFunc(this.currentValue);\n }\n this.targetKey = this.currentKey;\n return goog.iter.createEs6IteratorYield(\n [this.currentKey, this.groupItems_(this.targetKey)]);\n};\n\n\n/**\n * Performs the grouping of objects using the given key.\n * @param {KEY} targetKey The target key object for the group.\n * @return {!Array<VALUE>} An array of grouped objects.\n * @private\n */\ngoog.iter.GroupByIterator_.prototype.groupItems_ = function(targetKey) {\n 'use strict';\n const arr = [];\n while (this.currentKey == targetKey) {\n arr.push(this.currentValue);\n const it = this.iterator.next();\n if (it.done) break;\n this.currentValue = it.value;\n this.currentKey = this.keyFunc(this.currentValue);\n }\n return arr;\n};\n\n\n/**\n * Creates an iterator that returns arrays containing elements from the\n * `iterable` grouped by a key value. For iterables with repeated\n * elements (i.e. sorted according to a particular key function), this function\n * has a `uniq`-like effect. For example, grouping the array:\n * {@code [A, B, B, C, C, A]} produces\n * {@code [A, [A]], [B, [B, B]], [C, [C, C]], [A, [A]]}.\n * @see http://docs.python.org/2/library/itertools.html#itertools.groupby\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to group.\n * @param {function(VALUE): KEY=} opt_keyFunc Optional function for\n * determining the key value for each group in the `iterable`. Default\n * is the identity function.\n * @return {!goog.iter.Iterator<!Array<?>>} A new iterator that returns\n * arrays of consecutive key and groups.\n * @template KEY, VALUE\n */\ngoog.iter.groupBy = function(iterable, opt_keyFunc) {\n 'use strict';\n return new goog.iter.GroupByIterator_(iterable, opt_keyFunc);\n};\n\n\n/**\n * Gives an iterator that gives the result of calling the given function\n * <code>f</code> with the arguments taken from the next element from\n * <code>iterable</code> (the elements are expected to also be iterables).\n *\n * Similar to {@see goog.iter.map} but allows the function to accept multiple\n * arguments from the iterable.\n *\n * @param {!goog.iter.Iterator<?>|!goog.iter.Iterable} iterable The iterable of\n * iterables to iterate over.\n * @param {function(this:THIS,...*):RESULT} f The function to call for every\n * element. This function takes N+2 arguments, where N represents the\n * number of items from the next element of the iterable. The two\n * additional arguments passed to the function are undefined and the\n * iterator itself. The function should return a new value.\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\n * `f`.\n * @return {!goog.iter.Iterator<RESULT>} A new iterator that returns the\n * results of applying the function to each element in the original\n * iterator.\n * @template THIS, RESULT\n */\ngoog.iter.starMap = function(iterable, f, opt_obj) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n const iter =\n /** @type {!goog.iter.Iterator<RESULT>} */ (new goog.iter.Iterator());\n\n /**\n * @return {!IIterableResult<RESULT>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n const it = /** @type {!IIterableResult<!goog.iter.Iterator<?>>} */ (\n iterator.next());\n if (it.done) return goog.iter.ES6_ITERATOR_DONE;\n const args = goog.iter.toArray(it.value);\n const value = f.apply(opt_obj, [].concat(args, undefined, iterator));\n return goog.iter.createEs6IteratorYield(value);\n };\n\n\n return iter;\n};\n\n\n/**\n * Returns an array of iterators each of which can iterate over the values in\n * `iterable` without advancing the others.\n * @see http://docs.python.org/2/library/itertools.html#itertools.tee\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to tee.\n * @param {number=} opt_num The number of iterators to create. Default is 2.\n * @return {!Array<goog.iter.Iterator<VALUE>>} An array of iterators.\n * @template VALUE\n */\ngoog.iter.tee = function(iterable, opt_num) {\n 'use strict';\n const iterator = goog.iter.toIterator(iterable);\n const num = (typeof opt_num === 'number') ? opt_num : 2;\n const buffers = goog.array.map(goog.array.range(num), function() {\n 'use strict';\n return [];\n });\n\n /***\n * @return {boolean} True iff something was added to the buffers, false\n * otherwise. Used to signal whether there were any more iterators, or if\n * the parent iterator should indicate exhaustion.\n */\n function addNextIteratorValueToBuffers() {\n 'use strict';\n const {done, value} = iterator.next();\n if (done) return false;\n for (let i = 0, buffer; buffer = buffers[i++];) {\n buffer.push(value);\n }\n return true;\n }\n\n /***\n * @param {!Array<VALUE>} buffer\n * @return {!goog.iter.Iterator<VALUE>}\n */\n function createIterator(buffer) {\n 'use strict';\n // Each tee'd iterator has an associated buffer (initially empty). When a\n // tee'd iterator's buffer is empty, it calls\n // addNextIteratorValueToBuffers(), adding the next value to all tee'd\n // iterators' buffers, and then returns that value. This allows each\n // iterator to be advanced independently.\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n if (goog.array.isEmpty(buffer)) {\n const added = addNextIteratorValueToBuffers();\n if (!added) return goog.iter.ES6_ITERATOR_DONE;\n }\n goog.asserts.assert(!goog.array.isEmpty(buffer));\n return goog.iter.createEs6IteratorYield(buffer.shift());\n };\n\n return iter;\n }\n\n return goog.array.map(buffers, createIterator);\n};\n\n\n/**\n * Creates an iterator that returns arrays containing a count and an element\n * obtained from the given `iterable`.\n * @see http://docs.python.org/2/library/functions.html#enumerate\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to enumerate.\n * @param {number=} opt_start Optional starting value. Default is 0.\n * @return {!goog.iter.Iterator<!Array<?>>} A new iterator containing\n * count/item pairs.\n * @template VALUE\n */\ngoog.iter.enumerate = function(iterable, opt_start) {\n 'use strict';\n return goog.iter.zip(goog.iter.count(opt_start), iterable);\n};\n\n\n/**\n * Creates an iterator that returns the first `limitSize` elements from an\n * iterable. If this number is greater than the number of elements in the\n * iterable, all the elements are returned.\n * @see http://goo.gl/V0sihp Inspired by the limit iterator in Guava.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to limit.\n * @param {number} limitSize The maximum number of elements to return.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator containing\n * `limitSize` elements.\n * @template VALUE\n */\ngoog.iter.limit = function(iterable, limitSize) {\n 'use strict';\n goog.asserts.assert(goog.math.isInt(limitSize) && limitSize >= 0);\n\n const iterator = goog.iter.toIterator(iterable);\n\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n let remaining = limitSize;\n\n /**\n * @return {!IIterableResult<VALUE>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n if (remaining-- > 0) {\n return iterator.next();\n }\n return goog.iter.ES6_ITERATOR_DONE;\n };\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that is advanced `count` steps ahead. Consumed\n * values are silently discarded. If `count` is greater than the number\n * of elements in `iterable`, an empty iterator is returned. Subsequent\n * calls to `next()` will return `goog.iter.ES6_ITERATOR_DONE`.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to consume.\n * @param {number} count The number of elements to consume from the iterator.\n * @return {!goog.iter.Iterator<VALUE>} An iterator advanced zero or more steps\n * ahead.\n * @template VALUE\n */\ngoog.iter.consume = function(iterable, count) {\n 'use strict';\n goog.asserts.assert(goog.math.isInt(count) && count >= 0);\n\n const iterator = goog.iter.toIterator(iterable);\n\n while (count-- > 0) {\n goog.iter.nextOrValue(iterator, null);\n }\n\n return iterator;\n};\n\n\n/**\n * Creates an iterator that returns a range of elements from an iterable.\n * Similar to {@see goog.array.slice} but does not support negative indexes.\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to slice.\n * @param {number} start The index of the first element to return.\n * @param {number=} opt_end The index after the last element to return. If\n * defined, must be greater than or equal to `start`.\n * @return {!goog.iter.Iterator<VALUE>} A new iterator containing a slice of\n * the original.\n * @template VALUE\n */\ngoog.iter.slice = function(iterable, start, opt_end) {\n 'use strict';\n goog.asserts.assert(goog.math.isInt(start) && start >= 0);\n\n let iterator = goog.iter.consume(iterable, start);\n\n if (typeof opt_end === 'number') {\n goog.asserts.assert(goog.math.isInt(opt_end) && opt_end >= start);\n iterator = goog.iter.limit(iterator, opt_end - start /* limitSize */);\n }\n\n return iterator;\n};\n\n\n/**\n * Checks an array for duplicate elements.\n * @param {?IArrayLike<VALUE>} arr The array to check for\n * duplicates.\n * @return {boolean} True, if the array contains duplicates, false otherwise.\n * @private\n * @template VALUE\n */\n// TODO(user): Consider moving this into goog.array as a public function.\ngoog.iter.hasDuplicates_ = function(arr) {\n 'use strict';\n const deduped = [];\n goog.array.removeDuplicates(arr, deduped);\n return arr.length != deduped.length;\n};\n\n\n/**\n * Creates an iterator that returns permutations of elements in\n * `iterable`.\n *\n * Permutations are obtained by taking the Cartesian product of\n * `opt_length` iterables and filtering out those with repeated\n * elements. For example, the permutations of {@code [1,2,3]} are\n * {@code [[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]}.\n * @see http://docs.python.org/2/library/itertools.html#itertools.permutations\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable from which to generate permutations.\n * @param {number=} opt_length Length of each permutation. If omitted, defaults\n * to the length of `iterable`.\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing the\n * permutations of `iterable`.\n * @template VALUE\n */\ngoog.iter.permutations = function(iterable, opt_length) {\n 'use strict';\n const elements = goog.iter.toArray(iterable);\n const length =\n (typeof opt_length === 'number') ? opt_length : elements.length;\n\n const sets = goog.array.repeat(elements, length);\n const product = goog.iter.product.apply(undefined, sets);\n\n return goog.iter.filter(product, function(arr) {\n 'use strict';\n return !goog.iter.hasDuplicates_(arr);\n });\n};\n\n\n/**\n * Creates an iterator that returns combinations of elements from\n * `iterable`.\n *\n * Combinations are obtained by taking the {@see goog.iter.permutations} of\n * `iterable` and filtering those whose elements appear in the order they\n * are encountered in `iterable`. For example, the 3-length combinations\n * of {@code [0,1,2,3]} are {@code [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]}.\n * @see http://docs.python.org/2/library/itertools.html#itertools.combinations\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable from which to generate combinations.\n * @param {number} length The length of each combination.\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing\n * combinations from the `iterable`.\n * @template VALUE\n */\ngoog.iter.combinations = function(iterable, length) {\n 'use strict';\n const elements = goog.iter.toArray(iterable);\n const indexes = goog.iter.range(elements.length);\n const indexIterator = goog.iter.permutations(indexes, length);\n // sortedIndexIterator will now give arrays of with the given length that\n // indicate what indexes into \"elements\" should be returned on each iteration.\n const sortedIndexIterator = goog.iter.filter(indexIterator, function(arr) {\n 'use strict';\n return goog.array.isSorted(arr);\n });\n\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n function getIndexFromElements(index) {\n return elements[index];\n }\n /**\n * @return {!IIterableResult<!Array<VALUE>>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n const {done, value} = sortedIndexIterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n return goog.iter.createEs6IteratorYield(\n goog.array.map(value, getIndexFromElements));\n };\n\n return iter;\n};\n\n\n/**\n * Creates an iterator that returns combinations of elements from\n * `iterable`, with repeated elements possible.\n *\n * Combinations are obtained by taking the Cartesian product of `length`\n * iterables and filtering those whose elements appear in the order they are\n * encountered in `iterable`. For example, the 2-length combinations of\n * {@code [1,2,3]} are {@code [[1,1], [1,2], [1,3], [2,2], [2,3], [3,3]]}.\n * @see https://goo.gl/C0yXe4\n * @see https://goo.gl/djOCsk\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\n * iterable to combine.\n * @param {number} length The length of each combination.\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing\n * combinations from the `iterable`.\n * @template VALUE\n */\ngoog.iter.combinationsWithReplacement = function(iterable, length) {\n 'use strict';\n const elements = goog.iter.toArray(iterable);\n const indexes = goog.array.range(elements.length);\n const sets = goog.array.repeat(indexes, length);\n const indexIterator = goog.iter.product.apply(undefined, sets);\n // sortedIndexIterator will now give arrays of with the given length that\n // indicate what indexes into \"elements\" should be returned on each iteration.\n const sortedIndexIterator = goog.iter.filter(indexIterator, function(arr) {\n 'use strict';\n return goog.array.isSorted(arr);\n });\n\n const iter =\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\n\n function getIndexFromElements(index) {\n return elements[index];\n }\n\n /**\n * @return {!IIterableResult<!Array<VALUE>>}\n * @override\n */\n iter.next = function() {\n 'use strict';\n const {done, value} = sortedIndexIterator.next();\n if (done) return goog.iter.ES6_ITERATOR_DONE;\n return goog.iter.createEs6IteratorYield(goog.array.map(\n /** @type {!Array<number>} */ (value), getIndexFromElements));\n };\n\n return iter;\n};\n","~:compiled-at",1684858198019,"~:source-map-json","{\n\"version\":3,\n\"file\":\"goog.iter.iter.js\",\n\"lineCount\":585,\n\"mappings\":\"AAWAA,IAAKC,CAAAA,OAAL,CAAa,WAAb,CAAA;AACAD,IAAKC,CAAAA,OAAL,CAAa,oBAAb,CAAA;AACAD,IAAKC,CAAAA,OAAL,CAAa,oBAAb,CAAA;AAEAD,IAAKE,CAAAA,OAAL,CAAa,YAAb,CAAA;AACAF,IAAKE,CAAAA,OAAL,CAAa,cAAb,CAAA;AACAF,IAAKE,CAAAA,OAAL,CAAa,YAAb,CAAA;AACAF,IAAKE,CAAAA,OAAL,CAAa,gBAAb,CAAA;AACAF,IAAKE,CAAAA,OAAL,CAAa,WAAb,CAAA;AAMAF,IAAKG,CAAAA,IAAKC,CAAAA,QAAV;AAYAJ,IAAKG,CAAAA,IAAKE,CAAAA,QAAV,GAAqBC,QAAQ,EAAG;CAAhC;AAQAN,IAAKG,CAAAA,IAAKE,CAAAA,QA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IAAKG,CAAAA,IAAKE,CAAAA,QAAd,EAD/C;AAGAmM,UAASA,qBAAoB,CAACC,KAAD,CAAQ;AACnC,WAAOT,QAAA,CAASS,KAAT,CAAP;AADmC;AAQrCtM,MAAKK,CAAAA,IAAL,GAAYoE,QAAQ,EAAG;AAErB,UAAM,CAAC/D,IAAD,EAAOC,KAAP,CAAA,GAAgBwL,mBAAoB9L,CAAAA,IAApB,EAAtB;AACA,QAAIK,IAAJ;AAAU,aAAOb,IAAKG,CAAAA,IAAKO,CAAAA,iBAAjB;AAAV;AACA,WAAOV,IAAKG,CAAAA,IAAKa,CAAAA,sBAAV,CAAiChB,IAAKmC,CAAAA,KAAMuB,CAAAA,GAAX,CACL5C,KADK,EACG0L,oBADH,CAAjC,CAAP;AAJqB,GAAvB;AAQA,SAAOrM,IAAP;AAhCiE,CAAnE;;\",\n\"sources\":[\"goog/iter/iter.js\"],\n\"sourcesContent\":[\"/**\\n * @license\\n * Copyright The Closure Library Authors.\\n * SPDX-License-Identifier: Apache-2.0\\n */\\n\\n/**\\n * @fileoverview Python style iteration utilities.\\n */\\n\\n\\ngoog.provide('goog.iter');\\ngoog.provide('goog.iter.Iterable');\\ngoog.provide('goog.iter.Iterator');\\n\\ngoog.require('goog.array');\\ngoog.require('goog.asserts');\\ngoog.require('goog.debug');\\ngoog.require('goog.functions');\\ngoog.require('goog.math');\\n\\n\\n/**\\n * @typedef {{length:number}|{__iterator__}}\\n */\\ngoog.iter.Iterable;\\n\\n\\n/**\\n * Class/interface for iterators.\\n * @constructor\\n * @template VALUE\\n * @implements {Iterator<VALUE>}\\n * @deprecated Use objects implementing JavaScript iterable protocol introduced\\n * in ES6.\\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols\\n */\\ngoog.iter.Iterator = function() {};\\n\\n\\n/**\\n * Returns the next value of the iteration as an an ES6 IIterableResult.\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\ngoog.iter.Iterator.prototype.next = function() {\\n 'use strict';\\n return goog.iter.ES6_ITERATOR_DONE;\\n};\\n\\n\\n/**\\n * An ES6 Iteration protocol result indicating iteration has completed for an\\n * iterator.\\n * @const {!IIterableResult<?>}\\n */\\ngoog.iter.ES6_ITERATOR_DONE = goog.debug.freeze({done: true, value: undefined});\\n\\n\\n/**\\n * Wraps a VALUE in the ES6 Iterator protocol's IIterableResult container,\\n * including the compiler-mandated 'done' key, set to false.\\n * @param {VALUE} value\\n * @return {!IIterableResult<VALUE>} An ES6 Iteration Protocol compatible result\\n * object, indicating iteration is not done.\\n * @template VALUE\\n */\\ngoog.iter.createEs6IteratorYield = function(value) {\\n return {value, done: false};\\n};\\n\\n\\n/**\\n * Returns the `Iterator` object itself. This is used to implement\\n * the iterator protocol in JavaScript 1.7\\n * @param {boolean=} opt_keys Whether to return the keys or values. Default is\\n * to only return the values. This is being used by the for-in loop (true)\\n * and the for-each-in loop (false). Even though the param gives a hint\\n * about what the iterator will return there is no guarantee that it will\\n * return the keys when true is passed.\\n * @return {!goog.iter.Iterator<VALUE>} The object itself.\\n */\\ngoog.iter.Iterator.prototype.__iterator__ = function(opt_keys) {\\n 'use strict';\\n return this;\\n};\\n\\n\\n/**\\n * Returns an iterator that knows how to iterate over the values in the object.\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable If the\\n * object is an iterator it will be returned as is. If the object has an\\n * `__iterator__` method that will be called to get the value\\n * iterator. If the object is an array-like object we create an iterator\\n * for that.\\n * @return {!goog.iter.Iterator<VALUE>} An iterator that knows how to iterate\\n * over the values in `iterable`.\\n * @template VALUE\\n */\\ngoog.iter.toIterator = function(iterable) {\\n 'use strict';\\n if (iterable instanceof goog.iter.Iterator) {\\n return iterable;\\n }\\n if (typeof iterable.__iterator__ == 'function') {\\n return /** @type {{__iterator__:function(this:?, boolean=)}} */ (iterable)\\n .__iterator__(false);\\n }\\n if (goog.isArrayLike(iterable)) {\\n const like = /** @type {!IArrayLike<number|string>} */ (iterable);\\n let i = 0;\\n const newIter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n newIter.next = function() {\\n 'use strict';\\n while (true) {\\n if (i >= like.length) {\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n // Don't include deleted elements.\\n if (!(i in like)) {\\n i++;\\n continue;\\n }\\n return goog.iter.createEs6IteratorYield(like[i++]);\\n }\\n };\\n\\n return newIter;\\n }\\n\\n\\n // TODO(arv): Should we fall back on goog.structs.getValues()?\\n throw new Error('Not implemented');\\n};\\n\\n\\n/**\\n * Calls a function for each element in the iterator with the element of the\\n * iterator passed as argument.\\n *\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * to iterate over. If the iterable is an object `toIterator` will be\\n * called on it.\\n * @param {function(this:THIS,VALUE,?,!goog.iter.Iterator<VALUE>)} f\\n * The function to call for every element. This function takes 3 arguments\\n * (the element, undefined, and the iterator) and the return value is\\n * irrelevant. The reason for passing undefined as the second argument is\\n * so that the same function can be used in {@see goog.array.forEach} as\\n * well as others. The third parameter is of type \\\"number\\\" for\\n * arraylike objects, undefined, otherwise.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @template THIS, VALUE\\n */\\ngoog.iter.forEach = function(iterable, f, opt_obj) {\\n 'use strict';\\n if (goog.isArrayLike(iterable)) {\\n // NOTES: this passes the index number to the second parameter\\n // of the callback contrary to the documentation above.\\n goog.array.forEach(\\n /** @type {IArrayLike<?>} */ (iterable), f, opt_obj);\\n } else {\\n const iterator = goog.iter.toIterator(iterable);\\n while (true) {\\n const {done, value} = iterator.next();\\n if (done) return;\\n f.call(opt_obj, value, undefined, iterator);\\n }\\n }\\n};\\n\\n\\n/**\\n * Calls a function for every element in the iterator, and if the function\\n * returns true adds the element to a new iterator.\\n *\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * to iterate over.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\\n * The function to call for every element. This function takes 3 arguments\\n * (the element, undefined, and the iterator) and should return a boolean.\\n * If the return value is true the element will be included in the returned\\n * iterator. If it is false the element is not included.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator in which only elements\\n * that passed the test are present.\\n * @template THIS, VALUE\\n */\\ngoog.iter.filter = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n const newIter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n newIter.next = function() {\\n 'use strict';\\n while (true) {\\n const {done, value} = iterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n if (f.call(opt_obj, value, undefined, iterator)) {\\n return goog.iter.createEs6IteratorYield(value);\\n }\\n }\\n };\\n\\n return newIter;\\n};\\n\\n\\n/**\\n * Calls a function for every element in the iterator, and if the function\\n * returns false adds the element to a new iterator.\\n *\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * to iterate over.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\\n * The function to call for every element. This function takes 3 arguments\\n * (the element, undefined, and the iterator) and should return a boolean.\\n * If the return value is false the element will be included in the returned\\n * iterator. If it is true the element is not included.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator in which only elements\\n * that did not pass the test are present.\\n * @template THIS, VALUE\\n */\\ngoog.iter.filterFalse = function(iterable, f, opt_obj) {\\n 'use strict';\\n return goog.iter.filter(iterable, goog.functions.not(f), opt_obj);\\n};\\n\\n\\n/**\\n * Creates a new iterator that returns the values in a range. This function\\n * can take 1, 2 or 3 arguments:\\n * <pre>\\n * range(5) same as range(0, 5, 1)\\n * range(2, 5) same as range(2, 5, 1)\\n * </pre>\\n *\\n * @param {number} startOrStop The stop value if only one argument is provided.\\n * The start value if 2 or more arguments are provided. If only one\\n * argument is used the start value is 0.\\n * @param {number=} opt_stop The stop value. If left out then the first\\n * argument is used as the stop value.\\n * @param {number=} opt_step The number to increment with between each call to\\n * next. This can be negative.\\n * @return {!goog.iter.Iterator<number>} A new iterator that returns the values\\n * in the range.\\n */\\ngoog.iter.range = function(startOrStop, opt_stop, opt_step) {\\n 'use strict';\\n let start = 0;\\n let stop = startOrStop;\\n let step = opt_step || 1;\\n if (arguments.length > 1) {\\n start = startOrStop;\\n stop = +opt_stop;\\n }\\n if (step == 0) {\\n throw new Error('Range step argument must not be zero');\\n }\\n\\n const newIter =\\n /** @type {!goog.iter.Iterator<number>} */ (new goog.iter.Iterator());\\n /**\\n * @return {!IIterableResult<number>}\\n * @override\\n */\\n newIter.next = function() {\\n 'use strict';\\n if (step > 0 && start >= stop || step < 0 && start <= stop) {\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n const rv = start;\\n start += step;\\n return goog.iter.createEs6IteratorYield(rv);\\n };\\n\\n return newIter;\\n};\\n\\n\\n/**\\n * Joins the values in a iterator with a delimiter.\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * to get the values from.\\n * @param {string} deliminator The text to put between the values.\\n * @return {string} The joined value string.\\n * @template VALUE\\n */\\ngoog.iter.join = function(iterable, deliminator) {\\n 'use strict';\\n return goog.iter.toArray(iterable).join(deliminator);\\n};\\n\\n\\n/**\\n * For every element in the iterator call a function and return a new iterator\\n * with that value.\\n *\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterator to iterate over.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):RESULT} f\\n * The function to call for every element. This function takes 3 arguments\\n * (the element, undefined, and the iterator) and should return a new value.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {!goog.iter.Iterator<RESULT>} A new iterator that returns the\\n * results of applying the function to each element in the original\\n * iterator.\\n * @template THIS, VALUE, RESULT\\n */\\ngoog.iter.map = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n const newIter =\\n /** @type {!goog.iter.Iterator<RESULT>} */ (new goog.iter.Iterator());\\n /**\\n * @return {!IIterableResult<RESULT>}\\n * @override\\n */\\n newIter.next = function() {\\n 'use strict';\\n const {done, value} = iterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n const mappedVal = f.call(opt_obj, value, undefined, iterator);\\n return goog.iter.createEs6IteratorYield(mappedVal);\\n };\\n\\n return newIter;\\n};\\n\\n\\n/**\\n * Passes every element of an iterator into a function and accumulates the\\n * result.\\n *\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable<VALUE>} iterable The\\n * iterator to iterate over.\\n * @param {function(this:THIS,RVALUE,VALUE):RVALUE} f The function to call for\\n * every element. This function takes 2 arguments (the function's previous\\n * result or the initial value, and the value of the current element).\\n * function(previousValue, currentElement) : newValue.\\n * @param {RVALUE} val The initial value to pass into the function on the first\\n * call.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * f.\\n * @return {RVALUE} Result of evaluating f repeatedly across the values of\\n * the iterator.\\n * @template THIS, VALUE, RVALUE\\n */\\ngoog.iter.reduce = function(iterable, f, val, opt_obj) {\\n 'use strict';\\n let rval = val;\\n goog.iter.forEach(iterable, function(val) {\\n 'use strict';\\n rval = f.call(opt_obj, rval, val);\\n });\\n return rval;\\n};\\n\\n\\n/**\\n * Goes through the values in the iterator. Calls f for each of these, and if\\n * any of them returns true, this returns true (without checking the rest). If\\n * all return false this will return false.\\n *\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * object.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\\n * The function to call for every value. This function takes 3 arguments\\n * (the value, undefined, and the iterator) and should return a boolean.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {boolean} true if any value passes the test.\\n * @template THIS, VALUE\\n */\\ngoog.iter.some = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n\\n while (true) {\\n const {done, value} = iterator.next();\\n if (done) return false;\\n if (f.call(opt_obj, value, undefined, iterator)) {\\n return true;\\n }\\n }\\n};\\n\\n\\n/**\\n * Goes through the values in the iterator. Calls f for each of these and if any\\n * of them returns false this returns false (without checking the rest). If all\\n * return true this will return true.\\n *\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * object.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\\n * The function to call for every value. This function takes 3 arguments\\n * (the value, undefined, and the iterator) and should return a boolean.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {boolean} true if every value passes the test.\\n * @template THIS, VALUE\\n */\\ngoog.iter.every = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n\\n while (true) {\\n const {done, value} = iterator.next();\\n if (done) return true;\\n if (!f.call(opt_obj, value, undefined, iterator)) {\\n return false;\\n }\\n }\\n};\\n\\n\\n/**\\n * Takes zero or more iterables and returns one iterator that will iterate over\\n * them in the order chained.\\n * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any\\n * number of iterable objects.\\n * @return {!goog.iter.Iterator<VALUE>} Returns a new iterator that will\\n * iterate over all the given iterables' contents.\\n * @template VALUE\\n */\\ngoog.iter.chain = function(var_args) {\\n 'use strict';\\n return goog.iter.chainFromIterable(arguments);\\n};\\n\\n\\n/**\\n * Takes a single iterable containing zero or more iterables and returns one\\n * iterator that will iterate over each one in the order given.\\n * @see https://goo.gl/5NRp5d\\n * @param {goog.iter.Iterator<?>|goog.iter.Iterable} iterable The iterable of\\n * iterables to chain.\\n * @return {!goog.iter.Iterator<VALUE>} Returns a new iterator that will\\n * iterate over all the contents of the iterables contained within\\n * `iterable`.\\n * @template VALUE\\n */\\ngoog.iter.chainFromIterable = function(iterable) {\\n 'use strict';\\n const iteratorOfIterators = goog.iter.toIterator(iterable);\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n let current = null;\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n while (true) {\\n if (current == null) {\\n const it = iteratorOfIterators.next();\\n if (it.done) return goog.iter.ES6_ITERATOR_DONE;\\n const value = /** @type {!goog.iter.Iterator<VALUE>} */ (it.value);\\n current = goog.iter.toIterator(value);\\n }\\n const it = current.next();\\n if (it.done) {\\n // If the child iterator is out of values, set current to null which\\n // triggers iterating over the parent above.\\n current = null;\\n continue;\\n }\\n const value = /** @type {VALUE} */ (it.value);\\n return goog.iter.createEs6IteratorYield(value);\\n }\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Builds a new iterator that iterates over the original, but skips elements as\\n * long as a supplied function returns true.\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * object.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\\n * The function to call for every value. This function takes 3 arguments\\n * (the value, undefined, and the iterator) and should return a boolean.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that drops elements from\\n * the original iterator as long as `f` is true.\\n * @template THIS, VALUE\\n */\\ngoog.iter.dropWhile = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n\\n const newIter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n let dropping = true;\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n newIter.next = function() {\\n 'use strict';\\n while (true) {\\n const {done, value} = iterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n if (dropping && f.call(opt_obj, value, undefined, iterator)) {\\n continue;\\n } else {\\n dropping = false;\\n }\\n return goog.iter.createEs6IteratorYield(value);\\n }\\n };\\n\\n return newIter;\\n};\\n\\n\\n/**\\n * Builds a new iterator that iterates over the original, but only as long as a\\n * supplied function returns true.\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * object.\\n * @param {\\n * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f\\n * The function to call for every value. This function takes 3 arguments\\n * (the value, undefined, and the iterator) and should return a boolean.\\n * @param {THIS=} opt_obj This is used as the 'this' object in f when called.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that keeps elements in\\n * the original iterator as long as the function is true.\\n * @template THIS, VALUE\\n */\\ngoog.iter.takeWhile = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n const {done, value} = iterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n if (f.call(opt_obj, value, undefined, iterator)) {\\n return goog.iter.createEs6IteratorYield(value);\\n }\\n return goog.iter.ES6_ITERATOR_DONE;\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Converts the iterator to an array\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator\\n * to convert to an array.\\n * @return {!Array<VALUE>} An array of the elements the iterator iterates over.\\n * @template VALUE\\n */\\ngoog.iter.toArray = function(iterable) {\\n 'use strict';\\n // Fast path for array-like.\\n if (goog.isArrayLike(iterable)) {\\n return goog.array.toArray(/** @type {!IArrayLike<?>} */ (iterable));\\n }\\n iterable = goog.iter.toIterator(iterable);\\n const array = [];\\n goog.iter.forEach(iterable, function(val) {\\n 'use strict';\\n array.push(val);\\n });\\n return array;\\n};\\n\\n\\n/**\\n * Iterates over two iterables and returns true if they contain the same\\n * sequence of elements and have the same length.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable1 The first\\n * iterable object.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable2 The second\\n * iterable object.\\n * @param {function(VALUE,VALUE):boolean=} opt_equalsFn Optional comparison\\n * function.\\n * Should take two arguments to compare, and return true if the arguments\\n * are equal. Defaults to {@link goog.array.defaultCompareEquality} which\\n * compares the elements using the built-in '===' operator.\\n * @return {boolean} true if the iterables contain the same sequence of elements\\n * and have the same length.\\n * @template VALUE\\n */\\ngoog.iter.equals = function(iterable1, iterable2, opt_equalsFn) {\\n 'use strict';\\n const fillValue = {};\\n const pairs = goog.iter.zipLongest(fillValue, iterable1, iterable2);\\n const equalsFn = opt_equalsFn || goog.array.defaultCompareEquality;\\n return goog.iter.every(pairs, function(pair) {\\n 'use strict';\\n return equalsFn(pair[0], pair[1]);\\n });\\n};\\n\\n\\n/**\\n * Advances the iterator to the next position, returning the given default value\\n * instead of throwing an exception if the iterator has no more entries.\\n * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterable\\n * object.\\n * @param {VALUE} defaultValue The value to return if the iterator is empty.\\n * @return {VALUE} The next item in the iteration, or defaultValue if the\\n * iterator was empty.\\n * @template VALUE\\n */\\ngoog.iter.nextOrValue = function(iterable, defaultValue) {\\n 'use strict';\\n const iterator = /** @type {!goog.iter.Iterator<VALUE>} */ (\\n goog.iter.toIterator(iterable));\\n const {done, value} = iterator.next();\\n if (done) return defaultValue;\\n return value;\\n};\\n\\n\\n/**\\n * Cartesian product of zero or more sets. Gives an iterator that gives every\\n * combination of one element chosen from each set. For example,\\n * ([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]).\\n * @see http://docs.python.org/library/itertools.html#itertools.product\\n * @param {...!IArrayLike<VALUE>} var_args Zero or more sets, as\\n * arrays.\\n * @return {!goog.iter.Iterator<!Array<VALUE>>} An iterator that gives each\\n * n-tuple (as an array).\\n * @template VALUE\\n */\\ngoog.iter.product = function(var_args) {\\n 'use strict';\\n const someArrayEmpty = Array.prototype.some.call(arguments, function(arr) {\\n 'use strict';\\n return !arr.length;\\n });\\n\\n // An empty set in a cartesian product gives an empty set.\\n if (someArrayEmpty || !arguments.length) {\\n return /** @type {!goog.iter.Iterator<!Array<VALUE>>} */ (\\n new goog.iter.Iterator());\\n }\\n\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n const arrays = arguments;\\n\\n // The first indices are [0, 0, ...]\\n /** @type {?Array<number>} */\\n let indices = goog.array.repeat(0, arrays.length);\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n if (indices) {\\n const retVal = goog.array.map(indices, function(valueIndex, arrayIndex) {\\n 'use strict';\\n return arrays[arrayIndex][valueIndex];\\n });\\n\\n // Generate the next-largest indices for the next call.\\n // Increase the rightmost index. If it goes over, increase the next\\n // rightmost (like carry-over addition).\\n for (let i = indices.length - 1; i >= 0; i--) {\\n // Assertion prevents compiler warning below.\\n goog.asserts.assert(indices);\\n if (indices[i] < arrays[i].length - 1) {\\n indices[i]++;\\n break;\\n }\\n\\n // We're at the last indices (the last element of every array), so\\n // the iteration is over on the next call.\\n if (i == 0) {\\n indices = null;\\n break;\\n }\\n // Reset the index in this column and loop back to increment the\\n // next one.\\n indices[i] = 0;\\n }\\n return goog.iter.createEs6IteratorYield(retVal);\\n }\\n\\n return goog.iter.ES6_ITERATOR_DONE;\\n };\\n\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Create an iterator to cycle over the iterable's elements indefinitely.\\n * For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ...\\n * @see: http://docs.python.org/library/itertools.html#itertools.cycle.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable object.\\n * @return {!goog.iter.Iterator<VALUE>} An iterator that iterates indefinitely\\n * over the values in `iterable`.\\n * @template VALUE\\n */\\ngoog.iter.cycle = function(iterable) {\\n 'use strict';\\n const baseIterator = /** @type {!goog.iter.Iterator<VALUE>} */ (\\n goog.iter.toIterator(iterable));\\n\\n // We maintain a cache to store the iterable elements as we iterate\\n // over them. The cache is used to return elements once we have\\n // iterated over the iterable once.\\n const cache = [];\\n let cacheIndex = 0;\\n\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n // This flag is set after the iterable is iterated over once\\n let useCache = false;\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n let returnElement = null;\\n\\n // Pull elements off the original iterator if not using cache\\n if (!useCache) {\\n const it = baseIterator.next();\\n if (it.done) {\\n if (goog.array.isEmpty(cache)) {\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n // set useCache to true after we've exhausted the inner iterator and\\n // there is at least one element in the cache.\\n useCache = true;\\n // Fallthrough to using the cache immediately.\\n } else {\\n cache.push(it.value);\\n return it;\\n }\\n }\\n\\n returnElement = cache[cacheIndex];\\n cacheIndex = (cacheIndex + 1) % cache.length;\\n\\n return goog.iter.createEs6IteratorYield(returnElement);\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that counts indefinitely from a starting value.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.count\\n * @param {number=} opt_start The starting value. Default is 0.\\n * @param {number=} opt_step The number to increment with between each call to\\n * next. Negative and floating point numbers are allowed. Default is 1.\\n * @return {!goog.iter.Iterator<number>} A new iterator that returns the values\\n * in the series.\\n */\\ngoog.iter.count = function(opt_start, opt_step) {\\n 'use strict';\\n let counter = opt_start || 0;\\n const step = (opt_step !== undefined) ? opt_step : 1;\\n const iter =\\n /** @type {!goog.iter.Iterator<number>} */ (new goog.iter.Iterator());\\n\\n /**\\n * @return {!IIterableResult<number>}\\n * @override @see {!goog.iter.Iterator}\\n */\\n iter.next = function() {\\n 'use strict';\\n const returnValue = counter;\\n counter += step;\\n return goog.iter.createEs6IteratorYield(returnValue);\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns the same object or value repeatedly.\\n * @param {VALUE} value Any object or value to repeat.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that returns the\\n * repeated value.\\n * @template VALUE\\n */\\ngoog.iter.repeat = function(value) {\\n 'use strict';\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n return goog.iter.createEs6IteratorYield(value);\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns running totals from the numbers in\\n * `iterable`. For example, the array {@code [1, 2, 3, 4, 5]} yields\\n * {@code 1 -> 3 -> 6 -> 10 -> 15}.\\n * @see http://docs.python.org/3.2/library/itertools.html#itertools.accumulate\\n * @param {!goog.iter.Iterator<number>|!goog.iter.Iterable} iterable The\\n * iterable of numbers to accumulate.\\n * @return {!goog.iter.Iterator<number>} A new iterator that returns the\\n * numbers in the series.\\n */\\ngoog.iter.accumulate = function(iterable) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n let total = 0;\\n const iter =\\n /** @type {!goog.iter.Iterator<number>} */ (new goog.iter.Iterator());\\n\\n /**\\n * @return {!IIterableResult<number>}\\n * @override @see {!goog.iter.Iterator}\\n */\\n iter.next = function() {\\n 'use strict';\\n const {done, value} = iterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n total += value;\\n return goog.iter.createEs6IteratorYield(total);\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns arrays containing the ith elements from the\\n * provided iterables. The returned arrays will be the same size as the number\\n * of iterables given in `var_args`. Once the shortest iterable is\\n * exhausted, subsequent calls to `next()` will return\\n * `goog.iter.ES6_ITERATOR_DONE`.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.izip\\n * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any\\n * number of iterable objects.\\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator that returns\\n * arrays of elements from the provided iterables.\\n * @template VALUE\\n */\\ngoog.iter.zip = function(var_args) {\\n 'use strict';\\n const args = arguments;\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n if (args.length > 0) {\\n const iterators = goog.array.map(args, goog.iter.toIterator);\\n let allDone = false;\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n if (allDone) return goog.iter.ES6_ITERATOR_DONE;\\n\\n const arr = [];\\n for (let i = 0, iterator; iterator = iterators[i++];) {\\n const it = /** @type {!IIterableResult<VALUE>} */ (iterator.next());\\n if (it.done) {\\n // One of the iterators being zipped is done, so set allDone and\\n // return.\\n allDone = true;\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n arr.push(it.value);\\n }\\n return goog.iter.createEs6IteratorYield(arr);\\n };\\n }\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns arrays containing the ith elements from the\\n * provided iterables. The returned arrays will be the same size as the number\\n * of iterables given in `var_args`. Shorter iterables will be extended\\n * with `fillValue`. Once the longest iterable is exhausted, subsequent\\n * calls to `next()` will return `goog.iter.ES6_ITERATOR_DONE`.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.izip_longest\\n * @param {VALUE} fillValue The object or value used to fill shorter iterables.\\n * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any\\n * number of iterable objects.\\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator that returns\\n * arrays of elements from the provided iterables.\\n * @template VALUE\\n */\\ngoog.iter.zipLongest = function(fillValue, var_args) {\\n 'use strict';\\n const args = Array.prototype.slice.call(arguments, 1);\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n if (args.length > 0) {\\n const iterators = goog.array.map(args, goog.iter.toIterator);\\n\\n let allDone = false; // set to true once all iterators are empty.\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n if (allDone) return goog.iter.ES6_ITERATOR_DONE;\\n\\n let iteratorsHaveValues = false;\\n const arr = [];\\n for (let i = 0, iterator; iterator = iterators[i++];) {\\n const it = /** @type {!IIterableResult<VALUE>} */ (iterator.next());\\n if (it.done) {\\n // If this iterator is empty, others might not be, so use the\\n // fillValue.\\n arr.push(fillValue);\\n continue;\\n }\\n arr.push(it.value);\\n iteratorsHaveValues = true;\\n }\\n\\n if (!iteratorsHaveValues) {\\n allDone = true;\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n return goog.iter.createEs6IteratorYield(arr);\\n };\\n }\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that filters `iterable` based on a series of\\n * `selectors`. On each call to `next()`, one item is taken from\\n * both the `iterable` and `selectors` iterators. If the item from\\n * `selectors` evaluates to true, the item from `iterable` is given.\\n * Otherwise, it is skipped. Once either `iterable` or `selectors`\\n * is exhausted, subsequent calls to `next()` will return\\n * `goog.iter.ES6_ITERATOR_DONE`.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.compress\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to filter.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} selectors An\\n * iterable of items to be evaluated in a boolean context to determine if\\n * the corresponding element in `iterable` should be included in the\\n * result.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator that returns the\\n * filtered values.\\n * @template VALUE\\n */\\ngoog.iter.compress = function(iterable, selectors) {\\n 'use strict';\\n const valueIterator = goog.iter.toIterator(iterable);\\n const selectorIterator = goog.iter.toIterator(selectors);\\n\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n let allDone = false;\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n if (allDone) return goog.iter.ES6_ITERATOR_DONE;\\n\\n while (true) {\\n const valIt = valueIterator.next();\\n if (valIt.done) {\\n allDone = true;\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n\\n const selectorIt = selectorIterator.next();\\n if (selectorIt.done) {\\n allDone = true;\\n return goog.iter.ES6_ITERATOR_DONE;\\n }\\n\\n const val = valIt.value;\\n const selectorVal = selectorIt.value;\\n if (selectorVal) return goog.iter.createEs6IteratorYield(val);\\n }\\n };\\n\\n return iter;\\n};\\n\\n\\n\\n/**\\n * Implements the `goog.iter.groupBy` iterator.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to group.\\n * @param {function(VALUE): KEY=} opt_keyFunc Optional function for\\n * determining the key value for each group in the `iterable`. Default\\n * is the identity function.\\n * @constructor\\n * @extends {goog.iter.Iterator<!Array<?>>}\\n * @template KEY, VALUE\\n * @private\\n */\\ngoog.iter.GroupByIterator_ = function(iterable, opt_keyFunc) {\\n 'use strict';\\n /**\\n * The iterable to group, coerced to an iterator.\\n * @type {!goog.iter.Iterator}\\n */\\n this.iterator = goog.iter.toIterator(iterable);\\n\\n /**\\n * A function for determining the key value for each element in the iterable.\\n * If no function is provided, the identity function is used and returns the\\n * element unchanged.\\n * @type {function(VALUE): KEY}\\n */\\n this.keyFunc = opt_keyFunc || goog.functions.identity;\\n\\n /**\\n * The target key for determining the start of a group.\\n * @type {KEY}\\n */\\n this.targetKey;\\n\\n /**\\n * The current key visited during iteration.\\n * @type {KEY}\\n */\\n this.currentKey;\\n\\n /**\\n * The current value being added to the group.\\n * @type {VALUE}\\n */\\n this.currentValue;\\n};\\ngoog.inherits(goog.iter.GroupByIterator_, goog.iter.Iterator);\\n\\n\\n/**\\n * @return {!IIterableResult<!Array<?>>}\\n * @override\\n */\\ngoog.iter.GroupByIterator_.prototype.next = function() {\\n 'use strict';\\n while (this.currentKey == this.targetKey) {\\n const it = this.iterator.next();\\n if (it.done) return goog.iter.ES6_ITERATOR_DONE;\\n this.currentValue = it.value;\\n this.currentKey = this.keyFunc(this.currentValue);\\n }\\n this.targetKey = this.currentKey;\\n return goog.iter.createEs6IteratorYield(\\n [this.currentKey, this.groupItems_(this.targetKey)]);\\n};\\n\\n\\n/**\\n * Performs the grouping of objects using the given key.\\n * @param {KEY} targetKey The target key object for the group.\\n * @return {!Array<VALUE>} An array of grouped objects.\\n * @private\\n */\\ngoog.iter.GroupByIterator_.prototype.groupItems_ = function(targetKey) {\\n 'use strict';\\n const arr = [];\\n while (this.currentKey == targetKey) {\\n arr.push(this.currentValue);\\n const it = this.iterator.next();\\n if (it.done) break;\\n this.currentValue = it.value;\\n this.currentKey = this.keyFunc(this.currentValue);\\n }\\n return arr;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns arrays containing elements from the\\n * `iterable` grouped by a key value. For iterables with repeated\\n * elements (i.e. sorted according to a particular key function), this function\\n * has a `uniq`-like effect. For example, grouping the array:\\n * {@code [A, B, B, C, C, A]} produces\\n * {@code [A, [A]], [B, [B, B]], [C, [C, C]], [A, [A]]}.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.groupby\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to group.\\n * @param {function(VALUE): KEY=} opt_keyFunc Optional function for\\n * determining the key value for each group in the `iterable`. Default\\n * is the identity function.\\n * @return {!goog.iter.Iterator<!Array<?>>} A new iterator that returns\\n * arrays of consecutive key and groups.\\n * @template KEY, VALUE\\n */\\ngoog.iter.groupBy = function(iterable, opt_keyFunc) {\\n 'use strict';\\n return new goog.iter.GroupByIterator_(iterable, opt_keyFunc);\\n};\\n\\n\\n/**\\n * Gives an iterator that gives the result of calling the given function\\n * <code>f</code> with the arguments taken from the next element from\\n * <code>iterable</code> (the elements are expected to also be iterables).\\n *\\n * Similar to {@see goog.iter.map} but allows the function to accept multiple\\n * arguments from the iterable.\\n *\\n * @param {!goog.iter.Iterator<?>|!goog.iter.Iterable} iterable The iterable of\\n * iterables to iterate over.\\n * @param {function(this:THIS,...*):RESULT} f The function to call for every\\n * element. This function takes N+2 arguments, where N represents the\\n * number of items from the next element of the iterable. The two\\n * additional arguments passed to the function are undefined and the\\n * iterator itself. The function should return a new value.\\n * @param {THIS=} opt_obj The object to be used as the value of 'this' within\\n * `f`.\\n * @return {!goog.iter.Iterator<RESULT>} A new iterator that returns the\\n * results of applying the function to each element in the original\\n * iterator.\\n * @template THIS, RESULT\\n */\\ngoog.iter.starMap = function(iterable, f, opt_obj) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n const iter =\\n /** @type {!goog.iter.Iterator<RESULT>} */ (new goog.iter.Iterator());\\n\\n /**\\n * @return {!IIterableResult<RESULT>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n const it = /** @type {!IIterableResult<!goog.iter.Iterator<?>>} */ (\\n iterator.next());\\n if (it.done) return goog.iter.ES6_ITERATOR_DONE;\\n const args = goog.iter.toArray(it.value);\\n const value = f.apply(opt_obj, [].concat(args, undefined, iterator));\\n return goog.iter.createEs6IteratorYield(value);\\n };\\n\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Returns an array of iterators each of which can iterate over the values in\\n * `iterable` without advancing the others.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.tee\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to tee.\\n * @param {number=} opt_num The number of iterators to create. Default is 2.\\n * @return {!Array<goog.iter.Iterator<VALUE>>} An array of iterators.\\n * @template VALUE\\n */\\ngoog.iter.tee = function(iterable, opt_num) {\\n 'use strict';\\n const iterator = goog.iter.toIterator(iterable);\\n const num = (typeof opt_num === 'number') ? opt_num : 2;\\n const buffers = goog.array.map(goog.array.range(num), function() {\\n 'use strict';\\n return [];\\n });\\n\\n /***\\n * @return {boolean} True iff something was added to the buffers, false\\n * otherwise. Used to signal whether there were any more iterators, or if\\n * the parent iterator should indicate exhaustion.\\n */\\n function addNextIteratorValueToBuffers() {\\n 'use strict';\\n const {done, value} = iterator.next();\\n if (done) return false;\\n for (let i = 0, buffer; buffer = buffers[i++];) {\\n buffer.push(value);\\n }\\n return true;\\n }\\n\\n /***\\n * @param {!Array<VALUE>} buffer\\n * @return {!goog.iter.Iterator<VALUE>}\\n */\\n function createIterator(buffer) {\\n 'use strict';\\n // Each tee'd iterator has an associated buffer (initially empty). When a\\n // tee'd iterator's buffer is empty, it calls\\n // addNextIteratorValueToBuffers(), adding the next value to all tee'd\\n // iterators' buffers, and then returns that value. This allows each\\n // iterator to be advanced independently.\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n if (goog.array.isEmpty(buffer)) {\\n const added = addNextIteratorValueToBuffers();\\n if (!added) return goog.iter.ES6_ITERATOR_DONE;\\n }\\n goog.asserts.assert(!goog.array.isEmpty(buffer));\\n return goog.iter.createEs6IteratorYield(buffer.shift());\\n };\\n\\n return iter;\\n }\\n\\n return goog.array.map(buffers, createIterator);\\n};\\n\\n\\n/**\\n * Creates an iterator that returns arrays containing a count and an element\\n * obtained from the given `iterable`.\\n * @see http://docs.python.org/2/library/functions.html#enumerate\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to enumerate.\\n * @param {number=} opt_start Optional starting value. Default is 0.\\n * @return {!goog.iter.Iterator<!Array<?>>} A new iterator containing\\n * count/item pairs.\\n * @template VALUE\\n */\\ngoog.iter.enumerate = function(iterable, opt_start) {\\n 'use strict';\\n return goog.iter.zip(goog.iter.count(opt_start), iterable);\\n};\\n\\n\\n/**\\n * Creates an iterator that returns the first `limitSize` elements from an\\n * iterable. If this number is greater than the number of elements in the\\n * iterable, all the elements are returned.\\n * @see http://goo.gl/V0sihp Inspired by the limit iterator in Guava.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to limit.\\n * @param {number} limitSize The maximum number of elements to return.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator containing\\n * `limitSize` elements.\\n * @template VALUE\\n */\\ngoog.iter.limit = function(iterable, limitSize) {\\n 'use strict';\\n goog.asserts.assert(goog.math.isInt(limitSize) && limitSize >= 0);\\n\\n const iterator = goog.iter.toIterator(iterable);\\n\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n let remaining = limitSize;\\n\\n /**\\n * @return {!IIterableResult<VALUE>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n if (remaining-- > 0) {\\n return iterator.next();\\n }\\n return goog.iter.ES6_ITERATOR_DONE;\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that is advanced `count` steps ahead. Consumed\\n * values are silently discarded. If `count` is greater than the number\\n * of elements in `iterable`, an empty iterator is returned. Subsequent\\n * calls to `next()` will return `goog.iter.ES6_ITERATOR_DONE`.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to consume.\\n * @param {number} count The number of elements to consume from the iterator.\\n * @return {!goog.iter.Iterator<VALUE>} An iterator advanced zero or more steps\\n * ahead.\\n * @template VALUE\\n */\\ngoog.iter.consume = function(iterable, count) {\\n 'use strict';\\n goog.asserts.assert(goog.math.isInt(count) && count >= 0);\\n\\n const iterator = goog.iter.toIterator(iterable);\\n\\n while (count-- > 0) {\\n goog.iter.nextOrValue(iterator, null);\\n }\\n\\n return iterator;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns a range of elements from an iterable.\\n * Similar to {@see goog.array.slice} but does not support negative indexes.\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to slice.\\n * @param {number} start The index of the first element to return.\\n * @param {number=} opt_end The index after the last element to return. If\\n * defined, must be greater than or equal to `start`.\\n * @return {!goog.iter.Iterator<VALUE>} A new iterator containing a slice of\\n * the original.\\n * @template VALUE\\n */\\ngoog.iter.slice = function(iterable, start, opt_end) {\\n 'use strict';\\n goog.asserts.assert(goog.math.isInt(start) && start >= 0);\\n\\n let iterator = goog.iter.consume(iterable, start);\\n\\n if (typeof opt_end === 'number') {\\n goog.asserts.assert(goog.math.isInt(opt_end) && opt_end >= start);\\n iterator = goog.iter.limit(iterator, opt_end - start /* limitSize */);\\n }\\n\\n return iterator;\\n};\\n\\n\\n/**\\n * Checks an array for duplicate elements.\\n * @param {?IArrayLike<VALUE>} arr The array to check for\\n * duplicates.\\n * @return {boolean} True, if the array contains duplicates, false otherwise.\\n * @private\\n * @template VALUE\\n */\\n// TODO(user): Consider moving this into goog.array as a public function.\\ngoog.iter.hasDuplicates_ = function(arr) {\\n 'use strict';\\n const deduped = [];\\n goog.array.removeDuplicates(arr, deduped);\\n return arr.length != deduped.length;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns permutations of elements in\\n * `iterable`.\\n *\\n * Permutations are obtained by taking the Cartesian product of\\n * `opt_length` iterables and filtering out those with repeated\\n * elements. For example, the permutations of {@code [1,2,3]} are\\n * {@code [[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]}.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.permutations\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable from which to generate permutations.\\n * @param {number=} opt_length Length of each permutation. If omitted, defaults\\n * to the length of `iterable`.\\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing the\\n * permutations of `iterable`.\\n * @template VALUE\\n */\\ngoog.iter.permutations = function(iterable, opt_length) {\\n 'use strict';\\n const elements = goog.iter.toArray(iterable);\\n const length =\\n (typeof opt_length === 'number') ? opt_length : elements.length;\\n\\n const sets = goog.array.repeat(elements, length);\\n const product = goog.iter.product.apply(undefined, sets);\\n\\n return goog.iter.filter(product, function(arr) {\\n 'use strict';\\n return !goog.iter.hasDuplicates_(arr);\\n });\\n};\\n\\n\\n/**\\n * Creates an iterator that returns combinations of elements from\\n * `iterable`.\\n *\\n * Combinations are obtained by taking the {@see goog.iter.permutations} of\\n * `iterable` and filtering those whose elements appear in the order they\\n * are encountered in `iterable`. For example, the 3-length combinations\\n * of {@code [0,1,2,3]} are {@code [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]}.\\n * @see http://docs.python.org/2/library/itertools.html#itertools.combinations\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable from which to generate combinations.\\n * @param {number} length The length of each combination.\\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing\\n * combinations from the `iterable`.\\n * @template VALUE\\n */\\ngoog.iter.combinations = function(iterable, length) {\\n 'use strict';\\n const elements = goog.iter.toArray(iterable);\\n const indexes = goog.iter.range(elements.length);\\n const indexIterator = goog.iter.permutations(indexes, length);\\n // sortedIndexIterator will now give arrays of with the given length that\\n // indicate what indexes into \\\"elements\\\" should be returned on each iteration.\\n const sortedIndexIterator = goog.iter.filter(indexIterator, function(arr) {\\n 'use strict';\\n return goog.array.isSorted(arr);\\n });\\n\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n function getIndexFromElements(index) {\\n return elements[index];\\n }\\n /**\\n * @return {!IIterableResult<!Array<VALUE>>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n const {done, value} = sortedIndexIterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n return goog.iter.createEs6IteratorYield(\\n goog.array.map(value, getIndexFromElements));\\n };\\n\\n return iter;\\n};\\n\\n\\n/**\\n * Creates an iterator that returns combinations of elements from\\n * `iterable`, with repeated elements possible.\\n *\\n * Combinations are obtained by taking the Cartesian product of `length`\\n * iterables and filtering those whose elements appear in the order they are\\n * encountered in `iterable`. For example, the 2-length combinations of\\n * {@code [1,2,3]} are {@code [[1,1], [1,2], [1,3], [2,2], [2,3], [3,3]]}.\\n * @see https://goo.gl/C0yXe4\\n * @see https://goo.gl/djOCsk\\n * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The\\n * iterable to combine.\\n * @param {number} length The length of each combination.\\n * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing\\n * combinations from the `iterable`.\\n * @template VALUE\\n */\\ngoog.iter.combinationsWithReplacement = function(iterable, length) {\\n 'use strict';\\n const elements = goog.iter.toArray(iterable);\\n const indexes = goog.array.range(elements.length);\\n const sets = goog.array.repeat(indexes, length);\\n const indexIterator = goog.iter.product.apply(undefined, sets);\\n // sortedIndexIterator will now give arrays of with the given length that\\n // indicate what indexes into \\\"elements\\\" should be returned on each iteration.\\n const sortedIndexIterator = goog.iter.filter(indexIterator, function(arr) {\\n 'use strict';\\n return goog.array.isSorted(arr);\\n });\\n\\n const iter =\\n /** @type {!goog.iter.Iterator<VALUE>} */ (new goog.iter.Iterator());\\n\\n function getIndexFromElements(index) {\\n return elements[index];\\n }\\n\\n /**\\n * @return {!IIterableResult<!Array<VALUE>>}\\n * @override\\n */\\n iter.next = function() {\\n 'use strict';\\n const {done, value} = sortedIndexIterator.next();\\n if (done) return goog.iter.ES6_ITERATOR_DONE;\\n return goog.iter.createEs6IteratorYield(goog.array.map(\\n /** @type {!Array<number>} */ (value), getIndexFromElements));\\n };\\n\\n return iter;\\n};\\n\"],\n\"names\":[\"goog\",\"provide\",\"require\",\"iter\",\"Iterable\",\"Iterator\",\"goog.iter.Iterator\",\"prototype\",\"next\",\"goog.iter.Iterator.prototype.next\",\"ES6_ITERATOR_DONE\",\"debug\",\"freeze\",\"done\",\"value\",\"undefined\",\"createEs6IteratorYield\",\"goog.iter.createEs6IteratorYield\",\"__iterator__\",\"goog.iter.Iterator.prototype.__iterator__\",\"opt_keys\",\"toIterator\",\"goog.iter.toIterator\",\"iterable\",\"isArrayLike\",\"like\",\"i\",\"newIter\",\"newIter.next\",\"length\",\"Error\",\"forEach\",\"goog.iter.forEach\",\"f\",\"opt_obj\",\"array\",\"iterator\",\"call\",\"filter\",\"goog.iter.filter\",\"filterFalse\",\"goog.iter.filterFalse\",\"functions\",\"not\",\"range\",\"goog.iter.range\",\"startOrStop\",\"opt_stop\",\"opt_step\",\"start\",\"stop\",\"step\",\"arguments\",\"rv\",\"join\",\"goog.iter.join\",\"deliminator\",\"toArray\",\"map\",\"goog.iter.map\",\"mappedVal\",\"reduce\",\"goog.iter.reduce\",\"val\",\"rval\",\"some\",\"goog.iter.some\",\"every\",\"goog.iter.every\",\"chain\",\"goog.iter.chain\",\"var_args\",\"chainFromIterable\",\"goog.iter.chainFromIterable\",\"iteratorOfIterators\",\"current\",\"iter.next\",\"it\",\"dropWhile\",\"goog.iter.dropWhile\",\"dropping\",\"takeWhile\",\"goog.iter.takeWhile\",\"goog.iter.toArray\",\"push\",\"equals\",\"goog.iter.equals\",\"iterable1\",\"iterable2\",\"opt_equalsFn\",\"fillValue\",\"pairs\",\"zipLongest\",\"equalsFn\",\"defaultCompareEquality\",\"pair\",\"nextOrValue\",\"goog.iter.nextOrValue\",\"defaultValue\",\"product\",\"goog.iter.product\",\"someArrayEmpty\",\"Array\",\"arr\",\"arrays\",\"indices\",\"repeat\",\"retVal\",\"valueIndex\",\"arrayIndex\",\"asserts\",\"assert\",\"cycle\",\"goog.iter.cycle\",\"baseIterator\",\"cache\",\"cacheIndex\",\"useCache\",\"returnElement\",\"isEmpty\",\"count\",\"goog.iter.count\",\"opt_start\",\"counter\",\"returnValue\",\"goog.iter.repeat\",\"accumulate\",\"goog.iter.accumulate\",\"total\",\"zip\",\"goog.iter.zip\",\"args\",\"iterators\",\"allDone\",\"goog.iter.zipLongest\",\"slice\",\"iteratorsHaveValues\",\"compress\",\"goog.iter.compress\",\"selectors\",\"valueIterator\",\"selectorIterator\",\"valIt\",\"selectorIt\",\"selectorVal\",\"GroupByIterator_\",\"goog.iter.GroupByIterator_\",\"opt_keyFunc\",\"keyFunc\",\"identity\",\"targetKey\",\"currentKey\",\"currentValue\",\"inherits\",\"goog.iter.GroupByIterator_.prototype.next\",\"groupItems_\",\"goog.iter.GroupByIterator_.prototype.groupItems_\",\"groupBy\",\"goog.iter.groupBy\",\"starMap\",\"goog.iter.starMap\",\"apply\",\"concat\",\"tee\",\"goog.iter.tee\",\"opt_num\",\"num\",\"buffers\",\"addNextIteratorValueToBuffers\",\"buffer\",\"createIterator\",\"added\",\"shift\",\"enumerate\",\"goog.iter.enumerate\",\"limit\",\"goog.iter.limit\",\"limitSize\",\"math\",\"isInt\",\"remaining\",\"consume\",\"goog.iter.consume\",\"goog.iter.slice\",\"opt_end\",\"hasDuplicates_\",\"goog.iter.hasDuplicates_\",\"deduped\",\"removeDuplicates\",\"permutations\",\"goog.iter.permutations\",\"opt_length\",\"elements\",\"sets\",\"combinations\",\"goog.iter.combinations\",\"indexes\",\"indexIterator\",\"sortedIndexIterator\",\"isSorted\",\"getIndexFromElements\",\"index\",\"combinationsWithReplacement\",\"goog.iter.combinationsWithReplacement\"]\n}\n"] |