Class HashCodes.Combiner
java.lang.Object
cloud.opencode.base.hash.HashCodes.Combiner
- Enclosing class:
HashCodes
Chainable hash code combiner
可链式调用的哈希码组合器
Accumulates hash values incrementally and produces a final combined hash code. Each value is mixed in using the fmix32 function.
增量累积哈希值并产生最终的组合哈希码。 每个值都使用fmix32函数混合进来。
Usage Examples | 使用示例:
int hash = HashCodes.start()
.add(name.hashCode())
.add(42L)
.add(true)
.add(someObject)
.result();
Security | 安全性:
- Thread-safe: No (mutable state) - 线程安全: 否(可变状态)
- Since:
- JDK 25, opencode-base-hash V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
-
Method Summary
Modifier and TypeMethodDescriptionadd(boolean value) Adds a boolean value to the hash combination 向哈希组合中添加boolean值add(int value) Adds an int value to the hash combination 向哈希组合中添加int值add(long value) Adds a long value to the hash combination (splits into two ints) 向哈希组合中添加long值(拆分为两个int)Adds an object's hash code to the hash combination (0 for null) 向哈希组合中添加对象的哈希码(null为0)intresult()Returns the final combined hash code 返回最终的组合哈希码
-
Method Details
-
add
Adds an int value to the hash combination 向哈希组合中添加int值- Parameters:
value- int value | int值- Returns:
- this combiner | 此组合器
-
add
Adds a long value to the hash combination (splits into two ints) 向哈希组合中添加long值(拆分为两个int)- Parameters:
value- long value | long值- Returns:
- this combiner | 此组合器
-
add
Adds a boolean value to the hash combination 向哈希组合中添加boolean值- Parameters:
value- boolean value | boolean值- Returns:
- this combiner | 此组合器
-
add
Adds an object's hash code to the hash combination (0 for null) 向哈希组合中添加对象的哈希码(null为0)- Parameters:
obj- object | 对象- Returns:
- this combiner | 此组合器
-
result
public int result()Returns the final combined hash code 返回最终的组合哈希码- Returns:
- combined hash code | 组合后的哈希码
-