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