Package org.onosproject.store.service
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
AsyncDistributedSetimmediately return afuture. The returned future will becompletedwhen the operation completes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.onosproject.store.service.DistributedPrimitive
DistributedPrimitive.Status, DistributedPrimitive.Type
-
-
Field Summary
-
Fields inherited from interface org.onosproject.store.service.DistributedPrimitive
DEFAULT_OPERATION_TIMEOUT_MILLIS
-
-
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 newDistributedSetthat is backed by this instance.default DistributedSet<E>asDistributedSet(long timeoutMillis)Returns a newDistributedSetthat 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.TypeprimitiveType()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.-
Methods inherited from interface org.onosproject.store.service.DistributedPrimitive
addStatusChangeListener, applicationId, destroy, name, removeStatusChangeListener, statusChangeListeners
-
-
-
-
Method Detail
-
primitiveType
default DistributedPrimitive.Type primitiveType()
Description copied from interface:DistributedPrimitiveReturns the type of primitive.- Specified by:
primitiveTypein interfaceDistributedPrimitive- Returns:
- primitive type
-
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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif 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:
trueif this set changed as a result of the call
-
asDistributedSet
default DistributedSet<E> asDistributedSet()
Returns a newDistributedSetthat is backed by this instance.- Returns:
- new
DistributedSetinstance
-
asDistributedSet
default DistributedSet<E> asDistributedSet(long timeoutMillis)
Returns a newDistributedSetthat is backed by this instance.- Parameters:
timeoutMillis- timeout duration for the returned DistributedSet operations- Returns:
- new
DistributedSetinstance
-
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
-
-