MutableLongFloatMap
public final class MutableLongFloatMap extends LongFloatMap
MutableLongFloatMap is a container with a MutableMap-like interface for Long primitive keys and Float primitive values.
The underlying implementation is designed to avoid allocations from boxing, and insertion, removal, retrieval, and iteration operations. Allocations may still happen on insertion when the underlying storage needs to grow to accommodate newly added entries to the table. In addition, this implementation minimizes memory usage by avoiding the use of separate objects to hold key/value pairs.
This implementation makes no guarantee as to the order of the keys and values 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 map (insertion or removal for instance), the calling code must provide the appropriate synchronization. Multiple threads are safe to read from this map concurrently if no write is happening.
| See also | |
|---|---|
MutableScatterMap |
Summary
Public constructors |
|---|
MutableLongFloatMap(int initialCapacity)Creates a new |
Public methods |
|
|---|---|
final void |
clear()Removes all mappings from this map. |
final float |
Returns the value to which the specified |
final void |
minusAssign(long key)Removes the specified |
final void |
minusAssign(@NonNull long[] keys)Removes the specified |
final void |
minusAssign(@NonNull LongList keys)Removes the specified |
final void |
minusAssign(@NonNull LongSet keys)Removes the specified |
final void |
plusAssign(@NonNull LongFloatMap from)Puts all the key/value mappings in the |
final void |
put(long key, float value) |
final float |
put(long key, float value, float default) |
final void |
putAll(@NonNull LongFloatMap from)Puts all the key/value mappings in the |
final void |
remove(long key)Removes the specified |
final boolean |
remove(long key, float value)Removes the specified |
final void |
Removes any mapping for which the specified |
final void |
set(long key, float value) |
final int |
trim()Trims this |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
MutableLongFloatMap
public MutableLongFloatMap(int initialCapacity)
Creates a new MutableLongFloatMap
| 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 entries without requiring any allocations. The initial capacity can be set to 0. |
Public methods
getOrPut
public final float getOrPut(long key, @NonNull Function0<@NonNull Float> defaultValue)
Returns the value to which the specified key is mapped, if the value is present in the map and not null. Otherwise, calls defaultValue() and puts the result in the map associated with key.
minusAssign
public final void minusAssign(long key)
Removes the specified key and its associated value from the map.
minusAssign
public final void minusAssign(@NonNull long[] keys)
Removes the specified keys and their associated value from the map.
minusAssign
public final void minusAssign(@NonNull LongList keys)
Removes the specified keys and their associated value from the map.
minusAssign
public final void minusAssign(@NonNull LongSet keys)
Removes the specified keys and their associated value from the map.
plusAssign
public final void plusAssign(@NonNull LongFloatMap from)
Puts all the key/value mappings in the from map into this map.
put
public final void put(long key, float value)
Creates a new mapping from key to value in this map. If key is already present in the map, the association is modified and the previously associated value is replaced with value. If key is not present, a new entry is added to the map, which may require to grow the underlying storage and cause allocations. Return the previous value associated with the key, or null if the key was not present in the map.
put
public final float put(long key, float value, float default)
Creates a new mapping from key to value in this map. If key is already present in the map, the association is modified and the previously associated value is replaced with value. If key is not present, a new entry is added to the map, which may require to grow the underlying storage and cause allocations.
putAll
public final void putAll(@NonNull LongFloatMap from)
Puts all the key/value mappings in the from map into this map.
remove
public final void remove(long key)
Removes the specified key and its associated value from the map.
remove
public final boolean remove(long key, float value)
Removes the specified key and its associated value from the map if the associated value equals value. Returns whether the removal happened.
removeIf
public final void removeIf(
@NonNull Function2<@NonNull Long, @NonNull Float, @NonNull Boolean> predicate
)
Removes any mapping for which the specified predicate returns true.
set
public final void set(long key, float value)
Creates a new mapping from key to value in this map. If key is already present in the map, the association is modified and the previously associated value is replaced with value. If key is not present, a new entry is added to the map, which may require to grow the underlying storage and cause allocations.
trim
public final int trim()
Trims this MutableLongFloatMap's storage so it is sized appropriately to hold the current mappings.
Returns the number of empty entries removed from this map's storage. Returns be 0 if no trimming is necessary or possible.