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