Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
26 | 2 | 5 | 0.959 | SourceElements[2] |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 26 | 415 | Closure/closure/goog/array/array.js |
2 | 26 | 455 | Closure/closure/goog/array/array.js |
| ||||
/** * Search an array for the first element that satisfies a given condition and * return that element. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {*} The first array element that passes the test, or null if no * element is found. */ goog.array.find= function (arr, f, opt_obj){ var i= goog.array.findIndex(arr, f, opt_obj); return i< 0 ? null : goog.isString(arr) ? arr.charAt(i) : arr[i]; } ; /** * Search an array for the first element that satisfies a given condition and * return its index. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {number} The index of the first array element that passes the test, * or -1 if no element is found. */ goog.array.findIndex= function (arr, f, opt_obj){ var l= arr.length; // must be fixed during loop... see docs var arr2= goog.isString(arr) ? arr.split('') : arr; for (var i= 0; i< l; i++) { if (i in arr2 && f.call(opt_obj, arr2[i], i, arr)) { return i; } } return -1; } ; |
| ||||
/** * Search an array (in reverse order) for the last element that satisfies a * given condition and return that element. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {*} The last array element that passes the test, or null if no * element is found. */ goog.array.findRight= function (arr, f, opt_obj){ var i= goog.array.findIndexRight(arr, f, opt_obj); return i< 0 ? null : goog.isString(arr) ? arr.charAt(i) : arr[i]; } ; /** * Search an array (in reverse order) for the last element that satisfies a * given condition and return its index. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {number} The index of the last array element that passes the test, * or -1 if no element is found. */ goog.array.findIndexRight= function (arr, f, opt_obj){ var l= arr.length; // must be fixed during loop... see docs var arr2= goog.isString(arr) ? arr.split('') : arr; for (var i= l- 1; i>= 0; i--) { if (i in arr2 && f.call(opt_obj, arr2[i], i, arr)) { return i; } } return -1; } ; |
| |||
/** * Search an array for the first element that satisfies a given condition and * return that element. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {*} The first array element that passes the test, or null if no * element is found. */ /** * Search an array (in reverse order) for the last element that satisfies a * given condition and return that element. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {*} The last array element that passes the test, or null if no * element is found. */ goog.array. [[#variable5ff868a0]]= function (arr,f,opt_obj) { var i=goog.array. [[#variable5ff86860]](arr,f,opt_obj); return i<0 ?null :goog.isString(arr) ?arr.charAt(i) :arr[i]; } ; /** * Search an array for the first element that satisfies a given condition and * return its index. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {number} The index of the first array element that passes the test, * or -1 if no element is found. */ /** * Search an array (in reverse order) for the last element that satisfies a * given condition and return its index. * @param {goog.array.ArrayLike} arr The array to search. * @param {Function} f The function to call for every element. This function * takes 3 arguments (the element, the index and the array) and should * return a boolean. * @param {Object=} opt_obj An optional "this" context for the function. * @return {number} The index of the last array element that passes the test, * or -1 if no element is found. */ goog.array. [[#variable5ff86860]]= function (arr,f,opt_obj) { var l=arr.length; // must be fixed during loop... see docs var arr2=goog.isString(arr) ?arr.split('') :arr; for (var i= [[#variable5ff867e0]]; [[#variable5ff86720]]; [[#variable5ff866e0]]) { if (i in arr2 && f.call(opt_obj,arr2[i],i,arr)) { return i; } } return -1; } ; |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#5ff868a0]] | find |
1 | 2 | [[#5ff868a0]] | findRight |
2 | 1 | [[#5ff86860]] | findIndex |
2 | 2 | [[#5ff86860]] | findIndexRight |
3 | 1 | [[#5ff867e0]] | 0 |
3 | 2 | [[#5ff867e0]] | l-1 |
4 | 1 | [[#5ff86720]] | i<l |
4 | 2 | [[#5ff86720]] | i>=0 |
5 | 1 | [[#5ff866e0]] | i++ |
5 | 2 | [[#5ff866e0]] | i-- |