(array, equalityComparer, comparer)
| 979 | } |
| 980 | ts.indicesOf = indicesOf; |
| 981 | function deduplicateRelational(array, equalityComparer, comparer) { |
| 982 | // Perform a stable sort of the array. This ensures the first entry in a list of |
| 983 | // duplicates remains the first entry in the result. |
| 984 | var indices = indicesOf(array); |
| 985 | stableSortIndices(array, indices, comparer); |
| 986 | var last = array[indices[0]]; |
| 987 | var deduplicated = [indices[0]]; |
| 988 | for (var i = 1; i < indices.length; i++) { |
| 989 | var index = indices[i]; |
| 990 | var item = array[index]; |
| 991 | if (!equalityComparer(last, item)) { |
| 992 | deduplicated.push(index); |
| 993 | last = item; |
| 994 | } |
| 995 | } |
| 996 | // restore original order |
| 997 | deduplicated.sort(); |
| 998 | return deduplicated.map(function (i) { return array[i]; }); |
| 999 | } |
| 1000 | function deduplicateEquality(array, equalityComparer) { |
| 1001 | var result = []; |
| 1002 | for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { |
no test coverage detected