• 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 * TreeSet is implemented based on TreeMap. In TreeSet, only value objects are processed.
23 * TreeSet can be used to store values, each of which must be unique.
24 *
25 * @syscap SystemCapability.Utils.Lang
26 * @since 8
27 */
28/**
29 * TreeSet is implemented based on TreeMap. In TreeSet, only value objects are processed.
30 * TreeSet can be used to store values, each of which must be unique.
31 *
32 * @syscap SystemCapability.Utils.Lang
33 * @crossplatform
34 * @since 10
35 */
36/**
37 * TreeSet is implemented based on TreeMap. In TreeSet, only value objects are processed.
38 * TreeSet can be used to store values, each of which must be unique.
39 *
40 * @syscap SystemCapability.Utils.Lang
41 * @crossplatform
42 * @atomicservice
43 * @since 12
44 */
45declare class TreeSet<T> {
46  /**
47   * A constructor used to create a TreeSet object.
48   *
49   * @param { function } [comparator] - comparator
50   * comparator (Optional) User-defined comparison functions.
51   * firstValue (required) previous element.
52   * secondValue (required) next element.
53   * @throws { BusinessError } 10200012 - The TreeSet's constructor cannot be directly invoked.
54   * @throws { BusinessError } 401 - Parameter error. Possible causes:
55   * 1.Incorrect parameter types;
56   * 2.Parameter verification failed.
57   * @syscap SystemCapability.Utils.Lang
58   * @since 8
59   */
60  /**
61   * A constructor used to create a TreeSet object.
62   *
63   * @param { function } [comparator] - comparator
64   * comparator (Optional) User-defined comparison functions.
65   * firstValue (required) previous element.
66   * secondValue (required) next element.
67   * @throws { BusinessError } 10200012 - The TreeSet's constructor cannot be directly invoked.
68   * @throws { BusinessError } 401 - Parameter error. Possible causes:
69   * 1.Incorrect parameter types;
70   * 2.Parameter verification failed.
71   * @syscap SystemCapability.Utils.Lang
72   * @crossplatform
73   * @since 10
74   */
75  /**
76   * A constructor used to create a TreeSet object.
77   *
78   * @param { function } [comparator] - comparator
79   * comparator (Optional) User-defined comparison functions.
80   * firstValue (required) previous element.
81   * secondValue (required) next element.
82   * @throws { BusinessError } 10200012 - The TreeSet's constructor cannot be directly invoked.
83   * @throws { BusinessError } 401 - Parameter error. Possible causes:
84   * 1.Incorrect parameter types;
85   * 2.Parameter verification failed.
86   * @syscap SystemCapability.Utils.Lang
87   * @crossplatform
88   * @atomicservice
89   * @since 12
90   */
91  constructor(comparator?: (firstValue: T, secondValue: T) => boolean);
92  /**
93   * Gets the element number of the TreeSet.
94   *
95   * @type { number }
96   * @syscap SystemCapability.Utils.Lang
97   * @since 8
98   */
99  /**
100   * Gets the element number of the TreeSet.
101   *
102   * @type { number }
103   * @syscap SystemCapability.Utils.Lang
104   * @crossplatform
105   * @since 10
106   */
107  /**
108   * Gets the element number of the TreeSet.
109   *
110   * @type { number }
111   * @syscap SystemCapability.Utils.Lang
112   * @crossplatform
113   * @atomicservice
114   * @since 12
115   */
116  length: number;
117  /**
118   * Returns whether the Set object contains elements
119   *
120   * @returns { boolean } the boolean type
121   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
122   * @syscap SystemCapability.Utils.Lang
123   * @since 8
124   */
125  /**
126   * Returns whether the Set object contains elements
127   *
128   * @returns { boolean } the boolean type
129   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
130   * @syscap SystemCapability.Utils.Lang
131   * @crossplatform
132   * @since 10
133   */
134  /**
135   * Returns whether the Set object contains elements
136   *
137   * @returns { boolean } the boolean type
138   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
139   * @syscap SystemCapability.Utils.Lang
140   * @crossplatform
141   * @atomicservice
142   * @since 12
143   */
144  isEmpty(): boolean;
145  /**
146   * Returns whether the Set object contain s the elements
147   *
148   * @param { T } value - value value need to determine whether to include the element
149   * @returns { boolean } the boolean type
150   * @throws { BusinessError } 10200011 - The has method cannot be bound.
151   * @syscap SystemCapability.Utils.Lang
152   * @since 8
153   */
154  /**
155   * Returns whether the Set object contain s the elements
156   *
157   * @param { T } value - value value need to determine whether to include the element
158   * @returns { boolean } the boolean type
159   * @throws { BusinessError } 10200011 - The has method cannot be bound.
160   * @syscap SystemCapability.Utils.Lang
161   * @crossplatform
162   * @since 10
163   */
164  /**
165   * Returns whether the Set object contain s the elements
166   *
167   * @param { T } value - value value need to determine whether to include the element
168   * @returns { boolean } the boolean type
169   * @throws { BusinessError } 10200011 - The has method cannot be bound.
170   * @syscap SystemCapability.Utils.Lang
171   * @crossplatform
172   * @atomicservice
173   * @since 12
174   */
175  has(value: T): boolean;
176  /**
177   * If the set does not contain the element, the specified element is added
178   *
179   * @param { T } value - value value Added element
180   * @returns { boolean } the boolean type(Is there contain this element)
181   * @throws { BusinessError } 401 - Parameter error. Possible causes:
182   * 1.Mandatory parameters are left unspecified;
183   * 2.Incorrect parameter types;
184   * 3.Parameter verification failed.
185   * @throws { BusinessError } 10200011 - The add method cannot be bound.
186   * @syscap SystemCapability.Utils.Lang
187   * @since 8
188   */
189  /**
190   * If the set does not contain the element, the specified element is added
191   *
192   * @param { T } value - value value Added element
193   * @returns { boolean } the boolean type(Is there contain this element)
194   * @throws { BusinessError } 401 - Parameter error. Possible causes:
195   * 1.Mandatory parameters are left unspecified;
196   * 2.Incorrect parameter types;
197   * 3.Parameter verification failed.
198   * @throws { BusinessError } 10200011 - The add method cannot be bound.
199   * @syscap SystemCapability.Utils.Lang
200   * @crossplatform
201   * @since 10
202   */
203  /**
204   * If the set does not contain the element, the specified element is added
205   *
206   * @param { T } value - value value Added element
207   * @returns { boolean } the boolean type(Is there contain this element)
208   * @throws { BusinessError } 401 - Parameter error. Possible causes:
209   * 1.Mandatory parameters are left unspecified;
210   * 2.Incorrect parameter types;
211   * 3.Parameter verification failed.
212   * @throws { BusinessError } 10200011 - The add method cannot be bound.
213   * @syscap SystemCapability.Utils.Lang
214   * @crossplatform
215   * @atomicservice
216   * @since 12
217   */
218  add(value: T): boolean;
219  /**
220   * Remove a specified element from a Set object
221   *
222   * @param { T } value - value value Target to be deleted
223   * @returns { boolean } the boolean type(Is there contain this element)
224   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
225   * @syscap SystemCapability.Utils.Lang
226   * @since 8
227   */
228  /**
229   * Remove a specified element from a Set object
230   *
231   * @param { T } value - value value Target to be deleted
232   * @returns { boolean } the boolean type(Is there contain this element)
233   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
234   * @syscap SystemCapability.Utils.Lang
235   * @crossplatform
236   * @since 10
237   */
238  /**
239   * Remove a specified element from a Set object
240   *
241   * @param { T } value - value value Target to be deleted
242   * @returns { boolean } the boolean type(Is there contain this element)
243   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
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   * Gets the first elements in a set
277   *
278   * @returns { T } value or undefined
279   * @throws { BusinessError } 10200011 - The getFirstValue method cannot be bound.
280   * @syscap SystemCapability.Utils.Lang
281   * @since 8
282   */
283  /**
284   * Gets the first elements in a set
285   *
286   * @returns { T } value or undefined
287   * @throws { BusinessError } 10200011 - The getFirstValue method cannot be bound.
288   * @syscap SystemCapability.Utils.Lang
289   * @crossplatform
290   * @since 10
291   */
292  /**
293   * Gets the first elements in a set
294   *
295   * @returns { T } value or undefined
296   * @throws { BusinessError } 10200011 - The getFirstValue method cannot be bound.
297   * @syscap SystemCapability.Utils.Lang
298   * @crossplatform
299   * @atomicservice
300   * @since 12
301   */
302  getFirstValue(): T;
303  /**
304   * Gets the last elements in a set
305   *
306   * @returns { T } value or undefined
307   * @throws { BusinessError } 10200011 - The getLastValue method cannot be bound.
308   * @syscap SystemCapability.Utils.Lang
309   * @since 8
310   */
311  /**
312   * Gets the last elements in a set
313   *
314   * @returns { T } value or undefined
315   * @throws { BusinessError } 10200011 - The getLastValue method cannot be bound.
316   * @syscap SystemCapability.Utils.Lang
317   * @crossplatform
318   * @since 10
319   */
320  /**
321   * Gets the last elements in a set
322   *
323   * @returns { T } value or undefined
324   * @throws { BusinessError } 10200011 - The getLastValue method cannot be bound.
325   * @syscap SystemCapability.Utils.Lang
326   * @crossplatform
327   * @atomicservice
328   * @since 12
329   */
330  getLastValue(): T;
331  /**
332   * Returns the greatest element smaller than or equal to the specified key
333   * if the key does not exist, undefined is returned
334   *
335   * @param { T } key - key key Objective of comparison
336   * @returns { T } key or undefined
337   * @throws { BusinessError } 10200011 - The getLowerValue method cannot be bound.
338   * @throws { BusinessError } 401 - Parameter error. Possible causes:
339   * 1.Mandatory parameters are left unspecified;
340   * 2.Incorrect parameter types;
341   * 3.Parameter verification failed.
342   * @syscap SystemCapability.Utils.Lang
343   * @since 8
344   */
345  /**
346   * Returns the greatest element smaller than or equal to the specified key
347   * if the key does not exist, undefined is returned
348   *
349   * @param { T } key - key key Objective of comparison
350   * @returns { T } key or undefined
351   * @throws { BusinessError } 10200011 - The getLowerValue method cannot be bound.
352   * @throws { BusinessError } 401 - Parameter error. Possible causes:
353   * 1.Mandatory parameters are left unspecified;
354   * 2.Incorrect parameter types;
355   * 3.Parameter verification failed.
356   * @syscap SystemCapability.Utils.Lang
357   * @crossplatform
358   * @since 10
359   */
360  /**
361   * Returns the greatest element smaller than or equal to the specified key
362   * if the key does not exist, undefined is returned
363   *
364   * @param { T } key - key key Objective of comparison
365   * @returns { T } key or undefined
366   * @throws { BusinessError } 10200011 - The getLowerValue method cannot be bound.
367   * @throws { BusinessError } 401 - Parameter error. Possible causes:
368   * 1.Mandatory parameters are left unspecified;
369   * 2.Incorrect parameter types;
370   * 3.Parameter verification failed.
371   * @syscap SystemCapability.Utils.Lang
372   * @crossplatform
373   * @atomicservice
374   * @since 12
375   */
376  getLowerValue(key: T): T;
377  /**
378   * Returns the least element greater than or equal to the specified key
379   * if the key does not exist, undefined is returned
380   *
381   * @param { T } key - key key Objective of comparison
382   * @returns { T } key or undefined
383   * @throws { BusinessError } 10200011 - The getHigherValue method cannot be bound.
384   * @throws { BusinessError } 401 - Parameter error. Possible causes:
385   * 1.Mandatory parameters are left unspecified;
386   * 2.Incorrect parameter types;
387   * 3.Parameter verification failed.
388   * @syscap SystemCapability.Utils.Lang
389   * @since 8
390   */
391  /**
392   * Returns the least element greater than or equal to the specified key
393   * if the key does not exist, undefined is returned
394   *
395   * @param { T } key - key key Objective of comparison
396   * @returns { T } key or undefined
397   * @throws { BusinessError } 10200011 - The getHigherValue method cannot be bound.
398   * @throws { BusinessError } 401 - Parameter error. Possible causes:
399   * 1.Mandatory parameters are left unspecified;
400   * 2.Incorrect parameter types;
401   * 3.Parameter verification failed.
402   * @syscap SystemCapability.Utils.Lang
403   * @crossplatform
404   * @since 10
405   */
406  /**
407   * Returns the least element greater than or equal to the specified key
408   * if the key does not exist, undefined is returned
409   *
410   * @param { T } key - key key Objective of comparison
411   * @returns { T } key or undefined
412   * @throws { BusinessError } 10200011 - The getHigherValue method cannot be bound.
413   * @throws { BusinessError } 401 - Parameter error. Possible causes:
414   * 1.Mandatory parameters are left unspecified;
415   * 2.Incorrect parameter types;
416   * 3.Parameter verification failed.
417   * @syscap SystemCapability.Utils.Lang
418   * @crossplatform
419   * @atomicservice
420   * @since 12
421   */
422  getHigherValue(key: T): T;
423  /**
424   * Return and delete the first element, returns undefined if tree set is empty
425   *
426   * @returns { T } first value or undefined
427   * @throws { BusinessError } 10200011 - The popFirst method cannot be bound.
428   * @syscap SystemCapability.Utils.Lang
429   * @since 8
430   */
431  /**
432   * Return and delete the first element, returns undefined if tree set is empty
433   *
434   * @returns { T } first value or undefined
435   * @throws { BusinessError } 10200011 - The popFirst method cannot be bound.
436   * @syscap SystemCapability.Utils.Lang
437   * @crossplatform
438   * @since 10
439   */
440  /**
441   * Return and delete the first element, returns undefined if tree set is empty
442   *
443   * @returns { T } first value or undefined
444   * @throws { BusinessError } 10200011 - The popFirst method cannot be bound.
445   * @syscap SystemCapability.Utils.Lang
446   * @crossplatform
447   * @atomicservice
448   * @since 12
449   */
450  popFirst(): T;
451  /**
452   * Return and delete the last element, returns undefined if tree set is empty
453   *
454   * @returns { T } last value or undefined
455   * @throws { BusinessError } 10200011 - The popLast method cannot be bound.
456   * @syscap SystemCapability.Utils.Lang
457   * @since 8
458   */
459  /**
460   * Return and delete the last element, returns undefined if tree set is empty
461   *
462   * @returns { T } last value or undefined
463   * @throws { BusinessError } 10200011 - The popLast method cannot be bound.
464   * @syscap SystemCapability.Utils.Lang
465   * @crossplatform
466   * @since 10
467   */
468  /**
469   * Return and delete the last element, returns undefined if tree set is empty
470   *
471   * @returns { T } last value or undefined
472   * @throws { BusinessError } 10200011 - The popLast method cannot be bound.
473   * @syscap SystemCapability.Utils.Lang
474   * @crossplatform
475   * @atomicservice
476   * @since 12
477   */
478  popLast(): T;
479  /**
480   * Executes a provided function once for each value in the Set object.
481   *
482   * @param { function } callbackFn - callbackFn
483   * callbackFn (required) A function that accepts up to three arguments.
484   * The function to be called for each element.
485   * @param { Object } [thisArg] - thisArg
486   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
487   * If thisArg is omitted, undefined is used as the this value.
488   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
489   * @throws { BusinessError } 401 - Parameter error. Possible causes:
490   * 1.Mandatory parameters are left unspecified;
491   * 2.Incorrect parameter types.
492   * @syscap SystemCapability.Utils.Lang
493   * @since 8
494   */
495  /**
496   * Executes a provided function once for each value in the Set object.
497   *
498   * @param { function } callbackFn - callbackFn
499   * callbackFn (required) A function that accepts up to three arguments.
500   * The function to be called for each element.
501   * @param { Object } [thisArg] - thisArg
502   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
503   * If thisArg is omitted, undefined is used as the this value.
504   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
505   * @throws { BusinessError } 401 - Parameter error. Possible causes:
506   * 1.Mandatory parameters are left unspecified;
507   * 2.Incorrect parameter types.
508   * @syscap SystemCapability.Utils.Lang
509   * @crossplatform
510   * @since 10
511   */
512  /**
513   * Executes a provided function once for each value in the Set object.
514   *
515   * @param { function } callbackFn - callbackFn
516   * callbackFn (required) A function that accepts up to three arguments.
517   * The function to be called for each element.
518   * @param { Object } [thisArg] - thisArg
519   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
520   * If thisArg is omitted, undefined is used as the this value.
521   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
522   * @throws { BusinessError } 401 - Parameter error. Possible causes:
523   * 1.Mandatory parameters are left unspecified;
524   * 2.Incorrect parameter types.
525   * @syscap SystemCapability.Utils.Lang
526   * @crossplatform
527   * @atomicservice
528   * @since 12
529   */
530  forEach(callbackFn: (value?: T, key?: T, set?: TreeSet<T>) => void, thisArg?: Object): void;
531  /**
532   * Returns a new Iterator object that contains the values contained in this set
533   *
534   * @returns { IterableIterator<T> }
535   * @throws { BusinessError } 10200011 - The values method cannot be bound.
536   * @syscap SystemCapability.Utils.Lang
537   * @since 8
538   */
539  /**
540   * Returns a new Iterator object that contains the values contained in this set
541   *
542   * @returns { IterableIterator<T> }
543   * @throws { BusinessError } 10200011 - The values method cannot be bound.
544   * @syscap SystemCapability.Utils.Lang
545   * @crossplatform
546   * @since 10
547   */
548  /**
549   * Returns a new Iterator object that contains the values contained in this set
550   *
551   * @returns { IterableIterator<T> }
552   * @throws { BusinessError } 10200011 - The values method cannot be bound.
553   * @syscap SystemCapability.Utils.Lang
554   * @crossplatform
555   * @atomicservice
556   * @since 12
557   */
558  values(): IterableIterator<T>;
559  /**
560   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
561   *
562   * @returns { IterableIterator<[T, T]> }
563   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
564   * @syscap SystemCapability.Utils.Lang
565   * @since 8
566   */
567  /**
568   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
569   *
570   * @returns { IterableIterator<[T, T]> }
571   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
572   * @syscap SystemCapability.Utils.Lang
573   * @crossplatform
574   * @since 10
575   */
576  /**
577   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
578   *
579   * @returns { IterableIterator<[T, T]> }
580   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
581   * @syscap SystemCapability.Utils.Lang
582   * @crossplatform
583   * @atomicservice
584   * @since 12
585   */
586  entries(): IterableIterator<[T, T]>;
587  /**
588   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
589   *
590   * @returns { IterableIterator<T> }
591   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
592   * @syscap SystemCapability.Utils.Lang
593   * @since 8
594   */
595  /**
596   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
597   *
598   * @returns { IterableIterator<T> }
599   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
600   * @syscap SystemCapability.Utils.Lang
601   * @crossplatform
602   * @since 10
603   */
604  /**
605   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
606   *
607   * @returns { IterableIterator<T> }
608   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
609   * @syscap SystemCapability.Utils.Lang
610   * @crossplatform
611   * @atomicservice
612   * @since 12
613   */
614  [Symbol.iterator](): IterableIterator<T>;
615}
616
617export default TreeSet;
618