• 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 * Stack is implemented based on the array data structure.
23 * It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
24 *
25 * @syscap SystemCapability.Utils.Lang
26 * @since 8
27 */
28/**
29 * Stack is implemented based on the array data structure.
30 * It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
31 *
32 * @syscap SystemCapability.Utils.Lang
33 * @crossplatform
34 * @since 10
35 */
36/**
37 * Stack is implemented based on the array data structure.
38 * It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
39 *
40 * @syscap SystemCapability.Utils.Lang
41 * @crossplatform
42 * @atomicservice
43 * @since 12
44 */
45declare class Stack<T> {
46  /**
47   * A constructor used to create a Stack object.
48   *
49   * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked.
50   * @syscap SystemCapability.Utils.Lang
51   * @since 8
52   */
53  /**
54   * A constructor used to create a Stack object.
55   *
56   * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked.
57   * @syscap SystemCapability.Utils.Lang
58   * @crossplatform
59   * @since 10
60   */
61  /**
62   * A constructor used to create a Stack object.
63   *
64   * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked.
65   * @syscap SystemCapability.Utils.Lang
66   * @crossplatform
67   * @atomicservice
68   * @since 12
69   */
70  constructor();
71  /**
72   * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack.
73   *
74   * @type { number }
75   * @syscap SystemCapability.Utils.Lang
76   * @since 8
77   */
78  /**
79   * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack.
80   *
81   * @type { number }
82   * @syscap SystemCapability.Utils.Lang
83   * @crossplatform
84   * @since 10
85   */
86  /**
87   * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack.
88   *
89   * @type { number }
90   * @syscap SystemCapability.Utils.Lang
91   * @crossplatform
92   * @atomicservice
93   * @since 12
94   */
95  length: number;
96  /**
97   * Tests if this stack is empty
98   *
99   * @returns { boolean } the boolean type
100   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
101   * @syscap SystemCapability.Utils.Lang
102   * @since 8
103   */
104  /**
105   * Tests if this stack is empty
106   *
107   * @returns { boolean } the boolean type
108   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
109   * @syscap SystemCapability.Utils.Lang
110   * @crossplatform
111   * @since 10
112   */
113  /**
114   * Tests if this stack is empty
115   *
116   * @returns { boolean } the boolean type
117   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
118   * @syscap SystemCapability.Utils.Lang
119   * @crossplatform
120   * @atomicservice
121   * @since 12
122   */
123  isEmpty(): boolean;
124  /**
125   * Looks at the object at the top of this stack without removing it from the stack
126   * Return undefined if this stack is empty
127   *
128   * @returns { T } the top value or undefined
129   * @throws { BusinessError } 10200011 - The peek method cannot be bound.
130   * @syscap SystemCapability.Utils.Lang
131   * @since 8
132   */
133  /**
134   * Looks at the object at the top of this stack without removing it from the stack
135   * Return undefined if this stack is empty
136   *
137   * @returns { T } the top value or undefined
138   * @throws { BusinessError } 10200011 - The peek method cannot be bound.
139   * @syscap SystemCapability.Utils.Lang
140   * @crossplatform
141   * @since 10
142   */
143  /**
144   * Looks at the object at the top of this stack without removing it from the stack
145   * Return undefined if this stack is empty
146   *
147   * @returns { T } the top value or undefined
148   * @throws { BusinessError } 10200011 - The peek method cannot be bound.
149   * @syscap SystemCapability.Utils.Lang
150   * @crossplatform
151   * @atomicservice
152   * @since 12
153   */
154  peek(): T;
155  /**
156   * Removes the object at the top of this stack and returns that object as the value of this function
157   * an exception if the stack is empty
158   *
159   * @returns { T } Stack top value or undefined
160   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
161   * @syscap SystemCapability.Utils.Lang
162   * @since 8
163   */
164  /**
165   * Removes the object at the top of this stack and returns that object as the value of this function
166   * an exception if the stack is empty
167   *
168   * @returns { T } Stack top value or undefined
169   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
170   * @syscap SystemCapability.Utils.Lang
171   * @crossplatform
172   * @since 10
173   */
174  /**
175   * Removes the object at the top of this stack and returns that object as the value of this function
176   * an exception if the stack is empty
177   *
178   * @returns { T } Stack top value or undefined
179   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
180   * @syscap SystemCapability.Utils.Lang
181   * @crossplatform
182   * @atomicservice
183   * @since 12
184   */
185  pop(): T;
186  /**
187   * Pushes an item onto the top of this stack
188   *
189   * @param { T } item - item item to be appended to this Stack
190   * @returns { T } the T type
191   * @throws { BusinessError } 10200011 - The push method cannot be bound.
192   * @syscap SystemCapability.Utils.Lang
193   * @since 8
194   */
195  /**
196   * Pushes an item onto the top of this stack
197   *
198   * @param { T } item - item item to be appended to this Stack
199   * @returns { T } the T type
200   * @throws { BusinessError } 10200011 - The push method cannot be bound.
201   * @syscap SystemCapability.Utils.Lang
202   * @crossplatform
203   * @since 10
204   */
205  /**
206   * Pushes an item onto the top of this stack
207   *
208   * @param { T } item - item item to be appended to this Stack
209   * @returns { T } the T type
210   * @throws { BusinessError } 10200011 - The push method cannot be bound.
211   * @syscap SystemCapability.Utils.Lang
212   * @crossplatform
213   * @atomicservice
214   * @since 12
215   */
216  push(item: T): T;
217  /**
218   * Returns the 1-based position where an object is on this stack
219   *
220   * @param { T } element - element element Target to be deleted
221   * @returns { number } the T type,If there is no such element, return -1
222   * @throws { BusinessError } 10200011 - The locate method cannot be bound.
223   * @syscap SystemCapability.Utils.Lang
224   * @since 8
225   */
226  /**
227   * Returns the 1-based position where an object is on this stack
228   *
229   * @param { T } element - element element Target to be deleted
230   * @returns { number } the T type,If there is no such element, return -1
231   * @throws { BusinessError } 10200011 - The locate method cannot be bound.
232   * @syscap SystemCapability.Utils.Lang
233   * @crossplatform
234   * @since 10
235   */
236  /**
237   * Returns the 1-based position where an object is on this stack
238   *
239   * @param { T } element - element element Target to be deleted
240   * @returns { number } the T type,If there is no such element, return -1
241   * @throws { BusinessError } 10200011 - The locate method cannot be bound.
242   * @syscap SystemCapability.Utils.Lang
243   * @crossplatform
244   * @atomicservice
245   * @since 12
246   */
247  locate(element: T): number;
248  /**
249   * Executes a provided function once for each value in the Stack object.
250   *
251   * @param { function } callbackFn - callbackFn
252   * callbackFn (required) A function that accepts up to three arguments.
253   * The function to be called for each element.
254   * @param { Object } [thisArg] - thisArg
255   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
256   * If thisArg is omitted, undefined is used as the this value.
257   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
258   * @throws { BusinessError } 401 - Parameter error. Possible causes:
259   * 1.Mandatory parameters are left unspecified;
260   * 2.Incorrect parameter types.
261   * @syscap SystemCapability.Utils.Lang
262   * @since 8
263   */
264  /**
265   * Executes a provided function once for each value in the Stack object.
266   *
267   * @param { function } callbackFn - callbackFn
268   * callbackFn (required) A function that accepts up to three arguments.
269   * The function to be called for each element.
270   * @param { Object } [thisArg] - thisArg
271   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
272   * If thisArg is omitted, undefined is used as the this value.
273   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
274   * @throws { BusinessError } 401 - Parameter error. Possible causes:
275   * 1.Mandatory parameters are left unspecified;
276   * 2.Incorrect parameter types.
277   * @syscap SystemCapability.Utils.Lang
278   * @crossplatform
279   * @since 10
280   */
281  /**
282   * Executes a provided function once for each value in the Stack object.
283   *
284   * @param { function } callbackFn - callbackFn
285   * callbackFn (required) A function that accepts up to three arguments.
286   * The function to be called for each element.
287   * @param { Object } [thisArg] - thisArg
288   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
289   * If thisArg is omitted, undefined is used as the this value.
290   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
291   * @throws { BusinessError } 401 - Parameter error. Possible causes:
292   * 1.Mandatory parameters are left unspecified;
293   * 2.Incorrect parameter types.
294   * @syscap SystemCapability.Utils.Lang
295   * @crossplatform
296   * @atomicservice
297   * @since 12
298   */
299  forEach(callbackFn: (value: T, index?: number, stack?: Stack<T>) => void, thisArg?: Object): void;
300  /**
301   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
302   *
303   * @returns { IterableIterator<T> }
304   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
305   * @syscap SystemCapability.Utils.Lang
306   * @since 8
307   */
308  /**
309   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
310   *
311   * @returns { IterableIterator<T> }
312   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
313   * @syscap SystemCapability.Utils.Lang
314   * @crossplatform
315   * @since 10
316   */
317  /**
318   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
319   *
320   * @returns { IterableIterator<T> }
321   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
322   * @syscap SystemCapability.Utils.Lang
323   * @crossplatform
324   * @atomicservice
325   * @since 12
326   */
327  [Symbol.iterator](): IterableIterator<T>;
328}
329
330export default Stack;
331