• 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 * Double-ended queue (deque) is a sequence container implemented based on the queue data structure that
18 * follows the principles of First In First Out (FIFO) and Last In First Out (LIFO).
19 * It allows insertion and removal of elements at both the ends.
20 *
21 * @namespace Deque
22 * @syscap SystemCapability.Utils.Lang
23 * @since 8
24 */
25/**
26 * Double-ended queue (deque) is a sequence container implemented based on the queue data structure that
27 * follows the principles of First In First Out (FIFO) and Last In First Out (LIFO).
28 * It allows insertion and removal of elements at both the ends.
29 *
30 * @namespace Deque
31 * @syscap SystemCapability.Utils.Lang
32 * @crossplatform
33 * @since 10
34 */
35declare class Deque<T> {
36  /**
37   * A constructor used to create a Deque object.
38   *
39   * @throws { BusinessError } 10200012 - The Deque's constructor cannot be directly invoked.
40   * @syscap SystemCapability.Utils.Lang
41   * @since 8
42   */
43  /**
44   * A constructor used to create a Deque object.
45   *
46   * @throws { BusinessError } 10200012 - The Deque'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 Deque.This is a number one higher than the highest index in the deque.
54   *
55   * @syscap SystemCapability.Utils.Lang
56   * @since 8
57   */
58  /**
59   * Gets the element number of the Deque.This is a number one higher than the highest index in the deque.
60   *
61   * @syscap SystemCapability.Utils.Lang
62   * @crossplatform
63   * @since 10
64   */
65  length: number;
66  /**
67   * Inserts an element into the deque header.
68   *
69   * @param { T } element - element element to be appended to this deque
70   * @throws { BusinessError } 10200011 - The insertFront method cannot be bound.
71   * @syscap SystemCapability.Utils.Lang
72   * @since 8
73   */
74  /**
75   * Inserts an element into the deque header.
76   *
77   * @param { T } element - element element to be appended to this deque
78   * @throws { BusinessError } 10200011 - The insertFront method cannot be bound.
79   * @syscap SystemCapability.Utils.Lang
80   * @crossplatform
81   * @since 10
82   */
83  insertFront(element: T): void;
84  /**
85   * Inserting an element at the end of a deque
86   *
87   * @param { T } element - element element to be appended to this deque
88   * @throws { BusinessError } 10200011 - The insertEnd method cannot be bound.
89   * @syscap SystemCapability.Utils.Lang
90   * @since 8
91   */
92  /**
93   * Inserting an element at the end of a deque
94   *
95   * @param { T } element - element element to be appended to this deque
96   * @throws { BusinessError } 10200011 - The insertEnd method cannot be bound.
97   * @syscap SystemCapability.Utils.Lang
98   * @crossplatform
99   * @since 10
100   */
101  insertEnd(element: T): void;
102  /**
103   * Check if deque contains the specified element
104   *
105   * @param { T } element - element element to be contained
106   * @returns { boolean } the boolean type,if deque contains the specified element,return true,else return false
107   * @throws { BusinessError } 10200011 - The has method cannot be bound.
108   * @syscap SystemCapability.Utils.Lang
109   * @since 8
110   */
111  /**
112   * Check if deque contains the specified element
113   *
114   * @param { T } element - element element to be contained
115   * @returns { boolean } the boolean type,if deque contains the specified element,return true,else return false
116   * @throws { BusinessError } 10200011 - The has method cannot be bound.
117   * @syscap SystemCapability.Utils.Lang
118   * @crossplatform
119   * @since 10
120   */
121  has(element: T): boolean;
122  /**
123   * Obtains the header element of a deque.
124   *
125   * @returns { T } the T type
126   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
127   * @syscap SystemCapability.Utils.Lang
128   * @since 8
129   */
130  /**
131   * Obtains the header element of a deque.
132   *
133   * @returns { T } the T type
134   * @throws { BusinessError } 10200011 - The getFirst method cannot be bound.
135   * @syscap SystemCapability.Utils.Lang
136   * @crossplatform
137   * @since 10
138   */
139  getFirst(): T;
140  /**
141   * Obtains the end element of a deque.
142   *
143   * @returns { T } the T type
144   * @throws { BusinessError } 10200011 - The getLast method cannot be bound.
145   * @syscap SystemCapability.Utils.Lang
146   * @since 8
147   */
148  /**
149   * Obtains the end element of a deque.
150   *
151   * @returns { T } the T type
152   * @throws { BusinessError } 10200011 - The getLast method cannot be bound.
153   * @syscap SystemCapability.Utils.Lang
154   * @crossplatform
155   * @since 10
156   */
157  getLast(): T;
158  /**
159   * Obtains the header element of a deque and delete the element.
160   *
161   * @returns { T } the T type
162   * @throws { BusinessError } 10200011 - The popFirst method cannot be bound.
163   * @syscap SystemCapability.Utils.Lang
164   * @since 8
165   */
166  /**
167   * Obtains the header element of a deque and delete the element.
168   *
169   * @returns { T } the T type
170   * @throws { BusinessError } 10200011 - The popFirst method cannot be bound.
171   * @syscap SystemCapability.Utils.Lang
172   * @crossplatform
173   * @since 10
174   */
175  popFirst(): T;
176  /**
177   * Obtains the end element of a deque and delete the element.
178   *
179   * @returns { T } the T type
180   * @throws { BusinessError } 10200011 - The popLast method cannot be bound.
181   * @syscap SystemCapability.Utils.Lang
182   * @since 8
183   */
184  /**
185   * Obtains the end element of a deque and delete the element.
186   *
187   * @returns { T } the T type
188   * @throws { BusinessError } 10200011 - The popLast method cannot be bound.
189   * @syscap SystemCapability.Utils.Lang
190   * @crossplatform
191   * @since 10
192   */
193  popLast(): T;
194  /**
195   * Executes a provided function once for each value in the deque object.
196   *
197   * @param { (value: T, index?: number, deque?: Deque<T>) => void } callbackFn - callbackFn
198   * callbackFn (required) A function that accepts up to four arguments.The function to be called for each element in the deque
199   * @param { Object } thisArg - thisArg thisArg (Optional) The value passed to the function generally uses the "this" value.
200   * If this parameter is empty, "undefined" will be passed to the "this" value
201   * @throws { BusinessError } 401 - The type of parameters are invalid.
202   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
203   * @syscap SystemCapability.Utils.Lang
204   * @since 8
205   */
206  /**
207   * Executes a provided function once for each value in the deque object.
208   *
209   * @param { (value: T, index?: number, deque?: Deque<T>) => void } callbackFn - callbackFn
210   * callbackFn (required) A function that accepts up to four arguments.The function to be called for each element in the deque
211   * @param { Object } thisArg - thisArg thisArg (Optional) The value passed to the function generally uses the "this" value.
212   * If this parameter is empty, "undefined" will be passed to the "this" value
213   * @throws { BusinessError } 401 - The type of parameters are invalid.
214   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
215   * @syscap SystemCapability.Utils.Lang
216   * @crossplatform
217   * @since 10
218   */
219  forEach(callbackFn: (value: T, index?: number, deque?: Deque<T>) => void, thisArg?: Object): void;
220  /**
221   * returns an iterator.Each item of the iterator is a Javascript Object
222   *
223   * @returns { IterableIterator<T> }
224   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
225   * @syscap SystemCapability.Utils.Lang
226   * @since 8
227   */
228  /**
229   * returns an iterator.Each item of the iterator is a Javascript Object
230   *
231   * @returns { IterableIterator<T> }
232   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
233   * @syscap SystemCapability.Utils.Lang
234   * @crossplatform
235   * @since 10
236   */
237  [Symbol.iterator](): IterableIterator<T>;
238}
239
240export default Deque;
241