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 * LinkedList is implemented based on the doubly linked list. Each node of the doubly linked list has 23 * references pointing to the previous element and the next element. When querying an element, 24 * the system traverses the list from the beginning or end. 25 * 26 * @syscap SystemCapability.Utils.Lang 27 * @since 8 28 */ 29/** 30 * LinkedList is implemented based on the doubly linked list. Each node of the doubly linked list has 31 * references pointing to the previous element and the next element. When querying an element, 32 * the system traverses the list from the beginning or end. 33 * 34 * @syscap SystemCapability.Utils.Lang 35 * @crossplatform 36 * @since 10 37 */ 38/** 39 * the system traverses the list from the beginning or end. LinkedList offers efficient insertion and 40 * removal operations but supports low query efficiency. LinkedList allows null elements. 41 * 42 * @syscap SystemCapability.Utils.Lang 43 * @crossplatform 44 * @atomicservice 45 * @since arkts {'1.1':'12', '1.2':'20'} 46 * @arkts 1.1&1.2 47 */ 48declare class LinkedList<T> { 49 /** 50 * A constructor used to create a LinkedList object. 51 * 52 * @throws { BusinessError } 10200012 - The LinkedList's constructor cannot be directly invoked. 53 * @syscap SystemCapability.Utils.Lang 54 * @since 8 55 */ 56 /** 57 * A constructor used to create a LinkedList object. 58 * 59 * @throws { BusinessError } 10200012 - The LinkedList's constructor cannot be directly invoked. 60 * @syscap SystemCapability.Utils.Lang 61 * @crossplatform 62 * @since 10 63 */ 64 /** 65 * A constructor used to create a LinkedList instance. 66 * 67 * @throws { BusinessError } 10200012 - The LinkedList's constructor cannot be directly invoked. 68 * @syscap SystemCapability.Utils.Lang 69 * @crossplatform 70 * @atomicservice 71 * @since arkts {'1.1':'12', '1.2':'20'} 72 * @arkts 1.1&1.2 73 */ 74 constructor(); 75 /** 76 * Gets the element number of the LinkedList. This is a number one higher than the highest index in the linkedlist. 77 * 78 * @type { number } 79 * @syscap SystemCapability.Utils.Lang 80 * @since 8 81 */ 82 /** 83 * Gets the element number of the LinkedList. This is a number one higher than the highest index in the linkedlist. 84 * 85 * @type { number } 86 * @syscap SystemCapability.Utils.Lang 87 * @crossplatform 88 * @since 10 89 */ 90 /** 91 * Number of elements in a linked list. 92 * 93 * @type { number } 94 * @syscap SystemCapability.Utils.Lang 95 * @crossplatform 96 * @atomicservice 97 * @since 12 98 */ 99 length: number; 100 101 /** 102 * Gets the element number of the LinkedList. 103 * 104 * @type { number } 105 * @syscap SystemCapability.Utils.Lang 106 * @crossplatform 107 * @atomicservice 108 * @since 20 109 * @arkts 1.2 110 */ 111 get length(): number; 112 113 /** 114 * Appends the specified element to the end of this linkedlist. 115 * 116 * @param { T } element - element element to be appended to this linkedlist 117 * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. 118 * @throws { BusinessError } 10200011 - The add method cannot be bound. 119 * @syscap SystemCapability.Utils.Lang 120 * @since 8 121 */ 122 /** 123 * Appends the specified element to the end of this linkedlist. 124 * 125 * @param { T } element - element element to be appended to this linkedlist 126 * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. 127 * @throws { BusinessError } 10200011 - The add method cannot be bound. 128 * @syscap SystemCapability.Utils.Lang 129 * @crossplatform 130 * @since 10 131 */ 132 /** 133 * Adds an element at the end of this container. 134 * 135 * @param { T } element - Target element. 136 * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. 137 * @throws { BusinessError } 10200011 - The add method cannot be bound. 138 * @syscap SystemCapability.Utils.Lang 139 * @crossplatform 140 * @atomicservice 141 * @since arkts {'1.1':'12', '1.2':'20'} 142 * @arkts 1.1&1.2 143 */ 144 add(element: T): boolean; 145 /** 146 * Inserts the specified element at the specified position in this linkedlist. 147 * 148 * @param { number } index - index index index at which the specified element is to be inserted 149 * @param { T } element - element element element to be inserted 150 * @throws { BusinessError } 10200011 - The insert method cannot be bound. 151 * @throws { BusinessError } 401 - Parameter error. Possible causes: 152 * 1.Mandatory parameters are left unspecified; 153 * 2.Incorrect parameter types; 154 * 3.Parameter verification failed. 155 * @throws { BusinessError } 10200001 - The value of index is out of range. 156 * @syscap SystemCapability.Utils.Lang 157 * @since 8 158 */ 159 /** 160 * Inserts the specified element at the specified position in this linkedlist. 161 * 162 * @param { number } index - index index index at which the specified element is to be inserted 163 * @param { T } element - element element element to be inserted 164 * @throws { BusinessError } 10200011 - The insert method cannot be bound. 165 * @throws { BusinessError } 401 - Parameter error. Possible causes: 166 * 1.Mandatory parameters are left unspecified; 167 * 2.Incorrect parameter types; 168 * 3.Parameter verification failed. 169 * @throws { BusinessError } 10200001 - The value of index is out of range. 170 * @syscap SystemCapability.Utils.Lang 171 * @crossplatform 172 * @since 10 173 */ 174 /** 175 * Inserts an element at the specified position in this container. 176 * @param { number } index - Index of the position where the element is to be inserted. 177 * @param { T } element - Target element. 178 * @throws { BusinessError } 10200011 - The insert method cannot be bound. 179 * @throws { BusinessError } 401 - Parameter error. Possible causes: 180 * 1.Mandatory parameters are left unspecified; 181 * 2.Incorrect parameter types; 182 * 3.Parameter verification failed. 183 * @throws { BusinessError } 10200001 - The value of index is out of range. 184 * @syscap SystemCapability.Utils.Lang 185 * @crossplatform 186 * @atomicservice 187 * @since arkts {'1.1':'12', '1.2':'20'} 188 * @arkts 1.1&1.2 189 */ 190 insert(index: number, element: T): void; 191 /** 192 * Returns the element at the specified position in this linkedlist, 193 * or returns undefined if this linkedlist is empty 194 * 195 * @param { number } index - index index specified position 196 * @returns { T } the T type 197 * @throws { BusinessError } 10200011 - The get 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 * @syscap SystemCapability.Utils.Lang 202 * @since 8 203 */ 204 /** 205 * Returns the element at the specified position in this linkedlist, 206 * or returns undefined if this linkedlist is empty 207 * 208 * @param { number } index - index index specified position 209 * @returns { T } the T type 210 * @throws { BusinessError } 10200011 - The get method cannot be bound. 211 * @throws { BusinessError } 401 - Parameter error. Possible causes: 212 * 1.Mandatory parameters are left unspecified; 213 * 2.Incorrect parameter types. 214 * @syscap SystemCapability.Utils.Lang 215 * @crossplatform 216 * @since 10 217 */ 218 /** 219 * Obtains an element at the specified position in this container. 220 * 221 * @param { number } index - Position index of the target element. 222 * @returns { T } the T type 223 * @throws { BusinessError } 10200011 - The get method cannot be bound. 224 * @throws { BusinessError } 401 - Parameter error. Possible causes: 225 * 1.Mandatory parameters are left unspecified; 226 * 2.Incorrect parameter types. 227 * @syscap SystemCapability.Utils.Lang 228 * @crossplatform 229 * @atomicservice 230 * @since 12 231 */ 232 get(index: number): T; 233 234 /** 235 * Obtains an element at the specified position in this container. 236 * 237 * @param { number } index - Position index of the target element. 238 * @returns { T | undefined} the element at the specified index, or undefined if the index is out of range. 239 * @syscap SystemCapability.Utils.Lang 240 * @crossplatform 241 * @atomicservice 242 * @since 20 243 * @arkts 1.2 244 */ 245 get(index: number): T | undefined; 246 247 /** 248 * Inserts the specified element at the beginning of this LinkedList. 249 * 250 * @param { T } element - element element the element to add 251 * @throws { BusinessError } 10200011 - The addFirst method cannot be bound. 252 * @syscap SystemCapability.Utils.Lang 253 * @since 8 254 */ 255 /** 256 * Inserts the specified element at the beginning of this LinkedList. 257 * 258 * @param { T } element - element element the element to add 259 * @throws { BusinessError } 10200011 - The addFirst method cannot be bound. 260 * @syscap SystemCapability.Utils.Lang 261 * @crossplatform 262 * @since 10 263 */ 264 /** 265 * Adds an element at the top of this container. 266 * 267 * @param { T } element - Target element. 268 * @throws { BusinessError } 10200011 - The addFirst method cannot be bound. 269 * @syscap SystemCapability.Utils.Lang 270 * @crossplatform 271 * @atomicservice 272 * @since arkts {'1.1':'12', '1.2':'20'} 273 * @arkts 1.1&1.2 274 */ 275 addFirst(element: T): void; 276 /** 277 * Retrieves and removes the head (first element) of this linkedlist. 278 * 279 * @returns { T } the head of this list 280 * @throws { BusinessError } 10200011 - The removeFirst method cannot be bound. 281 * @throws { BusinessError } 10200010 - Container is empty. 282 * @syscap SystemCapability.Utils.Lang 283 * @since 8 284 */ 285 /** 286 * Retrieves and removes the head (first element) of this linkedlist. 287 * 288 * @returns { T } the head of this list 289 * @throws { BusinessError } 10200011 - The removeFirst method cannot be bound. 290 * @throws { BusinessError } 10200010 - Container is empty. 291 * @syscap SystemCapability.Utils.Lang 292 * @crossplatform 293 * @since 10 294 */ 295 /** 296 * Retrieves and removes the head (first element) of this linkedlist. 297 * 298 * @returns { T } the head of this list 299 * @throws { BusinessError } 10200011 - The removeFirst method cannot be bound. 300 * @throws { BusinessError } 10200010 - Container is empty. 301 * @syscap SystemCapability.Utils.Lang 302 * @crossplatform 303 * @atomicservice 304 * @since 12 305 */ 306 removeFirst(): T; 307 308 /** 309 * Removes the first element from this container. 310 * 311 * @returns { T | undefined } the head of this list 312 * @throws { BusinessError } 10200010 - Container is empty. 313 * @syscap SystemCapability.Utils.Lang 314 * @crossplatform 315 * @atomicservice 316 * @since 20 317 * @arkts 1.2 318 */ 319 removeFirst(): T | undefined; 320 321 /** 322 * Removes and returns the last element from this linkedlist. 323 * 324 * @returns { T } the head of this list 325 * @throws { BusinessError } 10200011 - The removeLast method cannot be bound. 326 * @throws { BusinessError } 10200010 - Container is empty. 327 * @syscap SystemCapability.Utils.Lang 328 * @since 8 329 */ 330 /** 331 * Removes and returns the last element from this linkedlist. 332 * 333 * @returns { T } the head of this list 334 * @throws { BusinessError } 10200011 - The removeLast method cannot be bound. 335 * @throws { BusinessError } 10200010 - Container is empty. 336 * @syscap SystemCapability.Utils.Lang 337 * @crossplatform 338 * @since 10 339 */ 340 /** 341 * Removes the last element from this container. 342 * 343 * @returns { T } the head of this list 344 * @throws { BusinessError } 10200011 - The removeLast method cannot be bound. 345 * @throws { BusinessError } 10200010 - Container is empty. 346 * @syscap SystemCapability.Utils.Lang 347 * @crossplatform 348 * @atomicservice 349 * @since 12 350 */ 351 removeLast(): T; 352 353 /** 354 * Removes and returns the last element from this linkedList. 355 * 356 * @returns { T | undefined } the head of this list 357 * @throws { BusinessError } 10200010 - Container is empty. 358 * @syscap SystemCapability.Utils.Lang 359 * @crossplatform 360 * @atomicservice 361 * @since 20 362 * @arkts 1.2 363 */ 364 removeLast(): T | undefined; 365 366 /** 367 * Check if linkedlist contains the specified element 368 * 369 * @param { T } element - element element element to be contained 370 * @returns { boolean } the boolean type,if linkedList contains the specified element,return true,else return false 371 * @throws { BusinessError } 10200011 - The has method cannot be bound. 372 * @syscap SystemCapability.Utils.Lang 373 * @since 8 374 */ 375 /** 376 * Check if linkedlist contains the specified element 377 * 378 * @param { T } element - element element element to be contained 379 * @returns { boolean } the boolean type,if linkedList contains the specified element,return true,else return false 380 * @throws { BusinessError } 10200011 - The has method cannot be bound. 381 * @syscap SystemCapability.Utils.Lang 382 * @crossplatform 383 * @since 10 384 */ 385 /** 386 * Checks whether this container has the specified element. 387 * 388 * @param { T } element - Target element. 389 * @returns { boolean } the boolean type,if linkedList contains the specified element,return true,else return false 390 * @throws { BusinessError } 10200011 - The has method cannot be bound. 391 * @syscap SystemCapability.Utils.Lang 392 * @crossplatform 393 * @atomicservice 394 * @since arkts {'1.1':'12', '1.2':'20'} 395 * @arkts 1.1&1.2 396 */ 397 has(element: T): boolean; 398 /** 399 * Returns the index of the first occurrence of the specified element 400 * in this linkedlist, or -1 if this linkedlist does not contain the element. 401 * 402 * @param { T } element - element element element to be contained 403 * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. 404 * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. 405 * @syscap SystemCapability.Utils.Lang 406 * @since 8 407 */ 408 /** 409 * Returns the index of the first occurrence of the specified element 410 * in this linkedlist, or -1 if this linkedlist does not contain the element. 411 * 412 * @param { T } element - element element element to be contained 413 * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. 414 * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. 415 * @syscap SystemCapability.Utils.Lang 416 * @crossplatform 417 * @since 10 418 */ 419 /** 420 * Obtains the index of the first occurrence of the specified element in this container. 421 * 422 * @param { T } element - Target element. 423 * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. 424 * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. 425 * @syscap SystemCapability.Utils.Lang 426 * @crossplatform 427 * @atomicservice 428 * @since arkts {'1.1':'12', '1.2':'20'} 429 * @arkts 1.1&1.2 430 */ 431 getIndexOf(element: T): number; 432 /** 433 * Find the corresponding element according to the index. 434 * 435 * @param { number } index - index index the index in the linkedlist 436 * @returns { T } the T type ,returns undefined if linkedlist is empty,If the index is 437 * out of bounds (greater than or equal to length or less than 0), throw an exception 438 * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. 439 * @throws { BusinessError } 401 - Parameter error. Possible causes: 440 * 1.Mandatory parameters are left unspecified; 441 * 2.Incorrect parameter types; 442 * 3.Parameter verification failed. 443 * @throws { BusinessError } 10200001 - The value of index is out of range. 444 * @syscap SystemCapability.Utils.Lang 445 * @since 8 446 */ 447 /** 448 * Find the corresponding element according to the index. 449 * 450 * @param { number } index - index index the index in the linkedlist 451 * @returns { T } the T type ,returns undefined if linkedlist is empty,If the index is 452 * out of bounds (greater than or equal to length or less than 0), throw an exception 453 * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. 454 * @throws { BusinessError } 401 - Parameter error. Possible causes: 455 * 1.Mandatory parameters are left unspecified; 456 * 2.Incorrect parameter types; 457 * 3.Parameter verification failed. 458 * @throws { BusinessError } 10200001 - The value of index is out of range. 459 * @syscap SystemCapability.Utils.Lang 460 * @crossplatform 461 * @since 10 462 */ 463 /** 464 * Searches for an element based on its index and then removes it. 465 * 466 * @param { number } index - Position index of the target element. 467 * @returns { T } the T type ,returns undefined if linkedlist is empty,If the index is 468 * out of bounds (greater than or equal to length or less than 0), throw an exception 469 * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. 470 * @throws { BusinessError } 401 - Parameter error. Possible causes: 471 * 1.Mandatory parameters are left unspecified; 472 * 2.Incorrect parameter types; 473 * 3.Parameter verification failed. 474 * @throws { BusinessError } 10200001 - The value of index is out of range. 475 * @syscap SystemCapability.Utils.Lang 476 * @crossplatform 477 * @atomicservice 478 * @since 12 479 */ 480 removeByIndex(index: number): T; 481 482 /** 483 * Find the corresponding element according to the index. 484 * 485 * @param { number } index - the index in the linkedList 486 * @returns { T | undefined } the T type, if the index is 487 * out of bounds (greater than or equal to length or less than 0), throw an exception 488 * @throws { BusinessError } 10200001 - The value of "index" is out of range. It must be >= 0 && <= ${length}. 489 * Received value is: ${index} 490 * @syscap SystemCapability.Utils.Lang 491 * @crossplatform 492 * @atomicservice 493 * @since 20 494 * @arkts 1.2 495 */ 496 removeByIndex(index: number): T | undefined; 497 498 /** 499 * Removes the first occurrence of the specified element from this linkedlist, 500 * if it is present. If the linkedlist does not contain the element, it is 501 * unchanged. More formally, removes the element with the lowest index 502 * 503 * @param { T } element - element element element to remove 504 * @returns { boolean } the boolean type ,If there is no such element, return false 505 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 506 * @syscap SystemCapability.Utils.Lang 507 * @since 8 508 */ 509 /** 510 * Removes the first occurrence of the specified element from this linkedlist, 511 * if it is present. If the linkedlist does not contain the element, it is 512 * unchanged. More formally, removes the element with the lowest index 513 * 514 * @param { T } element - element element element to remove 515 * @returns { boolean } the boolean type ,If there is no such element, return false 516 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 517 * @syscap SystemCapability.Utils.Lang 518 * @crossplatform 519 * @since 10 520 */ 521 /** 522 * Removes the first occurrence of the specified element from this container. 523 * 524 * @param { T } element - Target element. 525 * @returns { boolean } the boolean type ,If there is no such element, return false 526 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 527 * @syscap SystemCapability.Utils.Lang 528 * @crossplatform 529 * @atomicservice 530 * @since arkts {'1.1':'12', '1.2':'20'} 531 * @arkts 1.1&1.2 532 */ 533 remove(element: T): boolean; 534 /** 535 * Removes the first occurrence of the specified element from this linkedlist, 536 * if it is present. If the linkedlist does not contain the element, it is 537 * unchanged. More formally, removes the element with the lowest index 538 * 539 * @param { T } element - element element element to remove 540 * @returns { boolean } the boolean type ,If there is no such element, return false 541 * @throws { BusinessError } 10200011 - The removeFirstFound method cannot be bound. 542 * @throws { BusinessError } 10200010 - Container is empty. 543 * @throws { BusinessError } 10200017 - The element does not exist in this container. 544 * @syscap SystemCapability.Utils.Lang 545 * @since 8 546 */ 547 /** 548 * Removes the first occurrence of the specified element from this linkedlist, 549 * if it is present. If the linkedlist does not contain the element, it is 550 * unchanged. More formally, removes the element with the lowest index 551 * 552 * @param { T } element - element element element to remove 553 * @returns { boolean } the boolean type ,If there is no such element, return false 554 * @throws { BusinessError } 10200011 - The removeFirstFound method cannot be bound. 555 * @throws { BusinessError } 10200010 - Container is empty. 556 * @throws { BusinessError } 10200017 - The element does not exist in this container. 557 * @syscap SystemCapability.Utils.Lang 558 * @crossplatform 559 * @since 10 560 */ 561 /** 562 * Removes the first occurrence of the specified element from this container. 563 * 564 * @param { T } element - Target element. 565 * @returns { boolean } the boolean type ,If there is no such element, return false 566 * @throws { BusinessError } 10200011 - The removeFirstFound method cannot be bound. 567 * @throws { BusinessError } 10200010 - Container is empty. 568 * @throws { BusinessError } 10200017 - The element does not exist in this container. 569 * @syscap SystemCapability.Utils.Lang 570 * @crossplatform 571 * @atomicservice 572 * @since arkts {'1.1':'12', '1.2':'20'} 573 * @arkts 1.1&1.2 574 */ 575 removeFirstFound(element: T): boolean; 576 /** 577 * Removes the last occurrence of the specified element from this linkedlist, 578 * if it is present. If the linkedlist does not contain the element, it is 579 * unchanged. More formally, removes the element with the lowest index 580 * 581 * @param { T } element - element element element to remove 582 * @returns { boolean } the boolean type ,If there is no such element, return false 583 * @throws { BusinessError } 10200011 - The removeLastFound method cannot be bound. 584 * @throws { BusinessError } 10200010 - Container is empty. 585 * @throws { BusinessError } 10200017 - The element does not exist in this container. 586 * @syscap SystemCapability.Utils.Lang 587 * @since 8 588 */ 589 /** 590 * Removes the last occurrence of the specified element from this linkedlist, 591 * if it is present. If the linkedlist does not contain the element, it is 592 * unchanged. More formally, removes the element with the lowest index 593 * 594 * @param { T } element - element element element to remove 595 * @returns { boolean } the boolean type ,If there is no such element, return false 596 * @throws { BusinessError } 10200011 - The removeLastFound method cannot be bound. 597 * @throws { BusinessError } 10200010 - Container is empty. 598 * @throws { BusinessError } 10200017 - The element does not exist in this container. 599 * @syscap SystemCapability.Utils.Lang 600 * @crossplatform 601 * @since 10 602 */ 603 /** 604 * Removes the last occurrence of the specified element from this container. 605 * 606 * @param { T } element - Target element. 607 * @returns { boolean } the boolean type ,If there is no such element, return false 608 * @throws { BusinessError } 10200011 - The removeLastFound method cannot be bound. 609 * @throws { BusinessError } 10200010 - Container is empty. 610 * @throws { BusinessError } 10200017 - The element does not exist in this container. 611 * @syscap SystemCapability.Utils.Lang 612 * @crossplatform 613 * @atomicservice 614 * @since arkts {'1.1':'12', '1.2':'20'} 615 * @arkts 1.1&1.2 616 */ 617 removeLastFound(element: T): boolean; 618 /** 619 * Returns in the index of the last occurrence of the specified element in this linkedlist , 620 * or -1 if the linkedlist does not contain the element. 621 * 622 * @param { T } element - element element element to find 623 * @returns { number } the number type 624 * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. 625 * @syscap SystemCapability.Utils.Lang 626 * @since 8 627 */ 628 /** 629 * Returns in the index of the last occurrence of the specified element in this linkedlist , 630 * or -1 if the linkedlist does not contain the element. 631 * 632 * @param { T } element - element element element to find 633 * @returns { number } the number type 634 * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. 635 * @syscap SystemCapability.Utils.Lang 636 * @crossplatform 637 * @since 10 638 */ 639 /** 640 * Obtains the index of the last occurrence of the specified element in this container. 641 * 642 * @param { T } element - Target element. 643 * @returns { number } the number type 644 * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. 645 * @syscap SystemCapability.Utils.Lang 646 * @crossplatform 647 * @atomicservice 648 * @since arkts {'1.1':'12', '1.2':'20'} 649 * @arkts 1.1&1.2 650 */ 651 getLastIndexOf(element: T): number; 652 /** 653 * Returns the first element (the item at index 0) of this linkedlist. 654 * or returns undefined if linkedlist is empty 655 * 656 * @returns { T } the T type ,returns undefined if linkedList is empty 657 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 658 * @syscap SystemCapability.Utils.Lang 659 * @since 8 660 */ 661 /** 662 * Returns the first element (the item at index 0) of this linkedlist. 663 * or returns undefined if linkedlist is empty 664 * 665 * @returns { T } the T type ,returns undefined if linkedList is empty 666 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 667 * @syscap SystemCapability.Utils.Lang 668 * @crossplatform 669 * @since 10 670 */ 671 /** 672 * Obtains the first element in this container. 673 * 674 * @returns { T } the T type ,returns undefined if linkedList is empty 675 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 676 * @syscap SystemCapability.Utils.Lang 677 * @crossplatform 678 * @atomicservice 679 * @since 12 680 */ 681 getFirst(): T; 682 683 /** 684 * Obtains the first element in this container. 685 * 686 * @returns { T | undefined } the T type, returns undefined if linkedList is empty 687 * @syscap SystemCapability.Utils.Lang 688 * @crossplatform 689 * @atomicservice 690 * @since 20 691 * @arkts 1.2 692 */ 693 getFirst(): T | undefined; 694 695 /** 696 * Returns the Last element (the item at index length-1) of this linkedlist. 697 * or returns undefined if linkedlist is empty 698 * 699 * @returns { T } the T type ,returns undefined if linkedList is empty 700 * @throws { BusinessError } 10200011 - The getLast method cannot be bound. 701 * @syscap SystemCapability.Utils.Lang 702 * @since 8 703 */ 704 /** 705 * Returns the Last element (the item at index length-1) of this linkedlist. 706 * or returns undefined if linkedlist is empty 707 * 708 * @returns { T } the T type ,returns undefined if linkedList is empty 709 * @throws { BusinessError } 10200011 - The getLast method cannot be bound. 710 * @syscap SystemCapability.Utils.Lang 711 * @crossplatform 712 * @since 10 713 */ 714 /** 715 * Obtains the last element in this container. 716 * 717 * @returns { T } the T type ,returns undefined if linkedList is empty 718 * @throws { BusinessError } 10200011 - The getLast method cannot be bound. 719 * @syscap SystemCapability.Utils.Lang 720 * @crossplatform 721 * @atomicservice 722 * @since 12 723 */ 724 getLast(): T; 725 726 /** 727 * Obtains the last element in this container. 728 * 729 * @returns { T | undefined } the T type, returns undefined if linkedList is empty 730 * @syscap SystemCapability.Utils.Lang 731 * @crossplatform 732 * @atomicservice 733 * @since 20 734 * @arkts 1.2 735 */ 736 getLast(): T | undefined; 737 738 /** 739 * Replaces the element at the specified position in this Vector with the specified element 740 * 741 * @param { number } index - index index index to find 742 * @param { T } element - element element replaced element 743 * @returns { T } the T type ,returns undefined if linkedList is empty 744 * @throws { BusinessError } 10200011 - The set method cannot be bound. 745 * @throws { BusinessError } 10200001 - The value of index is out of range. 746 * @throws { BusinessError } 401 - Parameter error. Possible causes: 747 * 1.Mandatory parameters are left unspecified; 748 * 2.Incorrect parameter types; 749 * 3.Parameter verification failed. 750 * @syscap SystemCapability.Utils.Lang 751 * @since 8 752 */ 753 /** 754 * Replaces the element at the specified position in this Vector with the specified element 755 * 756 * @param { number } index - index index index to find 757 * @param { T } element - element element replaced element 758 * @returns { T } the T type ,returns undefined if linkedList is empty 759 * @throws { BusinessError } 10200011 - The set method cannot be bound. 760 * @throws { BusinessError } 10200001 - The value of index is out of range. 761 * @throws { BusinessError } 401 - Parameter error. Possible causes: 762 * 1.Mandatory parameters are left unspecified; 763 * 2.Incorrect parameter types; 764 * 3.Parameter verification failed. 765 * @syscap SystemCapability.Utils.Lang 766 * @crossplatform 767 * @since 10 768 */ 769 /** 770 * Replaces an element at the specified position in this container with a given element. 771 * 772 * @param { number } index - Position index of the target element. 773 * @param { T } element - Element to be used for replacement. 774 * @returns { T } the T type ,returns undefined if linkedList is empty 775 * @throws { BusinessError } 10200011 - The set method cannot be bound. 776 * @throws { BusinessError } 10200001 - The value of index is out of range. 777 * @throws { BusinessError } 401 - Parameter error. Possible causes: 778 * 1.Mandatory parameters are left unspecified; 779 * 2.Incorrect parameter types; 780 * 3.Parameter verification failed. 781 * @syscap SystemCapability.Utils.Lang 782 * @crossplatform 783 * @atomicservice 784 * @since 12 785 */ 786 set(index: number, element: T): T; 787 788 /** 789 * Replaces an element at the specified position in this container with a given element. 790 * 791 * @param { number } index - Position index of the target element. 792 * @param { T } element - Element to be used for replacement. 793 * @returns { T | undefined } the T type ,returns undefined if linkedList is empty 794 * @throws { BusinessError } 10200001 - The value of index is out of range. 795 * 1.Mandatory parameters are left unspecified; 796 * 2.Incorrect parameter types; 797 * 3.Parameter verification failed. 798 * @syscap SystemCapability.Utils.Lang 799 * @crossplatform 800 * @atomicservice 801 * @since 20 802 * @arkts 1.2 803 */ 804 set(index: number, element: T): T | undefined; 805 806 /** 807 * Replaces each element of this linkedlist with the result of applying the operator to that element. 808 * 809 * @param { function } callbackFn - callbackFn 810 * callbackFn (required) A function that accepts up to three arguments. 811 * The function to be called for each element. 812 * Value (required) current element 813 * Index (Optional) The index value of the current element. 814 * LinkedList (Optional) The linkedlist object to which the current element belongs. 815 * @param { Object } [thisArg] - thisArg 816 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 817 * If thisArg is omitted, undefined is used as the this value. 818 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 819 * @throws { BusinessError } 401 - Parameter error. Possible causes: 820 * 1.Mandatory parameters are left unspecified; 821 * 2.Incorrect parameter types. 822 * @syscap SystemCapability.Utils.Lang 823 * @since 8 824 */ 825 /** 826 * Replaces each element of this linkedlist with the result of applying the operator to that element. 827 * 828 * @param { function } callbackFn - callbackFn 829 * callbackFn (required) A function that accepts up to three arguments. 830 * The function to be called for each element. 831 * Value (required) current element 832 * Index (Optional) The index value of the current element. 833 * LinkedList (Optional) The linkedlist object to which the current element belongs. 834 * @param { Object } [thisArg] - thisArg 835 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 836 * If thisArg is omitted, undefined is used as the this value. 837 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 838 * @throws { BusinessError } 401 - Parameter error. Possible causes: 839 * 1.Mandatory parameters are left unspecified; 840 * 2.Incorrect parameter types. 841 * @syscap SystemCapability.Utils.Lang 842 * @crossplatform 843 * @since 10 844 */ 845 /** 846 * Uses a callback to traverse the elements in this container and obtain their position indexes. 847 * 848 * @param { function } callbackFn - Callback invoked to traverse the elements in the container. 849 * @param { Object } [thisArg] - Value of this to use when callbackFn is invoked. The default value is this instance. 850 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 851 * @throws { BusinessError } 401 - Parameter error. Possible causes: 852 * 1.Mandatory parameters are left unspecified; 853 * 2.Incorrect parameter types. 854 * @syscap SystemCapability.Utils.Lang 855 * @crossplatform 856 * @atomicservice 857 * @since 12 858 */ 859 forEach(callbackFn: (value: T, index?: number, LinkedList?: LinkedList<T>) => void, thisArg?: Object): void; 860 861 /** 862 * Uses a callback to traverse the elements in this container and obtain their position indexes. 863 * 864 * @param { LinkedListForEachCb } callbackFn - Callback invoked to traverse the elements in the container. 865 * @syscap SystemCapability.Utils.Lang 866 * @crossplatform 867 * @atomicservice 868 * @since 20 869 * @arkts 1.2 870 */ 871 forEach(callbackfn: LinkedListForEachCb<T>): void; 872 873 /** 874 * Removes all of the elements from this linkedlist.The linkedlist will 875 * be empty after this call returns.length becomes 0 876 * 877 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 878 * @syscap SystemCapability.Utils.Lang 879 * @since 8 880 */ 881 /** 882 * Removes all of the elements from this linkedlist.The linkedlist will 883 * be empty after this call returns.length becomes 0 884 * 885 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 886 * @syscap SystemCapability.Utils.Lang 887 * @crossplatform 888 * @since 10 889 */ 890 /** 891 * Clears this container and sets its length to 0. 892 * 893 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 894 * @syscap SystemCapability.Utils.Lang 895 * @crossplatform 896 * @atomicservice 897 * @since arkts {'1.1':'12', '1.2':'20'} 898 * @arkts 1.1&1.2 899 */ 900 clear(): void; 901 /** 902 * Returns a shallow copy of this instance. (The elements themselves are not copied.) 903 * 904 * @returns { LinkedList<T> } this linkedlist instance 905 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 906 * @syscap SystemCapability.Utils.Lang 907 * @since 8 908 */ 909 /** 910 * Returns a shallow copy of this instance. (The elements themselves are not copied.) 911 * 912 * @returns { LinkedList<T> } this linkedlist instance 913 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 914 * @syscap SystemCapability.Utils.Lang 915 * @crossplatform 916 * @since 10 917 */ 918 /** 919 * Clones this container and returns a copy. The modification to the copy does not affect the original instance. 920 * 921 * @returns { LinkedList<T> } this linkedlist instance 922 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 923 * @syscap SystemCapability.Utils.Lang 924 * @crossplatform 925 * @atomicservice 926 * @since arkts {'1.1':'12', '1.2':'20'} 927 * @arkts 1.1&1.2 928 */ 929 clone(): LinkedList<T>; 930 /** 931 * convert linkedlist to array 932 * 933 * @returns { Array<T> } the Array type 934 * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. 935 * @syscap SystemCapability.Utils.Lang 936 * @since 8 937 */ 938 /** 939 * convert linkedlist to array 940 * 941 * @returns { Array<T> } the Array type 942 * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. 943 * @syscap SystemCapability.Utils.Lang 944 * @crossplatform 945 * @since 10 946 */ 947 /** 948 * Converts this container into an array. 949 * 950 * @returns { Array<T> } the Array type 951 * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. 952 * @syscap SystemCapability.Utils.Lang 953 * @crossplatform 954 * @atomicservice 955 * @since arkts {'1.1':'12', '1.2':'20'} 956 * @arkts 1.1&1.2 957 */ 958 convertToArray(): Array<T>; 959 /** 960 * returns an iterator.Each item of the iterator is a Javascript Object 961 * 962 * @returns { IterableIterator<T> } 963 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 964 * @syscap SystemCapability.Utils.Lang 965 * @since 8 966 */ 967 /** 968 * returns an iterator.Each item of the iterator is a Javascript Object 969 * 970 * @returns { IterableIterator<T> } 971 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 972 * @syscap SystemCapability.Utils.Lang 973 * @crossplatform 974 * @since 10 975 */ 976 /** 977 * Obtains an iterator, each item of which is a JavaScript object. 978 * 979 * @returns { IterableIterator<T> } 980 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 981 * @syscap SystemCapability.Utils.Lang 982 * @crossplatform 983 * @atomicservice 984 * @since 12 985 */ 986 [Symbol.iterator](): IterableIterator<T>; 987 988 /** 989 * Obtains an iterator, each item of which is a JavaScript object. 990 * 991 * @returns { IterableIterator<T> } 992 * @syscap SystemCapability.Utils.Lang 993 * @crossplatform 994 * @atomicservice 995 * @since 20 996 * @arkts 1.2 997 */ 998 $_iterator(): IterableIterator<T>; 999 1000} 1001 1002/** 1003 * The type of LinkedList callback function. 1004 * 1005 * @typedef { function } LinkedListForEachCb 1006 * @param { T } value - The value of current element 1007 * @param { number } index - The index of current element 1008 * @param { LinkedList<T> } linkedList - The LinkedList instance being traversed 1009 * @returns { void } This callback does not return a value 1010 * @syscap SystemCapability.Utils.Lang 1011 * @atomicservice 1012 * @since 20 1013 * @arkts 1.2 1014 */ 1015type LinkedListForEachCb<T> = (value: T, index: number, linkedList: LinkedList<T>) => void 1016 1017export default LinkedList; 1018