Package org.onosproject.store.service
Interface AsyncDistributedSet<E>
-
- Type Parameters:
E
- set entry type
- All Superinterfaces:
DistributedPrimitive
public interface AsyncDistributedSet<E> extends DistributedPrimitive
-
-
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 CompletableFuture<Boolean>
add(E element)
Adds the specified element to this set if it is not already present (optional operation).CompletableFuture<Boolean>
addAll(Collection<? extends E> c)
Adds all of the elements in the specified collection to this set if they're not already present (optional operation).CompletableFuture<Void>
addListener(SetEventListener<E> listener)
Registers the specified listener to be notified whenever the set is updated.default DistributedSet<E>
asDistributedSet()
Returns a newDistributedSet
that is backed by this instance.default DistributedSet<E>
asDistributedSet(long timeoutMillis)
Returns a newDistributedSet
that is backed by this instance.CompletableFuture<Void>
clear()
Removes all elements from the set.CompletableFuture<Boolean>
contains(E element)
Returns if this set contains the specified element.CompletableFuture<Boolean>
containsAll(Collection<? extends E> c)
Returns if this set contains all the elements in specified collection.CompletableFuture<? extends Set<E>>
getAsImmutableSet()
Returns the entries as a immutable set.CompletableFuture<Boolean>
isEmpty()
Returns if the set is empty.default DistributedPrimitive.Type
primitiveType()
Returns the type of primitive.CompletableFuture<Boolean>
remove(E element)
Removes the specified element to this set if it is present (optional operation).CompletableFuture<Boolean>
removeAll(Collection<? extends E> c)
Removes from this set all of its elements that are contained in the specified collection (optional operation).CompletableFuture<Void>
removeListener(SetEventListener<E> listener)
Unregisters the specified listener.CompletableFuture<Boolean>
retainAll(Collection<? extends E> c)
Retains only the elements in this set that are contained in the specified collection (optional operation).CompletableFuture<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:DistributedPrimitive
Returns the type of primitive.- Specified by:
primitiveType
in interfaceDistributedPrimitive
- Returns:
- primitive type
-
addListener
CompletableFuture<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
CompletableFuture<Void> removeListener(SetEventListener<E> listener)
Unregisters the specified listener.- Parameters:
listener
- listener to unregister.- Returns:
- CompletableFuture that is completed when the operation completes
-
add
CompletableFuture<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
CompletableFuture<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
CompletableFuture<Integer> size()
Returns the number of elements in the set.- Returns:
- size of the set
-
isEmpty
CompletableFuture<Boolean> isEmpty()
Returns if the set is empty.- Returns:
true
if this set is empty
-
clear
CompletableFuture<Void> clear()
Removes all elements from the set.- Returns:
- CompletableFuture that is completed when the operation completes
-
contains
CompletableFuture<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
CompletableFuture<Boolean> addAll(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
CompletableFuture<Boolean> containsAll(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
CompletableFuture<Boolean> retainAll(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
CompletableFuture<Boolean> removeAll(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 newDistributedSet
that is backed by this instance.- Returns:
- new
DistributedSet
instance
-
asDistributedSet
default DistributedSet<E> asDistributedSet(long timeoutMillis)
Returns a newDistributedSet
that is backed by this instance.- Parameters:
timeoutMillis
- timeout duration for the returned DistributedSet operations- Returns:
- new
DistributedSet
instance
-
getAsImmutableSet
CompletableFuture<? extends 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
-
-