• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/**
17 * @file
18 * @kit ArkTS
19 */
20
21/**
22 * HashSet is implemented based on HashMap. In HashSet, only the value object is processed.
23 *
24 * @syscap SystemCapability.Utils.Lang
25 * @since 8
26 */
27/**
28 * HashSet is implemented based on HashMap. In HashSet, only the value object is processed.
29 *
30 * @syscap SystemCapability.Utils.Lang
31 * @crossplatform
32 * @since 10
33 */
34/**
35 * HashSet is implemented based on HashMap. In HashSet, only the value object is processed.
36 *
37 * @syscap SystemCapability.Utils.Lang
38 * @crossplatform
39 * @atomicservice
40 * @since 12
41 */
42declare class HashSet<T> {
43  /**
44   * A constructor used to create a HashSet object.
45   *
46   * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked.
47   * @syscap SystemCapability.Utils.Lang
48   * @since 8
49   */
50  /**
51   * A constructor used to create a HashSet object.
52   *
53   * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked.
54   * @syscap SystemCapability.Utils.Lang
55   * @crossplatform
56   * @since 10
57   */
58  /**
59   * A constructor used to create a HashSet object.
60   *
61   * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked.
62   * @syscap SystemCapability.Utils.Lang
63   * @crossplatform
64   * @atomicservice
65   * @since 12
66   */
67  constructor();
68  /**
69   * Gets the element number of the hashset.
70   *
71   * @type { number }
72   * @syscap SystemCapability.Utils.Lang
73   * @since 8
74   */
75  /**
76   * Gets the element number of the hashset.
77   *
78   * @type { number }
79   * @syscap SystemCapability.Utils.Lang
80   * @crossplatform
81   * @since 10
82   */
83  /**
84   * Gets the element number of the hashset.
85   *
86   * @type { number }
87   * @syscap SystemCapability.Utils.Lang
88   * @crossplatform
89   * @atomicservice
90   * @since 12
91   */
92  length: number;
93  /**
94   * Returns whether the Set object contains elements
95   *
96   * @returns { boolean } the boolean type
97   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
98   * @syscap SystemCapability.Utils.Lang
99   * @since 8
100   */
101  /**
102   * Returns whether the Set object contains elements
103   *
104   * @returns { boolean } the boolean type
105   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
106   * @syscap SystemCapability.Utils.Lang
107   * @crossplatform
108   * @since 10
109   */
110  /**
111   * Returns whether the Set object contains elements
112   *
113   * @returns { boolean } the boolean type
114   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
115   * @syscap SystemCapability.Utils.Lang
116   * @crossplatform
117   * @atomicservice
118   * @since 12
119   */
120  isEmpty(): boolean;
121  /**
122   * Returns whether the Set object contain s the elements
123   *
124   * @param { T } value - value value need to determine whether to include the element
125   * @returns { boolean } the boolean type
126   * @throws { BusinessError } 10200011 - The has method cannot be bound.
127   * @throws { BusinessError } 401 - Parameter error. Possible causes:
128   * 1.Mandatory parameters are left unspecified;
129   * 2.Incorrect parameter types;
130   * 3.Parameter verification failed.
131   * @syscap SystemCapability.Utils.Lang
132   * @since 8
133   */
134  /**
135   * Returns whether the Set object contain s the elements
136   *
137   * @param { T } value - value value need to determine whether to include the element
138   * @returns { boolean } the boolean type
139   * @throws { BusinessError } 10200011 - The has method cannot be bound.
140   * @throws { BusinessError } 401 - Parameter error. Possible causes:
141   * 1.Mandatory parameters are left unspecified;
142   * 2.Incorrect parameter types;
143   * 3.Parameter verification failed.
144   * @syscap SystemCapability.Utils.Lang
145   * @crossplatform
146   * @since 10
147   */
148  /**
149   * Returns whether the Set object contain s the elements
150   *
151   * @param { T } value - value value need to determine whether to include the element
152   * @returns { boolean } the boolean type
153   * @throws { BusinessError } 10200011 - The has method cannot be bound.
154   * @throws { BusinessError } 401 - Parameter error. Possible causes:
155   * 1.Mandatory parameters are left unspecified;
156   * 2.Incorrect parameter types;
157   * 3.Parameter verification failed.
158   * @syscap SystemCapability.Utils.Lang
159   * @crossplatform
160   * @atomicservice
161   * @since 12
162   */
163  has(value: T): boolean;
164  /**
165   * If the set does not contain the element, the specified element is added
166   *
167   * @param { T } value - value value Added element
168   * @returns { boolean } the boolean type(Is there contain this element)
169   * @throws { BusinessError } 10200011 - The add method cannot be bound.
170   * @throws { BusinessError } 401 - Parameter error. Possible causes:
171   * 1.Mandatory parameters are left unspecified;
172   * 2.Incorrect parameter types;
173   * 3.Parameter verification failed.
174   * @syscap SystemCapability.Utils.Lang
175   * @since 8
176   */
177  /**
178   * If the set does not contain the element, the specified element is added
179   *
180   * @param { T } value - value value Added element
181   * @returns { boolean } the boolean type(Is there contain this element)
182   * @throws { BusinessError } 10200011 - The add method cannot be bound.
183   * @throws { BusinessError } 401 - Parameter error. Possible causes:
184   * 1.Mandatory parameters are left unspecified;
185   * 2.Incorrect parameter types;
186   * 3.Parameter verification failed.
187   * @syscap SystemCapability.Utils.Lang
188   * @crossplatform
189   * @since 10
190   */
191  /**
192   * If the set does not contain the element, the specified element is added
193   *
194   * @param { T } value - value value Added element
195   * @returns { boolean } the boolean type(Is there contain this element)
196   * @throws { BusinessError } 10200011 - The add method cannot be bound.
197   * @throws { BusinessError } 401 - Parameter error. Possible causes:
198   * 1.Mandatory parameters are left unspecified;
199   * 2.Incorrect parameter types;
200   * 3.Parameter verification failed.
201   * @syscap SystemCapability.Utils.Lang
202   * @crossplatform
203   * @atomicservice
204   * @since 12
205   */
206  add(value: T): boolean;
207  /**
208   * Remove a specified element from a Set object
209   *
210   * @param { T } value - value value Target to be deleted
211   * @returns { boolean } the boolean type(Is there contain this element)
212   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
213   * @throws { BusinessError } 401 - Parameter error. Possible causes:
214   * 1.Mandatory parameters are left unspecified;
215   * 2.Incorrect parameter types;
216   * 3.Parameter verification failed.
217   * @syscap SystemCapability.Utils.Lang
218   * @since 8
219   */
220  /**
221   * Remove a specified element from a Set object
222   *
223   * @param { T } value - value value Target to be deleted
224   * @returns { boolean } the boolean type(Is there contain this element)
225   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
226   * @throws { BusinessError } 401 - Parameter error. Possible causes:
227   * 1.Mandatory parameters are left unspecified;
228   * 2.Incorrect parameter types;
229   * 3.Parameter verification failed.
230   * @syscap SystemCapability.Utils.Lang
231   * @crossplatform
232   * @since 10
233   */
234  /**
235   * Remove a specified element from a Set object
236   *
237   * @param { T } value - value value Target to be deleted
238   * @returns { boolean } the boolean type(Is there contain this element)
239   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
240   * @throws { BusinessError } 401 - Parameter error. Possible causes:
241   * 1.Mandatory parameters are left unspecified;
242   * 2.Incorrect parameter types;
243   * 3.Parameter verification failed.
244   * @syscap SystemCapability.Utils.Lang
245   * @crossplatform
246   * @atomicservice
247   * @since 12
248   */
249  remove(value: T): boolean;
250  /**
251   * Clears all element groups in a set
252   *
253   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
254   * @syscap SystemCapability.Utils.Lang
255   * @since 8
256   */
257  /**
258   * Clears all element groups in a set
259   *
260   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
261   * @syscap SystemCapability.Utils.Lang
262   * @crossplatform
263   * @since 10
264   */
265  /**
266   * Clears all element groups in a set
267   *
268   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
269   * @syscap SystemCapability.Utils.Lang
270   * @crossplatform
271   * @atomicservice
272   * @since 12
273   */
274  clear(): void;
275  /**
276   * Executes a provided function once for each value in the Set object.
277   *
278   * @param { function } callbackFn - callbackFn
279   * callbackFn (required) A function that accepts up to three arguments.
280   * The function to be called for each element.
281   * @param { Object } [thisArg] - thisArg
282   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
283   * If thisArg is omitted, undefined is used as the this value.
284   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
285   * @throws { BusinessError } 401 - Parameter error. Possible causes:
286   * 1.Mandatory parameters are left unspecified;
287   * 2.Incorrect parameter types.
288   * @syscap SystemCapability.Utils.Lang
289   * @since 8
290   */
291  /**
292   * Executes a provided function once for each value in the Set object.
293   *
294   * @param { function } callbackFn - callbackFn
295   * callbackFn (required) A function that accepts up to three arguments.
296   * The function to be called for each element.
297   * @param { Object } [thisArg] - thisArg
298   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
299   * If thisArg is omitted, undefined is used as the this value.
300   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
301   * @throws { BusinessError } 401 - Parameter error. Possible causes:
302   * 1.Mandatory parameters are left unspecified;
303   * 2.Incorrect parameter types.
304   * @syscap SystemCapability.Utils.Lang
305   * @crossplatform
306   * @since 10
307   */
308  /**
309   * Executes a provided function once for each value in the Set object.
310   *
311   * @param { function } callbackFn - callbackFn
312   * callbackFn (required) A function that accepts up to three arguments.
313   * The function to be called for each element.
314   * @param { Object } [thisArg] - thisArg
315   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
316   * If thisArg is omitted, undefined is used as the this value.
317   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
318   * @throws { BusinessError } 401 - Parameter error. Possible causes:
319   * 1.Mandatory parameters are left unspecified;
320   * 2.Incorrect parameter types.
321   * @syscap SystemCapability.Utils.Lang
322   * @crossplatform
323   * @atomicservice
324   * @since 12
325   */
326  forEach(callbackFn: (value?: T, key?: T, set?: HashSet<T>) => void, thisArg?: Object): void;
327  /**
328   * Returns a new Iterator object that contains the values contained in this set
329   *
330   * @returns { IterableIterator<T> }
331   * @throws { BusinessError } 10200011 - The values method cannot be bound.
332   * @syscap SystemCapability.Utils.Lang
333   * @since 8
334   */
335  /**
336   * Returns a new Iterator object that contains the values contained in this set
337   *
338   * @returns { IterableIterator<T> }
339   * @throws { BusinessError } 10200011 - The values method cannot be bound.
340   * @syscap SystemCapability.Utils.Lang
341   * @crossplatform
342   * @since 10
343   */
344  /**
345   * Returns a new Iterator object that contains the values contained in this set
346   *
347   * @returns { IterableIterator<T> }
348   * @throws { BusinessError } 10200011 - The values method cannot be bound.
349   * @syscap SystemCapability.Utils.Lang
350   * @crossplatform
351   * @atomicservice
352   * @since 12
353   */
354  values(): IterableIterator<T>;
355  /**
356   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
357   *
358   * @returns { IterableIterator<[T, T]> }
359   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
360   * @syscap SystemCapability.Utils.Lang
361   * @since 8
362   */
363  /**
364   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
365   *
366   * @returns { IterableIterator<[T, T]> }
367   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
368   * @syscap SystemCapability.Utils.Lang
369   * @crossplatform
370   * @since 10
371   */
372  /**
373   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
374   *
375   * @returns { IterableIterator<[T, T]> }
376   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
377   * @syscap SystemCapability.Utils.Lang
378   * @crossplatform
379   * @atomicservice
380   * @since 12
381   */
382  entries(): IterableIterator<[T, T]>;
383  /**
384   * returns an iterator.Each item of the iterator is a Javascript Object
385   *
386   * @returns { IterableIterator<T> }
387   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
388   * @syscap SystemCapability.Utils.Lang
389   * @since 8
390   */
391  /**
392   * returns an iterator.Each item of the iterator is a Javascript Object
393   *
394   * @returns { IterableIterator<T> }
395   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
396   * @syscap SystemCapability.Utils.Lang
397   * @crossplatform
398   * @since 10
399   */
400  /**
401   * returns an iterator.Each item of the iterator is a Javascript Object
402   *
403   * @returns { IterableIterator<T> }
404   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
405   * @syscap SystemCapability.Utils.Lang
406   * @crossplatform
407   * @atomicservice
408   * @since 12
409   */
410  [Symbol.iterator](): IterableIterator<T>;
411}
412
413export default HashSet;
414