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 arkts {'1.1':'12', '1.2':'20'} 41 * @arkts 1.1&1.2 42 */ 43declare class HashSet<T> { 44 /** 45 * A constructor used to create a HashSet object. 46 * 47 * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked. 48 * @syscap SystemCapability.Utils.Lang 49 * @since 8 50 */ 51 /** 52 * A constructor used to create a HashSet object. 53 * 54 * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked. 55 * @syscap SystemCapability.Utils.Lang 56 * @crossplatform 57 * @since 10 58 */ 59 /** 60 * A constructor used to create a HashSet object. 61 * 62 * @throws { BusinessError } 10200012 - The HashSet's constructor cannot be directly invoked. 63 * @syscap SystemCapability.Utils.Lang 64 * @crossplatform 65 * @atomicservice 66 * @since arkts {'1.1':'12', '1.2':'20'} 67 * @arkts 1.1&1.2 68 */ 69 constructor(); 70 /** 71 * Gets the element number of the hashset. 72 * 73 * @type { number } 74 * @syscap SystemCapability.Utils.Lang 75 * @since 8 76 */ 77 /** 78 * Gets the element number of the hashset. 79 * 80 * @type { number } 81 * @syscap SystemCapability.Utils.Lang 82 * @crossplatform 83 * @since 10 84 */ 85 /** 86 * Gets the element number of the hashset. 87 * 88 * @type { number } 89 * @syscap SystemCapability.Utils.Lang 90 * @crossplatform 91 * @atomicservice 92 * @since 12 93 */ 94 length: number; 95 /** 96 * Gets the element number of the HashSet. 97 * 98 * @type { number } 99 * @syscap SystemCapability.Utils.Lang 100 * @crossplatform 101 * @atomicservice 102 * @since 20 103 * @arkts 1.2 104 */ 105 get length(): number; 106 /** 107 * Returns whether the Set object contains elements 108 * 109 * @returns { boolean } the boolean type 110 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 111 * @syscap SystemCapability.Utils.Lang 112 * @since 8 113 */ 114 /** 115 * Returns whether the Set object contains elements 116 * 117 * @returns { boolean } the boolean type 118 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 119 * @syscap SystemCapability.Utils.Lang 120 * @crossplatform 121 * @since 10 122 */ 123 /** 124 * Returns whether the Set object contains elements 125 * 126 * @returns { boolean } the boolean type 127 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 128 * @syscap SystemCapability.Utils.Lang 129 * @crossplatform 130 * @atomicservice 131 * @since arkts {'1.1':'12', '1.2':'20'} 132 * @arkts 1.1&1.2 133 */ 134 isEmpty(): boolean; 135 /** 136 * Returns whether the Set object contain s the elements 137 * 138 * @param { T } value - value value need to determine whether to include the element 139 * @returns { boolean } the boolean type 140 * @throws { BusinessError } 10200011 - The has method cannot be bound. 141 * @throws { BusinessError } 401 - Parameter error. Possible causes: 142 * 1.Mandatory parameters are left unspecified; 143 * 2.Incorrect parameter types; 144 * 3.Parameter verification failed. 145 * @syscap SystemCapability.Utils.Lang 146 * @since 8 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 * @since 10 161 */ 162 /** 163 * Returns whether the Set object contain s the elements 164 * 165 * @param { T } value - value value need to determine whether to include the element 166 * @returns { boolean } the boolean type 167 * @throws { BusinessError } 10200011 - The has method cannot be bound. 168 * @throws { BusinessError } 401 - Parameter error. Possible causes: 169 * 1.Mandatory parameters are left unspecified; 170 * 2.Incorrect parameter types; 171 * 3.Parameter verification failed. 172 * @syscap SystemCapability.Utils.Lang 173 * @crossplatform 174 * @atomicservice 175 * @since arkts {'1.1':'12', '1.2':'20'} 176 * @arkts 1.1&1.2 177 */ 178 has(value: T): boolean; 179 /** 180 * If the set does not contain the element, the specified element is added 181 * 182 * @param { T } value - value value Added element 183 * @returns { boolean } the boolean type(Is there contain this element) 184 * @throws { BusinessError } 10200011 - The add method cannot be bound. 185 * @throws { BusinessError } 401 - Parameter error. Possible causes: 186 * 1.Mandatory parameters are left unspecified; 187 * 2.Incorrect parameter types; 188 * 3.Parameter verification failed. 189 * @syscap SystemCapability.Utils.Lang 190 * @since 8 191 */ 192 /** 193 * If the set does not contain the element, the specified element is added 194 * 195 * @param { T } value - value value Added element 196 * @returns { boolean } the boolean type(Is there contain this element) 197 * @throws { BusinessError } 10200011 - The add method cannot be bound. 198 * @throws { BusinessError } 401 - Parameter error. Possible causes: 199 * 1.Mandatory parameters are left unspecified; 200 * 2.Incorrect parameter types; 201 * 3.Parameter verification failed. 202 * @syscap SystemCapability.Utils.Lang 203 * @crossplatform 204 * @since 10 205 */ 206 /** 207 * If the set does not contain the element, the specified element is added 208 * 209 * @param { T } value - value value Added element 210 * @returns { boolean } the boolean type(Is there contain this element) 211 * @throws { BusinessError } 10200011 - The add method cannot be bound. 212 * @throws { BusinessError } 401 - Parameter error. Possible causes: 213 * 1.Mandatory parameters are left unspecified; 214 * 2.Incorrect parameter types; 215 * 3.Parameter verification failed. 216 * @syscap SystemCapability.Utils.Lang 217 * @crossplatform 218 * @atomicservice 219 * @since arkts {'1.1':'12', '1.2':'20'} 220 * @arkts 1.1&1.2 221 */ 222 add(value: T): boolean; 223 /** 224 * Remove a specified element from a Set object 225 * 226 * @param { T } value - value value Target to be deleted 227 * @returns { boolean } the boolean type(Is there contain this element) 228 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 229 * @throws { BusinessError } 401 - Parameter error. Possible causes: 230 * 1.Mandatory parameters are left unspecified; 231 * 2.Incorrect parameter types; 232 * 3.Parameter verification failed. 233 * @syscap SystemCapability.Utils.Lang 234 * @since 8 235 */ 236 /** 237 * Remove a specified element from a Set object 238 * 239 * @param { T } value - value value Target to be deleted 240 * @returns { boolean } the boolean type(Is there contain this element) 241 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 242 * @throws { BusinessError } 401 - Parameter error. Possible causes: 243 * 1.Mandatory parameters are left unspecified; 244 * 2.Incorrect parameter types; 245 * 3.Parameter verification failed. 246 * @syscap SystemCapability.Utils.Lang 247 * @crossplatform 248 * @since 10 249 */ 250 /** 251 * Remove a specified element from a Set object 252 * 253 * @param { T } value - value value Target to be deleted 254 * @returns { boolean } the boolean type(Is there contain this element) 255 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 256 * @throws { BusinessError } 401 - Parameter error. Possible causes: 257 * 1.Mandatory parameters are left unspecified; 258 * 2.Incorrect parameter types; 259 * 3.Parameter verification failed. 260 * @syscap SystemCapability.Utils.Lang 261 * @crossplatform 262 * @atomicservice 263 * @since arkts {'1.1':'12', '1.2':'20'} 264 * @arkts 1.1&1.2 265 */ 266 remove(value: T): boolean; 267 /** 268 * Clears all element groups in a set 269 * 270 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 271 * @syscap SystemCapability.Utils.Lang 272 * @since 8 273 */ 274 /** 275 * Clears all element groups in a set 276 * 277 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 278 * @syscap SystemCapability.Utils.Lang 279 * @crossplatform 280 * @since 10 281 */ 282 /** 283 * Clears all element groups in a set 284 * 285 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 286 * @syscap SystemCapability.Utils.Lang 287 * @crossplatform 288 * @atomicservice 289 * @since arkts {'1.1':'12', '1.2':'20'} 290 * @arkts 1.1&1.2 291 */ 292 clear(): void; 293 /** 294 * Executes a provided function once for each value in the Set object. 295 * 296 * @param { function } callbackFn - callbackFn 297 * callbackFn (required) A function that accepts up to three arguments. 298 * The function to be called for each element. 299 * @param { Object } [thisArg] - thisArg 300 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 301 * If thisArg is omitted, undefined is used as the this value. 302 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 303 * @throws { BusinessError } 401 - Parameter error. Possible causes: 304 * 1.Mandatory parameters are left unspecified; 305 * 2.Incorrect parameter types. 306 * @syscap SystemCapability.Utils.Lang 307 * @since 8 308 */ 309 /** 310 * Executes a provided function once for each value in the Set object. 311 * 312 * @param { function } callbackFn - callbackFn 313 * callbackFn (required) A function that accepts up to three arguments. 314 * The function to be called for each element. 315 * @param { Object } [thisArg] - thisArg 316 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 317 * If thisArg is omitted, undefined is used as the this value. 318 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 319 * @throws { BusinessError } 401 - Parameter error. Possible causes: 320 * 1.Mandatory parameters are left unspecified; 321 * 2.Incorrect parameter types. 322 * @syscap SystemCapability.Utils.Lang 323 * @crossplatform 324 * @since 10 325 */ 326 /** 327 * Executes a provided function once for each value in the Set object. 328 * 329 * @param { function } callbackFn - callbackFn 330 * callbackFn (required) A function that accepts up to three arguments. 331 * The function to be called for each element. 332 * @param { Object } [thisArg] - thisArg 333 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 334 * If thisArg is omitted, undefined is used as the this value. 335 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 336 * @throws { BusinessError } 401 - Parameter error. Possible causes: 337 * 1.Mandatory parameters are left unspecified; 338 * 2.Incorrect parameter types. 339 * @syscap SystemCapability.Utils.Lang 340 * @crossplatform 341 * @atomicservice 342 * @since 12 343 */ 344 forEach(callbackFn: (value?: T, key?: T, set?: HashSet<T>) => void, thisArg?: Object): void; 345 346 /** 347 * Iterates over all elements in the HashSet and executes a callback function for each element. 348 * 349 * @param { HashSetCbFn<T> } callbackFn - A callback function to execute for each element. 350 * @syscap SystemCapability.Utils.Lang 351 * @crossplatform 352 * @atomicservice 353 * @since 20 354 * @arkts 1.2 355 */ 356 forEach(callbackFn: HashSetCbFn<T>): void; 357 358 /** 359 * Returns a new Iterator object that contains the values contained in this set 360 * 361 * @returns { IterableIterator<T> } 362 * @throws { BusinessError } 10200011 - The values method cannot be bound. 363 * @syscap SystemCapability.Utils.Lang 364 * @since 8 365 */ 366 /** 367 * Returns a new Iterator object that contains the values contained in this set 368 * 369 * @returns { IterableIterator<T> } 370 * @throws { BusinessError } 10200011 - The values method cannot be bound. 371 * @syscap SystemCapability.Utils.Lang 372 * @crossplatform 373 * @since 10 374 */ 375 /** 376 * Returns a new Iterator object that contains the values contained in this set 377 * 378 * @returns { IterableIterator<T> } 379 * @throws { BusinessError } 10200011 - The values method cannot be bound. 380 * @syscap SystemCapability.Utils.Lang 381 * @crossplatform 382 * @atomicservice 383 * @since arkts {'1.1':'12', '1.2':'20'} 384 * @arkts 1.1&1.2 385 */ 386 values(): IterableIterator<T>; 387 /** 388 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order 389 * 390 * @returns { IterableIterator<[T, T]> } 391 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 392 * @syscap SystemCapability.Utils.Lang 393 * @since 8 394 */ 395 /** 396 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order 397 * 398 * @returns { IterableIterator<[T, T]> } 399 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 400 * @syscap SystemCapability.Utils.Lang 401 * @crossplatform 402 * @since 10 403 */ 404 /** 405 * Returns a new Iterator object that contains the [key, value] pairs for each element in the Set object in insertion order 406 * 407 * @returns { IterableIterator<[T, T]> } 408 * @throws { BusinessError } 10200011 - The entries method cannot be bound. 409 * @syscap SystemCapability.Utils.Lang 410 * @crossplatform 411 * @atomicservice 412 * @since arkts {'1.1':'12', '1.2':'20'} 413 * @arkts 1.1&1.2 414 */ 415 entries(): IterableIterator<[T, T]>; 416 /** 417 * returns an iterator.Each item of the iterator is a Javascript Object 418 * 419 * @returns { IterableIterator<T> } 420 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 421 * @syscap SystemCapability.Utils.Lang 422 * @since 8 423 */ 424 /** 425 * returns an iterator.Each item of the iterator is a Javascript Object 426 * 427 * @returns { IterableIterator<T> } 428 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 429 * @syscap SystemCapability.Utils.Lang 430 * @crossplatform 431 * @since 10 432 */ 433 /** 434 * returns an iterator.Each item of the iterator is a Javascript Object 435 * 436 * @returns { IterableIterator<T> } 437 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 438 * @syscap SystemCapability.Utils.Lang 439 * @crossplatform 440 * @atomicservice 441 * @since 12 442 */ 443 [Symbol.iterator](): IterableIterator<T>; 444 445 /** 446 * returns an iterator.Each item of the iterator is a Javascript Object 447 * 448 * @returns { IterableIterator<T> } an iterator for the HashSet 449 * @syscap SystemCapability.Utils.Lang 450 * @crossplatform 451 * @atomicservice 452 * @since 20 453 * @arkts 1.2 454 */ 455 $_iterator(): IterableIterator<T>; 456} 457 458/** 459 * The type of HashSet callback function. 460 * 461 * @typedef { function } HashSetCbFn 462 * @param { T } value - The current element being processed 463 * @param { T } key - [Deprecated] HashSet does not use key-value pairs, this parameter exists only for API compatibility 464 * @param { HashSet<T> } set - The HashSet instance being traversed 465 * @returns { void } This callback does not return a value 466 * @syscap SystemCapability.Utils.Lang 467 * @atomicservice 468 * @since 20 469 * @arkts 1.2 470 */ 471type HashSetCbFn<T> = (value: T, key: T, set: HashSet<T>) => void; 472 473export default HashSet; 474