1974 |
|
* or the mappingFunction is null |
1975 |
|
* @since 1.8 |
1976 |
|
*/ |
1977 |
< |
public V computeIfAbsent(K key, |
1977 |
> |
public V computeIfAbsent(K key, |
1978 |
|
Function<? super K, ? extends V> mappingFunction) { |
1979 |
< |
if (key == null || mappingFunction == null) |
1980 |
< |
throw new NullPointerException(); |
1979 |
> |
if (key == null || mappingFunction == null) |
1980 |
> |
throw new NullPointerException(); |
1981 |
|
Comparator<? super K> cmp; |
1982 |
< |
V v, p, r; |
1983 |
< |
if ((cmp = comparator) == null) { |
1984 |
< |
if ((v = doGet(key)) == null && |
1985 |
< |
(r = mappingFunction.apply(key)) != null) |
1986 |
< |
v = (p = doPut(key, r, true)) == null ? r : p; |
1987 |
< |
} |
1988 |
< |
else { |
1989 |
< |
if ((v = doGetCmp(cmp, key)) == null && |
1990 |
< |
(r = mappingFunction.apply(key)) != null) |
1991 |
< |
v = (p = doPutCmp(cmp, key, r, true)) == null ? r : p; |
1992 |
< |
} |
1982 |
> |
V v, p, r; |
1983 |
> |
if ((cmp = comparator) == null) { |
1984 |
> |
if ((v = doGet(key)) == null && |
1985 |
> |
(r = mappingFunction.apply(key)) != null) |
1986 |
> |
v = (p = doPut(key, r, true)) == null ? r : p; |
1987 |
> |
} |
1988 |
> |
else { |
1989 |
> |
if ((v = doGetCmp(cmp, key)) == null && |
1990 |
> |
(r = mappingFunction.apply(key)) != null) |
1991 |
> |
v = (p = doPutCmp(cmp, key, r, true)) == null ? r : p; |
1992 |
> |
} |
1993 |
|
return v; |
1994 |
|
} |
1995 |
|
|
2006 |
|
* or the remappingFunction is null |
2007 |
|
* @since 1.8 |
2008 |
|
*/ |
2009 |
< |
public V computeIfPresent(K key, |
2009 |
> |
public V computeIfPresent(K key, |
2010 |
|
BiFunction<? super K, ? super V, ? extends V> remappingFunction) { |
2011 |
< |
if (key == null || remappingFunction == null) |
2012 |
< |
throw new NullPointerException(); |
2011 |
> |
if (key == null || remappingFunction == null) |
2012 |
> |
throw new NullPointerException(); |
2013 |
|
Comparator<? super K> cmp; |
2014 |
|
if ((cmp = comparator) == null) { |
2015 |
|
Node<K,V> n; Object v; |
2026 |
|
else if (doRemove(k, vv) != null) |
2027 |
|
break; |
2028 |
|
} |
2029 |
< |
} |
2029 |
> |
} |
2030 |
|
} |
2031 |
|
else { |
2032 |
|
Node<K,V> n; Object v; |
2042 |
|
break; |
2043 |
|
} |
2044 |
|
} |
2045 |
< |
} |
2046 |
< |
return null; |
2045 |
> |
} |
2046 |
> |
return null; |
2047 |
|
} |
2048 |
|
|
2049 |
|
/** |
2059 |
|
* or the remappingFunction is null |
2060 |
|
* @since 1.8 |
2061 |
|
*/ |
2062 |
< |
public V compute(K key, |
2062 |
> |
public V compute(K key, |
2063 |
|
BiFunction<? super K, ? super V, ? extends V> remappingFunction) { |
2064 |
< |
if (key == null || remappingFunction == null) |
2065 |
< |
throw new NullPointerException(); |
2064 |
> |
if (key == null || remappingFunction == null) |
2065 |
> |
throw new NullPointerException(); |
2066 |
|
Comparator<? super K> cmp; |
2067 |
|
if ((cmp = comparator) == null) { |
2068 |
|
@SuppressWarnings("unchecked") Comparable<? super K> k = |
2106 |
|
} |
2107 |
|
} |
2108 |
|
} |
2109 |
< |
return null; |
2109 |
> |
return null; |
2110 |
|
} |
2111 |
|
|
2112 |
|
/** |
2126 |
|
*/ |
2127 |
|
public V merge(K key, V value, |
2128 |
|
BiFunction<? super V, ? super V, ? extends V> remappingFunction) { |
2129 |
< |
if (key == null || value == null || remappingFunction == null) |
2130 |
< |
throw new NullPointerException(); |
2129 |
> |
if (key == null || value == null || remappingFunction == null) |
2130 |
> |
throw new NullPointerException(); |
2131 |
|
Comparator<? super K> cmp; |
2132 |
|
if ((cmp = comparator) == null) { |
2133 |
|
@SuppressWarnings("unchecked") Comparable<? super K> k = |
2166 |
|
return null; |
2167 |
|
} |
2168 |
|
} |
2169 |
< |
} |
2169 |
> |
} |
2170 |
|
} |
2171 |
|
|
2172 |
|
/* ---------------- View methods -------------- */ |