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 LightWeightSet<T> { 17 /** 18 * A constructor used to create a LightWeightSet object. 19 * @throws { BusinessError } 10200012 - The LightWeightSet's constructor cannot be directly invoked. 20 * @since 8 21 * @syscap SystemCapability.Utils.Lang 22 */ 23 constructor(); 24 /** 25 * Gets the element number of the LightWeightSet. 26 * @since 8 27 * @syscap SystemCapability.Utils.Lang 28 */ 29 length: number; 30 /** 31 * If the set does not contain the element, the specified element is added 32 * @param value Added element 33 * @returns the boolean type(Is there contain this element) 34 * @throws { BusinessError } 10200011 - The add method cannot be bound. 35 * @since 8 36 * @syscap SystemCapability.Utils.Lang 37 */ 38 add(obj: T): boolean; 39 /** 40 * Adds all the objects in a specified LightWeightSet container to the current LightWeightSet container 41 * @param set the Set object to provide the added element 42 * @returns the boolean type(Is there any new data added successfully) 43 * @throws { BusinessError } 10200011 - The addAll method cannot be bound. 44 * @throws { BusinessError } 401 - The type of parameters are invalid. 45 * @since 8 46 * @syscap SystemCapability.Utils.Lang 47 */ 48 addAll(set: LightWeightSet<T>): boolean; 49 /** 50 * Returns whether this set has all the object in a specified set 51 * @param set the Set object to compare 52 * @returns the boolean type 53 * @throws { BusinessError } 10200011 - The hasAll method cannot be bound. 54 * @throws { BusinessError } 401 - The type of parameters are invalid. 55 * @since 8 56 * @syscap SystemCapability.Utils.Lang 57 */ 58 hasAll(set: LightWeightSet<T>): boolean; 59 /** 60 * Checks whether an LightWeightSet container has a specified key 61 * @param key need to determine whether to include the key 62 * @returns the boolean type 63 * @throws { BusinessError } 10200011 - The has method cannot be bound. 64 * @since 8 65 * @syscap SystemCapability.Utils.Lang 66 */ 67 has(key: T): boolean; 68 /** 69 * Checks whether an the objects of an LightWeighSet container are of the same type as a specified Object LightWeightSet 70 * @param obj need to determine whether to include the obj 71 * @returns the boolean type 72 * @throws { BusinessError } 10200011 - The equal method cannot be bound. 73 * @since 8 74 * @syscap SystemCapability.Utils.Lang 75 */ 76 equal(obj: Object): boolean; 77 /** 78 * Ensures that the capacity of an LightWeightSet container is greater than or equal to a specified value, 79 * and that the container has all the original objects after capacity expansion 80 * @param minimumCapacity Minimum capacity to be reserved 81 * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. 82 * @throws { BusinessError } 401 - The type of parameters are invalid. 83 * @throws { BusinessError } 10200001 - The value of minimumCapacity is out of range. 84 * @since 8 85 * @syscap SystemCapability.Utils.Lang 86 */ 87 increaseCapacityTo(minimumCapacity: number): void; 88 /** 89 * Obtains the index of s key of a specified Object type in an LightWeightSet container 90 * @param key Looking for goals 91 * @returns Subscript corresponding to target 92 * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. 93 * @since 8 94 * @syscap SystemCapability.Utils.Lang 95 */ 96 getIndexOf(key: T): number; 97 /** 98 * Deletes an object of a specified Object type from an LightWeightSet container 99 * @param key Target to be deleted 100 * @returns Target element 101 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 102 * @since 8 103 * @syscap SystemCapability.Utils.Lang 104 */ 105 remove(key: T): T; 106 /** 107 * Deletes an object at the location identified by index from an LightWeightSet container 108 * @param index Target subscript for search 109 * @returns the boolean type(Is there a delete value) 110 * @throws { BusinessError } 10200011 - The removeAt method cannot be bound. 111 * @throws { BusinessError } 401 - The type of parameters are invalid. 112 * @since 8 113 * @syscap SystemCapability.Utils.Lang 114 */ 115 removeAt(index: number): boolean; 116 /** 117 * Removes all of the mapping from this map 118 * The map will be empty after this call returns 119 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 120 * @since 8 121 * @syscap SystemCapability.Utils.Lang 122 */ 123 clear(): void; 124 /** 125 * Executes the given callback function once for each real key in the map. 126 * It does not perform functions on deleted keys 127 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 128 * @throws { BusinessError } 401 - The type of parameters are invalid. 129 * @since 8 130 * @syscap SystemCapability.Utils.Lang 131 */ 132 forEach(callbackFn: (value?: T, key?: T, set?: LightWeightSet<T>) => void, 133 thisArg?: Object): void; 134 /** 135 * returns an ES6 iterator.Each item of the iterator is a Javascript Object 136 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 137 * @since 8 138 * @syscap SystemCapability.Utils.Lang 139 */ 140 [Symbol.iterator](): IterableIterator<T>; 141 /** 142 * Obtains a string that contains all the keys and values in an LightWeightSet container 143 * @since 8 144 * @syscap SystemCapability.Utils.Lang 145 */ 146 toString(): String; 147 /** 148 * Obtains an Array that contains all the objects of an LightWeightSet container. 149 * @throws { BusinessError } 10200011 - The toArray method cannot be bound. 150 * @since 8 151 * @syscap SystemCapability.Utils.Lang 152 */ 153 toArray(): Array<T>; 154 /** 155 * Obtains the object at the location identified by index in an LightWeightSet container 156 * @param index Target subscript for search 157 * @returns the value of key-value pairs 158 * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound. 159 * @throws { BusinessError } 401 - The type of parameters are invalid. 160 * @since 8 161 * @syscap SystemCapability.Utils.Lang 162 */ 163 getValueAt(index: number): T; 164 /** 165 * Returns a ES6 iterator of the values contained in this Set 166 * @throws { BusinessError } 10200011 - The values method cannot be bound. 167 * @since 8 168 * @syscap SystemCapability.Utils.Lang 169 */ 170 values(): IterableIterator<T>; 171 /** 172 * Returns a Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order 173 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 174 * @since 8 175 * @syscap SystemCapability.Utils.Lang 176 */ 177 entries(): IterableIterator<[T, T]>; 178 /** 179 * Returns whether the set object contains elements 180 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 181 * @since 8 182 * @syscap SystemCapability.Utils.Lang 183 */ 184 isEmpty(): boolean; 185} 186 187export default LightWeightSet; 188