public final class CompositeDisposable extends Object implements Disposable, DisposableContainer
Disposables and
offers O(1) time complexity for add(Disposable), remove(Disposable) and delete(Disposable)
operations.| Constructor and Description |
|---|
CompositeDisposable()
Creates an empty
CompositeDisposable. |
CompositeDisposable(Disposable... disposables)
Creates a
CompositeDisposable with the given array of initial Disposable elements. |
CompositeDisposable(@NonNull Iterable<? extends Disposable> disposables)
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(@NonNull Disposable disposable)
Adds a
Disposable to this container or disposes it if the
container has been disposed. |
boolean |
addAll(Disposable... disposables)
Atomically adds the given array of
Disposables to the container or
disposes them all if the container has been disposed. |
void |
clear()
Atomically clears the container, then disposes all the previously contained
Disposables. |
boolean |
delete(@NonNull Disposable disposable)
Removes (but does not dispose) the given
Disposable if it is part of this
container. |
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed()
Returns true if this resource has been disposed.
|
boolean |
remove(@NonNull Disposable disposable)
Removes and disposes the given
Disposable if it is part of this
container. |
int |
size()
Returns the number of currently held
Disposables. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitdisposed, empty, fromAction, fromAutoCloseable, fromFuture, fromFuture, fromRunnable, fromSubscription, toAutoCloseablepublic CompositeDisposable()
CompositeDisposable.public CompositeDisposable(@NonNull Disposable... disposables)
CompositeDisposable with the given array of initial Disposable elements.disposables - the array of Disposables to start withNullPointerException - if disposables or any of its array items is nullpublic CompositeDisposable(@NonNull @NonNull Iterable<? extends Disposable> disposables)
disposables - the Iterable sequence of Disposable to start withNullPointerException - if disposables or any of its items is nullpublic void dispose()
Disposabledispose in interface Disposablepublic boolean isDisposed()
DisposableisDisposed in interface Disposablepublic boolean add(@NonNull @NonNull Disposable disposable)
Disposable to this container or disposes it if the
container has been disposed.add in interface DisposableContainerdisposable - the Disposable to add, not nulltrue if successful, false if this container has been disposedNullPointerException - if disposable is nullpublic boolean addAll(@NonNull Disposable... disposables)
Disposables to the container or
disposes them all if the container has been disposed.disposables - the array of Disposablestrue if the operation was successful, false if the container has been disposedNullPointerException - if disposables or any of its array items is nullpublic boolean remove(@NonNull @NonNull Disposable disposable)
Disposable if it is part of this
container.remove in interface DisposableContainerdisposable - the disposable to remove and dispose, not nulltrue if the operation was successfulNullPointerException - if disposable is nullpublic boolean delete(@NonNull @NonNull Disposable disposable)
Disposable if it is part of this
container.delete in interface DisposableContainerdisposable - the disposable to remove, not nulltrue if the operation was successfulNullPointerException - if disposable is nullpublic void clear()
Disposables.public int size()
Disposables.Disposables