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