• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16declare class ArrayList<T> {
17  /**
18   * A constructor used to create a ArrayList object.
19   * @throws { BusinessError } 10200012 - The ArrayList's constructor cannot be directly invoked.
20   * @since 8
21   * @syscap SystemCapability.Utils.Lang
22   */
23  constructor();
24  /**
25   * Gets the element number of the ArrayList.This is a number one higher than the highest index in the arraylist.
26   * @since 8
27   * @syscap SystemCapability.Utils.Lang
28   */
29  length: number;
30  /**
31   * Appends the specified element to the end of this arraylist.
32   * @param element to be appended to this arraylist
33   * @returns the boolean type, returns true if the addition is successful, and returns false if it fails.
34   * @throws { BusinessError } 10200011 - The add method cannot be bound.
35   * @since 8
36   * @syscap SystemCapability.Utils.Lang
37   */
38  add(element: T): boolean;
39  /**
40   * Inserts the specified element at the specified position in this
41   * arraylist. Shifts the element currently at that position (if any) and
42   * any subsequent elements to the right (adds one to their index).
43   * @param index index at which the specified element is to be inserted
44   * @param element element to be inserted
45   * @throws { BusinessError } 10200001 - The value of index is out of range.
46   * @throws { BusinessError } 10200011 - The insert method cannot be bound.
47   * @throws { BusinessError } 401 - The type of parameters are invalid.
48   * @since 8
49   * @syscap SystemCapability.Utils.Lang
50   */
51  insert(element: T, index: number): void;
52  /**
53   * Check if arraylist contains the specified element
54   * @param element element to be contained
55   * @returns the boolean type,if arraylist contains the specified element,return true,else return false
56   * @throws { BusinessError } 10200011 - The has method cannot be bound.
57   * @since 8
58   * @syscap SystemCapability.Utils.Lang
59   */
60  has(element: T): boolean;
61  /**
62   * Returns the index of the first occurrence of the specified element
63   * in this arraylist, or -1 if this arraylist does not contain the element.
64   * @param element element to be contained
65   * @returns the number type ,returns the lowest index such that or -1 if there is no such index.
66   * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound.
67   * @since 8
68   * @syscap SystemCapability.Utils.Lang
69   */
70  getIndexOf(element: T): number;
71  /**
72   * Find the corresponding element according to the index,
73   * delete the element, and move the index of all elements to the right of the element forward by one.
74   * @param index the index in the arraylist
75   * @returns the T type ,returns undefined if arraylist is empty,If the index is
76   * @throws { BusinessError } 10200001 - The value of index is out of range.
77   * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound.
78   * @throws { BusinessError } 401 - The type of parameters are invalid.
79   * @since 8
80   * @syscap SystemCapability.Utils.Lang
81   */
82  removeByIndex(index: number): T;
83  /**
84   * Removes the first occurrence of the specified element from this arraylist,
85   * if it is present.  If the arraylist does not contain the element, it is
86   * unchanged.  More formally, removes the element with the lowest index
87   * @param element element to remove
88   * @returns the boolean type ,If there is no such element, return false
89   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
90   * @since 8
91   * @syscap SystemCapability.Utils.Lang
92   */
93  remove(element: T): boolean;
94  /**
95   * Returns in the index of the last occurrence of the specified element in this arraylist ,
96   * or -1 if the arraylist does not contain the element.
97   * @param element element to find
98   * @returns the number type
99   * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound.
100   * @since 8
101   * @syscap SystemCapability.Utils.Lang
102   */
103  getLastIndexOf(element: T): number;
104  /**
105   * Removes from this arraylist all of the elements whose index is between fromIndex,inclusive,and toIndex ,exclusive.
106   * @param fromIndex The starting position of the index, containing the value at that index position
107   * @param toIndex the end of the index, excluding the value at that index
108   * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range.
109   * @throws { BusinessError } 10200011 - The removeByRange method cannot be bound.
110   * @throws { BusinessError } 401 - The type of parameters are invalid.
111   * @since 8
112   * @syscap SystemCapability.Utils.Lang
113   */
114  removeByRange(fromIndex: number, toIndex: number): void;
115  /**
116   * Replaces each element of this arraylist with the result of applying the operator to that element.
117   * @param callbackFn (required) A function that accepts up to four arguments.The function to be called for
118   * each element in the arraylist,Returns the result of an operation
119   * @param Value (required) current element
120   * @param Index (Optional) The index value of the current element.
121   * @param arrlist (Optional) The arraylist object to which the current element belongs.
122   * @param thisArg (Optional) The value passed to the function generally uses the "this" value.
123   * If this parameter is empty, "undefined" will be passed to the "this" value
124   * @throws { BusinessError } 10200011 - The replaceAllElements method cannot be bound.
125   * @throws { BusinessError } 401 - The type of parameters are invalid.
126   * @since 8
127   * @syscap SystemCapability.Utils.Lang
128   */
129  replaceAllElements(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => T,
130  thisArg?: Object): void;
131  /**
132   * Executes a provided function once for each value in the arraylist object.
133   * @param callbackFn (required) A function that accepts up to four arguments.The function to
134   * be called for each element in the arraylist
135   * @param Value (required) current element
136   * @param Index (Optional) The index value of the current element.
137   * @param arrlist (Optional) The arraylist object to which the current element belongs.
138   * @param thisArg (Optional) The value passed to the function generally uses the "this" value.
139   * If this parameter is empty, "undefined" will be passed to the "this" value
140   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
141   * @throws { BusinessError } 401 - The type of parameters are invalid.
142   * @since 8
143   * @syscap SystemCapability.Utils.Lang
144   */
145  forEach(callbackFn: (value: T, index?: number, arrlist?: ArrayList<T>) => void,
146  thisArg?: Object): void;
147  /**
148   * Sorts this arraylist according to the order induced by the specified comparator,without comparator this parameter,
149   * it will default to ASCII sorting
150   * @param comparator (Optional) A function that accepts up to two arguments.Specifies the sort order.
151   * Must be a function,return number type,If it returns firstValue minus secondValue, it returns an arraylist
152   * sorted in ascending order;If it returns secondValue minus firstValue, it returns an arraylist sorted in descending order;
153   * @param firstValue (Optional) previous element
154   * @param secondValue (Optional) next elements
155   * If this parameter is empty, it will default to ASCII sorting
156   * @throws { BusinessError } 10200011 - The sort method cannot be bound.
157   * @throws { BusinessError } 401 - The type of parameters are invalid.
158   * @since 8
159   * @syscap SystemCapability.Utils.Lang
160   */
161  sort(comparator?: (firstValue: T, secondValue: T) => number): void;
162  /**
163   * Returns a view of the portion of this arraylist between the specified fromIndex,inclusive,and toIndex,exclusive
164   * @param fromIndex The starting position of the index, containing the value at that index position
165   * @param toIndex the end of the index, excluding the value at that index
166   * @throws { BusinessError } 10200001 - The value of fromIndex or toIndex is out of range.
167   * @throws { BusinessError } 10200011 - The subArrayList method cannot be bound.
168   * @throws { BusinessError } 401 - The type of parameters are invalid.
169
170   * @since 8
171   * @syscap SystemCapability.Utils.Lang
172   */
173  subArrayList(fromIndex: number, toIndex: number): ArrayList<T>;
174  /**
175   * Removes all of the elements from this arraylist.The arraylist will
176   * be empty after this call returns.length becomes 0
177   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
178   * @since 8
179   * @syscap SystemCapability.Utils.Lang
180   */
181  clear(): void;
182  /**
183   * Returns a shallow copy of this instance. (The elements themselves are not copied.)
184   * @returns this arraylist instance
185   * @throws { BusinessError } 10200011 - The clone method cannot be bound.
186   * @since 8
187   * @syscap SystemCapability.Utils.Lang
188   */
189  clone(): ArrayList<T>;
190  /**
191   * returns the capacity of this arraylist
192   * @returns the number type
193   * @throws { BusinessError } 10200011 - The getCapacity method cannot be bound.
194   * @since 8
195   * @syscap SystemCapability.Utils.Lang
196   */
197  getCapacity(): number;
198  /**
199   * convert arraylist to array
200   * @returns the Array type
201   * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound.
202   * @since 8
203   * @syscap SystemCapability.Utils.Lang
204   */
205  convertToArray(): Array<T>;
206  /**
207   * Determine whether arraylist is empty and whether there is an element
208   * @returns the boolean type
209   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
210   * @since 8
211   * @syscap SystemCapability.Utils.Lang
212   */
213  isEmpty(): boolean;
214  /**
215   * If the newCapacity provided by the user is greater than or equal to length,
216   * change the capacity of the arraylist to newCapacity, otherwise the capacity will not be changed
217   * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound.
218   * @throws { BusinessError } 401 - The type of parameters are invalid.
219   * @since 8
220   * @syscap SystemCapability.Utils.Lang
221   */
222  increaseCapacityTo(newCapacity: number): void;
223  /**
224   * Limit the capacity to the current length
225   * @throws { BusinessError } 10200011 - The trimToCurrentLength method cannot be bound.
226   * @since 8
227   * @syscap SystemCapability.Utils.Lang
228   */
229  trimToCurrentLength(): void;
230  /**
231   * returns an iterator.Each item of the iterator is a Javascript Object
232   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
233   * @since 8
234   * @syscap SystemCapability.Utils.Lang
235   */
236  [Symbol.iterator](): IterableIterator<T>;
237}
238
239export default ArrayList;
240