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