[JAVA] HashMap hash table overview of new features in java8

getOrDefault

  • getOrDefault(Object key, V defaultValue)

  • If there are key returns the corresponding value, otherwise defaultValue

replaceAll

  • replaceAll(BiFunction<? super K, ? super V, ? extends V> function)

  • Key is to replace all of the dimensions of value, replacement logic function implemented in the

putIfAbsent

  • putIfAbsent(K key, V value)    

  • If there is a corresponding key value is returned, otherwise the key and value added to the map

computeIfAbsent

  • computeIfAbsent(K key,Function<? super K, ? extends V> mappingFunction)  

  • If key returns a corresponding value exists, if it does not exist and the value calculated by the function into the map

computeIfPresent

  • computeIfPresent(K key,BiFunction<? super K, ? super V, ? extends V> remappingFunction) 

  • If a key is present is calculated in accordance with the new value and the new value into the function map, if the new value is null to remove the map from the key.

compute

  • compute(K key,BiFunction<? super K, ? super V, ? extends V> remappingFunction)  

  • By calculating function key corresponding newValue, newValue not empty into the map, the key is removed or in the case of the presence of key.

merge

  • merge(K key, V value,BiFunction<? super V, ? super V, ? extends V> remappingFunction)  

  • Based on the corresponding key value and calculate a new oldValue newValue by function, newValue not empty into the map, otherwise the key is removed from the map.

END

Guess you like

Origin www.cnblogs.com/anliux/p/12364653.html