Class JsSet<V>
- java.lang.Object
-
- com.vaadin.client.flow.collection.JsSet<V>
-
- Type Parameters:
V- the value type
- Direct Known Subclasses:
JreJsSet
@JsType(isNative=true, name="Set", namespace="<global>") public class JsSet<V> extends ObjectNative JS Set interface with an alternative implementation for JRE usage. UseJsCollections.set()to create an appropriate instance.- Since:
- 1.0
- Author:
- Vaadin Ltd
-
-
Constructor Summary
Constructors Constructor Description JsSet()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsSet<V>add(V value)Adds a value to this set, overwriting any previous value if present.voidclear()Removes all values from this set.booleandelete(V value)Removes the given value from the set.voidforEach(JsCollections.ForEachCallback<V> callback)Invokes the provided callback for each value in this set.booleanhas(V value)Checks whether this set contains the given value.booleanisEmpty()Checks if the set is empty (size == 0).intsize()Gets the number of values in this set.
-
-
-
Method Detail
-
add
public JsSet<V> add(V value)
Adds a value to this set, overwriting any previous value if present.- Parameters:
value- the value to add- Returns:
- this set, for chaining.
-
has
public boolean has(V value)
Checks whether this set contains the given value.- Parameters:
value- the value to check for- Returns:
trueif the value is in the set;falseotherwise
-
delete
public boolean delete(V value)
Removes the given value from the set.- Parameters:
value- the value to remove- Returns:
trueif the map contained the value prior to calling this method;falseotherwise
-
clear
public void clear()
Removes all values from this set.
-
forEach
public void forEach(JsCollections.ForEachCallback<V> callback)
Invokes the provided callback for each value in this set.- Parameters:
callback- the callback to invoke for each value
-
size
@JsProperty(name="size") public int size()
Gets the number of values in this set.- Returns:
- the value count
-
isEmpty
@JsOverlay public final boolean isEmpty()
Checks if the set is empty (size == 0).- Returns:
trueif the set is empty,falseotherwise
-
-