[New] Added MapOfMaps.computeIfAbsent(T, U, Supplier<V>)
This allows one to compute the value for the two keys
This commit is contained in:
parent
6c43e54a93
commit
86a23fa056
|
@ -19,6 +19,7 @@ import java.util.*;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
|
@ -228,6 +229,12 @@ public class MapOfMaps<T, U, V> {
|
|||
return u;
|
||||
}
|
||||
|
||||
public V computeIfAbsent(T t, U u, Supplier<V> mappingFunction) {
|
||||
Objects.requireNonNull(mappingFunction);
|
||||
Map<U, V> uvMap = this.mapOfMaps.computeIfAbsent(t, k -> getMap());
|
||||
return uvMap.computeIfAbsent(u, k -> mappingFunction.get());
|
||||
}
|
||||
|
||||
public void forEach(BiConsumer<? super T, ? super Map<U, V>> action) {
|
||||
Objects.requireNonNull(action);
|
||||
for (Map.Entry<T, Map<U, V>> entry : this.mapOfMaps.entrySet()) {
|
||||
|
|
Loading…
Reference in New Issue