161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit ArkTS
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ci/**
2261847f8eSopenharmony_ci * Stack is implemented based on the array data structure. 
2361847f8eSopenharmony_ci * It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
2461847f8eSopenharmony_ci *
2561847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang
2661847f8eSopenharmony_ci * @since 8
2761847f8eSopenharmony_ci */
2861847f8eSopenharmony_ci/**
2961847f8eSopenharmony_ci * Stack is implemented based on the array data structure. 
3061847f8eSopenharmony_ci * It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
3161847f8eSopenharmony_ci *
3261847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang
3361847f8eSopenharmony_ci * @crossplatform
3461847f8eSopenharmony_ci * @since 10
3561847f8eSopenharmony_ci */
3661847f8eSopenharmony_ci/**
3761847f8eSopenharmony_ci * Stack is implemented based on the array data structure. 
3861847f8eSopenharmony_ci * It follows the principle Last Out First In (LOFI) and supports data insertion and removal at one end.
3961847f8eSopenharmony_ci *
4061847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang
4161847f8eSopenharmony_ci * @crossplatform
4261847f8eSopenharmony_ci * @atomicservice
4361847f8eSopenharmony_ci * @since 12
4461847f8eSopenharmony_ci */
4561847f8eSopenharmony_cideclare class Stack<T> {
4661847f8eSopenharmony_ci  /**
4761847f8eSopenharmony_ci   * A constructor used to create a Stack object.
4861847f8eSopenharmony_ci   *
4961847f8eSopenharmony_ci   * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked.
5061847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
5161847f8eSopenharmony_ci   * @since 8
5261847f8eSopenharmony_ci   */
5361847f8eSopenharmony_ci  /**
5461847f8eSopenharmony_ci   * A constructor used to create a Stack object.
5561847f8eSopenharmony_ci   *
5661847f8eSopenharmony_ci   * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked.
5761847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
5861847f8eSopenharmony_ci   * @crossplatform
5961847f8eSopenharmony_ci   * @since 10
6061847f8eSopenharmony_ci   */
6161847f8eSopenharmony_ci  /**
6261847f8eSopenharmony_ci   * A constructor used to create a Stack object.
6361847f8eSopenharmony_ci   *
6461847f8eSopenharmony_ci   * @throws { BusinessError } 10200012 - The Stack's constructor cannot be directly invoked.
6561847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
6661847f8eSopenharmony_ci   * @crossplatform
6761847f8eSopenharmony_ci   * @atomicservice
6861847f8eSopenharmony_ci   * @since 12
6961847f8eSopenharmony_ci   */
7061847f8eSopenharmony_ci  constructor();
7161847f8eSopenharmony_ci  /**
7261847f8eSopenharmony_ci   * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack.
7361847f8eSopenharmony_ci   *
7461847f8eSopenharmony_ci   * @type { number }
7561847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
7661847f8eSopenharmony_ci   * @since 8
7761847f8eSopenharmony_ci   */
7861847f8eSopenharmony_ci  /**
7961847f8eSopenharmony_ci   * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack.
8061847f8eSopenharmony_ci   *
8161847f8eSopenharmony_ci   * @type { number }
8261847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
8361847f8eSopenharmony_ci   * @crossplatform
8461847f8eSopenharmony_ci   * @since 10
8561847f8eSopenharmony_ci   */
8661847f8eSopenharmony_ci  /**
8761847f8eSopenharmony_ci   * Gets the element number of the Stack. This is a number one higher than the highest index in the Stack.
8861847f8eSopenharmony_ci   *
8961847f8eSopenharmony_ci   * @type { number }
9061847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
9161847f8eSopenharmony_ci   * @crossplatform
9261847f8eSopenharmony_ci   * @atomicservice
9361847f8eSopenharmony_ci   * @since 12
9461847f8eSopenharmony_ci   */
9561847f8eSopenharmony_ci  length: number;
9661847f8eSopenharmony_ci  /**
9761847f8eSopenharmony_ci   * Tests if this stack is empty
9861847f8eSopenharmony_ci   *
9961847f8eSopenharmony_ci   * @returns { boolean } the boolean type
10061847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
10161847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
10261847f8eSopenharmony_ci   * @since 8
10361847f8eSopenharmony_ci   */
10461847f8eSopenharmony_ci  /**
10561847f8eSopenharmony_ci   * Tests if this stack is empty
10661847f8eSopenharmony_ci   *
10761847f8eSopenharmony_ci   * @returns { boolean } the boolean type
10861847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
10961847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
11061847f8eSopenharmony_ci   * @crossplatform
11161847f8eSopenharmony_ci   * @since 10
11261847f8eSopenharmony_ci   */
11361847f8eSopenharmony_ci  /**
11461847f8eSopenharmony_ci   * Tests if this stack is empty
11561847f8eSopenharmony_ci   *
11661847f8eSopenharmony_ci   * @returns { boolean } the boolean type
11761847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
11861847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
11961847f8eSopenharmony_ci   * @crossplatform
12061847f8eSopenharmony_ci   * @atomicservice
12161847f8eSopenharmony_ci   * @since 12
12261847f8eSopenharmony_ci   */
12361847f8eSopenharmony_ci  isEmpty(): boolean;
12461847f8eSopenharmony_ci  /**
12561847f8eSopenharmony_ci   * Looks at the object at the top of this stack without removing it from the stack
12661847f8eSopenharmony_ci   * Return undefined if this stack is empty
12761847f8eSopenharmony_ci   *
12861847f8eSopenharmony_ci   * @returns { T } the top value or undefined
12961847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The peek method cannot be bound.
13061847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
13161847f8eSopenharmony_ci   * @since 8
13261847f8eSopenharmony_ci   */
13361847f8eSopenharmony_ci  /**
13461847f8eSopenharmony_ci   * Looks at the object at the top of this stack without removing it from the stack
13561847f8eSopenharmony_ci   * Return undefined if this stack is empty
13661847f8eSopenharmony_ci   *
13761847f8eSopenharmony_ci   * @returns { T } the top value or undefined
13861847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The peek method cannot be bound.
13961847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
14061847f8eSopenharmony_ci   * @crossplatform
14161847f8eSopenharmony_ci   * @since 10
14261847f8eSopenharmony_ci   */
14361847f8eSopenharmony_ci  /**
14461847f8eSopenharmony_ci   * Looks at the object at the top of this stack without removing it from the stack
14561847f8eSopenharmony_ci   * Return undefined if this stack is empty
14661847f8eSopenharmony_ci   *
14761847f8eSopenharmony_ci   * @returns { T } the top value or undefined
14861847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The peek method cannot be bound.
14961847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
15061847f8eSopenharmony_ci   * @crossplatform
15161847f8eSopenharmony_ci   * @atomicservice
15261847f8eSopenharmony_ci   * @since 12
15361847f8eSopenharmony_ci   */
15461847f8eSopenharmony_ci  peek(): T;
15561847f8eSopenharmony_ci  /**
15661847f8eSopenharmony_ci   * Removes the object at the top of this stack and returns that object as the value of this function
15761847f8eSopenharmony_ci   * an exception if the stack is empty
15861847f8eSopenharmony_ci   *
15961847f8eSopenharmony_ci   * @returns { T } Stack top value or undefined
16061847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
16161847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
16261847f8eSopenharmony_ci   * @since 8
16361847f8eSopenharmony_ci   */
16461847f8eSopenharmony_ci  /**
16561847f8eSopenharmony_ci   * Removes the object at the top of this stack and returns that object as the value of this function
16661847f8eSopenharmony_ci   * an exception if the stack is empty
16761847f8eSopenharmony_ci   *
16861847f8eSopenharmony_ci   * @returns { T } Stack top value or undefined
16961847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
17061847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
17161847f8eSopenharmony_ci   * @crossplatform
17261847f8eSopenharmony_ci   * @since 10
17361847f8eSopenharmony_ci   */
17461847f8eSopenharmony_ci  /**
17561847f8eSopenharmony_ci   * Removes the object at the top of this stack and returns that object as the value of this function
17661847f8eSopenharmony_ci   * an exception if the stack is empty
17761847f8eSopenharmony_ci   *
17861847f8eSopenharmony_ci   * @returns { T } Stack top value or undefined
17961847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
18061847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
18161847f8eSopenharmony_ci   * @crossplatform
18261847f8eSopenharmony_ci   * @atomicservice
18361847f8eSopenharmony_ci   * @since 12
18461847f8eSopenharmony_ci   */
18561847f8eSopenharmony_ci  pop(): T;
18661847f8eSopenharmony_ci  /**
18761847f8eSopenharmony_ci   * Pushes an item onto the top of this stack
18861847f8eSopenharmony_ci   *
18961847f8eSopenharmony_ci   * @param { T } item - item item to be appended to this Stack
19061847f8eSopenharmony_ci   * @returns { T } the T type
19161847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The push method cannot be bound.
19261847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
19361847f8eSopenharmony_ci   * @since 8
19461847f8eSopenharmony_ci   */
19561847f8eSopenharmony_ci  /**
19661847f8eSopenharmony_ci   * Pushes an item onto the top of this stack
19761847f8eSopenharmony_ci   *
19861847f8eSopenharmony_ci   * @param { T } item - item item to be appended to this Stack
19961847f8eSopenharmony_ci   * @returns { T } the T type
20061847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The push method cannot be bound.
20161847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
20261847f8eSopenharmony_ci   * @crossplatform
20361847f8eSopenharmony_ci   * @since 10
20461847f8eSopenharmony_ci   */
20561847f8eSopenharmony_ci  /**
20661847f8eSopenharmony_ci   * Pushes an item onto the top of this stack
20761847f8eSopenharmony_ci   *
20861847f8eSopenharmony_ci   * @param { T } item - item item to be appended to this Stack
20961847f8eSopenharmony_ci   * @returns { T } the T type
21061847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The push method cannot be bound.
21161847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
21261847f8eSopenharmony_ci   * @crossplatform
21361847f8eSopenharmony_ci   * @atomicservice
21461847f8eSopenharmony_ci   * @since 12
21561847f8eSopenharmony_ci   */
21661847f8eSopenharmony_ci  push(item: T): T;
21761847f8eSopenharmony_ci  /**
21861847f8eSopenharmony_ci   * Returns the 1-based position where an object is on this stack
21961847f8eSopenharmony_ci   *
22061847f8eSopenharmony_ci   * @param { T } element - element element Target to be deleted
22161847f8eSopenharmony_ci   * @returns { number } the T type,If there is no such element, return -1
22261847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The locate method cannot be bound.
22361847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
22461847f8eSopenharmony_ci   * @since 8
22561847f8eSopenharmony_ci   */
22661847f8eSopenharmony_ci  /**
22761847f8eSopenharmony_ci   * Returns the 1-based position where an object is on this stack
22861847f8eSopenharmony_ci   *
22961847f8eSopenharmony_ci   * @param { T } element - element element Target to be deleted
23061847f8eSopenharmony_ci   * @returns { number } the T type,If there is no such element, return -1
23161847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The locate method cannot be bound.
23261847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
23361847f8eSopenharmony_ci   * @crossplatform
23461847f8eSopenharmony_ci   * @since 10
23561847f8eSopenharmony_ci   */
23661847f8eSopenharmony_ci  /**
23761847f8eSopenharmony_ci   * Returns the 1-based position where an object is on this stack
23861847f8eSopenharmony_ci   *
23961847f8eSopenharmony_ci   * @param { T } element - element element Target to be deleted
24061847f8eSopenharmony_ci   * @returns { number } the T type,If there is no such element, return -1
24161847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The locate method cannot be bound.
24261847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
24361847f8eSopenharmony_ci   * @crossplatform
24461847f8eSopenharmony_ci   * @atomicservice
24561847f8eSopenharmony_ci   * @since 12
24661847f8eSopenharmony_ci   */
24761847f8eSopenharmony_ci  locate(element: T): number;
24861847f8eSopenharmony_ci  /**
24961847f8eSopenharmony_ci   * Executes a provided function once for each value in the Stack object.
25061847f8eSopenharmony_ci   *
25161847f8eSopenharmony_ci   * @param { function } callbackFn - callbackFn
25261847f8eSopenharmony_ci   * callbackFn (required) A function that accepts up to three arguments.
25361847f8eSopenharmony_ci   * The function to be called for each element.
25461847f8eSopenharmony_ci   * @param { Object } [thisArg] - thisArg
25561847f8eSopenharmony_ci   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
25661847f8eSopenharmony_ci   * If thisArg is omitted, undefined is used as the this value.
25761847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
25861847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
25961847f8eSopenharmony_ci   * 1.Mandatory parameters are left unspecified;
26061847f8eSopenharmony_ci   * 2.Incorrect parameter types.
26161847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
26261847f8eSopenharmony_ci   * @since 8
26361847f8eSopenharmony_ci   */
26461847f8eSopenharmony_ci  /**
26561847f8eSopenharmony_ci   * Executes a provided function once for each value in the Stack object.
26661847f8eSopenharmony_ci   *
26761847f8eSopenharmony_ci   * @param { function } callbackFn - callbackFn
26861847f8eSopenharmony_ci   * callbackFn (required) A function that accepts up to three arguments.
26961847f8eSopenharmony_ci   * The function to be called for each element.
27061847f8eSopenharmony_ci   * @param { Object } [thisArg] - thisArg
27161847f8eSopenharmony_ci   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
27261847f8eSopenharmony_ci   * If thisArg is omitted, undefined is used as the this value.
27361847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
27461847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
27561847f8eSopenharmony_ci   * 1.Mandatory parameters are left unspecified;
27661847f8eSopenharmony_ci   * 2.Incorrect parameter types.
27761847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
27861847f8eSopenharmony_ci   * @crossplatform
27961847f8eSopenharmony_ci   * @since 10
28061847f8eSopenharmony_ci   */
28161847f8eSopenharmony_ci  /**
28261847f8eSopenharmony_ci   * Executes a provided function once for each value in the Stack object.
28361847f8eSopenharmony_ci   *
28461847f8eSopenharmony_ci   * @param { function } callbackFn - callbackFn
28561847f8eSopenharmony_ci   * callbackFn (required) A function that accepts up to three arguments.
28661847f8eSopenharmony_ci   * The function to be called for each element.
28761847f8eSopenharmony_ci   * @param { Object } [thisArg] - thisArg
28861847f8eSopenharmony_ci   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
28961847f8eSopenharmony_ci   * If thisArg is omitted, undefined is used as the this value.
29061847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
29161847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
29261847f8eSopenharmony_ci   * 1.Mandatory parameters are left unspecified;
29361847f8eSopenharmony_ci   * 2.Incorrect parameter types.
29461847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
29561847f8eSopenharmony_ci   * @crossplatform
29661847f8eSopenharmony_ci   * @atomicservice
29761847f8eSopenharmony_ci   * @since 12
29861847f8eSopenharmony_ci   */
29961847f8eSopenharmony_ci  forEach(callbackFn: (value: T, index?: number, stack?: Stack<T>) => void, thisArg?: Object): void;
30061847f8eSopenharmony_ci  /**
30161847f8eSopenharmony_ci   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
30261847f8eSopenharmony_ci   *
30361847f8eSopenharmony_ci   * @returns { IterableIterator<T> }
30461847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
30561847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
30661847f8eSopenharmony_ci   * @since 8
30761847f8eSopenharmony_ci   */
30861847f8eSopenharmony_ci  /**
30961847f8eSopenharmony_ci   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
31061847f8eSopenharmony_ci   *
31161847f8eSopenharmony_ci   * @returns { IterableIterator<T> }
31261847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
31361847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
31461847f8eSopenharmony_ci   * @crossplatform
31561847f8eSopenharmony_ci   * @since 10
31661847f8eSopenharmony_ci   */
31761847f8eSopenharmony_ci  /**
31861847f8eSopenharmony_ci   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
31961847f8eSopenharmony_ci   *
32061847f8eSopenharmony_ci   * @returns { IterableIterator<T> }
32161847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
32261847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
32361847f8eSopenharmony_ci   * @crossplatform
32461847f8eSopenharmony_ci   * @atomicservice
32561847f8eSopenharmony_ci   * @since 12
32661847f8eSopenharmony_ci   */
32761847f8eSopenharmony_ci  [Symbol.iterator](): IterableIterator<T>;
32861847f8eSopenharmony_ci}
32961847f8eSopenharmony_ci
33061847f8eSopenharmony_ciexport default Stack;
331