• 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 HashMap<K, V> {
17  /**
18   * A constructor used to create a HashMap object.
19   * @throws { BusinessError } 10200012 - The HashMap'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 hashmap.
26   * @since 8
27   * @syscap SystemCapability.Utils.Lang
28   */
29  length: number;
30  /**
31   * Returns whether the Map object contains elements
32   * @returns the boolean type
33   * @throws { BusinessError } 10200011 - The isEmpty method cannot be bound.
34   * @since 8
35   * @syscap SystemCapability.Utils.Lang
36   */
37  isEmpty(): boolean;
38  /**
39   * Returns whether a key is contained in this map
40   * @param key need to determine whether to include the key
41   * @returns the boolean type
42   * @throws { BusinessError } 10200011 - The hasKey method cannot be bound.
43   * @since 8
44   * @syscap SystemCapability.Utils.Lang
45   */
46  hasKey(key: K): boolean;
47  /**
48   * Returns whether a value is contained in this map
49   * @param value need to determine whether to include the value
50   * @returns the boolean type
51   * @throws { BusinessError } 10200011 - The hasValue method cannot be bound.
52   * @since 8
53   * @syscap SystemCapability.Utils.Lang
54   */
55  hasValue(value: V): boolean;
56  /**
57   * Returns a specified element in a Map object, or null if there is no corresponding element
58   * @param key the index in HashMap
59   * @returns value or null
60   * @throws { BusinessError } 10200011 - The get method cannot be bound.
61   * @since 8
62   * @syscap SystemCapability.Utils.Lang
63   */
64  get(key: K): V;
65  /**
66   * Adds all element groups in one map to another map
67   * @param map the Map object to add members
68   * @throws { BusinessError } 10200011 - The setAll method cannot be bound.
69   * @throws { BusinessError } 401 - The type of parameters are invalid.
70   * @since 8
71   * @syscap SystemCapability.Utils.Lang
72   */
73  setAll(map: HashMap<K, V>): void;
74  /**
75   * Adds or updates a(new) key-value pair with a key and value specified for the Map object
76   * @param key Added or updated targets
77   * @param value Added or updated value
78   * @returns the map object after set
79   * @throws { BusinessError } 10200011 - The set method cannot be bound.
80   * @throws { BusinessError } 401 - The type of parameters are invalid.
81   * @since 8
82   * @syscap SystemCapability.Utils.Lang
83   */
84  set(key: K, value: V): Object;
85  /**
86   * Remove a specified element from a Map object
87   * @param key  Target to be deleted
88   * @returns Target mapped value
89   * @throws { BusinessError } 10200011 - The remove method cannot be bound.
90   * @since 8
91   * @syscap SystemCapability.Utils.Lang
92   */
93  remove(key: K): V;
94  /**
95   * Clear all element groups in the map
96   * @throws { BusinessError } 10200011 - The clear method cannot be bound.
97   * @since 8
98   * @syscap SystemCapability.Utils.Lang
99   */
100  clear(): void;
101  /**
102   * Returns a new Iterator object that contains the keys contained in this map
103   * @throws { BusinessError } 10200011 - The keys method cannot be bound.
104   * @since 8
105   * @syscap SystemCapability.Utils.Lang
106   */
107  keys(): IterableIterator<K>;
108  /**
109   * Returns a new Iterator object that contains the values contained in this map
110   * @throws { BusinessError } 10200011 - The values method cannot be bound.
111   * @since 8
112   * @syscap SystemCapability.Utils.Lang
113   */
114  values(): IterableIterator<V>;
115  /**
116   * Replace the old value by new value corresponding to the specified key
117   * @param key Updated targets
118   * @param newValue Updated the target mapped value
119   * @returns the boolean type(Is there a target pointed to by the key)
120   * @throws { BusinessError } 10200011 - The replace method cannot be bound.
121   * @since 8
122   * @syscap SystemCapability.Utils.Lang
123   */
124  replace(key: K, newValue: V): boolean;
125  /**
126   * Executes the given callback function once for each real key in the map.
127   * It does not perform functions on deleted keys
128   * @throws { BusinessError } 10200011 - The forEach method cannot be bound.
129   * @throws { BusinessError } 401 - The type of parameters are invalid.
130   * @since 8
131   * @syscap SystemCapability.Utils.Lang
132   */
133  forEach(callbackFn: (value?: V, key?: K, map?: HashMap<K, V>) => void,
134  thisArg?: Object): void;
135  /**
136   * Returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order
137   * @throws { BusinessError } 10200011 - The entries method cannot be bound.
138   * @since 8
139   * @syscap SystemCapability.Utils.Lang
140   */
141  entries(): IterableIterator<[K, V]>;
142  /**
143   * returns an iterator.Each item of the iterator is a Javascript Object
144   * @throws { BusinessError } 10200011 - The Symbol.iterator method cannot be bound.
145   * @since 8
146   * @syscap SystemCapability.Utils.Lang
147   */
148  [Symbol.iterator](): IterableIterator<[K, V]>;
149}
150
151export default HashMap;
152