Class LongObjectMap<V>
java.lang.Object
cloud.opencode.base.collections.primitive.LongObjectMap<V>
- Type Parameters:
V- value type | 值类型
- All Implemented Interfaces:
Serializable
LongObjectMap - Primitive long Key to Object Value Map
LongObjectMap - 原始 long 键到对象值映射
A map with primitive long keys and object values to avoid key boxing overhead.
具有原始 long 键和对象值的映射,以避免键装箱开销。
Features | 主要功能:
- No key boxing overhead - 无键装箱开销
- Memory efficient - 内存高效
- Fast long key operations - 快速 long 键操作
Usage Examples | 使用示例:
LongObjectMap<String> map = LongObjectMap.create();
map.put(1L, "one");
map.put(2L, "two");
String value = map.get(1L); // "one"
Performance | 性能特性:
- put: O(1) average - put: O(1) 平均
- get: O(1) average - get: O(1) 平均
- remove: O(1) average - remove: O(1) 平均
Security | 安全性:
- Thread-safe: No - 否
- Null-safe: Partial (values can be null) - 部分(值可以为null)
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceFunctional interface for long-object consumer. long-object 消费者函数式接口。 -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear this map.booleancontainsKey(long key) Check if this map contains the key.booleancontainsValue(Object value) Check if this map contains the value.static <V> LongObjectMap<V> create()Create an empty LongObjectMap.static <V> LongObjectMap<V> create(int initialCapacity) Create a LongObjectMap with initial capacity.booleanvoidforEach(LongObjectMap.LongObjectConsumer<? super V> action) Apply action to each entry.get(long key) Get the value for a key.getOrDefault(long key, V defaultValue) Get the value for a key or default.inthashCode()booleanisEmpty()Check if this map is empty.keySet()Return all keys as a LongSet.Put a key-value pair.remove(long key) Remove a key-value pair.intsize()Return the size of this map.toString()values()Return all values as a collection.
-
Method Details
-
create
Create an empty LongObjectMap. 创建空 LongObjectMap。- Type Parameters:
V- value type | 值类型- Returns:
- new empty LongObjectMap | 新空 LongObjectMap
-
create
Create a LongObjectMap with initial capacity. 创建指定初始容量的 LongObjectMap。- Type Parameters:
V- value type | 值类型- Parameters:
initialCapacity- initial capacity | 初始容量- Returns:
- new empty LongObjectMap | 新空 LongObjectMap
-
put
-
get
Get the value for a key. 获取键对应的值。- Parameters:
key- the key | 键- Returns:
- the value or null | 值或 null
-
getOrDefault
-
remove
Remove a key-value pair. 移除键值对。- Parameters:
key- the key | 键- Returns:
- the old value or null | 旧值或 null
-
containsKey
public boolean containsKey(long key) Check if this map contains the key. 检查此映射是否包含该键。- Parameters:
key- the key | 键- Returns:
- true if contains | 如果包含则返回 true
-
containsValue
Check if this map contains the value. 检查此映射是否包含该值。- Parameters:
value- the value | 值- Returns:
- true if contains | 如果包含则返回 true
-
size
public int size()Return the size of this map. 返回此映射的大小。- Returns:
- the size | 大小
-
isEmpty
public boolean isEmpty()Check if this map is empty. 检查此映射是否为空。- Returns:
- true if empty | 如果为空则返回 true
-
clear
public void clear()Clear this map. 清空此映射。 -
keySet
-
values
Return all values as a collection. 以集合形式返回所有值。- Returns:
- the values | 值
-
forEach
Apply action to each entry. 对每个条目应用操作。- Parameters:
action- the action | 操作
-
equals
-
hashCode
-
toString
-