MutableFloatSet



MutableFloatSet 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

MutableFloatSet(initialCapacity: Int)

Creates a new MutableFloatSet

Cmn

Public functions

Boolean
add(element: Float)

Adds the specified element to the set.

Cmn
Boolean
addAll(elements: FloatArray)

Adds all the elements into this set.

Cmn
Boolean
addAll(elements: FloatSet)

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

Cmn
Unit

Removes all elements from this set.

Cmn
operator Unit
minusAssign(element: Float)

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: FloatSet)

Removes the specified elements from the set, if present.

Cmn
operator Unit
plusAssign(element: Float)

Adds the specified element to the set.

Cmn
operator Unit

Adds all the elements into this set.

Cmn
operator Unit
plusAssign(elements: FloatSet)

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

Cmn
Boolean
remove(element: Float)

Removes the specified element from the set.

Cmn
Boolean
removeAll(elements: FloatArray)

Removes the specified elements from the set, if present.

Cmn
Boolean
removeAll(elements: FloatSet)

Removes the specified elements from the set, if present.

Cmn
@IntRange(from = 0) Int

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

Cmn

Inherited functions

From androidx.collection.FloatSet
inline Boolean
all(predicate: (element: Float) -> 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: Float) -> Boolean)

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

Cmn
operator Boolean
contains(element: Float)

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: Float) -> 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 Float

Returns the first element in the collection.

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

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

Cmn
inline Unit
forEach(block: (element: Float) -> 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: (Float) -> 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.FloatSet
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

MutableFloatSet

MutableFloatSet(initialCapacity: Int = DefaultScatterCapacity)

Creates a new MutableFloatSet

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

Adds the specified element to the set.

Parameters
element: Float

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

Adds all the elements into this set.

Parameters
elements: FloatArray

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

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

Parameters
elements: FloatSet

A FloatSet 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: Float): Unit

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

Parameters
element: Float

The element to remove from the set.

minusAssign

operator fun minusAssign(elements: FloatArray): Unit

Removes the specified elements from the set, if present.

Parameters
elements: FloatArray

An array of elements to be removed from the set.

minusAssign

operator fun minusAssign(elements: FloatSet): Unit

Removes the specified elements from the set, if present.

Parameters
elements: FloatSet

An FloatSet of elements to be removed from the set.

plusAssign

operator fun plusAssign(element: Float): Unit

Adds the specified element to the set.

Parameters
element: Float

The element to add to the set.

plusAssign

operator fun plusAssign(elements: FloatArray): Unit

Adds all the elements into this set.

Parameters
elements: FloatArray

An array of elements to add to the set.

plusAssign

operator fun plusAssign(elements: FloatSet): Unit

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

Parameters
elements: FloatSet

A FloatSet of elements to add to this set.

remove

fun remove(element: Float): Boolean

Removes the specified element from the set.

Parameters
element: Float

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

Removes the specified elements from the set, if present.

Parameters
elements: FloatArray

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

Removes the specified elements from the set, if present.

Parameters
elements: FloatSet

An FloatSet 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 MutableFloatSet'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.