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 * Queue follows the principle of First In First Out (FIFO). 23 * It supports insertion of elements at the end and removal from the front of the queue. 24 * Queue is implemented based on the queue data structure. 25 * 26 * @syscap SystemCapability.Utils.Lang 27 * @since 8 28 */ 29/** 30 * Queue follows the principle of First In First Out (FIFO). 31 * It supports insertion of elements at the end and removal from the front of the queue. 32 * Queue is implemented based on the queue data structure. 33 * 34 * @syscap SystemCapability.Utils.Lang 35 * @crossplatform 36 * @since 10 37 */ 38/** 39 * Queue follows the principle of First In First Out (FIFO). 40 * It supports insertion of elements at the end and removal from the front of the queue. 41 * Queue is implemented based on the queue data structure. 42 * 43 * @syscap SystemCapability.Utils.Lang 44 * @crossplatform 45 * @atomicservice 46 * @since 12 47 */ 48declare class Queue<T> { 49 /** 50 * A constructor used to create a Queue object. 51 * 52 * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked. 53 * @syscap SystemCapability.Utils.Lang 54 * @since 8 55 */ 56 /** 57 * A constructor used to create a Queue object. 58 * 59 * @throws { BusinessError } 10200012 - The Queue'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 Queue object. 66 * 67 * @throws { BusinessError } 10200012 - The Queue'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 Queue.This is a number one higher than the highest index in the queue. 76 * 77 * @syscap SystemCapability.Utils.Lang 78 * @since 8 79 */ 80 /** 81 * Gets the element number of the Queue.This is a number one higher than the highest index in the queue. 82 * 83 * @syscap SystemCapability.Utils.Lang 84 * @crossplatform 85 * @since 10 86 */ 87 /** 88 * Gets the element number of the Queue.This is a number one higher than the highest index in the queue. 89 * 90 * @syscap SystemCapability.Utils.Lang 91 * @crossplatform 92 * @atomicservice 93 * @since 12 94 */ 95 length: number; 96 /** 97 * Inserting specified element at the end of a queue if it is possible to do 98 * so immediately without violating capacity restrictions. 99 * 100 * @param { T } element - element element to be appended to this queue 101 * @returns { boolean } the boolean type 102 * @throws { BusinessError } 10200011 - The add method cannot be bound. 103 * @syscap SystemCapability.Utils.Lang 104 * @since 8 105 */ 106 /** 107 * Inserting specified element at the end of a queue if it is possible to do 108 * so immediately without violating capacity restrictions. 109 * 110 * @param { T } element - element element to be appended to this queue 111 * @returns { boolean } the boolean type 112 * @throws { BusinessError } 10200011 - The add method cannot be bound. 113 * @syscap SystemCapability.Utils.Lang 114 * @crossplatform 115 * @since 10 116 */ 117 /** 118 * Inserting specified element at the end of a queue if it is possible to do 119 * so immediately without violating capacity restrictions. 120 * 121 * @param { T } element - element element to be appended to this queue 122 * @returns { boolean } the boolean type 123 * @throws { BusinessError } 10200011 - The add method cannot be bound. 124 * @syscap SystemCapability.Utils.Lang 125 * @crossplatform 126 * @atomicservice 127 * @since 12 128 */ 129 add(element: T): boolean; 130 /** 131 * Obtains the header element of a queue. 132 * 133 * @returns { T } the T type 134 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 135 * @syscap SystemCapability.Utils.Lang 136 * @since 8 137 */ 138 /** 139 * Obtains the header element of a queue. 140 * 141 * @returns { T } the T type 142 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 143 * @syscap SystemCapability.Utils.Lang 144 * @crossplatform 145 * @since 10 146 */ 147 /** 148 * Obtains the header element of a queue. 149 * 150 * @returns { T } the T type 151 * @throws { BusinessError } 10200011 - The getFirst method cannot be bound. 152 * @syscap SystemCapability.Utils.Lang 153 * @crossplatform 154 * @atomicservice 155 * @since 12 156 */ 157 getFirst(): T; 158 /** 159 * Retrieves and removes the head of this queue 160 * 161 * @returns { T } the T type 162 * @throws { BusinessError } 10200011 - The pop method cannot be bound. 163 * @syscap SystemCapability.Utils.Lang 164 * @since 8 165 */ 166 /** 167 * Retrieves and removes the head of this queue 168 * 169 * @returns { T } the T type 170 * @throws { BusinessError } 10200011 - The pop method cannot be bound. 171 * @syscap SystemCapability.Utils.Lang 172 * @crossplatform 173 * @since 10 174 */ 175 /** 176 * Retrieves and removes the head of this queue 177 * 178 * @returns { T } the T type 179 * @throws { BusinessError } 10200011 - The pop method cannot be bound. 180 * @syscap SystemCapability.Utils.Lang 181 * @crossplatform 182 * @atomicservice 183 * @since 12 184 */ 185 pop(): T; 186 /** 187 * Executes a provided function once for each value in the queue object. 188 * 189 * @param { function } callbackFn - callbackFn 190 * callbackFn (required) A function that accepts up to three arguments. 191 * The function to be called for each element. 192 * @param { Object } [thisArg] - thisArg 193 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 194 * If thisArg is omitted, undefined is used as the this value. 195 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 196 * @throws { BusinessError } 401 - Parameter error. Possible causes: 197 * 1.Mandatory parameters are left unspecified; 198 * 2.Incorrect parameter types. 199 * @syscap SystemCapability.Utils.Lang 200 * @since 8 201 */ 202 /** 203 * Executes a provided function once for each value in the queue object. 204 * 205 * @param { function } callbackFn - callbackFn 206 * callbackFn (required) A function that accepts up to three arguments. 207 * The function to be called for each element. 208 * @param { Object } [thisArg] - thisArg 209 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 210 * If thisArg is omitted, undefined is used as the this value. 211 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 212 * @throws { BusinessError } 401 - Parameter error. Possible causes: 213 * 1.Mandatory parameters are left unspecified; 214 * 2.Incorrect parameter types. 215 * @syscap SystemCapability.Utils.Lang 216 * @crossplatform 217 * @since 10 218 */ 219 /** 220 * Executes a provided function once for each value in the queue object. 221 * 222 * @param { function } callbackFn - callbackFn 223 * callbackFn (required) A function that accepts up to three arguments. 224 * The function to be called for each element. 225 * @param { Object } [thisArg] - thisArg 226 * thisArg (Optional) The value to be used as this value for when callbackFn is called. 227 * If thisArg is omitted, undefined is used as the this value. 228 * @throws { BusinessError } 10200011 - The forEach method cannot be bound. 229 * @throws { BusinessError } 401 - Parameter error. Possible causes: 230 * 1.Mandatory parameters are left unspecified; 231 * 2.Incorrect parameter types. 232 * @syscap SystemCapability.Utils.Lang 233 * @crossplatform 234 * @atomicservice 235 * @since 12 236 */ 237 forEach(callbackFn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void; 238 /** 239 * returns an iterator.Each item of the iterator is a Javascript Object 240 * 241 * @returns { IterableIterator<T> } 242 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 243 * @syscap SystemCapability.Utils.Lang 244 * @since 8 245 */ 246 /** 247 * returns an iterator.Each item of the iterator is a Javascript Object 248 * 249 * @returns { IterableIterator<T> } 250 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 251 * @syscap SystemCapability.Utils.Lang 252 * @crossplatform 253 * @since 10 254 */ 255 /** 256 * returns an iterator.Each item of the iterator is a Javascript Object 257 * 258 * @returns { IterableIterator<T> } 259 * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound. 260 * @syscap SystemCapability.Utils.Lang 261 * @crossplatform 262 * @atomicservice 263 * @since 12 264 */ 265 [Symbol.iterator](): IterableIterator<T>; 266} 267 268export default Queue; 269