Interface AsyncDistributedSet<E>

  • Type Parameters:
    E - set entry type
    All Superinterfaces:
    DistributedPrimitive

    public interface AsyncDistributedSet<E>
    extends DistributedPrimitive
    A distributed collection designed for holding unique elements.

    All methods of AsyncDistributedSet immediately return a future. The returned future will be completed when the operation completes.

    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Boolean> add​(E element)
      Adds the specified element to this set if it is not already present (optional operation).
      java.util.concurrent.CompletableFuture<java.lang.Boolean> addAll​(java.util.Collection<? extends E> c)
      Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
      java.util.concurrent.CompletableFuture<java.lang.Void> addListener​(SetEventListener<E> listener)
      Registers the specified listener to be notified whenever the set is updated.
      default DistributedSet<E> asDistributedSet()
      Returns a new DistributedSet that is backed by this instance.
      default DistributedSet<E> asDistributedSet​(long timeoutMillis)
      Returns a new DistributedSet that is backed by this instance.
      java.util.concurrent.CompletableFuture<java.lang.Void> clear()
      Removes all elements from the set.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> contains​(E element)
      Returns if this set contains the specified element.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> containsAll​(java.util.Collection<? extends E> c)
      Returns if this set contains all the elements in specified collection.
      java.util.concurrent.CompletableFuture<? extends java.util.Set<E>> getAsImmutableSet()
      Returns the entries as a immutable set.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> isEmpty()
      Returns if the set is empty.
      default DistributedPrimitive.Type primitiveType()
      Returns the type of primitive.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> remove​(E element)
      Removes the specified element to this set if it is present (optional operation).
      java.util.concurrent.CompletableFuture<java.lang.Boolean> removeAll​(java.util.Collection<? extends E> c)
      Removes from this set all of its elements that are contained in the specified collection (optional operation).
      java.util.concurrent.CompletableFuture<java.lang.Void> removeListener​(SetEventListener<E> listener)
      Unregisters the specified listener.
      java.util.concurrent.CompletableFuture<java.lang.Boolean> retainAll​(java.util.Collection<? extends E> c)
      Retains only the elements in this set that are contained in the specified collection (optional operation).
      java.util.concurrent.CompletableFuture<java.lang.Integer> size()
      Returns the number of elements in the set.
    • Method Detail

      • addListener

        java.util.concurrent.CompletableFuture<java.lang.Void> addListener​(SetEventListener<E> listener)
        Registers the specified listener to be notified whenever the set is updated.
        Parameters:
        listener - listener to notify about set update events
        Returns:
        CompletableFuture that is completed when the operation completes
      • removeListener

        java.util.concurrent.CompletableFuture<java.lang.Void> removeListener​(SetEventListener<E> listener)
        Unregisters the specified listener.
        Parameters:
        listener - listener to unregister.
        Returns:
        CompletableFuture that is completed when the operation completes
      • add

        java.util.concurrent.CompletableFuture<java.lang.Boolean> add​(E element)
        Adds the specified element to this set if it is not already present (optional operation).
        Parameters:
        element - element to add
        Returns:
        true if this set did not already contain the specified element.
      • remove

        java.util.concurrent.CompletableFuture<java.lang.Boolean> remove​(E element)
        Removes the specified element to this set if it is present (optional operation).
        Parameters:
        element - element to remove
        Returns:
        true if this set contained the specified element
      • size

        java.util.concurrent.CompletableFuture<java.lang.Integer> size()
        Returns the number of elements in the set.
        Returns:
        size of the set
      • isEmpty

        java.util.concurrent.CompletableFuture<java.lang.Boolean> isEmpty()
        Returns if the set is empty.
        Returns:
        true if this set is empty
      • clear

        java.util.concurrent.CompletableFuture<java.lang.Void> clear()
        Removes all elements from the set.
        Returns:
        CompletableFuture that is completed when the operation completes
      • contains

        java.util.concurrent.CompletableFuture<java.lang.Boolean> contains​(E element)
        Returns if this set contains the specified element.
        Parameters:
        element - element to check
        Returns:
        true if this set contains the specified element
      • addAll

        java.util.concurrent.CompletableFuture<java.lang.Boolean> addAll​(java.util.Collection<? extends E> c)
        Adds all of the elements in the specified collection to this set if they're not already present (optional operation).
        Parameters:
        c - collection containing elements to be added to this set
        Returns:
        true if this set contains all elements in the collection
      • containsAll

        java.util.concurrent.CompletableFuture<java.lang.Boolean> containsAll​(java.util.Collection<? extends E> c)
        Returns if this set contains all the elements in specified collection.
        Parameters:
        c - collection
        Returns:
        true if this set contains all elements in the collection
      • retainAll

        java.util.concurrent.CompletableFuture<java.lang.Boolean> retainAll​(java.util.Collection<? extends E> c)
        Retains only the elements in this set that are contained in the specified collection (optional operation).
        Parameters:
        c - collection containing elements to be retained in this set
        Returns:
        true if this set changed as a result of the call
      • removeAll

        java.util.concurrent.CompletableFuture<java.lang.Boolean> removeAll​(java.util.Collection<? extends E> c)
        Removes from this set all of its elements that are contained in the specified collection (optional operation). If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.
        Parameters:
        c - collection containing elements to be removed from this set
        Returns:
        true if this set changed as a result of the call
      • asDistributedSet

        default DistributedSet<E> asDistributedSet()
        Returns a new DistributedSet that is backed by this instance.
        Returns:
        new DistributedSet instance
      • asDistributedSet

        default DistributedSet<E> asDistributedSet​(long timeoutMillis)
        Returns a new DistributedSet that is backed by this instance.
        Parameters:
        timeoutMillis - timeout duration for the returned DistributedSet operations
        Returns:
        new DistributedSet instance
      • getAsImmutableSet

        java.util.concurrent.CompletableFuture<? extends java.util.Set<E>> getAsImmutableSet()
        Returns the entries as a immutable set. The returned set is a snapshot and will not reflect new changes made to this AsyncDistributedSet
        Returns:
        immutable set copy