Modifier and Type | Method and Description |
---|---|
static <K,V> V |
getOrDefault(Map<K,V> map,
K key,
V defaultValue)
Returns a maps value or a given default if not present.
|
static <K,V extends Comparable<? super V>> |
sortByValue(Map<K,V> map)
This orders a Map by its values and returns a new
LinkedHashMap which maintains that order. |
static <K,V> Map<K,V> |
sortByValue(Map<K,V> map,
Comparator<V> comparator)
Order a Map by its values using the given value comparator and return a new
LinkedHashMap which maintains that order. |
public static <K,V extends Comparable<? super V>> Map<K,V> sortByValue(Map<K,V> map)
LinkedHashMap
which maintains that order.K
- type of the map keyV
- type of the map value, this needs to implement Comparable
map
- to sortpublic static <K,V> Map<K,V> sortByValue(Map<K,V> map, Comparator<V> comparator)
LinkedHashMap
which maintains that order.K
- type of the map keyV
- type of the map valuemap
- to sortpublic static <K,V> V getOrDefault(Map<K,V> map, K key, V defaultValue)
Copyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.