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