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 * ArrayList is a linear data structure that is implemented based on arrays. 23 * ArrayList can dynamically adjust the capacity based on project requirements. It increases the capacity by 50% each time. 24 * 25 * @syscap SystemCapability.Utils.Lang 26 * @since 8 27 */ 28/** 29 * ArrayList is a linear data structure that is implemented based on arrays. 30 * ArrayList can dynamically adjust the capacity based on project requirements. It increases the capacity by 50% each time. 31 * 32 * @syscap SystemCapability.Utils.Lang 33 * @crossplatform 34 * @since 10 35 */ 36declare class ArrayList<T> { 37 /** 38 * A constructor used to create a ArrayList object. 39 * 40 * @throws { BusinessError } 10200012 - The ArrayList's constructor cannot be directly invoked. 41 * @syscap SystemCapability.Utils.Lang 42 * @since 8 43 */ 44 /** 45 * A constructor used to create a ArrayList object. 46 * 47 * @throws { BusinessError } 10200012 - The ArrayList's constructor cannot be directly invoked. 48 * @syscap SystemCapability.Utils.Lang 49 * @crossplatform 50 * @since 10 51 */ 52 constructor(); 53 /** 54 * Gets the element number of the ArrayList.This is a number one higher than the highest index in the arraylist. 55 * 56 * @syscap SystemCapability.Utils.Lang 57 * @since 8 58 */ 59 /** 60 * Gets the element number of the ArrayList.This is a number one higher than the highest index in the arraylist. 61 * 62 * @syscap SystemCapability.Utils.Lang 63 * @crossplatform 64 * @since 10 65 */ 66 length: number; 67 /** 68 * Appends the specified element to the end of this arraylist. 69 * 70 * @param { T } element - element element to be appended to this arraylist 71 * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. 72 * @throws { BusinessError } 10200011 - The add method cannot be bound. 73 * @syscap SystemCapability.Utils.Lang 74 * @since 8 75 */ 76 /** 77 * Appends the specified element to the end of this arraylist. 78 * 79 * @param { T } element - element element to be appended to this arraylist 80 * @returns { boolean } the boolean type, returns true if the addition is successful, and returns false if it fails. 81 * @throws { BusinessError } 10200011 - The add method cannot be bound. 82 * @syscap SystemCapability.Utils.Lang 83 * @crossplatform 84 * @since 10 85 */ 86 add(element: T): boolean; 87 /** 88 * Inserts the specified element at the specified position in this 89 * arraylist. Shifts the element currently at that position (if any) and 90 * any subsequent elements to the right (adds one to their index). 91 * 92 * @param { T } element - element element element to be inserted 93 * @param { number } index - index index at which the specified element is to be inserted 94 * @throws { BusinessError } 10200001 - The value of index is out of range. 95 * @throws { BusinessError } 10200011 - The insert method cannot be bound. 96 * @throws { BusinessError } 401 - The type of parameters are invalid. 97 * @syscap SystemCapability.Utils.Lang 98 * @since 8 99 */ 100 /** 101 * Inserts the specified element at the specified position in this 102 * arraylist. Shifts the element currently at that position (if any) and 103 * any subsequent elements to the right (adds one to their index). 104 * 105 * @param { T } element - element element element to be inserted 106 * @param { number } index - index index at which the specified element is to be inserted 107 * @throws { BusinessError } 10200001 - The value of index is out of range. 108 * @throws { BusinessError } 10200011 - The insert method cannot be bound. 109 * @throws { BusinessError } 401 - The type of parameters are invalid. 110 * @syscap SystemCapability.Utils.Lang 111 * @crossplatform 112 * @since 10 113 */ 114 insert(element: T, index: number): void; 115 /** 116 * Check if arraylist contains the specified element 117 * 118 * @param { T } element - element element element to be contained 119 * @returns { boolean } the boolean type,if arraylist contains the specified element,return true,else return false 120 * @throws { BusinessError } 10200011 - The has method cannot be bound. 121 * @syscap SystemCapability.Utils.Lang 122 * @since 8 123 */ 124 /** 125 * Check if arraylist contains the specified element 126 * 127 * @param { T } element - element element element to be contained 128 * @returns { boolean } the boolean type,if arraylist contains the specified element,return true,else return false 129 * @throws { BusinessError } 10200011 - The has method cannot be bound. 130 * @syscap SystemCapability.Utils.Lang 131 * @crossplatform 132 * @since 10 133 */ 134 has(element: T): boolean; 135 /** 136 * Returns the index of the first occurrence of the specified element 137 * in this arraylist, or -1 if this arraylist does not contain the element. 138 * 139 * @param { T } element - element element element to be contained 140 * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. 141 * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. 142 * @syscap SystemCapability.Utils.Lang 143 * @since 8 144 */ 145 /** 146 * Returns the index of the first occurrence of the specified element 147 * in this arraylist, or -1 if this arraylist does not contain the element. 148 * 149 * @param { T } element - element element element to be contained 150 * @returns { number } the number type ,returns the lowest index such that or -1 if there is no such index. 151 * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound. 152 * @syscap SystemCapability.Utils.Lang 153 * @crossplatform 154 * @since 10 155 */ 156 getIndexOf(element: T): number; 157 /** 158 * Find the corresponding element according to the index, 159 * delete the element, and move the index of all elements to the right of the element forward by one. 160 * 161 * @param { number } index - index index the index in the arraylist 162 * @returns { T } the T type ,returns undefined if arraylist is empty,If the index is 163 * @throws { BusinessError } 10200001 - The value of index is out of range. 164 * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. 165 * @throws { BusinessError } 401 - The type of parameters are invalid. 166 * @syscap SystemCapability.Utils.Lang 167 * @since 8 168 */ 169 /** 170 * Find the corresponding element according to the index, 171 * delete the element, and move the index of all elements to the right of the element forward by one. 172 * 173 * @param { number } index - index index the index in the arraylist 174 * @returns { T } the T type ,returns undefined if arraylist is empty,If the index is 175 * @throws { BusinessError } 10200001 - The value of index is out of range. 176 * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound. 177 * @throws { BusinessError } 401 - The type of parameters are invalid. 178 * @syscap SystemCapability.Utils.Lang 179 * @crossplatform 180 * @since 10 181 */ 182 removeByIndex(index: number): T; 183 /** 184 * Removes the first occurrence of the specified element from this arraylist, 185 * if it is present. If the arraylist does not contain the element, it is 186 * unchanged. More formally, removes the element with the lowest index 187 * 188 * @param { T } element - element element element to remove 189 * @returns { boolean } the boolean type ,If there is no such element, return false 190 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 191 * @syscap SystemCapability.Utils.Lang 192 * @since 8 193 */ 194 /** 195 * Removes the first occurrence of the specified element from this arraylist, 196 * if it is present. If the arraylist does not contain the element, it is 197 * unchanged. More formally, removes the element with the lowest index 198 * 199 * @param { T } element - element element element to remove 200 * @returns { boolean } the boolean type ,If there is no such element, return false 201 * @throws { BusinessError } 10200011 - The remove method cannot be bound. 202 * @syscap SystemCapability.Utils.Lang 203 * @crossplatform 204 * @since 10 205 */ 206 remove(element: T): boolean; 207 /** 208 * Returns in the index of the last occurrence of the specified element in this arraylist , 209 * or -1 if the arraylist does not contain the element. 210 * 211 * @param { T } element - element element element to find 212 * @returns { number } the number type 213 * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. 214 * @syscap SystemCapability.Utils.Lang 215 * @since 8 216 */ 217 /** 218 * Returns in the index of the last occurrence of the specified element in this arraylist , 219 * or -1 if the arraylist does not contain the element. 220 * 221 * @param { T } element - element element element to find 222 * @returns { number } the number type 223 * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound. 224 * @syscap SystemCapability.Utils.Lang 225 * @crossplatform 226 * @since 10 227 */ 228 getLastIndexOf(element: T): number; 229 /** 230 * Removes from this arraylist all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. 231 * 232 * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position 233 * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index 234 * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. 235 * @throws { BusinessError } 10200011 - The removeByRange method cannot be bound. 236 * @throws { BusinessError } 401 - The type of parameters are invalid. 237 * @syscap SystemCapability.Utils.Lang 238 * @since 8 239 */ 240 /** 241 * Removes from this arraylist all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive. 242 * 243 * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position 244 * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index 245 * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. 246 * @throws { BusinessError } 10200011 - The removeByRange method cannot be bound. 247 * @throws { BusinessError } 401 - The type of parameters are invalid. 248 * @syscap SystemCapability.Utils.Lang 249 * @crossplatform 250 * @since 10 251 */ 252 removeByRange(fromIndex: number, toIndex: number): void; 253 /** 254 * Replaces each element of this arraylist with the result of applying the operator to that element. 255 * 256 * @param { function } callbackFn - callbackFn 257 * callbackFn (required) A function that accepts up to three arguments. 258 * The function to be called for each element. 259 * @param { Object } [thisArg] - thisArg 260 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 261 * If thisArg is omitted, undefined is used as the this value. 262 * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound. 263 * @throws { BusinessError } 401 - The type of parameters are invalid. 264 * @syscap SystemCapability.Utils.Lang 265 * @since 8 266 */ 267 /** 268 * Replaces each element of this arraylist with the result of applying the operator to that element. 269 * 270 * @param { function } callbackFn - callbackFn 271 * callbackFn (required) A function that accepts up to three arguments. 272 * The function to be called for each element. 273 * @param { Object } [thisArg] - thisArg 274 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 275 * If thisArg is omitted, undefined is used as the this value. 276 * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound. 277 * @throws { BusinessError } 401 - The type of parameters are invalid. 278 * @syscap SystemCapability.Utils.Lang 279 * @crossplatform 280 * @since 10 281 */ 282 replaceAllElements(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => T, thisArg?: Object): void; 283 /** 284 * Executes a provided function once for each value in the arraylist object. 285 * 286 * @param { function } callbackFn - callbackFn 287 * callbackFn (required) A function that accepts up to three arguments. 288 * The function to be called for each element. 289 * @param { Object } [thisArg] - thisArg 290 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 291 * If thisArg is omitted, undefined is used as the this value. 292 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 293 * @throws { BusinessError } 401 - The type of parameters are invalid. 294 * @syscap SystemCapability.Utils.Lang 295 * @since 8 296 */ 297 /** 298 * Executes a provided function once for each value in the arraylist object. 299 * 300 * @param { function } callbackFn - callbackFn 301 * callbackFn (required) A function that accepts up to three arguments. 302 * The function to be called for each element. 303 * @param { Object } [thisArg] - thisArg 304 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 305 * If thisArg is omitted, undefined is used as the this value. 306 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 307 * @throws { BusinessError } 401 - The type of parameters are invalid. 308 * @syscap SystemCapability.Utils.Lang 309 * @crossplatform 310 * @since 10 311 */ 312 forEach(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => void, thisArg?: Object): void; 313 /** 314 * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, 315 * it will default to ASCII sorting 316 * 317 * @param { function } [comparator] - comparator 318 * comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. 319 * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an arraylist 320 * sorted in ascending order;If it returns secondValue minus firstValue, it returns an arraylist sorted in descending order; 321 * If this parameter is empty, it will default to ASCII sorting 322 * @throws { BusinessError } 10200011 - The sort method cannot be bound. 323 * @throws { BusinessError } 401 - The type of parameters are invalid. 324 * @syscap SystemCapability.Utils.Lang 325 * @since 8 326 */ 327 /** 328 * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter, 329 * it will default to ASCII sorting 330 * 331 * @param { function } [comparator] - comparator 332 * comparator (Optional) A function that accepts up to two arguments.Specifies the sort order. 333 * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an arraylist 334 * sorted in ascending order;If it returns secondValue minus firstValue, it returns an arraylist sorted in descending order; 335 * If this parameter is empty, it will default to ASCII sorting 336 * @throws { BusinessError } 10200011 - The sort method cannot be bound. 337 * @throws { BusinessError } 401 - The type of parameters are invalid. 338 * @syscap SystemCapability.Utils.Lang 339 * @crossplatform 340 * @since 10 341 */ 342 sort(comparator?: (firstValue: T, secondValue: T) => number): void; 343 /** 344 * Returns a view of the portion of this arraylist between the specified fromIndex,inclusive,and toIndex,exclusive 345 * 346 * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position 347 * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index 348 * @returns { ArrayList<T> } 349 * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. 350 * @throws { BusinessError } 10200011 - The subArrayList method cannot be bound. 351 * @throws { BusinessError } 401 - The type of parameters are invalid. 352 * @syscap SystemCapability.Utils.Lang 353 * @since 8 354 */ 355 /** 356 * Returns a view of the portion of this arraylist between the specified fromIndex,inclusive,and toIndex,exclusive 357 * 358 * @param { number } fromIndex - fromIndex fromIndex The starting position of the index, containing the value at that index position 359 * @param { number } toIndex - toIndex toIndex the end of the index, excluding the value at that index 360 * @returns { ArrayList<T> } 361 * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range. 362 * @throws { BusinessError } 10200011 - The subArrayList method cannot be bound. 363 * @throws { BusinessError } 401 - The type of parameters are invalid. 364 * @syscap SystemCapability.Utils.Lang 365 * @crossplatform 366 * @since 10 367 */ 368 subArrayList(fromIndex: number, toIndex: number): ArrayList<T>; 369 /** 370 * Removes all of the elements from this arraylist.The arraylist will 371 * be empty after this call returns.length becomes 0 372 * 373 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 374 * @syscap SystemCapability.Utils.Lang 375 * @since 8 376 */ 377 /** 378 * Removes all of the elements from this arraylist.The arraylist will 379 * be empty after this call returns.length becomes 0 380 * 381 * @throws { BusinessError } 10200011 - The clear method cannot be bound. 382 * @syscap SystemCapability.Utils.Lang 383 * @crossplatform 384 * @since 10 385 */ 386 clear(): void; 387 /** 388 * Returns a shallow copy of this instance. (The elements themselves are not copied.) 389 * 390 * @returns { ArrayList<T> } this arraylist instance 391 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 392 * @syscap SystemCapability.Utils.Lang 393 * @since 8 394 */ 395 /** 396 * Returns a shallow copy of this instance. (The elements themselves are not copied.) 397 * 398 * @returns { ArrayList<T> } this arraylist instance 399 * @throws { BusinessError } 10200011 - The clone method cannot be bound. 400 * @syscap SystemCapability.Utils.Lang 401 * @crossplatform 402 * @since 10 403 */ 404 clone(): ArrayList<T>; 405 /** 406 * returns the capacity of this arraylist 407 * 408 * @returns { number } the number type 409 * @throws { BusinessError } 10200011 - The getCapacity method cannot be bound. 410 * @syscap SystemCapability.Utils.Lang 411 * @since 8 412 */ 413 /** 414 * returns the capacity of this arraylist 415 * 416 * @returns { number } the number type 417 * @throws { BusinessError } 10200011 - The getCapacity method cannot be bound. 418 * @syscap SystemCapability.Utils.Lang 419 * @crossplatform 420 * @since 10 421 */ 422 getCapacity(): number; 423 /** 424 * convert arraylist to array 425 * 426 * @returns { Array<T> } the Array type 427 * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. 428 * @syscap SystemCapability.Utils.Lang 429 * @since 8 430 */ 431 /** 432 * convert arraylist to array 433 * 434 * @returns { Array<T> } the Array type 435 * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound. 436 * @syscap SystemCapability.Utils.Lang 437 * @crossplatform 438 * @since 10 439 */ 440 convertToArray(): Array<T>; 441 /** 442 * Determine whether arraylist is empty and whether there is an element 443 * 444 * @returns { boolean } the boolean type 445 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 446 * @syscap SystemCapability.Utils.Lang 447 * @since 8 448 */ 449 /** 450 * Determine whether arraylist is empty and whether there is an element 451 * 452 * @returns { boolean } the boolean type 453 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 454 * @syscap SystemCapability.Utils.Lang 455 * @crossplatform 456 * @since 10 457 */ 458 isEmpty(): boolean; 459 /** 460 * If the newCapacity provided by the user is greater than or equal to length, 461 * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed 462 * 463 * @param { number } newCapacity - newCapacity newCapacity 464 * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. 465 * @throws { BusinessError } 401 - The type of parameters are invalid. 466 * @syscap SystemCapability.Utils.Lang 467 * @since 8 468 */ 469 /** 470 * If the newCapacity provided by the user is greater than or equal to length, 471 * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed 472 * 473 * @param { number } newCapacity - newCapacity newCapacity 474 * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound. 475 * @throws { BusinessError } 401 - The type of parameters are invalid. 476 * @syscap SystemCapability.Utils.Lang 477 * @crossplatform 478 * @since 10 479 */ 480 increaseCapacityTo(newCapacity: number): void; 481 /** 482 * Limit the capacity to the current length 483 * 484 * @throws { BusinessError } 10200011 - The trimToCurrentLength method cannot be bound. 485 * @syscap SystemCapability.Utils.Lang 486 * @since 8 487 */ 488 /** 489 * Limit the capacity to the current length 490 * 491 * @throws { BusinessError } 10200011 - The trimToCurrentLength method cannot be bound. 492 * @syscap SystemCapability.Utils.Lang 493 * @crossplatform 494 * @since 10 495 */ 496 trimToCurrentLength(): void; 497 /** 498 * returns an iterator.Each item of the iterator is a Javascript Object 499 * 500 * @returns { IterableIterator<T> } 501 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 502 * @syscap SystemCapability.Utils.Lang 503 * @since 8 504 */ 505 /** 506 * returns an iterator.Each item of the iterator is a Javascript Object 507 * 508 * @returns { IterableIterator<T> } 509 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 510 * @syscap SystemCapability.Utils.Lang 511 * @crossplatform 512 * @since 10 513 */ 514 [Symbol.iterator](): IterableIterator<T>; 515} 516 517export default ArrayList; 518