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