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 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1384 { | 1384 { |
1385 this._map = {}; | 1385 this._map = {}; |
1386 this._size = 0; | 1386 this._size = 0; |
1387 delete this._hasProtoKey; | 1387 delete this._hasProtoKey; |
1388 delete this._protoValue; | 1388 delete this._protoValue; |
1389 } | 1389 } |
1390 } | 1390 } |
1391 | 1391 |
1392 /** | 1392 /** |
1393 * @constructor | 1393 * @constructor |
| 1394 * @extends {StringMap.<Set.<!T>>} |
| 1395 * @template T |
| 1396 */ |
| 1397 var StringMultimap = function() |
| 1398 { |
| 1399 StringMap.call(this); |
| 1400 } |
| 1401 |
| 1402 StringMultimap.prototype = { |
| 1403 /** |
| 1404 * @param {string} key |
| 1405 * @param {T} value |
| 1406 */ |
| 1407 put: function(key, value) |
| 1408 { |
| 1409 if (key === "__proto__") { |
| 1410 if (!this._hasProtoKey) { |
| 1411 ++this._size; |
| 1412 this._hasProtoKey = true; |
| 1413 /** @type {!Set.<T>} */ |
| 1414 this._protoValue = new Set(); |
| 1415 } |
| 1416 this._protoValue.add(value); |
| 1417 return; |
| 1418 } |
| 1419 if (!Object.prototype.hasOwnProperty.call(this._map, key)) { |
| 1420 ++this._size; |
| 1421 this._map[key] = new Set(); |
| 1422 } |
| 1423 this._map[key].add(value); |
| 1424 }, |
| 1425 |
| 1426 __proto__: StringMap.prototype |
| 1427 } |
| 1428 |
| 1429 /** |
| 1430 * @constructor |
1394 */ | 1431 */ |
1395 var StringSet = function() | 1432 var StringSet = function() |
1396 { | 1433 { |
1397 /** @type {!StringMap.<boolean>} */ | 1434 /** @type {!StringMap.<boolean>} */ |
1398 this._map = new StringMap(); | 1435 this._map = new StringMap(); |
1399 } | 1436 } |
1400 | 1437 |
1401 StringSet.prototype = { | 1438 StringSet.prototype = { |
1402 /** | 1439 /** |
1403 * @param {string} value | 1440 * @param {string} value |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 this._outgoingCallback(); | 1597 this._outgoingCallback(); |
1561 } | 1598 } |
1562 } | 1599 } |
1563 | 1600 |
1564 /** | 1601 /** |
1565 * @param {*} value | 1602 * @param {*} value |
1566 */ | 1603 */ |
1567 function suppressUnused(value) | 1604 function suppressUnused(value) |
1568 { | 1605 { |
1569 } | 1606 } |
OLD | NEW |