Commit | Line | Data |
---|---|---|
f10d9af6 AE |
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> | |
f10d9af6 | 7 | */ |
fd6a70e0 | 8 | define(["require", "exports"], function (require, exports) { |
f73a2744 | 9 | "use strict"; |
f10d9af6 | 10 | /** @deprecated 5.4 Use a `Set` instead. */ |
f73a2744 | 11 | class List { |
2b2ad7a7 | 12 | _set = new Set(); |
f73a2744 AE |
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; | |
ca3ef487 | 48 | }); |