• 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 LinkedList<T> {
17  /**
18   * A constructor used to create a LinkedList object.
19   * @throws { BusinessError } 10200012 - The LinkedList'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 LinkedList. This is a number one higher than the highest index in the linkedlist.
26   * @since 8
27   * @syscap SystemCapability.Utils.Lang
28   */
29  length: number;
30  /**
31   * Appends the specified element to the end of this linkedlist.
32   * @param element to be appended to this linkedlist
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 linkedlist.
41   * @param index index at which the specified element is to be inserted
42   * @param element element to be inserted
43   * @throws { BusinessError } 10200011 - The insert method cannot be bound.
44   * @throws { BusinessError } 401 - The type of parameters are invalid.
45   * @throws { BusinessError } 10200001 - The value of index is out of range.
46   * @since 8
47   * @syscap SystemCapability.Utils.Lang
48   */
49  insert(index: number, element: T): void;
50  /**
51   * Returns the element at the specified position in this linkedlist,
52   * or returns undefined if this linkedlist is empty
53   * @param index specified position
54   * @returns the T type
55   * @throws { BusinessError } 10200011 - The get method cannot be bound.
56   * @throws { BusinessError } 401 - The type of parameters are invalid.
57   * @since 8
58   * @syscap SystemCapability.Utils.Lang
59   */
60  get(index: number): T;
61  /**
62   * Inserts the specified element at the beginning of this LinkedList.
63   * @param element the element to add
64   * @throws { BusinessError } 10200011 - The addFirst method cannot be bound.
65   * @since 8
66   * @syscap SystemCapability.Utils.Lang
67   */
68  addFirst(element: T): void;
69  /**
70   * Retrieves and removes the head (first element) of this linkedlist.
71   * @returns the head of this list
72   * @throws { BusinessError } 10200011 - The removeFirst method cannot be bound.
73   * @throws { BusinessError } 10200010 - Container is empty.
74   * @since 8
75   * @syscap SystemCapability.Utils.Lang
76   */
77  removeFirst(): T;
78  /**
79   * Removes and returns the last element from this linkedlist.
80   * @returns the head of this list
81   * @throws { BusinessError } 10200011 - The removeLast method cannot be bound.
82   * @throws { BusinessError } 10200010 - Container is empty.
83   * @since 8
84   * @syscap SystemCapability.Utils.Lang
85   */
86  removeLast(): T;
87  /**
88   * Check if linkedlist contains the specified element
89   * @param element element to be contained
90   * @returns the boolean type,if linkedList contains the specified element,return true,else return false
91   * @throws { BusinessError } 10200011 - The has method cannot be bound.
92   * @since 8
93   * @syscap SystemCapability.Utils.Lang
94   */
95  has(element: T): boolean;
96  /**
97   * Returns the index of the first occurrence of the specified element
98   * in this linkedlist, or -1 if this linkedlist does not contain the element.
99   * @param element element to be contained
100   * @returns the number type ,returns the lowest index such that or -1 if there is no such index.
101   * @throws { BusinessError } 10200011 - The getIndexOf method cannot be bound.
102   * @since 8
103   * @syscap SystemCapability.Utils.Lang
104   */
105  getIndexOf(element: T): number;
106  /**
107   * Find the corresponding element according to the index,
108   * @param index the index in the linkedlist
109   * @returns the T type ,returns undefined if linkedlist is empty,If the index is
110   * out of bounds (greater than or equal to length or less than 0), throw an exception
111   * @throws { BusinessError } 10200011 - The removeByIndex method cannot be bound.
112   * @throws { BusinessError } 401 - The type of parameters are invalid.
113   * @throws { BusinessError } 10200001 - The value of index is out of range.
114   * @since 8
115   * @syscap SystemCapability.Utils.Lang
116   */
117  removeByIndex(index: number): T;
118  /**
119   * Removes the first occurrence of the specified element from this linkedlist,
120   * if it is present.  If the linkedlist does not contain the element, it is
121   * unchanged.  More formally, removes the element with the lowest index
122   * @param element element to remove
123   * @returns the boolean type ,If there is no such element, return false
124   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
125   * @since 8
126   * @syscap SystemCapability.Utils.Lang
127   */
128  remove(element: T): boolean;
129  /**
130   * Removes the first occurrence of the specified element from this linkedlist,
131   * if it is present.  If the linkedlist does not contain the element, it is
132   * unchanged.  More formally, removes the element with the lowest index
133   * @param element element to remove
134   * @returns the boolean type ,If there is no such element, return false
135   * @throws { BusinessError } 10200011 - The removeFirstFound method cannot be bound.
136   * @throws { BusinessError } 10200010 - Container is empty.
137   * @throws { BusinessError } 10200017 - The element does not exist in this container.
138   * @since 8
139   * @syscap SystemCapability.Utils.Lang
140   */
141  removeFirstFound(element: T): boolean;
142  /**
143   * Removes the last occurrence of the specified element from this linkedlist,
144   * if it is present.  If the linkedlist does not contain the element, it is
145   * unchanged.  More formally, removes the element with the lowest index
146   * @param element element to remove
147   * @returns the boolean type ,If there is no such element, return false
148   * @throws { BusinessError } 10200011 - The removeLastFound method cannot be bound.
149   * @throws { BusinessError } 10200010 - Container is empty.
150   * @throws { BusinessError } 10200017 - The element does not exist in this container.
151   * @since 8
152   * @syscap SystemCapability.Utils.Lang
153   */
154  removeLastFound(element: T): boolean;
155  /**
156   * Returns in the index of the last occurrence of the specified element in this linkedlist ,
157   * or -1 if the linkedlist does not contain the element.
158   * @param element element to find
159   * @returns the number type
160   * @throws { BusinessError } 10200011 - The getLastIndexOf method cannot be bound.
161   * @since 8
162   * @syscap SystemCapability.Utils.Lang
163   */
164  getLastIndexOf(element: T): number;
165  /**
166   * Returns the first element (the item at index 0) of this linkedlist.
167   * or returns undefined if linkedlist is empty
168   * @returns the T type ,returns undefined if linkedList is empty
169   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
170   * @since 8
171   * @syscap SystemCapability.Utils.Lang
172   */
173  getFirst(): T;
174  /**
175   * Returns the Last element (the item at index length-1) of this linkedlist.
176   * or returns undefined if linkedlist is empty
177   * @returns the T type ,returns undefined if linkedList is empty
178   * @throws { BusinessError } 10200011 - The getLast method cannot be bound.
179   * @since 8
180   * @syscap SystemCapability.Utils.Lang
181   */
182  getLast(): T;
183  /**
184   * Replaces the element at the specified position in this Vector with the specified element
185   * @param element replaced element
186   * @param index index to find
187   * @returns the T type ,returns undefined if linkedList is empty
188   * @throws { BusinessError } 10200011 - The set method cannot be bound.
189   * @throws { BusinessError } 10200001 - The value of index is out of range.
190   * @throws { BusinessError } 401 - The type of parameters are invalid.
191   * @since 8
192   * @syscap SystemCapability.Utils.Lang
193   */
194  set(index: number, element: T): T;
195  /**
196   * Replaces each element of this linkedlist with the result of applying the operator to that element.
197   * @param callbackFn (required) A function that accepts up to four arguments.
198   * The function to be called for each element in the linkedlist,Returns the result of an operation
199   * @param Value (required) current element
200   * @param Index (Optional) The index value of the current element.
201   * @param LinkedList (Optional) The linkedlist object to which the current element belongs.
202   * @param thisArg (Optional) The value passed to the function generally uses the "this" value.
203   * If this parameter is empty, "undefined" will be passed to the "this" value
204   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
205   * @throws { BusinessError } 401 - The type of parameters are invalid.
206   * @since 8
207   * @syscap SystemCapability.Utils.Lang
208   */
209  forEach(callbackFn: (value: T, index?: number, LinkedList?: LinkedList<T>) => void,
210  thisArg?: Object): void;
211  /**
212   * Removes all of the elements from this linkedlist.The linkedlist will
213   * be empty after this call returns.length becomes 0
214   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
215   * @since 8
216   * @syscap SystemCapability.Utils.Lang
217   */
218  clear(): void;
219  /**
220   * Returns a shallow copy of this instance. (The elements themselves are not copied.)
221   * @returns this linkedlist instance
222   * @throws { BusinessError } 10200011 - The clone method cannot be bound.
223   * @since 8
224   * @syscap SystemCapability.Utils.Lang
225   */
226  clone(): LinkedList<T>;
227  /**
228   * convert linkedlist to array
229   * @returns the Array type
230   * @throws { BusinessError } 10200011 - The convertToArray method cannot be bound.
231   * @since 8
232   * @syscap SystemCapability.Utils.Lang
233   */
234  convertToArray(): Array<T>;
235  /**
236   * returns an iterator.Each item of the iterator is a Javascript Object
237   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
238   * @since 8
239   * @syscap SystemCapability.Utils.Lang
240   */
241  [Symbol.iterator](): IterableIterator<T>;
242}
243
244export default LinkedList;
245