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. Use JsCollections.set() to create an appropriate instance.
Since:
1.0
Author:
Vaadin Ltd
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    add(V value)
    Adds a value to this set, overwriting any previous value if present.
    void
    Removes all values from this set.
    boolean
    delete(V value)
    Removes the given value from the set.
    void
    Invokes the provided callback for each value in this set.
    boolean
    has(V value)
    Checks whether this set contains the given value.
    final boolean
    Checks if the set is empty (size == 0).
    int
    Gets the number of values in this set.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JsSet

      public JsSet()
      Creates a new instance.
  • Method Details

    • 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