Class 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 Detail

      • JsSet

        public JsSet()
        Creates a new instance.
    • 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