• 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
16declare class LightWeightMap<K, V> {
17  /**
18   * A constructor used to create a LightWeightMap object.
19   * @throws { BusinessError } 10200012 - The LightWeightMap's constructor cannot be directly invoked.
20   * @since 8
21   * @syscap SystemCapability.Utils.Lang
22   */
23  constructor();
24  /**
25   * Gets the element number of the LightWeightMap.
26   * @since 8
27   * @syscap SystemCapability.Utils.Lang
28   */
29  length: number;
30  /**
31   * Returns whether this map has all the object in a specified map
32   * @param map the Map object to compare
33   * @returns the boolean type
34   * @throws { BusinessError } 401 - The type of parameters are invalid.
35   * @throws { BusinessError } 10200011 - The hasAll method cannot be bound.
36   * @since 8
37   * @syscap SystemCapability.Utils.Lang
38   */
39  hasAll(map: LightWeightMap<K, V>): boolean;
40  /**
41   * Returns whether a key is contained in this map
42   * @param key need to determine whether to include the key
43   * @returns the boolean type
44   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
45   * @since 8
46   * @syscap SystemCapability.Utils.Lang
47   */
48  hasKey(key: K): boolean;
49  /**
50   * Returns whether a value is contained in this map
51   * @param value need to determine whether to include the value
52   * @returns the boolean type
53   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
54   * @since 8
55   * @syscap SystemCapability.Utils.Lang
56   */
57  hasValue(value: V): boolean;
58  /**
59   * Ensures that the capacity of an LightWeightMap container is greater than or equal to a specified value,
60   * and that the container has all the original objects after capacity expansion
61   * @param minimumCapacity Minimum capacity to be reserved
62   * @throws { BusinessError } 10200011 - The increaseCapacityTo method cannot be bound.
63   * @throws { BusinessError } 401 - The type of parameters are invalid.
64   * @since 8
65   * @syscap SystemCapability.Utils.Lang
66   */
67  increaseCapacityTo(minimumCapacity: number): void;
68  /**
69   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
70   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
71   * @since 8
72   * @syscap SystemCapability.Utils.Lang
73   */
74  entries(): IterableIterator<[K, V]>;
75  /**
76   * Returns the value to which the specified key is mapped, or undefined if this map contains no mapping for the key
77   * @param key the index in LightWeightMap
78   * @returns value or undefined
79   * @throws { BusinessError } 10200011 - The get method cannot be bound.
80   * @since 8
81   * @syscap SystemCapability.Utils.Lang
82   */
83  get(key: K): V;
84  /**
85   * Obtains the index of the key equal to a specified key in an LightWeightMap container
86   * @param key Looking for goals
87   * @returns Subscript corresponding to target
88   * @throws { BusinessError } 10200011 - The getIndexOfKey method cannot be bound.
89   * @since 8
90   * @syscap SystemCapability.Utils.Lang
91   */
92  getIndexOfKey(key: K): number;
93  /**
94   * Obtains the index of the value equal to a specified value in an LightWeightMap container
95   * @param value Looking for goals
96   * @returns Subscript corresponding to target
97   * @throws { BusinessError } 10200011 - The getIndexOfValue method cannot be bound.
98   * @since 8
99   * @syscap SystemCapability.Utils.Lang
100   */
101  getIndexOfValue(value: V): number;
102  /**
103   * Returns whether the Map object contains elements
104   * @returns the boolean type
105   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
106   * @since 8
107   * @syscap SystemCapability.Utils.Lang
108   */
109  isEmpty(): boolean;
110  /**
111   * Obtains the key at the location identified by index in an LightWeightMap container
112   * @param index Target subscript for search
113   * @returns the key of key-value pairs
114   * @throws { BusinessError } 10200011 - The getKeyAt method cannot be bound.
115   * @throws { BusinessError } 10200001 - The value of index is out of range.
116   * @throws { BusinessError } 401 - The type of parameters are invalid.
117   * @since 8
118   * @syscap SystemCapability.Utils.Lang
119   */
120  getKeyAt(index: number): K;
121  /**
122   * Obtains a ES6 iterator that contains all the keys of an LightWeightMap container
123   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
124   * @since 8
125   * @syscap SystemCapability.Utils.Lang
126   */
127  keys(): IterableIterator<K>;
128  /**
129   * Adds all element groups in one map to another map
130   * @param map the Map object to add members
131   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
132   * @throws { BusinessError } 401 - The type of parameters are invalid.
133   * @since 8
134   * @syscap SystemCapability.Utils.Lang
135   */
136  setAll(map: LightWeightMap<K, V>): void;
137  /**
138   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
139   * @param key Added or updated targets
140   * @param value Added or updated value
141   * @returns the map object after set
142   * @throws { BusinessError } 10200011 - The set method cannot be bound.
143   * @since 8
144   * @syscap SystemCapability.Utils.Lang
145   */
146  set(key: K, value: V): Object;
147  /**
148   * Remove the mapping for this key from this map if present
149   * @param key  Target to be deleted
150   * @returns Target mapped value
151   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
152   * @since 8
153   * @syscap SystemCapability.Utils.Lang
154   */
155  remove(key: K): V;
156  /**
157   * Deletes a key-value pair at the location identified by index from an LightWeightMap container
158   * @param index  Target subscript for search
159   * @returns the boolean type(Is there a delete value)
160   * @throws { BusinessError } 10200011 - The removeAt method cannot be bound.
161   * @throws { BusinessError } 401 - The type of parameters are invalid.
162   * @since 8
163   * @syscap SystemCapability.Utils.Lang
164   */
165  removeAt(index: number): boolean;
166  /**
167   * Removes all of the mapping from this map
168   * The map will be empty after this call returns
169   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
170   * @since 8
171   * @syscap SystemCapability.Utils.Lang
172   */
173  clear(): void;
174  /**
175   * Sets the value identified by index in an LightWeightMap container to a specified value
176   * @param index Target subscript for search
177   * @param value Updated the target mapped value
178   * @returns the boolean type(Is there a value corresponding to the subscript)
179   * @throws { BusinessError } 10200011 - The setValueAt method cannot be bound.
180   * @throws { BusinessError } 10200001 - The value of index is out of range.
181   * @throws { BusinessError } 401 - The type of parameters are invalid.
182   * @since 8
183   * @syscap SystemCapability.Utils.Lang
184   */
185  setValueAt(index: number, newValue: V): boolean;
186  /**
187   * Executes the given callback function once for each real key in the map.
188   * It does not perform functions on deleted keys
189   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
190   * @throws { BusinessError } 401 - The type of parameters are invalid.
191   * @since 8
192   * @syscap SystemCapability.Utils.Lang
193   */
194  forEach(callbackFn: (value?: V, key?: K, map?: LightWeightMap<K, V>) => void,
195  thisArg?: Object): void;
196  /**
197   * returns an ES6 iterator.Each item of the iterator is a Javascript Object
198   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
199   * @since 8
200   * @syscap SystemCapability.Utils.Lang
201   */
202  [Symbol.iterator](): IterableIterator<[K, V]>;
203  /**
204   * Obtains a string that contains all the keys and values in an LightWeightMap container
205   * @throws { BusinessError } 10200011 - The toString method cannot be bound.
206   * @since 8
207   * @syscap SystemCapability.Utils.Lang
208   */
209  toString(): String;
210  /**
211   * Obtains the value identified by index in an LightWeightMap container
212   * @param index Target subscript for search
213   * @returns the value of key-value pairs
214   * @throws { BusinessError } 10200011 - The getValueAt method cannot be bound.
215   * @throws { BusinessError } 10200001 - The value of index is out of range.
216   * @throws { BusinessError } 401 - The type of parameters are invalid.
217   * @since 8
218   * @syscap SystemCapability.Utils.Lang
219   */
220  getValueAt(index: number): V;
221  /**
222   * Returns an iterator of the values contained in this map
223   * @throws { BusinessError } 10200011 - The values method cannot be bound.
224   * @since 8
225   * @syscap SystemCapability.Utils.Lang
226   */
227  values(): IterableIterator<V>;
228}
229
230export default LightWeightMap;