MutableIntSet
-
Cmn
class MutableIntSet : IntSet
MutableIntSet 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.
Summary
Public constructors |
|
|---|---|
MutableIntSet(initialCapacity: Int)Creates a new |
Cmn
|
Public functions |
||
|---|---|---|
Boolean |
Adds the specified element to the set. |
Cmn
|
Boolean |
Adds all the |
Cmn
|
Boolean |
Adds all the elements in the |
Cmn
|
Unit |
clear()Removes all elements from this set. |
Cmn
|
operator Unit |
minusAssign(element: Int)Removes the specified |
Cmn
|
operator Unit |
minusAssign(elements: IntArray)Removes the specified |
Cmn
|
operator Unit |
minusAssign(elements: IntSet)Removes the specified |
Cmn
|
operator Unit |
plusAssign(element: Int)Adds the specified element to the set. |
Cmn
|
operator Unit |
plusAssign(elements: IntArray)Adds all the |
Cmn
|
operator Unit |
plusAssign(elements: IntSet)Adds all the elements in the |
Cmn
|
Boolean |
Removes the specified |
Cmn
|
Boolean |
Removes the specified |
Cmn
|
Boolean |
Removes the specified |
Cmn
|
@IntRange(from = 0) Int |
trim()Trims this |
Cmn
|
Inherited functions |
|||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Inherited properties |
|---|
Public constructors
MutableIntSet
MutableIntSet(initialCapacity: Int = DefaultScatterCapacity)
Creates a new MutableIntSet
| 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: Int): Boolean
Adds the specified element to the set.
| Parameters | |
|---|---|
element: Int |
The element to add to the set. |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: IntArray): Boolean
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: IntArray |
An array of elements to add to the set. |
| Returns | |
|---|---|
Boolean |
|
addAll
fun addAll(elements: IntSet): Boolean
Adds all the elements in the elements set into this set.
| Returns | |
|---|---|
Boolean |
|
minusAssign
operator fun minusAssign(element: Int): Unit
Removes the specified element from the set if it is present.
| Parameters | |
|---|---|
element: Int |
The element to remove from the set. |
minusAssign
operator fun minusAssign(elements: IntArray): Unit
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: IntArray |
An array of elements to be removed from the set. |
minusAssign
operator fun minusAssign(elements: IntSet): Unit
Removes the specified elements from the set, if present.
plusAssign
operator fun plusAssign(element: Int): Unit
Adds the specified element to the set.
| Parameters | |
|---|---|
element: Int |
The element to add to the set. |
plusAssign
operator fun plusAssign(elements: IntArray): Unit
Adds all the elements into this set.
| Parameters | |
|---|---|
elements: IntArray |
An array of elements to add to the set. |
plusAssign
operator fun plusAssign(elements: IntSet): Unit
Adds all the elements in the elements set into this set.
remove
fun remove(element: Int): Boolean
Removes the specified element from the set.
| Parameters | |
|---|---|
element: Int |
The element to remove from the set. |
removeAll
fun removeAll(elements: IntArray): Boolean
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
elements: IntArray |
An array of elements to be removed from the set. |
| Returns | |
|---|---|
Boolean |
|
removeAll
fun removeAll(elements: IntSet): Boolean
Removes the specified elements from the set, if present.
| Returns | |
|---|---|
Boolean |
|
trim
fun trim(): @IntRange(from = 0) Int
Trims this MutableIntSet'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.