MutableLongSet



MutableLongSet 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

MutableLongSet(initialCapacity: Int)

Creates a new MutableLongSet

Cmn

Public functions

Boolean
add(element: Long)

Adds the specified element to the set.

Cmn
Boolean
addAll(elements: LongArray)

Adds all the elements into this set.

Cmn
Boolean
addAll(elements: LongSet)

Adds all the elements in the elements set into this set.

Cmn
Unit

Removes all elements from this set.

Cmn
operator Unit
minusAssign(element: Long)

Removes the specified element from the set if it is present.

Cmn
operator Unit

Removes the specified elements from the set, if present.

Cmn
operator Unit
minusAssign(elements: LongSet)

Removes the specified elements from the set, if present.

Cmn
operator Unit
plusAssign(element: Long)

Adds the specified element to the set.

Cmn
operator Unit
plusAssign(elements: LongArray)

Adds all the elements into this set.

Cmn
operator Unit
plusAssign(elements: LongSet)

Adds all the elements in the elements set into this set.

Cmn
Boolean
remove(element: Long)

Removes the specified element from the set.

Cmn
Boolean
removeAll(elements: LongArray)

Removes the specified elements from the set, if present.

Cmn
Boolean
removeAll(elements: LongSet)

Removes the specified elements from the set, if present.

Cmn
@IntRange(from = 0) Int

Trims this MutableLongSet's storage so it is sized appropriately to hold the current elements.

Cmn

Inherited functions

From androidx.collection.LongSet
inline Boolean
all(predicate: (element: Long) -> Boolean)

Returns true if all elements match the given predicate.

Cmn
Boolean
any()

Returns true if this set has at least one element.

Cmn
inline Boolean
any(predicate: (element: Long) -> Boolean)

Returns true if at least one element matches the given predicate.

Cmn
operator Boolean
contains(element: Long)

Returns true if the specified element is present in this set, false otherwise.

Cmn
@IntRange(from = 0) Int

Returns the number of elements in this set.

Cmn
inline @IntRange(from = 0) Int
count(predicate: (element: Long) -> Boolean)

Returns the number of elements matching the given predicate.

Cmn
open operator Boolean
equals(other: Any?)

Compares the specified object other with this set for equality.

Cmn
inline Long

Returns the first element in the collection.

Cmn
inline Long
first(predicate: (element: Long) -> Boolean)

Returns the first element in the collection for which predicate returns true.

Cmn
inline Unit
forEach(block: (element: Long) -> Unit)

Iterates over every element stored in this set by invoking the specified block lambda.

Cmn
open Int

Returns the hash code value for this set.

Cmn
Boolean

Indicates whether this set is empty.

Cmn
Boolean

Returns true if this set is not empty.

Cmn
String
joinToString(
    separator: CharSequence,
    prefix: CharSequence,
    postfix: CharSequence,
    limit: Int,
    truncated: CharSequence
)

Creates a String from the elements separated by separator and using prefix before and postfix after, if supplied.

Cmn
inline String
joinToString(
    separator: CharSequence,
    prefix: CharSequence,
    postfix: CharSequence,
    limit: Int,
    truncated: CharSequence,
    crossinline transform: (Long) -> CharSequence
)

Creates a String from the elements separated by separator and using prefix before and postfix after, if supplied.

Cmn
Boolean

Returns true if this set has no elements.

Cmn
open String

Returns a string representation of this set.

Cmn

Inherited properties

From androidx.collection.LongSet
Int

Returns the number of elements that can be stored in this set without requiring internal storage reallocation.

Cmn
Int

Returns the number of elements in this set.

Cmn

Public constructors

MutableLongSet

MutableLongSet(initialCapacity: Int = DefaultScatterCapacity)

Creates a new MutableLongSet

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: Long): Boolean

Adds the specified element to the set.

Parameters
element: Long

The element to add to the set.

Returns
Boolean

true if the element has been added or false if the element is already contained within the set.

addAll

fun addAll(elements: LongArray): Boolean

Adds all the elements into this set.

Parameters
elements: LongArray

An array of elements to add to the set.

Returns
Boolean

true if any of the specified elements were added to the collection, false if the collection was not modified.

addAll

fun addAll(elements: LongSet): Boolean

Adds all the elements in the elements set into this set.

Parameters
elements: LongSet

A LongSet of elements to add to this set.

Returns
Boolean

true if any of the specified elements were added to the collection, false if the collection was not modified.

clear

fun clear(): Unit

Removes all elements from this set.

minusAssign

operator fun minusAssign(element: Long): Unit

Removes the specified element from the set if it is present.

Parameters
element: Long

The element to remove from the set.

minusAssign

operator fun minusAssign(elements: LongArray): Unit

Removes the specified elements from the set, if present.

Parameters
elements: LongArray

An array of elements to be removed from the set.

minusAssign

operator fun minusAssign(elements: LongSet): Unit

Removes the specified elements from the set, if present.

Parameters
elements: LongSet

An LongSet of elements to be removed from the set.

plusAssign

operator fun plusAssign(element: Long): Unit

Adds the specified element to the set.

Parameters
element: Long

The element to add to the set.

plusAssign

operator fun plusAssign(elements: LongArray): Unit

Adds all the elements into this set.

Parameters
elements: LongArray

An array of elements to add to the set.

plusAssign

operator fun plusAssign(elements: LongSet): Unit

Adds all the elements in the elements set into this set.

Parameters
elements: LongSet

A LongSet of elements to add to this set.

remove

fun remove(element: Long): Boolean

Removes the specified element from the set.

Parameters
element: Long

The element to remove from the set.

Returns
Boolean

true if the element was present in the set, or false if it wasn't present before removal.

removeAll

fun removeAll(elements: LongArray): Boolean

Removes the specified elements from the set, if present.

Parameters
elements: LongArray

An array of elements to be removed from the set.

Returns
Boolean

true if the set was changed or false if none of the elements were present.

removeAll

fun removeAll(elements: LongSet): Boolean

Removes the specified elements from the set, if present.

Parameters
elements: LongSet

An LongSet of elements to be removed from the set.

Returns
Boolean

true if the set was changed or false if none of the elements were present.

trim

fun trim(): @IntRange(from = 0) Int

Trims this MutableLongSet'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.