OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 var result = []; | 477 var result = []; |
478 for (var i = index; i < index + this.length; ++i) | 478 for (var i = index; i < index + this.length; ++i) |
479 result.push(this[i % this.length]); | 479 result.push(this[i % this.length]); |
480 return result; | 480 return result; |
481 } | 481 } |
482 }); | 482 }); |
483 | 483 |
484 Object.defineProperty(Array.prototype, 'sortNumbers', { | 484 Object.defineProperty(Array.prototype, 'sortNumbers', { |
485 /** | 485 /** |
486 * @this {Array.<number>} | 486 * @this {Array.<number>} |
487 * @return {!Array.<number>} | |
allada
2016/12/20 01:35:00
I didn't realize sort() sorted in place. Lets foll
| |
487 */ | 488 */ |
488 value: function() { | 489 value: function() { |
489 /** | 490 /** |
490 * @param {number} a | 491 * @param {number} a |
491 * @param {number} b | 492 * @param {number} b |
492 * @return {number} | 493 * @return {number} |
493 */ | 494 */ |
494 function numericComparator(a, b) { | 495 function numericComparator(a, b) { |
495 return a - b; | 496 return a - b; |
496 } | 497 } |
497 | 498 |
498 this.sort(numericComparator); | 499 return this.sort(numericComparator); |
allada
2016/12/20 01:35:00
and this.
| |
499 } | 500 } |
500 }); | 501 }); |
501 | 502 |
502 Object.defineProperty(Uint32Array.prototype, 'sort', {value: Array.prototype.sor t}); | 503 Object.defineProperty(Uint32Array.prototype, 'sort', {value: Array.prototype.sor t}); |
503 | 504 |
504 (function() { | 505 (function() { |
505 var partition = { | 506 var partition = { |
506 /** | 507 /** |
507 * @this {Array.<number>} | 508 * @this {Array.<number>} |
508 * @param {function(number, number): number} comparator | 509 * @param {function(number, number): number} comparator |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1146 }; | 1147 }; |
1147 | 1148 |
1148 /** | 1149 /** |
1149 * @return {!Array<!KEY>} | 1150 * @return {!Array<!KEY>} |
1150 */ | 1151 */ |
1151 Map.prototype.keysArray = function() { | 1152 Map.prototype.keysArray = function() { |
1152 return Array.from(this.keys()); | 1153 return Array.from(this.keys()); |
1153 }; | 1154 }; |
1154 | 1155 |
1155 /** | 1156 /** |
1156 * @return {!Multimap<!KEY, !VALUE>} | 1157 * @param {!Object=} config |
1158 * @return {!Multimap<!KEY, !VALUE>|!Map<!KEY, !VALUE>} | |
1157 */ | 1159 */ |
1158 Map.prototype.inverse = function() { | 1160 Map.prototype.inverse = function(config) { |
1159 var result = new Multimap(); | 1161 var result = (config && config.regularMap) ? new Map() : new Multimap(); |
allada
2016/12/20 01:35:00
I spoke to one of the members of our team and he d
| |
1160 for (var key of this.keys()) { | 1162 for (var key of this.keys()) { |
1161 var value = this.get(key); | 1163 var value = this.get(key); |
1162 result.set(value, key); | 1164 result.set(value, key); |
1163 } | 1165 } |
1164 return result; | 1166 return result; |
1165 }; | 1167 }; |
1166 | 1168 |
1167 /** | 1169 /** |
1168 * @constructor | 1170 * @constructor |
1169 * @template K, V | 1171 * @template K, V |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1429 while (leftIndex < leftKeys.length) { | 1431 while (leftIndex < leftKeys.length) { |
1430 var leftKey = leftKeys[leftIndex++]; | 1432 var leftKey = leftKeys[leftIndex++]; |
1431 removed.push(this.get(leftKey)); | 1433 removed.push(this.get(leftKey)); |
1432 } | 1434 } |
1433 while (rightIndex < rightKeys.length) { | 1435 while (rightIndex < rightKeys.length) { |
1434 var rightKey = rightKeys[rightIndex++]; | 1436 var rightKey = rightKeys[rightIndex++]; |
1435 added.push(other.get(rightKey)); | 1437 added.push(other.get(rightKey)); |
1436 } | 1438 } |
1437 return {added: added, removed: removed, equal: equal}; | 1439 return {added: added, removed: removed, equal: equal}; |
1438 }; | 1440 }; |
OLD | NEW |