• 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
16declare class TreeSet<T> {
17  /**
18   * A constructor used to create a TreeSet object.
19   * @param comparator (Optional) User-defined comparison functions
20   * @param firstValue (Optional) previous element
21   * @param secondValue (Optional) next element
22   * @throws { BusinessError } 10200012 - The TreeSet's constructor cannot be directly invoked.
23   * @throws { BusinessError } 401 - The type of parameters are invalid.
24   * @since 8
25   * @syscap SystemCapability.Utils.Lang
26   */
27  constructor(comparator?: (firstValue: T, secondValue: T) => boolean)
28  /**
29   * Gets the element number of the TreeSet.
30   * @since 8
31   * @syscap SystemCapability.Utils.Lang
32   */
33  length: number;
34  /**
35   * Returns whether the Set object contains elements
36   * @returns the boolean type
37   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
38   * @since 8
39   * @syscap SystemCapability.Utils.Lang
40   */
41  isEmpty(): boolean;
42  /**
43   * Returns whether the Set object contain s the elements
44   * @param value need to determine whether to include the element
45   * @returns the boolean type
46   * @throws { BusinessError } 10200011 - The has method cannot be bound.
47   * @since 8
48   * @syscap SystemCapability.Utils.Lang
49   */
50  has(value: T): boolean;
51  /**
52   * If the set does not contain the element, the specified element is added
53   * @param value Added element
54   * @returns the boolean type(Is there contain this element)
55   * @throws { BusinessError } 401 - The type of parameters are invalid.
56   * @throws { BusinessError } 10200011 - The add method cannot be bound.
57   * @since 8
58   * @syscap SystemCapability.Utils.Lang
59   */
60  add(value: T): boolean;
61  /**
62   * Remove a specified element from a Set object
63   * @param value  Target to be deleted
64   * @returns the boolean type(Is there contain this element)
65   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
66   * @since 8
67   * @syscap SystemCapability.Utils.Lang
68   */
69  remove(value: T): boolean;
70  /**
71   * Clears all element groups in a set
72   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
73   * @since 8
74   * @syscap SystemCapability.Utils.Lang
75   */
76  clear(): void;
77  /**
78   * Gets the first elements in a set
79   * @returns value or undefined
80   * @throws { BusinessError } 10200011 - The getFirstValue method cannot be bound.
81   * @since 8
82   * @syscap SystemCapability.Utils.Lang
83   */
84  getFirstValue(): T;
85  /**
86   * Gets the last elements in a set
87   * @returns value or undefined
88   * @throws { BusinessError } 10200011 - The getLastValue method cannot be bound.
89   * @since 8
90   * @syscap SystemCapability.Utils.Lang
91   */
92  getLastValue(): T;
93  /**
94   * Returns the greatest element smaller than or equal to the specified key
95   * if the key does not exist, undefined is returned
96   * @param key Objective of comparison
97   * @returns key or undefined
98   * @throws { BusinessError } 10200011 - The getLowerValue method cannot be bound.
99   * @throws { BusinessError } 401 - The type of parameters are invalid.
100   * @since 8
101   * @syscap SystemCapability.Utils.Lang
102   */
103  getLowerValue(key: T): T;
104  /**
105   * Returns the least element greater than or equal to the specified key
106   * if the key does not exist, undefined is returned
107   * @param key Objective of comparison
108   * @returns key or undefined
109   * @throws { BusinessError } 10200011 - The getHigherValue method cannot be bound.
110   * @throws { BusinessError } 401 - The type of parameters are invalid.
111   * @since 8
112   * @syscap SystemCapability.Utils.Lang
113   */
114  getHigherValue(key: T): T;
115  /**
116   * Return and delete the first element, returns undefined if tree set is empty
117   * @returns first value or undefined
118   * @throws { BusinessError } 10200011 - The popFirst method cannot be bound.
119   * @since 8
120   * @syscap SystemCapability.Utils.Lang
121   */
122  popFirst(): T;
123  /**
124   * Return and delete the last element, returns undefined if tree set is empty
125   * @returns last value or undefined
126   * @throws { BusinessError } 10200011 - The popLast method cannot be bound.
127   * @since 8
128   * @syscap SystemCapability.Utils.Lang
129   */
130  popLast(): T;
131  /**
132   * Executes a provided function once for each value in the Set object.
133   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
134   * @throws { BusinessError } 401 - The type of parameters are invalid.
135   * @since 8
136   * @syscap SystemCapability.Utils.Lang
137   */
138  forEach(callbackFn: (value?: T, key?: T, set?: TreeSet<T>) => void,
139  thisArg?: Object): void;
140  /**
141   * Returns a new Iterator object that contains the values contained in this set
142   * @throws { BusinessError } 10200011 - The values method cannot be bound.
143   * @since 8
144   * @syscap SystemCapability.Utils.Lang
145   */
146  values(): IterableIterator<T>;
147  /**
148   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order
149   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
150   * @since 8
151   * @syscap SystemCapability.Utils.Lang
152   */
153  entries(): IterableIterator<[T, T]>;
154  /**
155   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
156   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
157   * @since 8
158   * @syscap SystemCapability.Utils.Lang
159   */
160  [Symbol.iterator](): IterableIterator<T>;
161}
162
163export default TreeSet;
164