• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * Queue follows the principle of First In First Out (FIFO).
18 * It supports insertion of elements at the end and removal from the front of the queue.
19 * Queue is implemented based on the queue data structure.
20 *
21 * @namespace Queue
22 * @syscap SystemCapability.Utils.Lang
23 * @since 8
24 */
25/**
26 * Queue follows the principle of First In First Out (FIFO).
27 * It supports insertion of elements at the end and removal from the front of the queue.
28 * Queue is implemented based on the queue data structure.
29 *
30 * @namespace Queue
31 * @syscap SystemCapability.Utils.Lang
32 * @crossplatform
33 * @since 10
34 */
35declare class Queue<T> {
36  /**
37   * A constructor used to create a Queue object.
38   *
39   * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked.
40   * @syscap SystemCapability.Utils.Lang
41   * @since 8
42   */
43  /**
44   * A constructor used to create a Queue object.
45   *
46   * @throws { BusinessError } 10200012 - The Queue's constructor cannot be directly invoked.
47   * @syscap SystemCapability.Utils.Lang
48   * @crossplatform
49   * @since 10
50   */
51  constructor();
52  /**
53   * Gets the element number of the Queue.This is a number one higher than the highest index in the queue.
54   *
55   * @syscap SystemCapability.Utils.Lang
56   * @since 8
57   */
58  /**
59   * Gets the element number of the Queue.This is a number one higher than the highest index in the queue.
60   *
61   * @syscap SystemCapability.Utils.Lang
62   * @crossplatform
63   * @since 10
64   */
65  length: number;
66  /**
67   * Inserting specified element at the end of a queue if it is possible to do
68   * so immediately without violating capacity restrictions.
69   *
70   * @param { T } element - element element to be appended to this queue
71   * @returns { boolean } the boolean type
72   * @throws { BusinessError } 10200011 - The add method cannot be bound.
73   * @syscap SystemCapability.Utils.Lang
74   * @since 8
75   */
76  /**
77   * Inserting specified element at the end of a queue if it is possible to do
78   * so immediately without violating capacity restrictions.
79   *
80   * @param { T } element - element element to be appended to this queue
81   * @returns { boolean } the boolean type
82   * @throws { BusinessError } 10200011 - The add method cannot be bound.
83   * @syscap SystemCapability.Utils.Lang
84   * @crossplatform
85   * @since 10
86   */
87  add(element: T): boolean;
88  /**
89   * Obtains the header element of a queue.
90   *
91   * @returns { T } the T type
92   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
93   * @syscap SystemCapability.Utils.Lang
94   * @since 8
95   */
96  /**
97   * Obtains the header element of a queue.
98   *
99   * @returns { T } the T type
100   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
101   * @syscap SystemCapability.Utils.Lang
102   * @crossplatform
103   * @since 10
104   */
105  getFirst(): T;
106  /**
107   * Retrieves and removes the head of this queue
108   *
109   * @returns { T } the T type
110   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
111   * @syscap SystemCapability.Utils.Lang
112   * @since 8
113   */
114  /**
115   * Retrieves and removes the head of this queue
116   *
117   * @returns { T } the T type
118   * @throws { BusinessError } 10200011 - The pop method cannot be bound.
119   * @syscap SystemCapability.Utils.Lang
120   * @crossplatform
121   * @since 10
122   */
123  pop(): T;
124  /**
125   * Executes a provided function once for each value in the queue object.
126   *
127   * @param { (value: T, index?: number, Queue?: Queue<T>) => void } callbackFn - callbackFn
128   * callbackFn (required) A function that accepts up to four arguments.The function to
129   * be called for each element in the queue
130   * @param { Object } thisArg - thisArg thisArg (Optional) The value passed to the function generally uses the "this" value.
131   * If this parameter is empty, "undefined" will be passed to the "this" value
132   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
133   * @throws { BusinessError } 401 - The type of parameters are invalid.
134   * @syscap SystemCapability.Utils.Lang
135   * @since 8
136   */
137  /**
138   * Executes a provided function once for each value in the queue object.
139   *
140   * @param { (value: T, index?: number, Queue?: Queue<T>) => void } callbackFn - callbackFn
141   * callbackFn (required) A function that accepts up to four arguments.The function to
142   * be called for each element in the queue
143   * @param { Object } thisArg - thisArg thisArg (Optional) The value passed to the function generally uses the "this" value.
144   * If this parameter is empty, "undefined" will be passed to the "this" value
145   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
146   * @throws { BusinessError } 401 - The type of parameters are invalid.
147   * @syscap SystemCapability.Utils.Lang
148   * @crossplatform
149   * @since 10
150   */
151  forEach(callbackFn: (value: T, index?: number, Queue?: Queue<T>) => void, thisArg?: Object): void;
152  /**
153   * returns an iterator.Each item of the iterator is a Javascript Object
154   *
155   * @returns { IterableIterator<T> }
156   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
157   * @syscap SystemCapability.Utils.Lang
158   * @since 8
159   */
160  /**
161   * returns an iterator.Each item of the iterator is a Javascript Object
162   *
163   * @returns { IterableIterator<T> }
164   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
165   * @syscap SystemCapability.Utils.Lang
166   * @crossplatform
167   * @since 10
168   */
169  [Symbol.iterator](): IterableIterator<T>;
170}
171
172export default Queue;
173