| 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 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1085 | 1085 |
| 1086 /** | 1086 /** |
| 1087 * @return {!Array.<T>} | 1087 * @return {!Array.<T>} |
| 1088 * @template T | 1088 * @template T |
| 1089 */ | 1089 */ |
| 1090 Set.prototype.valuesArray = function() { | 1090 Set.prototype.valuesArray = function() { |
| 1091 return Array.from(this.values()); | 1091 return Array.from(this.values()); |
| 1092 }; | 1092 }; |
| 1093 | 1093 |
| 1094 /** | 1094 /** |
| 1095 * @return {?T} |
| 1096 * @template T |
| 1097 */ |
| 1098 Set.prototype.firstValue = function() { |
| 1099 if (!this.size) |
| 1100 return null; |
| 1101 return this.values().next().value; |
| 1102 }; |
| 1103 |
| 1104 /** |
| 1095 * @param {!Iterable<T>|!Array<!T>} iterable | 1105 * @param {!Iterable<T>|!Array<!T>} iterable |
| 1096 * @template T | 1106 * @template T |
| 1097 */ | 1107 */ |
| 1098 Set.prototype.addAll = function(iterable) { | 1108 Set.prototype.addAll = function(iterable) { |
| 1099 for (var e of iterable) | 1109 for (var e of iterable) |
| 1100 this.add(e); | 1110 this.add(e); |
| 1101 }; | 1111 }; |
| 1102 | 1112 |
| 1103 /** | 1113 /** |
| 1104 * @param {!Iterable<T>|!Array<!T>} iterable | 1114 * @param {!Iterable<T>|!Array<!T>} iterable |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 * @param {function(new:T, ...)} constructorFunction | 1462 * @param {function(new:T, ...)} constructorFunction |
| 1453 * @return {!T} | 1463 * @return {!T} |
| 1454 */ | 1464 */ |
| 1455 function singleton(constructorFunction) { | 1465 function singleton(constructorFunction) { |
| 1456 if (_singletonSymbol in constructorFunction) | 1466 if (_singletonSymbol in constructorFunction) |
| 1457 return constructorFunction[_singletonSymbol]; | 1467 return constructorFunction[_singletonSymbol]; |
| 1458 var instance = new constructorFunction(); | 1468 var instance = new constructorFunction(); |
| 1459 constructorFunction[_singletonSymbol] = instance; | 1469 constructorFunction[_singletonSymbol] = instance; |
| 1460 return instance; | 1470 return instance; |
| 1461 } | 1471 } |
| OLD | NEW |