Skip to content

Commit ba583cf

Browse files
committed
Create DoubleHashMap.java
1 parent b6ab7a6 commit ba583cf

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package io.github.intisy.utils.custom;
2+
3+
import io.github.intisy.utils.custom.Doublet;
4+
import io.github.intisy.utils.custom.Triplet;
5+
6+
import java.util.Collection;
7+
import java.util.HashMap;
8+
import java.util.stream.Collectors;
9+
10+
public class DoubleHashMap<K, V1, V2> extends HashMap<K, Doublet<V1, V2>> {
11+
public void put(K key, V1 value1, V2 value2) {
12+
super.put(key, new Doublet<>(value1, value2));
13+
}
14+
15+
public V1 getValue1(K key) {
16+
return get(key).getKey();
17+
}
18+
19+
public V2 getValue2(K key) {
20+
return get(key).getValue();
21+
}
22+
23+
24+
public Collection<V1> values1() {
25+
return values().stream().map(Doublet::getKey).collect(Collectors.toList());
26+
}
27+
28+
public Collection<V2> values2() {
29+
return values().stream().map(Doublet::getValue).collect(Collectors.toList());
30+
}
31+
32+
}
33+

0 commit comments

Comments
 (0)