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 Stack<T> { 17 /** 18 * A constructor used to create a Stack object. 19 * @throws { BusinessError } 10200012 - The Stack'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 Stack. This is a number one higher than the highest index in the Stack. 26 * @since 8 27 * @syscap SystemCapability.Utils.Lang 28 */ 29 length: number; 30 /** 31 * Tests if this stack is empty 32 * @returns the boolean type 33 * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound. 34 * @since 8 35 * @syscap SystemCapability.Utils.Lang 36 */ 37 isEmpty(): boolean; 38 /** 39 * Looks at the object at the top of this stack without removing it from the stack 40 * Return undefined if this stack is empty 41 * @returns the top value or undefined 42 * @throws { BusinessError } 10200011 - The peek method cannot be bound. 43 * @since 8 44 * @syscap SystemCapability.Utils.Lang 45 */ 46 peek(): T; 47 /** 48 * Removes the object at the top of this stack and returns that object as the value of this function 49 * an exception if the stack is empty 50 * @returns Stack top value or undefined 51 * @throws { BusinessError } 10200011 - The pop method cannot be bound. 52 * @since 8 53 * @syscap SystemCapability.Utils.Lang 54 */ 55 pop(): T; 56 /** 57 * Pushes an item onto the top of this stack 58 * @param item to be appended to this Stack 59 * @returns the T type 60 * @throws { BusinessError } 10200011 - The push method cannot be bound. 61 * @since 8 62 * @syscap SystemCapability.Utils.Lang 63 */ 64 push(item: T): T; 65 /** 66 * Returns the 1-based position where an object is on this stack 67 * @param element Target to be deleted 68 * @returns the T type,If there is no such element, return -1 69 * @throws { BusinessError } 10200011 - The locate method cannot be bound. 70 * @since 8 71 * @syscap SystemCapability.Utils.Lang 72 */ 73 locate(element: T): number; 74 /** 75 * Executes a provided function once for each value in the Stack object. 76 * @param callbackFn (required) A function that accepts up to four arguments.The function 77 * to be called for each element in the Stack 78 * @param Value (required) current element 79 * @param Index (Optional) The index value of the current element. 80 * @param stack (Optional) The Stack object to which the current element belongs. 81 * @param thisArg (Optional) The value passed to the function generally uses the "this" value. 82 * If this parameter is empty, "undefined" will be passed to the "this" value 83 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 84 * @throws { BusinessError } 401 - The type of parameters are invalid. 85 * @since 8 86 * @syscap SystemCapability.Utils.Lang 87 */ 88 forEach(callbackFn: (value: T, index?: number, stack?: Stack<T>) => void, 89 thisArg?: Object): void; 90 /** 91 * returns an ES6 iterator.Each item of the iterator is a Javascript Object 92 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 93 * @since 8 94 * @syscap SystemCapability.Utils.Lang 95 */ 96 [Symbol.iterator](): IterableIterator<T>; 97} 98 99export default Stack; 100