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 * Double-ended queue (deque) is a sequence container implemented based on the queue data structure that 23 * follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). 24 * It allows insertion and removal of elements at both the ends. 25 * 26 * @syscap SystemCapability.Utils.Lang 27 * @since 8 28 */ 29/** 30 * Double-ended queue (deque) is a sequence container implemented based on the queue data structure that 31 * follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). 32 * It allows insertion and removal of elements at both the ends. 33 * 34 * @syscap SystemCapability.Utils.Lang 35 * @crossplatform 36 * @since 10 37 */ 38/** 39 * Double-ended queue (deque) is a sequence container implemented based on the queue data structure that 40 * follows the principles of First In First Out (FIFO) and Last In First Out (LIFO). 41 * It allows insertion and removal of elements at both the ends. 42 * 43 * @syscap SystemCapability.Utils.Lang 44 * @crossplatform 45 * @atomicservice 46 * @since 12 47 */ 48declare class Deque<T> { 49 /** 50 * A constructor used to create a Deque object. 51 * 52 * @throws { BusinessError } 10200012 - The Deque's constructor cannot be directly invoked. 53 * @syscap SystemCapability.Utils.Lang 54 * @since 8 55 */ 56 /** 57 * A constructor used to create a Deque object. 58 * 59 * @throws { BusinessError } 10200012 - The Deque's constructor cannot be directly invoked. 60 * @syscap SystemCapability.Utils.Lang 61 * @crossplatform 62 * @since 10 63 */ 64 /** 65 * A constructor used to create a Deque object. 66 * 67 * @throws { BusinessError } 10200012 - The Deque's constructor cannot be directly invoked. 68 * @syscap SystemCapability.Utils.Lang 69 * @crossplatform 70 * @atomicservice 71 * @since 12 72 */ 73 constructor(); 74 /** 75 * Gets the element number of the Deque.This is a number one higher than the highest index in the deque. 76 * 77 * @syscap SystemCapability.Utils.Lang 78 * @since 8 79 */ 80 /** 81 * Gets the element number of the Deque.This is a number one higher than the highest index in the deque. 82 * 83 * @syscap SystemCapability.Utils.Lang 84 * @crossplatform 85 * @since 10 86 */ 87 /** 88 * Gets the element number of the Deque.This is a number one higher than the highest index in the deque. 89 * 90 * @syscap SystemCapability.Utils.Lang 91 * @crossplatform 92 * @atomicservice 93 * @since 12 94 */ 95 length: number; 96 /** 97 * Inserts an element into the deque header. 98 * 99 * @param { T } element - element element to be appended to this deque 100 * @throws { BusinessError } 10200011 - The insertFront method cannot be bound. 101 * @syscap SystemCapability.Utils.Lang 102 * @since 8 103 */ 104 /** 105 * Inserts an element into the deque header. 106 * 107 * @param { T } element - element element to be appended to this deque 108 * @throws { BusinessError } 10200011 - The insertFront method cannot be bound. 109 * @syscap SystemCapability.Utils.Lang 110 * @crossplatform 111 * @since 10 112 */ 113 /** 114 * Inserts an element into the deque header. 115 * 116 * @param { T } element - element element to be appended to this deque 117 * @throws { BusinessError } 10200011 - The insertFront method cannot be bound. 118 * @syscap SystemCapability.Utils.Lang 119 * @crossplatform 120 * @atomicservice 121 * @since 12 122 */ 123 insertFront(element: T): void; 124 /** 125 * Inserting an element at the end of a deque 126 * 127 * @param { T } element - element element to be appended to this deque 128 * @throws { BusinessError } 10200011 - The insertEnd method cannot be bound. 129 * @syscap SystemCapability.Utils.Lang 130 * @since 8 131 */ 132 /** 133 * Inserting an element at the end of a deque 134 * 135 * @param { T } element - element element to be appended to this deque 136 * @throws { BusinessError } 10200011 - The insertEnd method cannot be bound. 137 * @syscap SystemCapability.Utils.Lang 138 * @crossplatform 139 * @since 10 140 */ 141 /** 142 * Inserting an element at the end of a deque 143 * 144 * @param { T } element - element element to be appended to this deque 145 * @throws { BusinessError } 10200011 - The insertEnd method cannot be bound. 146 * @syscap SystemCapability.Utils.Lang 147 * @crossplatform 148 * @atomicservice 149 * @since 12 150 */ 151 insertEnd(element: T): void; 152 /** 153 * Check if deque contains the specified element 154 * 155 * @param { T } element - element element to be contained 156 * @returns { boolean } the boolean type,if deque contains the specified element,return true,else return false 157 * @throws { BusinessError } 10200011 - The has method cannot be bound. 158 * @syscap SystemCapability.Utils.Lang 159 * @since 8 160 */ 161 /** 162 * Check if deque contains the specified element 163 * 164 * @param { T } element - element element to be contained 165 * @returns { boolean } the boolean type,if deque contains the specified element,return true,else return false 166 * @throws { BusinessError } 10200011 - The has method cannot be bound. 167 * @syscap SystemCapability.Utils.Lang 168 * @crossplatform 169 * @since 10 170 */ 171 /** 172 * Check if deque contains the specified element 173 * 174 * @param { T } element - element element to be contained 175 * @returns { boolean } the boolean type,if deque contains the specified element,return true,else return false 176 * @throws { BusinessError } 10200011 - The has method cannot be bound. 177 * @syscap SystemCapability.Utils.Lang 178 * @crossplatform 179 * @atomicservice 180 * @since 12 181 */ 182 has(element: T): boolean; 183 /** 184 * Obtains the header element of a deque. 185 * 186 * @returns { T } the T type 187 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 188 * @syscap SystemCapability.Utils.Lang 189 * @since 8 190 */ 191 /** 192 * Obtains the header element of a deque. 193 * 194 * @returns { T } the T type 195 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 196 * @syscap SystemCapability.Utils.Lang 197 * @crossplatform 198 * @since 10 199 */ 200 /** 201 * Obtains the header element of a deque. 202 * 203 * @returns { T } the T type 204 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 205 * @syscap SystemCapability.Utils.Lang 206 * @crossplatform 207 * @atomicservice 208 * @since 12 209 */ 210 getFirst(): T; 211 /** 212 * Obtains the end element of a deque. 213 * 214 * @returns { T } the T type 215 * @throws { BusinessError } 10200011 - The getLast method cannot be bound. 216 * @syscap SystemCapability.Utils.Lang 217 * @since 8 218 */ 219 /** 220 * Obtains the end element of a deque. 221 * 222 * @returns { T } the T type 223 * @throws { BusinessError } 10200011 - The getLast method cannot be bound. 224 * @syscap SystemCapability.Utils.Lang 225 * @crossplatform 226 * @since 10 227 */ 228 /** 229 * Obtains the end element of a deque. 230 * 231 * @returns { T } the T type 232 * @throws { BusinessError } 10200011 - The getLast method cannot be bound. 233 * @syscap SystemCapability.Utils.Lang 234 * @crossplatform 235 * @atomicservice 236 * @since 12 237 */ 238 getLast(): T; 239 /** 240 * Obtains the header element of a deque and delete the element. 241 * 242 * @returns { T } the T type 243 * @throws { BusinessError } 10200011 - The popFirst method cannot be bound. 244 * @syscap SystemCapability.Utils.Lang 245 * @since 8 246 */ 247 /** 248 * Obtains the header element of a deque and delete the element. 249 * 250 * @returns { T } the T type 251 * @throws { BusinessError } 10200011 - The popFirst method cannot be bound. 252 * @syscap SystemCapability.Utils.Lang 253 * @crossplatform 254 * @since 10 255 */ 256 /** 257 * Obtains the header element of a deque and delete the element. 258 * 259 * @returns { T } the T type 260 * @throws { BusinessError } 10200011 - The popFirst method cannot be bound. 261 * @syscap SystemCapability.Utils.Lang 262 * @crossplatform 263 * @atomicservice 264 * @since 12 265 */ 266 popFirst(): T; 267 /** 268 * Obtains the end element of a deque and delete the element. 269 * 270 * @returns { T } the T type 271 * @throws { BusinessError } 10200011 - The popLast method cannot be bound. 272 * @syscap SystemCapability.Utils.Lang 273 * @since 8 274 */ 275 /** 276 * Obtains the end element of a deque and delete the element. 277 * 278 * @returns { T } the T type 279 * @throws { BusinessError } 10200011 - The popLast method cannot be bound. 280 * @syscap SystemCapability.Utils.Lang 281 * @crossplatform 282 * @since 10 283 */ 284 /** 285 * Obtains the end element of a deque and delete the element. 286 * 287 * @returns { T } the T type 288 * @throws { BusinessError } 10200011 - The popLast method cannot be bound. 289 * @syscap SystemCapability.Utils.Lang 290 * @crossplatform 291 * @atomicservice 292 * @since 12 293 */ 294 popLast(): T; 295 /** 296 * Executes a provided function once for each value in the deque object. 297 * 298 * @param { function } callbackFn - callbackFn 299 * callbackFn (required) A function that accepts up to three arguments. 300 * The function to be called for each element. 301 * @param { Object } [thisArg] - thisArg 302 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 303 * If thisArg is omitted, undefined is used as the this value. 304 * @throws { BusinessError } 401 - Parameter error. Possible causes: 305 * 1.Mandatory parameters are left unspecified; 306 * 2.Incorrect parameter types. 307 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 308 * @syscap SystemCapability.Utils.Lang 309 * @since 8 310 */ 311 /** 312 * Executes a provided function once for each value in the deque object. 313 * 314 * @param { function } callbackFn - callbackFn 315 * callbackFn (required) A function that accepts up to three arguments. 316 * The function to be called for each element. 317 * @param { Object } [thisArg] - thisArg 318 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 319 * If thisArg is omitted, undefined is used as the this value. 320 * @throws { BusinessError } 401 - Parameter error. Possible causes: 321 * 1.Mandatory parameters are left unspecified; 322 * 2.Incorrect parameter types. 323 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 324 * @syscap SystemCapability.Utils.Lang 325 * @crossplatform 326 * @since 10 327 */ 328 /** 329 * Executes a provided function once for each value in the deque object. 330 * 331 * @param { function } callbackFn - callbackFn 332 * callbackFn (required) A function that accepts up to three arguments. 333 * The function to be called for each element. 334 * @param { Object } [thisArg] - thisArg 335 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 336 * If thisArg is omitted, undefined is used as the this value. 337 * @throws { BusinessError } 401 - Parameter error. Possible causes: 338 * 1.Mandatory parameters are left unspecified; 339 * 2.Incorrect parameter types. 340 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 341 * @syscap SystemCapability.Utils.Lang 342 * @crossplatform 343 * @atomicservice 344 * @since 12 345 */ 346 forEach(callbackFn: (value: T, index?: number, deque?: Deque<T>) => void, thisArg?: Object): void; 347 /** 348 * returns an iterator.Each item of the iterator is a Javascript Object 349 * 350 * @returns { IterableIterator<T> } 351 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 352 * @syscap SystemCapability.Utils.Lang 353 * @since 8 354 */ 355 /** 356 * returns an iterator.Each item of the iterator is a Javascript Object 357 * 358 * @returns { IterableIterator<T> } 359 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 360 * @syscap SystemCapability.Utils.Lang 361 * @crossplatform 362 * @since 10 363 */ 364 /** 365 * returns an iterator.Each item of the iterator is a Javascript Object 366 * 367 * @returns { IterableIterator<T> } 368 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 369 * @syscap SystemCapability.Utils.Lang 370 * @crossplatform 371 * @atomicservice 372 * @since 12 373 */ 374 [Symbol.iterator](): IterableIterator<T>; 375} 376 377export default Deque; 378