| 1 | /** |
| 2 | * List implementation relying on an array or if supported on a Set to hold values. |
| 3 | * |
| 4 | * @author Alexander Ebert |
| 5 | * @copyright 2001-2019 WoltLab GmbH |
| 6 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
| 7 | */ |
| 8 | define(["require", "exports"], function (require, exports) { |
| 9 | "use strict"; |
| 10 | /** @deprecated 5.4 Use a `Set` instead. */ |
| 11 | class List { |
| 12 | _set = new Set(); |
| 13 | /** |
| 14 | * Appends an element to the list, silently rejects adding an already existing value. |
| 15 | */ |
| 16 | add(value) { |
| 17 | this._set.add(value); |
| 18 | } |
| 19 | /** |
| 20 | * Removes all elements from the list. |
| 21 | */ |
| 22 | clear() { |
| 23 | this._set.clear(); |
| 24 | } |
| 25 | /** |
| 26 | * Removes an element from the list, returns true if the element was in the list. |
| 27 | */ |
| 28 | delete(value) { |
| 29 | return this._set.delete(value); |
| 30 | } |
| 31 | /** |
| 32 | * Invokes the `callback` for each element in the list. |
| 33 | */ |
| 34 | forEach(callback) { |
| 35 | this._set.forEach(callback); |
| 36 | } |
| 37 | /** |
| 38 | * Returns true if the list contains the element. |
| 39 | */ |
| 40 | has(value) { |
| 41 | return this._set.has(value); |
| 42 | } |
| 43 | get size() { |
| 44 | return this._set.size; |
| 45 | } |
| 46 | } |
| 47 | return List; |
| 48 | }); |