MutableFloatSet
public final class MutableFloatSet extends FloatSet
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(int initialCapacity)Creates a new |
Public methods |
|
|---|---|
final boolean |
add(float element)Adds the specified element to the set. |
final boolean |
Adds all the |
final boolean |
Adds all the elements in the |
final void |
clear()Removes all elements from this set. |
final void |
minusAssign(float element)Removes the specified |
final void |
minusAssign(@NonNull float[] elements)Removes the specified |
final void |
minusAssign(@NonNull FloatSet elements)Removes the specified |
final void |
plusAssign(float element)Adds the specified element to the set. |
final void |
plusAssign(@NonNull float[] elements)Adds all the |
final void |
plusAssign(@NonNull FloatSet elements)Adds all the elements in the |
final boolean |
remove(float element)Removes the specified |
final boolean |
Removes the specified |
final boolean |
Removes the specified |
final @IntRange(from = 0) int |
trim()Trims this |
Inherited methods |
||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableFloatSet
public MutableFloatSet(int initialCapacity)
Creates a new MutableFloatSet
| Parameters | |
|---|---|
int initialCapacity |
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 methods
add
public final boolean add(float element)
Adds the specified element to the set.
| Parameters | |
|---|---|
float element |
The element to add to the set. |
| Returns | |
|---|---|
boolean |
|
addAll
public final boolean addAll(@NonNull float[] elements)
Adds all the elements into this set.
| Parameters | |
|---|---|
@NonNull float[] elements |
An array of elements to add to the set. |
| Returns | |
|---|---|
boolean |
|
addAll
public final boolean addAll(@NonNull FloatSet elements)
Adds all the elements in the elements set into this set.
| Returns | |
|---|---|
boolean |
|
minusAssign
public final void minusAssign(float element)
Removes the specified element from the set if it is present.
| Parameters | |
|---|---|
float element |
The element to remove from the set. |
minusAssign
public final void minusAssign(@NonNull float[] elements)
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
@NonNull float[] elements |
An array of elements to be removed from the set. |
minusAssign
public final void minusAssign(@NonNull FloatSet elements)
Removes the specified elements from the set, if present.
plusAssign
public final void plusAssign(float element)
Adds the specified element to the set.
| Parameters | |
|---|---|
float element |
The element to add to the set. |
plusAssign
public final void plusAssign(@NonNull float[] elements)
Adds all the elements into this set.
| Parameters | |
|---|---|
@NonNull float[] elements |
An array of elements to add to the set. |
plusAssign
public final void plusAssign(@NonNull FloatSet elements)
Adds all the elements in the elements set into this set.
remove
public final boolean remove(float element)
Removes the specified element from the set.
| Parameters | |
|---|---|
float element |
The element to remove from the set. |
| Returns | |
|---|---|
boolean |
|
removeAll
public final boolean removeAll(@NonNull float[] elements)
Removes the specified elements from the set, if present.
| Parameters | |
|---|---|
@NonNull float[] elements |
An array of elements to be removed from the set. |
| Returns | |
|---|---|
boolean |
|
removeAll
public final boolean removeAll(@NonNull FloatSet elements)
Removes the specified elements from the set, if present.
| Returns | |
|---|---|
boolean |
|
trim
public final @IntRange(from = 0) int trim()
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.