FloatLongMap
public sealed class FloatLongMap
MutableFloatLongMap |
|
FloatLongMap is a container with a Map-like interface for Float primitive keys and Long 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.
This implementation is read-only and only allows data to be queried. A mutable implementation is provided by MutableFloatLongMap.
| See also | |
|---|---|
MutableFloatLongMap |
|
ScatterMap |
Summary
Protected constructors |
|---|
Public methods |
|
|---|---|
final boolean |
Returns true if all entries match the given |
final boolean |
any()Returns |
final boolean |
Returns true if at least one entry matches the given |
final boolean |
contains(float key)Returns true if the specified |
final boolean |
containsKey(float key)Returns true if the specified |
final boolean |
containsValue(long value)Returns true if the specified |
final int |
count()Returns the number of entries in this map. |
final int |
Returns the number of entries matching the given |
boolean |
Compares the specified object |
final void |
Iterates over every key/value pair stored in this map by invoking the specified |
final void |
forEachKey(@NonNull Function1<@NonNull Float, Unit> block)Iterates over every key stored in this map by invoking the specified |
final void |
forEachValue(@NonNull Function1<@NonNull Long, Unit> block)Iterates over every value stored in this map by invoking the specified |
final long |
get(float key)Returns the value corresponding to the given |
final int |
Returns the number of key-value pairs that can be stored in this map without requiring internal storage reallocation. |
final long |
getOrDefault(float key, long defaultValue)Returns the value to which the specified |
final long |
Returns the value for the given |
final int |
getSize()Returns the number of key-value pairs in this map. |
int |
hashCode()Returns the hash code value for this map. |
final boolean |
isEmpty()Indicates whether this map is empty. |
final boolean |
Returns |
final @NonNull String |
joinToString(Creates a String from the entries, separated by |
final @NonNull String |
joinToString(Creates a String from the entries, separated by |
final boolean |
none()Returns |
@NonNull String |
toString()Returns a string representation of this map. |
Protected constructors
Public methods
all
public final boolean all(
@NonNull Function2<@NonNull Float, @NonNull Long, @NonNull Boolean> predicate
)
Returns true if all entries match the given predicate.
any
public final boolean any(
@NonNull Function2<@NonNull Float, @NonNull Long, @NonNull Boolean> predicate
)
Returns true if at least one entry matches the given predicate.
contains
public final boolean contains(float key)
Returns true if the specified key is present in this map, false otherwise.
containsKey
public final boolean containsKey(float key)
Returns true if the specified key is present in this map, false otherwise.
containsValue
public final boolean containsValue(long value)
Returns true if the specified value is present in this map, false otherwise.
count
public final int count(
@NonNull Function2<@NonNull Float, @NonNull Long, @NonNull Boolean> predicate
)
Returns the number of entries matching the given predicate.
equals
public boolean equals(Object other)
Compares the specified object other with this hash map for equality. The two objects are considered equal if other:
-
Is a
FloatLongMap -
Has the same
sizeas this map -
Contains key/value pairs equal to this map's pair
forEach
public final void forEach(@NonNull Function2<@NonNull Float, @NonNull Long, Unit> block)
Iterates over every key/value pair stored in this map by invoking the specified block lambda.
forEachKey
public final void forEachKey(@NonNull Function1<@NonNull Float, Unit> block)
Iterates over every key stored in this map by invoking the specified block lambda.
forEachValue
public final void forEachValue(@NonNull Function1<@NonNull Long, Unit> block)
Iterates over every value stored in this map by invoking the specified block lambda.
get
public final long get(float key)
Returns the value corresponding to the given key.
| Throws | |
|---|---|
kotlin.NoSuchElementException |
if |
getCapacity
public final int getCapacity()
Returns the number of key-value pairs that can be stored in this map without requiring internal storage reallocation.
getOrDefault
public final long getOrDefault(float key, long defaultValue)
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
getOrElse
public final long getOrElse(float key, @NonNull Function0<@NonNull Long> defaultValue)
Returns the value for the given key if the value is present and not null. Otherwise, returns the result of the defaultValue function.
getSize
public final int getSize()
Returns the number of key-value pairs in this map.
hashCode
public int hashCode()
Returns the hash code value for this map. The hash code the sum of the hash codes of each key/value pair.
joinToString
public final @NonNull String joinToString(
@NonNull CharSequence separator,
@NonNull CharSequence prefix,
@NonNull CharSequence postfix,
int limit,
@NonNull CharSequence truncated
)
Creates a String from the entries, separated by separator and using prefix before and postfix after, if supplied.
When a non-negative value of limit is provided, a maximum of limit items are used to generate the string. If the collection holds more than limit items, the string is terminated with truncated.
joinToString
public final @NonNull String joinToString(
@NonNull CharSequence separator,
@NonNull CharSequence prefix,
@NonNull CharSequence postfix,
int limit,
@NonNull CharSequence truncated,
@NonNull Function2<@NonNull Float, @NonNull Long, @NonNull CharSequence> transform
)
Creates a String from the entries, separated by separator and using prefix before and postfix after, if supplied. Each entry is created with transform.
When a non-negative value of limit is provided, a maximum of limit items are used to generate the string. If the collection holds more than limit items, the string is terminated with truncated.