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 Object
Native 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.void
clear()
Removes all values from this set.boolean
delete(V value)
Removes the given value from the set.void
forEach(JsCollections.ForEachCallback<V> callback)
Invokes the provided callback for each value in this set.boolean
has(V value)
Checks whether this set contains the given value.boolean
isEmpty()
Checks if the set is empty (size == 0).int
size()
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:
true
if the value is in the set;false
otherwise
-
delete
public boolean delete(V value)
Removes the given value from the set.- Parameters:
value
- the value to remove- Returns:
true
if the map contained the value prior to calling this method;false
otherwise
-
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:
true
if the set is empty,false
otherwise
-
-