161847f8eSopenharmony_ci/*
261847f8eSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
361847f8eSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
461847f8eSopenharmony_ci * you may not use this file except in compliance with the License.
561847f8eSopenharmony_ci * You may obtain a copy of the License at
661847f8eSopenharmony_ci *
761847f8eSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
861847f8eSopenharmony_ci *
961847f8eSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1061847f8eSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1161847f8eSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1261847f8eSopenharmony_ci * See the License for the specific language governing permissions and
1361847f8eSopenharmony_ci * limitations under the License.
1461847f8eSopenharmony_ci */
1561847f8eSopenharmony_ci
1661847f8eSopenharmony_ci/**
1761847f8eSopenharmony_ci * @file
1861847f8eSopenharmony_ci * @kit ArkTS
1961847f8eSopenharmony_ci */
2061847f8eSopenharmony_ci
2161847f8eSopenharmony_ci/**
2261847f8eSopenharmony_ci * Queue follows the principle of First In First Out (FIFO). 
2361847f8eSopenharmony_ci * It supports insertion of elements at the end and removal from the front of the queue. 
2461847f8eSopenharmony_ci * Queue is implemented based on the queue data structure. 
2561847f8eSopenharmony_ci *
2661847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang
2761847f8eSopenharmony_ci * @since 8
2861847f8eSopenharmony_ci */
2961847f8eSopenharmony_ci/**
3061847f8eSopenharmony_ci * Queue follows the principle of First In First Out (FIFO). 
3161847f8eSopenharmony_ci * It supports insertion of elements at the end and removal from the front of the queue. 
3261847f8eSopenharmony_ci * Queue is implemented based on the queue data structure. 
3361847f8eSopenharmony_ci *
3461847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang
3561847f8eSopenharmony_ci * @crossplatform
3661847f8eSopenharmony_ci * @since 10
3761847f8eSopenharmony_ci */
3861847f8eSopenharmony_ci/**
3961847f8eSopenharmony_ci * Queue follows the principle of First In First Out (FIFO). 
4061847f8eSopenharmony_ci * It supports insertion of elements at the end and removal from the front of the queue. 
4161847f8eSopenharmony_ci * Queue is implemented based on the queue data structure. 
4261847f8eSopenharmony_ci *
4361847f8eSopenharmony_ci * @syscap SystemCapability.Utils.Lang
4461847f8eSopenharmony_ci * @crossplatform
4561847f8eSopenharmony_ci * @atomicservice
4661847f8eSopenharmony_ci * @since 12
4761847f8eSopenharmony_ci */
4861847f8eSopenharmony_cideclare class Queue<T> {
4961847f8eSopenharmony_ci  /**
5061847f8eSopenharmony_ci   * A constructor used to create a Queue object.
5161847f8eSopenharmony_ci   *
5261847f8eSopenharmony_ci   * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked.
5361847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
5461847f8eSopenharmony_ci   * @since 8
5561847f8eSopenharmony_ci   */
5661847f8eSopenharmony_ci  /**
5761847f8eSopenharmony_ci   * A constructor used to create a Queue object.
5861847f8eSopenharmony_ci   *
5961847f8eSopenharmony_ci   * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked.
6061847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
6161847f8eSopenharmony_ci   * @crossplatform
6261847f8eSopenharmony_ci   * @since 10
6361847f8eSopenharmony_ci   */
6461847f8eSopenharmony_ci  /**
6561847f8eSopenharmony_ci   * A constructor used to create a Queue object.
6661847f8eSopenharmony_ci   *
6761847f8eSopenharmony_ci   * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked.
6861847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
6961847f8eSopenharmony_ci   * @crossplatform
7061847f8eSopenharmony_ci   * @atomicservice
7161847f8eSopenharmony_ci   * @since 12
7261847f8eSopenharmony_ci   */
7361847f8eSopenharmony_ci  constructor();
7461847f8eSopenharmony_ci  /**
7561847f8eSopenharmony_ci   * Gets the element number of the Queue.This is a number one higher than the highest index in the queue.
7661847f8eSopenharmony_ci   *
7761847f8eSopenharmony_ci   * @type { number }
7861847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
7961847f8eSopenharmony_ci   * @since 8
8061847f8eSopenharmony_ci   */
8161847f8eSopenharmony_ci  /**
8261847f8eSopenharmony_ci   * Gets the element number of the Queue.This is a number one higher than the highest index in the queue.
8361847f8eSopenharmony_ci   *
8461847f8eSopenharmony_ci   * @type { number }
8561847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
8661847f8eSopenharmony_ci   * @crossplatform
8761847f8eSopenharmony_ci   * @since 10
8861847f8eSopenharmony_ci   */
8961847f8eSopenharmony_ci  /**
9061847f8eSopenharmony_ci   * Gets the element number of the Queue.This is a number one higher than the highest index in the queue.
9161847f8eSopenharmony_ci   *
9261847f8eSopenharmony_ci   * @type { number }
9361847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
9461847f8eSopenharmony_ci   * @crossplatform
9561847f8eSopenharmony_ci   * @atomicservice
9661847f8eSopenharmony_ci   * @since 12
9761847f8eSopenharmony_ci   */
9861847f8eSopenharmony_ci  length: number;
9961847f8eSopenharmony_ci  /**
10061847f8eSopenharmony_ci   * Inserting specified element at the end of a queue if it is possible to do
10161847f8eSopenharmony_ci   * so immediately without violating capacity restrictions.
10261847f8eSopenharmony_ci   *
10361847f8eSopenharmony_ci   * @param { T } element - element element to be appended to this queue
10461847f8eSopenharmony_ci   * @returns { boolean } the boolean type
10561847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The add method cannot be bound.
10661847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
10761847f8eSopenharmony_ci   * @since 8
10861847f8eSopenharmony_ci   */
10961847f8eSopenharmony_ci  /**
11061847f8eSopenharmony_ci   * Inserting specified element at the end of a queue if it is possible to do
11161847f8eSopenharmony_ci   * so immediately without violating capacity restrictions.
11261847f8eSopenharmony_ci   *
11361847f8eSopenharmony_ci   * @param { T } element - element element to be appended to this queue
11461847f8eSopenharmony_ci   * @returns { boolean } the boolean type
11561847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The add method cannot be bound.
11661847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
11761847f8eSopenharmony_ci   * @crossplatform
11861847f8eSopenharmony_ci   * @since 10
11961847f8eSopenharmony_ci   */
12061847f8eSopenharmony_ci  /**
12161847f8eSopenharmony_ci   * Inserting specified element at the end of a queue if it is possible to do
12261847f8eSopenharmony_ci   * so immediately without violating capacity restrictions.
12361847f8eSopenharmony_ci   *
12461847f8eSopenharmony_ci   * @param { T } element - element element to be appended to this queue
12561847f8eSopenharmony_ci   * @returns { boolean } the boolean type
12661847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The add method cannot be bound.
12761847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
12861847f8eSopenharmony_ci   * @crossplatform
12961847f8eSopenharmony_ci   * @atomicservice
13061847f8eSopenharmony_ci   * @since 12
13161847f8eSopenharmony_ci   */
13261847f8eSopenharmony_ci  add(element: T): boolean;
13361847f8eSopenharmony_ci  /**
13461847f8eSopenharmony_ci   * Obtains the header element of a queue.
13561847f8eSopenharmony_ci   *
13661847f8eSopenharmony_ci   * @returns { T } the T type
13761847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
13861847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
13961847f8eSopenharmony_ci   * @since 8
14061847f8eSopenharmony_ci   */
14161847f8eSopenharmony_ci  /**
14261847f8eSopenharmony_ci   * Obtains the header element of a queue.
14361847f8eSopenharmony_ci   *
14461847f8eSopenharmony_ci   * @returns { T } the T type
14561847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
14661847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
14761847f8eSopenharmony_ci   * @crossplatform
14861847f8eSopenharmony_ci   * @since 10
14961847f8eSopenharmony_ci   */
15061847f8eSopenharmony_ci  /**
15161847f8eSopenharmony_ci   * Obtains the header element of a queue.
15261847f8eSopenharmony_ci   *
15361847f8eSopenharmony_ci   * @returns { T } the T type
15461847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
15561847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
15661847f8eSopenharmony_ci   * @crossplatform
15761847f8eSopenharmony_ci   * @atomicservice
15861847f8eSopenharmony_ci   * @since 12
15961847f8eSopenharmony_ci   */
16061847f8eSopenharmony_ci  getFirst(): T;
16161847f8eSopenharmony_ci  /**
16261847f8eSopenharmony_ci   * Retrieves and removes the head of this queue
16361847f8eSopenharmony_ci   *
16461847f8eSopenharmony_ci   * @returns { T } the T type
16561847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
16661847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
16761847f8eSopenharmony_ci   * @since 8
16861847f8eSopenharmony_ci   */
16961847f8eSopenharmony_ci  /**
17061847f8eSopenharmony_ci   * Retrieves and removes the head of this queue
17161847f8eSopenharmony_ci   *
17261847f8eSopenharmony_ci   * @returns { T } the T type
17361847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
17461847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
17561847f8eSopenharmony_ci   * @crossplatform
17661847f8eSopenharmony_ci   * @since 10
17761847f8eSopenharmony_ci   */
17861847f8eSopenharmony_ci  /**
17961847f8eSopenharmony_ci   * Retrieves and removes the head of this queue
18061847f8eSopenharmony_ci   *
18161847f8eSopenharmony_ci   * @returns { T } the T type
18261847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
18361847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
18461847f8eSopenharmony_ci   * @crossplatform
18561847f8eSopenharmony_ci   * @atomicservice
18661847f8eSopenharmony_ci   * @since 12
18761847f8eSopenharmony_ci   */
18861847f8eSopenharmony_ci  pop(): T;
18961847f8eSopenharmony_ci  /**
19061847f8eSopenharmony_ci   * Executes a provided function once for each value in the queue object.
19161847f8eSopenharmony_ci   *
19261847f8eSopenharmony_ci   * @param { function } callbackFn - callbackFn
19361847f8eSopenharmony_ci   * callbackFn (required) A function that accepts up to three arguments.
19461847f8eSopenharmony_ci   * The function to be called for each element.
19561847f8eSopenharmony_ci   * @param { Object } [thisArg] - thisArg
19661847f8eSopenharmony_ci   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
19761847f8eSopenharmony_ci   * If thisArg is omitted, undefined is used as the this value.
19861847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
19961847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
20061847f8eSopenharmony_ci   * 1.Mandatory parameters are left unspecified;
20161847f8eSopenharmony_ci   * 2.Incorrect parameter types.
20261847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
20361847f8eSopenharmony_ci   * @since 8
20461847f8eSopenharmony_ci   */
20561847f8eSopenharmony_ci  /**
20661847f8eSopenharmony_ci   * Executes a provided function once for each value in the queue object.
20761847f8eSopenharmony_ci   *
20861847f8eSopenharmony_ci   * @param { function } callbackFn - callbackFn
20961847f8eSopenharmony_ci   * callbackFn (required) A function that accepts up to three arguments.
21061847f8eSopenharmony_ci   * The function to be called for each element.
21161847f8eSopenharmony_ci   * @param { Object } [thisArg] - thisArg
21261847f8eSopenharmony_ci   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
21361847f8eSopenharmony_ci   * If thisArg is omitted, undefined is used as the this value.
21461847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
21561847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
21661847f8eSopenharmony_ci   * 1.Mandatory parameters are left unspecified;
21761847f8eSopenharmony_ci   * 2.Incorrect parameter types.
21861847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
21961847f8eSopenharmony_ci   * @crossplatform
22061847f8eSopenharmony_ci   * @since 10
22161847f8eSopenharmony_ci   */
22261847f8eSopenharmony_ci  /**
22361847f8eSopenharmony_ci   * Executes a provided function once for each value in the queue object.
22461847f8eSopenharmony_ci   *
22561847f8eSopenharmony_ci   * @param { function } callbackFn - callbackFn
22661847f8eSopenharmony_ci   * callbackFn (required) A function that accepts up to three arguments.
22761847f8eSopenharmony_ci   * The function to be called for each element.
22861847f8eSopenharmony_ci   * @param { Object } [thisArg] - thisArg
22961847f8eSopenharmony_ci   * thisArg (Optional) The value to be used as this value for when callbackFn is called.
23061847f8eSopenharmony_ci   * If thisArg is omitted, undefined is used as the this value.
23161847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
23261847f8eSopenharmony_ci   * @throws { BusinessError } 401 - Parameter error. Possible causes:
23361847f8eSopenharmony_ci   * 1.Mandatory parameters are left unspecified;
23461847f8eSopenharmony_ci   * 2.Incorrect parameter types.
23561847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
23661847f8eSopenharmony_ci   * @crossplatform
23761847f8eSopenharmony_ci   * @atomicservice
23861847f8eSopenharmony_ci   * @since 12
23961847f8eSopenharmony_ci   */
24061847f8eSopenharmony_ci  forEach(callbackFn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void;
24161847f8eSopenharmony_ci  /**
24261847f8eSopenharmony_ci   * returns an iterator.Each item of the iterator is a Javascript Object
24361847f8eSopenharmony_ci   *
24461847f8eSopenharmony_ci   * @returns { IterableIterator<T> }
24561847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
24661847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
24761847f8eSopenharmony_ci   * @since 8
24861847f8eSopenharmony_ci   */
24961847f8eSopenharmony_ci  /**
25061847f8eSopenharmony_ci   * returns an iterator.Each item of the iterator is a Javascript Object
25161847f8eSopenharmony_ci   *
25261847f8eSopenharmony_ci   * @returns { IterableIterator<T> }
25361847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
25461847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
25561847f8eSopenharmony_ci   * @crossplatform
25661847f8eSopenharmony_ci   * @since 10
25761847f8eSopenharmony_ci   */
25861847f8eSopenharmony_ci  /**
25961847f8eSopenharmony_ci   * returns an iterator.Each item of the iterator is a Javascript Object
26061847f8eSopenharmony_ci   *
26161847f8eSopenharmony_ci   * @returns { IterableIterator<T> }
26261847f8eSopenharmony_ci   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
26361847f8eSopenharmony_ci   * @syscap SystemCapability.Utils.Lang
26461847f8eSopenharmony_ci   * @crossplatform
26561847f8eSopenharmony_ci   * @atomicservice
26661847f8eSopenharmony_ci   * @since 12
26761847f8eSopenharmony_ci   */
26861847f8eSopenharmony_ci  [Symbol.iterator](): IterableIterator<T>;
26961847f8eSopenharmony_ci}
27061847f8eSopenharmony_ci
27161847f8eSopenharmony_ciexport default Queue;
272