MutableScatterSet
-
Cmn
class MutableScatterSet<E : Any?> : ScatterSet
MutableScatterSet is a container with a MutableSet-like interface based on a flat hash table implementation. The underlying implementation is designed to avoid all allocations on insertion, removal, retrieval, and iteration. Allocations may still happen on insertion when the underlying storage needs to grow to accommodate newly added elements to the set.
This implementation makes no guarantee as to the order of the elements stored, nor does it make guarantees that the order remains constant over time.
This implementation is not thread-safe: if multiple threads access this container concurrently, and one or more threads modify the structure of the set (insertion or removal for instance), the calling code must provide the appropriate synchronization. Concurrent reads are however safe.
Note: when a Set is absolutely necessary, you can use the method asSet to create a thin wrapper around a MutableScatterSet. Please refer to asSet for more details and caveats.
Note: when a MutableSet is absolutely necessary, you can use the method asMutableSet to create a thin wrapper around a MutableScatterSet. Please refer to asMutableSet for more details and caveats.
| See also | |
|---|---|
Set |
Summary
Public constructors |
|
|---|---|
<E : Any?> MutableScatterSet(initialCapacity: Int)Creates a new |
Cmn
N
JS
|
Public functions |
||
|---|---|---|
Boolean |
add(element: E)Adds the specified element to the set. |
Cmn
N
JS
|
Boolean |
addAll(elements: <Error class: unknown class><E>) |
N
JS
|
Boolean |
Adds all the |
Cmn
N
JS
|
Boolean |
Adds all the |
Cmn
N
JS
|
Boolean |
addAll(elements: ObjectList<E>)Adds all the elements in the |
Cmn
N
JS
|
Boolean |
addAll(elements: OrderedScatterSet<E>)Adds all the elements in the |
Cmn
N
JS
|
Boolean |
addAll(elements: ScatterSet<E>)Adds all the elements in the |
Cmn
N
JS
|
Boolean |
Adds all the |
Cmn
|
MutableSet<E> |
Wraps this |
Cmn
N
JS
|
Unit |
clear()Removes all elements from this set. |
Cmn
N
JS
|
operator Unit |
minusAssign(element: E)Removes the specified |
Cmn
N
JS
|
operator Unit |
minusAssign(elements: <Error class: unknown class><E>) |
N
JS
|
operator Unit |
minusAssign(elements: Array<E>)Removes the specified |
Cmn
N
JS
|
operator Unit |
minusAssign(elements: Iterable<E>)Removes the specified |
Cmn
N
JS
|
operator Unit |
minusAssign(elements: ObjectList<E>)Removes the specified |
Cmn
N
JS
|
operator Unit |
minusAssign(elements: OrderedScatterSet<E>)Removes the specified |
Cmn
N
JS
|
operator Unit |
minusAssign(elements: ScatterSet<E>)Removes the specified |
Cmn
N
JS
|
operator Unit |
minusAssign(elements: Sequence<E>)Removes the specified |
Cmn
|
operator Unit |
plusAssign(element: E)Adds the specified element to the set. |
Cmn
N
JS
|
operator Unit |
plusAssign(elements: <Error class: unknown class><E>) |
N
JS
|
operator Unit |
plusAssign(elements: Array<E>)Adds all the |
Cmn
N
JS
|
operator Unit |
plusAssign(elements: Iterable<E>)Adds all the |
Cmn
N
JS
|
operator Unit |
plusAssign(elements: ObjectList<E>)Adds all the elements in the |
Cmn
N
JS
|
operator Unit |
plusAssign(elements: OrderedScatterSet<E>)Adds all the elements in the |
Cmn
N
JS
|
operator Unit |
plusAssign(elements: ScatterSet<E>)Adds all the elements in the |
Cmn
N
JS
|
operator Unit |
plusAssign(elements: Sequence<E>)Adds all the |
Cmn
|
Boolean |
remove(element: E)Removes the specified |
Cmn
N
JS
|
Boolean |
removeAll(elements: <Error class: unknown class><E>) |
N
JS
|
Boolean |
Removes the specified |
Cmn
N
JS
|
Boolean |
Removes the specified |
Cmn
N
JS
|
Boolean |
removeAll(elements: ObjectList<E>)Removes the specified |
Cmn
N
JS
|
Boolean |
removeAll(elements: OrderedScatterSet<E>)Removes the specified |
Cmn
N
JS
|
Boolean |
removeAll(elements: ScatterSet<E>)Removes the specified |
Cmn
N
JS
|
Boolean |
Removes the specified |
Cmn
|
inline Unit |
Removes any values for which the specified |
Cmn
N
JS
|
Boolean |
retainAll(elements: Collection<E>)Removes all the entries in this set that are not contained in |
Cmn
N
JS
|
Boolean |
retainAll(elements: OrderedScatterSet<E>)Removes all the entries in this set that are not contained in |
Cmn
N
JS
|
Boolean |
retainAll(elements: ScatterSet<E>)Removes all the entries in this set that are not contained in |
Cmn
N
JS
|
inline Boolean |
Removes all the elements in this set for which the specified |
Cmn
N
JS
|
@IntRange(from = 0) Int |
trim()Trims this |
Cmn
N
JS
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|---|
Public constructors
MutableScatterSet
<E : Any?> MutableScatterSet(initialCapacity: Int = DefaultScatterCapacity)
Creates a new MutableScatterSet
| Parameters | |
|---|---|
initialCapacity: Int = DefaultScatterCapacity |
The initial desired capacity for this container. the container will honor this value by guaranteeing its internal structures can hold that many elements without requiring any allocations. The initial capacity can be set to 0. |
Public functions
add
fun add(element: E): Boolean
Adds the specified element to the set.
| Parameters | |
|---|---|
element: E |
The element to add to the set. |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: Array<E>): Boolean
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: Array<E> |
An array of elements to add to the set. |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: Iterable<E>): Boolean
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: Iterable<E> |
Iterable elements to add to the set. |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: ObjectList<E>): Boolean
Adds all the elements in the elements set into this set.
| Parameters | |
|---|---|
elements: ObjectList<E> |
An |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: OrderedScatterSet<E>): Boolean
Adds all the elements in the elements set into this set.
| Parameters | |
|---|---|
elements: OrderedScatterSet<E> |
A |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: ScatterSet<E>): Boolean
Adds all the elements in the elements set into this set.
| Parameters | |
|---|---|
elements: ScatterSet<E> |
A |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: Sequence<E>): Boolean
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: Sequence<E> |
The sequence of elements to add to the set. |
| Returns | |
|---|---|
Boolean |
|
asMutableSet
fun asMutableSet(): MutableSet<E>
Wraps this ScatterSet with a MutableSet interface. The MutableSet is backed by the ScatterSet, so changes to the ScatterSet are reflected in the MutableSet and vice-versa. If the ScatterSet is modified while an iteration over the MutableSet is in progress (and vice- versa), the results of the iteration are undefined.
Note: while this method is useful to use this MutableScatterSet with APIs accepting MutableSet interfaces, it is less efficient to do so than to use MutableScatterSet's APIs directly. While the MutableSet implementation returned by this method tries to be as efficient as possible, the semantics of MutableSet may require the allocation of temporary objects for access and iteration.
minusAssign
operator fun minusAssign(element: E): Unit
Removes the specified element from the set if it is present.
| Parameters | |
|---|---|
element: E |
The element to be removed from the set. |
minusAssign
operator fun minusAssign(elements: Array<E>): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: Array<E> |
An array of elements to be removed from the set. |
minusAssign
operator fun minusAssign(elements: Iterable<E>): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: Iterable<E> |
A Iterable of elements to be removed from the set. |
minusAssign
operator fun minusAssign(elements: ObjectList<E>): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: ObjectList<E> |
An |
minusAssign
operator fun minusAssign(elements: OrderedScatterSet<E>): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: OrderedScatterSet<E> |
A |
minusAssign
operator fun minusAssign(elements: ScatterSet<E>): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: ScatterSet<E> |
A |
minusAssign
operator fun minusAssign(elements: Sequence<E>): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: Sequence<E> |
A sequence of elements to be removed from the set. |
plusAssign
operator fun plusAssign(element: E): Unit
Adds the specified element to the set.
| Parameters | |
|---|---|
element: E |
The element to add to the set. |
plusAssign
operator fun plusAssign(elements: Array<E>): Unit
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: Array<E> |
An array of elements to add to the set. |
plusAssign
operator fun plusAssign(elements: Iterable<E>): Unit
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: Iterable<E> |
Iterable elements to add to the set. |
plusAssign
operator fun plusAssign(elements: ObjectList<E>): Unit
Adds all the elements in the elements set into this set.
| Parameters | |
|---|---|
elements: ObjectList<E> |
An |
plusAssign
operator fun plusAssign(elements: OrderedScatterSet<E>): Unit
Adds all the elements in the elements set into this set.
| Parameters | |
|---|---|
elements: OrderedScatterSet<E> |
A |
plusAssign
operator fun plusAssign(elements: ScatterSet<E>): Unit
Adds all the elements in the elements set into this set.
| Parameters | |
|---|---|
elements: ScatterSet<E> |
A |
plusAssign
operator fun plusAssign(elements: Sequence<E>): Unit
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: Sequence<E> |
The sequence of elements to add to the set. |
remove
fun remove(element: E): Boolean
Removes the specified element from the set.
| Parameters | |
|---|---|
element: E |
The element to be removed from the set. |
removeAll
fun removeAll(elements: Array<E>): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: Array<E> |
An array of elements to be removed from the set. |
| Returns | |
|---|---|
Boolean |
|
removeAll
fun removeAll(elements: Iterable<E>): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: Iterable<E> |
A Iterable of elements to be removed from the set. |
| Returns | |
|---|---|
Boolean |
|
removeAll
fun removeAll(elements: ObjectList<E>): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: ObjectList<E> |
An |
| Returns | |
|---|---|
Boolean |
|
removeAll
fun removeAll(elements: OrderedScatterSet<E>): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: OrderedScatterSet<E> |
A |
| Returns | |
|---|---|
Boolean |
|
removeAll
fun removeAll(elements: ScatterSet<E>): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: ScatterSet<E> |
A |
| Returns | |
|---|---|
Boolean |
|
removeAll
fun removeAll(elements: Sequence<E>): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: Sequence<E> |
A sequence of elements to be removed from the set. |
| Returns | |
|---|---|
Boolean |
|
removeIf
inline fun removeIf(predicate: (E) -> Boolean): Unit
Removes any values for which the specified predicate returns true.
retainAll
fun retainAll(elements: Collection<E>): Boolean
Removes all the entries in this set that are not contained in elements.
| Parameters | |
|---|---|
elements: Collection<E> |
A collection of elements to preserve in this set. |
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: OrderedScatterSet<E>): Boolean
Removes all the entries in this set that are not contained in elements.
elements A set of elements to preserve in this set.
| Returns | |
|---|---|
Boolean |
|
retainAll
fun retainAll(elements: ScatterSet<E>): Boolean
Removes all the entries in this set that are not contained in elements.
elements A set of elements to preserve in this set.
| Returns | |
|---|---|
Boolean |
|
retainAll
inline fun retainAll(predicate: (E) -> Boolean): Boolean
Removes all the elements in this set for which the specified predicate is true. For each element in the set, the predicate is invoked with that element as the sole parameter.
| Parameters | |
|---|---|
predicate: (E) -> Boolean |
Predicate invoked for each element in the set. When the predicate returns |
| Returns | |
|---|---|
Boolean |
|
trim
fun trim(): @IntRange(from = 0) Int
Trims this MutableScatterSet's storage so it is sized appropriately to hold the current elements.
Returns the number of empty elements removed from this set's storage. Returns 0 if no trimming is necessary or possible.