LongLongHashMap Class — netty Architecture
Architecture documentation for the LongLongHashMap class in LongLongHashMap.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8["LongLongHashMap"] f0e206d2_68cc_8c7b_bbc1_c8d7eeb01608["LongLongHashMap.java"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|defined in| f0e206d2_68cc_8c7b_bbc1_c8d7eeb01608 cbd6d6ae_fb1b_107c_79f7_43ac31eb7671["LongLongHashMap()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| cbd6d6ae_fb1b_107c_79f7_43ac31eb7671 de2b9bd8_a556_f190_a2d4_14bd57210f3c["put()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| de2b9bd8_a556_f190_a2d4_14bd57210f3c 21c75f13_5c12_7a9d_24bf_25e83548d0bb["remove()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| 21c75f13_5c12_7a9d_24bf_25e83548d0bb 79bc14e4_5167_3c0d_a118_cf3f3fb50053["get()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| 79bc14e4_5167_3c0d_a118_cf3f3fb50053 d26bef1b_480a_bce1_986c_ff9e97408cb9["index()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| d26bef1b_480a_bce1_986c_ff9e97408cb9 09c316c3_bddf_b4f7_c3e8_69e3d1f83500["expand()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| 09c316c3_bddf_b4f7_c3e8_69e3d1f83500 30c4debd_f78c_0d76_d44b_29b4a12da039["computeMaskAndProbe()"] c69e9be2_01e3_83a0_b7d7_e4e8841e7bf8 -->|method| 30c4debd_f78c_0d76_d44b_29b4a12da039
Relationship Graph
Source Code
common/src/main/java/io/netty/util/internal/LongLongHashMap.java lines 20–135
public final class LongLongHashMap {
private static final int MASK_TEMPLATE = ~1;
private int mask;
private long[] array;
private int maxProbe;
private long zeroVal;
private final long emptyVal;
public LongLongHashMap(long emptyVal) {
this.emptyVal = emptyVal;
zeroVal = emptyVal;
int initialSize = 32;
array = new long[initialSize];
mask = initialSize - 1;
computeMaskAndProbe();
}
public LongLongHashMap(LongLongHashMap other) {
this.mask = other.mask;
this.array = Arrays.copyOf(other.array, other.array.length);
this.maxProbe = other.maxProbe;
this.zeroVal = other.zeroVal;
this.emptyVal = other.emptyVal;
}
public long put(long key, long value) {
if (key == 0) {
long prev = zeroVal;
zeroVal = value;
return prev;
}
for (;;) {
int index = index(key);
for (int i = 0; i < maxProbe; i++) {
long existing = array[index];
if (existing == key || existing == 0) {
long prev = existing == 0? emptyVal : array[index + 1];
array[index] = key;
array[index + 1] = value;
for (; i < maxProbe; i++) { // Nerf any existing misplaced entries.
index = index + 2 & mask;
if (array[index] == key) {
array[index] = 0;
prev = array[index + 1];
break;
}
}
return prev;
}
index = index + 2 & mask;
}
expand(); // Grow array and re-hash.
}
}
public void remove(long key) {
if (key == 0) {
zeroVal = emptyVal;
return;
}
int index = index(key);
for (int i = 0; i < maxProbe; i++) {
long existing = array[index];
if (existing == key) {
array[index] = 0;
break;
}
index = index + 2 & mask;
}
}
public long get(long key) {
if (key == 0) {
return zeroVal;
}
int index = index(key);
for (int i = 0; i < maxProbe; i++) {
long existing = array[index];
if (existing == key) {
return array[index + 1];
Source
Frequently Asked Questions
What is the LongLongHashMap class?
LongLongHashMap is a class in the netty codebase, defined in common/src/main/java/io/netty/util/internal/LongLongHashMap.java.
Where is LongLongHashMap defined?
LongLongHashMap is defined in common/src/main/java/io/netty/util/internal/LongLongHashMap.java at line 20.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free