K - the key typeV - the value type@JsType(isNative=true,
name="Map",
namespace="<global>")
public class JsMap<K,V>
extends Object
JsCollections.map() to create an appropriate instance.| Modifier and Type | Class and Description |
|---|---|
static interface |
JsMap.ForEachCallback<K,V>
Functional interface for iterating all the entries in a
JsMap. |
| Constructor and Description |
|---|
JsMap()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all mappings from this map.
|
boolean |
delete(K key)
Removes the mapping for a given key.
|
void |
forEach(JsMap.ForEachCallback<K,V> callback)
Invokes the provided callback for each mapping in this map.
|
V |
get(K key)
Gets the value mapped for the given key.
|
boolean |
has(K key)
Checks whether this map contains a mapping for the given key.
|
boolean |
isEmpty()
Checks if the map is empty (size == 0).
|
JsArray<V> |
mapValues()
Returns an array of the values in this
JsMap. |
JsMap<K,V> |
set(K key,
V value)
Sets a value in this map, overwriting any previous mapping if present.
|
int |
size()
Gets the number of entries in this map.
|
public JsMap<K,V> set(K key, V value)
key - the key to setvalue - the value to setpublic V get(K key)
null if
there is no mapping or if the key is explicitly mapped to
null.key - the key to get a value fornull
there is no mapping.public boolean has(K key)
key - the key to checktrue if there is a mapping for the key; false if
there is no mappingpublic boolean delete(K key)
key - the key for which to remove the mappingtrue if the map contained a mapping for the given key
prior to calling this method; false if no mapping was
presentpublic void clear()
public void forEach(JsMap.ForEachCallback<K,V> callback)
Note that this is the only way of iteration supported in IE11.
callback - the callback to invoke for each mapping@JsProperty(name="size") public int size()
@JsOverlay public final boolean isEmpty()
true if the map is empty, false otherwiseCopyright © 2000–2019 Vaadin Ltd. All rights reserved.