Index: third_party/google_input_tools/third_party/closure_library/closure/goog/iter/iter.js |
diff --git a/third_party/google_input_tools/third_party/closure_library/closure/goog/iter/iter.js b/third_party/google_input_tools/third_party/closure_library/closure/goog/iter/iter.js |
index b7744d5fbf9b92ba284127663501e6b53abe8750..5d913276f5608bdd3de875aeb51d204eaa224dd8 100644 |
--- a/third_party/google_input_tools/third_party/closure_library/closure/goog/iter/iter.js |
+++ b/third_party/google_input_tools/third_party/closure_library/closure/goog/iter/iter.js |
@@ -35,21 +35,14 @@ goog.require('goog.math'); |
goog.iter.Iterable; |
-// For script engines that already support iterators. |
-if ('StopIteration' in goog.global) { |
- /** |
- * Singleton Error object that is used to terminate iterations. |
- * @type {Error} |
- */ |
- goog.iter.StopIteration = goog.global['StopIteration']; |
-} else { |
- /** |
- * Singleton Error object that is used to terminate iterations. |
- * @type {Error} |
- * @suppress {duplicate} |
- */ |
- goog.iter.StopIteration = Error('StopIteration'); |
-} |
+/** |
+ * Singleton Error object that is used to terminate iterations. |
+ * @const {!Error} |
+ */ |
+goog.iter.StopIteration = ('StopIteration' in goog.global) ? |
+ // For script engines that support legacy iterators. |
+ goog.global['StopIteration'] : |
+ { message: 'StopIteration', stack: ''}; |
@@ -83,7 +76,7 @@ goog.iter.Iterator.prototype.next = function() { |
* and the for-each-in loop (false). Even though the param gives a hint |
* about what the iterator will return there is no guarantee that it will |
* return the keys when true is passed. |
- * @return {!goog.iter.Iterator.<VALUE>} The object itself. |
+ * @return {!goog.iter.Iterator<VALUE>} The object itself. |
*/ |
goog.iter.Iterator.prototype.__iterator__ = function(opt_keys) { |
return this; |
@@ -92,12 +85,12 @@ goog.iter.Iterator.prototype.__iterator__ = function(opt_keys) { |
/** |
* Returns an iterator that knows how to iterate over the values in the object. |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable If the |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable If the |
* object is an iterator it will be returned as is. If the object has an |
* {@code __iterator__} method that will be called to get the value |
* iterator. If the object is an array-like object we create an iterator |
* for that. |
- * @return {!goog.iter.Iterator.<VALUE>} An iterator that knows how to iterate |
+ * @return {!goog.iter.Iterator<VALUE>} An iterator that knows how to iterate |
* over the values in {@code iterable}. |
* @template VALUE |
*/ |
@@ -137,16 +130,16 @@ goog.iter.toIterator = function(iterable) { |
* Calls a function for each element in the iterator with the element of the |
* iterator passed as argument. |
* |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* to iterate over. If the iterable is an object {@code toIterator} will be |
* called on it. |
- * @param {function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>)| |
- * function(this:THIS,number,undefined,goog.iter.Iterator.<VALUE>)} f |
+ * @param {function(this:THIS,VALUE,?,!goog.iter.Iterator<VALUE>)} f |
* The function to call for every element. This function takes 3 arguments |
* (the element, undefined, and the iterator) and the return value is |
* irrelevant. The reason for passing undefined as the second argument is |
* so that the same function can be used in {@see goog.array#forEach} as |
- * well as others. |
+ * well as others. The third parameter is of type "number" for |
+ * arraylike objects, undefined, otherwise. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
* {@code f}. |
* @template THIS, VALUE |
@@ -184,17 +177,17 @@ goog.iter.forEach = function(iterable, f, opt_obj) { |
* Calls a function for every element in the iterator, and if the function |
* returns true adds the element to a new iterator. |
* |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* to iterate over. |
* @param { |
- * function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>):boolean} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f |
* The function to call for every element. This function takes 3 arguments |
* (the element, undefined, and the iterator) and should return a boolean. |
* If the return value is true the element will be included in the returned |
* iterator. If it is false the element is not included. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
* {@code f}. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator in which only elements |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator in which only elements |
* that passed the test are present. |
* @template THIS, VALUE |
*/ |
@@ -217,17 +210,17 @@ goog.iter.filter = function(iterable, f, opt_obj) { |
* Calls a function for every element in the iterator, and if the function |
* returns false adds the element to a new iterator. |
* |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* to iterate over. |
* @param { |
- * function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>):boolean} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f |
* The function to call for every element. This function takes 3 arguments |
* (the element, undefined, and the iterator) and should return a boolean. |
* If the return value is false the element will be included in the returned |
* iterator. If it is true the element is not included. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
* {@code f}. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator in which only elements |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator in which only elements |
* that did not pass the test are present. |
* @template THIS, VALUE |
*/ |
@@ -251,7 +244,7 @@ goog.iter.filterFalse = function(iterable, f, opt_obj) { |
* argument is used as the stop value. |
* @param {number=} opt_step The number to increment with between each call to |
* next. This can be negative. |
- * @return {!goog.iter.Iterator.<number>} A new iterator that returns the values |
+ * @return {!goog.iter.Iterator<number>} A new iterator that returns the values |
* in the range. |
*/ |
goog.iter.range = function(startOrStop, opt_stop, opt_step) { |
@@ -281,7 +274,7 @@ goog.iter.range = function(startOrStop, opt_stop, opt_step) { |
/** |
* Joins the values in a iterator with a delimiter. |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* to get the values from. |
* @param {string} deliminator The text to put between the values. |
* @return {string} The joined value string. |
@@ -296,15 +289,15 @@ goog.iter.join = function(iterable, deliminator) { |
* For every element in the iterator call a function and return a new iterator |
* with that value. |
* |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterator to iterate over. |
* @param { |
- * function(this:THIS,VALUE,undefined,!goog.iter.Iterator.<VALUE>):RESULT} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):RESULT} f |
* The function to call for every element. This function takes 3 arguments |
* (the element, undefined, and the iterator) and should return a new value. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
* {@code f}. |
- * @return {!goog.iter.Iterator.<RESULT>} A new iterator that returns the |
+ * @return {!goog.iter.Iterator<RESULT>} A new iterator that returns the |
* results of applying the function to each element in the original |
* iterator. |
* @template THIS, VALUE, RESULT |
@@ -324,7 +317,7 @@ goog.iter.map = function(iterable, f, opt_obj) { |
* Passes every element of an iterator into a function and accumulates the |
* result. |
* |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* to iterate over. |
* @param {function(this:THIS,VALUE,VALUE):VALUE} f The function to call for |
* every element. This function takes 2 arguments (the function's previous |
@@ -352,10 +345,10 @@ goog.iter.reduce = function(iterable, f, val, opt_obj) { |
* any of them returns true, this returns true (without checking the rest). If |
* all return false this will return false. |
* |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* object. |
* @param { |
- * function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>):boolean} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f |
* The function to call for every value. This function takes 3 arguments |
* (the value, undefined, and the iterator) and should return a boolean. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
@@ -386,10 +379,10 @@ goog.iter.some = function(iterable, f, opt_obj) { |
* of them returns false this returns false (without checking the rest). If all |
* return true this will return true. |
* |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* object. |
* @param { |
- * function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>):boolean} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f |
* The function to call for every value. This function takes 3 arguments |
* (the value, undefined, and the iterator) and should return a boolean. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
@@ -418,14 +411,29 @@ goog.iter.every = function(iterable, f, opt_obj) { |
/** |
* Takes zero or more iterables and returns one iterator that will iterate over |
* them in the order chained. |
- * @param {...!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} var_args Any |
+ * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any |
* number of iterable objects. |
- * @return {!goog.iter.Iterator.<VALUE>} Returns a new iterator that will |
+ * @return {!goog.iter.Iterator<VALUE>} Returns a new iterator that will |
* iterate over all the given iterables' contents. |
* @template VALUE |
*/ |
goog.iter.chain = function(var_args) { |
- var iterator = goog.iter.toIterator(arguments); |
+ return goog.iter.chainFromIterable(arguments); |
+}; |
+ |
+ |
+/** |
+ * Takes a single iterable containing zero or more iterables and returns one |
+ * iterator that will iterate over each one in the order given. |
+ * @see http://docs.python.org/2/library/itertools.html#itertools.chain.from_iterable |
+ * @param {goog.iter.Iterable} iterable The iterable of iterables to chain. |
+ * @return {!goog.iter.Iterator<VALUE>} Returns a new iterator that will |
+ * iterate over all the contents of the iterables contained within |
+ * {@code iterable}. |
+ * @template VALUE |
+ */ |
+goog.iter.chainFromIterable = function(iterable) { |
+ var iterator = goog.iter.toIterator(iterable); |
var iter = new goog.iter.Iterator(); |
var current = null; |
@@ -451,32 +459,17 @@ goog.iter.chain = function(var_args) { |
/** |
- * Takes a single iterable containing zero or more iterables and returns one |
- * iterator that will iterate over each one in the order given. |
- * @see http://docs.python.org/2/library/itertools.html#itertools.chain.from_iterable |
- * @param {goog.iter.Iterable} iterable The iterable of iterables to chain. |
- * @return {!goog.iter.Iterator.<VALUE>} Returns a new iterator that will |
- * iterate over all the contents of the iterables contained within |
- * {@code iterable}. |
- * @template VALUE |
- */ |
-goog.iter.chainFromIterable = function(iterable) { |
- return goog.iter.chain.apply(undefined, iterable); |
-}; |
- |
- |
-/** |
* Builds a new iterator that iterates over the original, but skips elements as |
* long as a supplied function returns true. |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* object. |
* @param { |
- * function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>):boolean} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f |
* The function to call for every value. This function takes 3 arguments |
* (the value, undefined, and the iterator) and should return a boolean. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
* {@code f}. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator that drops elements from |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator that drops elements from |
* the original iterator as long as {@code f} is true. |
* @template THIS, VALUE |
*/ |
@@ -502,44 +495,36 @@ goog.iter.dropWhile = function(iterable, f, opt_obj) { |
/** |
* Builds a new iterator that iterates over the original, but only as long as a |
* supplied function returns true. |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* object. |
* @param { |
- * function(this:THIS,VALUE,undefined,goog.iter.Iterator.<VALUE>):boolean} f |
+ * function(this:THIS,VALUE,undefined,!goog.iter.Iterator<VALUE>):boolean} f |
* The function to call for every value. This function takes 3 arguments |
* (the value, undefined, and the iterator) and should return a boolean. |
* @param {THIS=} opt_obj This is used as the 'this' object in f when called. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator that keeps elements in |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator that keeps elements in |
* the original iterator as long as the function is true. |
* @template THIS, VALUE |
*/ |
goog.iter.takeWhile = function(iterable, f, opt_obj) { |
var iterator = goog.iter.toIterator(iterable); |
- var newIter = new goog.iter.Iterator; |
- var taking = true; |
- newIter.next = function() { |
- while (true) { |
- if (taking) { |
- var val = iterator.next(); |
- if (f.call(opt_obj, val, undefined, iterator)) { |
- return val; |
- } else { |
- taking = false; |
- } |
- } else { |
- throw goog.iter.StopIteration; |
- } |
+ var iter = new goog.iter.Iterator(); |
+ iter.next = function() { |
+ var val = iterator.next(); |
+ if (f.call(opt_obj, val, undefined, iterator)) { |
+ return val; |
} |
+ throw goog.iter.StopIteration; |
}; |
- return newIter; |
+ return iter; |
}; |
/** |
* Converts the iterator to an array |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterator |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterator |
* to convert to an array. |
- * @return {!Array.<VALUE>} An array of the elements the iterator iterates over. |
+ * @return {!Array<VALUE>} An array of the elements the iterator iterates over. |
* @template VALUE |
*/ |
goog.iter.toArray = function(iterable) { |
@@ -559,19 +544,25 @@ goog.iter.toArray = function(iterable) { |
/** |
* Iterates over two iterables and returns true if they contain the same |
* sequence of elements and have the same length. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable1 The first |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable1 The first |
* iterable object. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable2 The second |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable2 The second |
* iterable object. |
+ * @param {function(VALUE,VALUE):boolean=} opt_equalsFn Optional comparison |
+ * function. |
+ * Should take two arguments to compare, and return true if the arguments |
+ * are equal. Defaults to {@link goog.array.defaultCompareEquality} which |
+ * compares the elements using the built-in '===' operator. |
* @return {boolean} true if the iterables contain the same sequence of elements |
* and have the same length. |
* @template VALUE |
*/ |
-goog.iter.equals = function(iterable1, iterable2) { |
+goog.iter.equals = function(iterable1, iterable2, opt_equalsFn) { |
var fillValue = {}; |
var pairs = goog.iter.zipLongest(fillValue, iterable1, iterable2); |
+ var equalsFn = opt_equalsFn || goog.array.defaultCompareEquality; |
return goog.iter.every(pairs, function(pair) { |
- return pair[0] == pair[1]; |
+ return equalsFn(pair[0], pair[1]); |
}); |
}; |
@@ -579,7 +570,7 @@ goog.iter.equals = function(iterable1, iterable2) { |
/** |
* Advances the iterator to the next position, returning the given default value |
* instead of throwing an exception if the iterator has no more entries. |
- * @param {goog.iter.Iterator.<VALUE>|goog.iter.Iterable} iterable The iterable |
+ * @param {goog.iter.Iterator<VALUE>|goog.iter.Iterable} iterable The iterable |
* object. |
* @param {VALUE} defaultValue The value to return if the iterator is empty. |
* @return {VALUE} The next item in the iteration, or defaultValue if the |
@@ -603,9 +594,9 @@ goog.iter.nextOrValue = function(iterable, defaultValue) { |
* combination of one element chosen from each set. For example, |
* ([1, 2], [3, 4]) gives ([1, 3], [1, 4], [2, 3], [2, 4]). |
* @see http://docs.python.org/library/itertools.html#itertools.product |
- * @param {...!goog.array.ArrayLike.<VALUE>} var_args Zero or more sets, as |
+ * @param {...!goog.array.ArrayLike<VALUE>} var_args Zero or more sets, as |
* arrays. |
- * @return {!goog.iter.Iterator.<!Array.<VALUE>>} An iterator that gives each |
+ * @return {!goog.iter.Iterator<!Array<VALUE>>} An iterator that gives each |
* n-tuple (as an array). |
* @template VALUE |
*/ |
@@ -667,9 +658,9 @@ goog.iter.product = function(var_args) { |
* Create an iterator to cycle over the iterable's elements indefinitely. |
* For example, ([1, 2, 3]) would return : 1, 2, 3, 1, 2, 3, ... |
* @see: http://docs.python.org/library/itertools.html#itertools.cycle. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable object. |
- * @return {!goog.iter.Iterator.<VALUE>} An iterator that iterates indefinitely |
+ * @return {!goog.iter.Iterator<VALUE>} An iterator that iterates indefinitely |
* over the values in {@code iterable}. |
* @template VALUE |
*/ |
@@ -727,7 +718,7 @@ goog.iter.cycle = function(iterable) { |
* @param {number=} opt_start The starting value. Default is 0. |
* @param {number=} opt_step The number to increment with between each call to |
* next. Negative and floating point numbers are allowed. Default is 1. |
- * @return {!goog.iter.Iterator.<number>} A new iterator that returns the values |
+ * @return {!goog.iter.Iterator<number>} A new iterator that returns the values |
* in the series. |
*/ |
goog.iter.count = function(opt_start, opt_step) { |
@@ -748,7 +739,7 @@ goog.iter.count = function(opt_start, opt_step) { |
/** |
* Creates an iterator that returns the same object or value repeatedly. |
* @param {VALUE} value Any object or value to repeat. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator that returns the |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator that returns the |
* repeated value. |
* @template VALUE |
*/ |
@@ -766,9 +757,9 @@ goog.iter.repeat = function(value) { |
* {@code iterable}. For example, the array {@code [1, 2, 3, 4, 5]} yields |
* {@code 1 -> 3 -> 6 -> 10 -> 15}. |
* @see http://docs.python.org/3.2/library/itertools.html#itertools.accumulate |
- * @param {!goog.iter.Iterable.<number>} iterable The iterable of numbers to |
+ * @param {!goog.iter.Iterable<number>} iterable The iterable of numbers to |
* accumulate. |
- * @return {!goog.iter.Iterator.<number>} A new iterator that returns the |
+ * @return {!goog.iter.Iterator<number>} A new iterator that returns the |
* numbers in the series. |
*/ |
goog.iter.accumulate = function(iterable) { |
@@ -792,9 +783,9 @@ goog.iter.accumulate = function(iterable) { |
* exhausted, subsequent calls to {@code next()} will throw |
* {@code goog.iter.StopIteration}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.izip |
- * @param {...!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} var_args Any |
+ * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any |
* number of iterable objects. |
- * @return {!goog.iter.Iterator.<!Array.<VALUE>>} A new iterator that returns |
+ * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator that returns |
* arrays of elements from the provided iterables. |
* @template VALUE |
*/ |
@@ -824,9 +815,9 @@ goog.iter.zip = function(var_args) { |
* calls to {@code next()} will throw {@code goog.iter.StopIteration}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.izip_longest |
* @param {VALUE} fillValue The object or value used to fill shorter iterables. |
- * @param {...!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} var_args Any |
+ * @param {...!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} var_args Any |
* number of iterable objects. |
- * @return {!goog.iter.Iterator.<!Array.<VALUE>>} A new iterator that returns |
+ * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator that returns |
* arrays of elements from the provided iterables. |
* @template VALUE |
*/ |
@@ -875,13 +866,13 @@ goog.iter.zipLongest = function(fillValue, var_args) { |
* is exhausted, subsequent calls to {@code next()} will throw |
* {@code goog.iter.StopIteration}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.compress |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to filter. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} selectors An |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} selectors An |
* iterable of items to be evaluated in a boolean context to determine if |
* the corresponding element in {@code iterable} should be included in the |
* result. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator that returns the |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator that returns the |
* filtered values. |
* @template VALUE |
*/ |
@@ -897,13 +888,13 @@ goog.iter.compress = function(iterable, selectors) { |
/** |
* Implements the {@code goog.iter.groupBy} iterator. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to group. |
- * @param {function(...[VALUE]): KEY=} opt_keyFunc Optional function for |
+ * @param {function(...VALUE): KEY=} opt_keyFunc Optional function for |
* determining the key value for each group in the {@code iterable}. Default |
* is the identity function. |
* @constructor |
- * @extends {goog.iter.Iterator.<!Array>} |
+ * @extends {goog.iter.Iterator<!Array<?>>} |
* @template KEY, VALUE |
* @private |
*/ |
@@ -919,7 +910,7 @@ goog.iter.GroupByIterator_ = function(iterable, opt_keyFunc) { |
* A function for determining the key value for each element in the iterable. |
* If no function is provided, the identity function is used and returns the |
* element unchanged. |
- * @type {function(...[VALUE]): KEY} |
+ * @type {function(...VALUE): KEY} |
*/ |
this.keyFunc = opt_keyFunc || goog.functions.identity; |
@@ -958,7 +949,7 @@ goog.iter.GroupByIterator_.prototype.next = function() { |
/** |
* Performs the grouping of objects using the given key. |
* @param {KEY} targetKey The target key object for the group. |
- * @return {!Array.<VALUE>} An array of grouped objects. |
+ * @return {!Array<VALUE>} An array of grouped objects. |
* @private |
*/ |
goog.iter.GroupByIterator_.prototype.groupItems_ = function(targetKey) { |
@@ -987,13 +978,13 @@ goog.iter.GroupByIterator_.prototype.groupItems_ = function(targetKey) { |
* {@code [A, B, B, C, C, A]} produces |
* {@code [A, [A]], [B, [B, B]], [C, [C, C]], [A, [A]]}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.groupby |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to group. |
- * @param {function(...[VALUE]): KEY=} opt_keyFunc Optional function for |
+ * @param {function(...VALUE): KEY=} opt_keyFunc Optional function for |
* determining the key value for each group in the {@code iterable}. Default |
* is the identity function. |
- * @return {!goog.iter.Iterator.<!Array>} A new iterator that returns arrays of |
- * consecutive key and groups. |
+ * @return {!goog.iter.Iterator<!Array<?>>} A new iterator that returns |
+ * arrays of consecutive key and groups. |
* @template KEY, VALUE |
*/ |
goog.iter.groupBy = function(iterable, opt_keyFunc) { |
@@ -1009,16 +1000,16 @@ goog.iter.groupBy = function(iterable, opt_keyFunc) { |
* Similar to {@see goog.iter#map} but allows the function to accept multiple |
* arguments from the iterable. |
* |
- * @param {!goog.iter.Iterable.<!goog.iter.Iterable>} iterable The iterable of |
+ * @param {!goog.iter.Iterable<!goog.iter.Iterable>} iterable The iterable of |
* iterables to iterate over. |
- * @param {function(this:THIS,...[*]):RESULT} f The function to call for every |
+ * @param {function(this:THIS,...*):RESULT} f The function to call for every |
* element. This function takes N+2 arguments, where N represents the |
* number of items from the next element of the iterable. The two |
* additional arguments passed to the function are undefined and the |
* iterator itself. The function should return a new value. |
* @param {THIS=} opt_obj The object to be used as the value of 'this' within |
* {@code f}. |
- * @return {!goog.iter.Iterator.<RESULT>} A new iterator that returns the |
+ * @return {!goog.iter.Iterator<RESULT>} A new iterator that returns the |
* results of applying the function to each element in the original |
* iterator. |
* @template THIS, RESULT |
@@ -1040,10 +1031,10 @@ goog.iter.starMap = function(iterable, f, opt_obj) { |
* Returns an array of iterators each of which can iterate over the values in |
* {@code iterable} without advancing the others. |
* @see http://docs.python.org/2/library/itertools.html#itertools.tee |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to tee. |
* @param {number=} opt_num The number of iterators to create. Default is 2. |
- * @return {!Array.<goog.iter.Iterator.<VALUE>>} An array of iterators. |
+ * @return {!Array<goog.iter.Iterator<VALUE>>} An array of iterators. |
* @template VALUE |
*/ |
goog.iter.tee = function(iterable, opt_num) { |
@@ -1087,11 +1078,11 @@ goog.iter.tee = function(iterable, opt_num) { |
* Creates an iterator that returns arrays containing a count and an element |
* obtained from the given {@code iterable}. |
* @see http://docs.python.org/2/library/functions.html#enumerate |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to enumerate. |
* @param {number=} opt_start Optional starting value. Default is 0. |
- * @return {!goog.iter.Iterator.<!Array>} A new iterator containing count/item |
- * pairs. |
+ * @return {!goog.iter.Iterator<!Array<?>>} A new iterator containing |
+ * count/item pairs. |
* @template VALUE |
*/ |
goog.iter.enumerate = function(iterable, opt_start) { |
@@ -1104,10 +1095,10 @@ goog.iter.enumerate = function(iterable, opt_start) { |
* iterable. If this number is greater than the number of elements in the |
* iterable, all the elements are returned. |
* @see http://goo.gl/V0sihp Inspired by the limit iterator in Guava. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to limit. |
* @param {number} limitSize The maximum number of elements to return. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator containing |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator containing |
* {@code limitSize} elements. |
* @template VALUE |
*/ |
@@ -1135,10 +1126,10 @@ goog.iter.limit = function(iterable, limitSize) { |
* values are silently discarded. If {@code count} is greater than the number |
* of elements in {@code iterable}, an empty iterator is returned. Subsequent |
* calls to {@code next()} will throw {@code goog.iter.StopIteration}. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to consume. |
* @param {number} count The number of elements to consume from the iterator. |
- * @return {!goog.iter.Iterator.<VALUE>} An iterator advanced zero or more steps |
+ * @return {!goog.iter.Iterator<VALUE>} An iterator advanced zero or more steps |
* ahead. |
* @template VALUE |
*/ |
@@ -1158,12 +1149,12 @@ goog.iter.consume = function(iterable, count) { |
/** |
* Creates an iterator that returns a range of elements from an iterable. |
* Similar to {@see goog.array#slice} but does not support negative indexes. |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to slice. |
* @param {number} start The index of the first element to return. |
* @param {number=} opt_end The index after the last element to return. If |
* defined, must be greater than or equal to {@code start}. |
- * @return {!goog.iter.Iterator.<VALUE>} A new iterator containing a slice of |
+ * @return {!goog.iter.Iterator<VALUE>} A new iterator containing a slice of |
* the original. |
* @template VALUE |
*/ |
@@ -1173,8 +1164,7 @@ goog.iter.slice = function(iterable, start, opt_end) { |
var iterator = goog.iter.consume(iterable, start); |
if (goog.isNumber(opt_end)) { |
- goog.asserts.assert( |
- goog.math.isInt(/** @type {number} */ (opt_end)) && opt_end >= start); |
+ goog.asserts.assert(goog.math.isInt(opt_end) && opt_end >= start); |
iterator = goog.iter.limit(iterator, opt_end - start /* limitSize */); |
} |
@@ -1184,7 +1174,7 @@ goog.iter.slice = function(iterable, start, opt_end) { |
/** |
* Checks an array for duplicate elements. |
- * @param {Array.<VALUE>|goog.array.ArrayLike} arr The array to check for |
+ * @param {Array<VALUE>|goog.array.ArrayLike} arr The array to check for |
* duplicates. |
* @return {boolean} True, if the array contains duplicates, false otherwise. |
* @private |
@@ -1207,11 +1197,11 @@ goog.iter.hasDuplicates_ = function(arr) { |
* elements. For example, the permutations of {@code [1,2,3]} are |
* {@code [[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.permutations |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable from which to generate permutations. |
* @param {number=} opt_length Length of each permutation. If omitted, defaults |
* to the length of {@code iterable}. |
- * @return {!goog.iter.Iterator.<!Array.<VALUE>>} A new iterator containing the |
+ * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing the |
* permutations of {@code iterable}. |
* @template VALUE |
*/ |
@@ -1237,10 +1227,10 @@ goog.iter.permutations = function(iterable, opt_length) { |
* are encountered in {@code iterable}. For example, the 3-length combinations |
* of {@code [0,1,2,3]} are {@code [[0,1,2], [0,1,3], [0,2,3], [1,2,3]]}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.combinations |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable from which to generate combinations. |
* @param {number} length The length of each combination. |
- * @return {!goog.iter.Iterator.<!Array.<VALUE>>} A new iterator containing |
+ * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing |
* combinations from the {@code iterable}. |
* @template VALUE |
*/ |
@@ -1261,9 +1251,7 @@ goog.iter.combinations = function(iterable, length) { |
} |
iter.next = function() { |
- return goog.array.map( |
- /** @type {!Array.<number>} */ |
- (sortedIndexIterator.next()), getIndexFromElements); |
+ return goog.array.map(sortedIndexIterator.next(), getIndexFromElements); |
}; |
return iter; |
@@ -1280,10 +1268,10 @@ goog.iter.combinations = function(iterable, length) { |
* {@code [1,2,3]} are {@code [[1,1], [1,2], [1,3], [2,2], [2,3], [3,3]]}. |
* @see http://docs.python.org/2/library/itertools.html#itertools.combinations_with_replacement |
* @see http://en.wikipedia.org/wiki/Combination#Number_of_combinations_with_repetition |
- * @param {!goog.iter.Iterator.<VALUE>|!goog.iter.Iterable} iterable The |
+ * @param {!goog.iter.Iterator<VALUE>|!goog.iter.Iterable} iterable The |
* iterable to combine. |
* @param {number} length The length of each combination. |
- * @return {!goog.iter.Iterator.<!Array.<VALUE>>} A new iterator containing |
+ * @return {!goog.iter.Iterator<!Array<VALUE>>} A new iterator containing |
* combinations from the {@code iterable}. |
* @template VALUE |
*/ |
@@ -1306,7 +1294,7 @@ goog.iter.combinationsWithReplacement = function(iterable, length) { |
iter.next = function() { |
return goog.array.map( |
- /** @type {!Array.<number>} */ |
+ /** @type {!Array<number>} */ |
(sortedIndexIterator.next()), getIndexFromElements); |
}; |