Add static Map.Entry methods (#530)

This commit is contained in:
Ivan Hetman 2020-10-12 09:39:16 +03:00 committed by GitHub
parent 55ba9be16a
commit e95092fd43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,22 @@ public interface TMap<K, V> {
V1 getValue();
V1 setValue(V1 value);
static <K extends Comparable<? super K>, V> TComparator<TMap.Entry<K, V>> comparingByKey() {
return (a, b) -> a.getKey().compareTo(b.getKey());
}
static <K, V extends Comparable<? super V>> TComparator<TMap.Entry<K, V>> comparingByValue() {
return (a, b) -> a.getValue().compareTo(b.getValue());
}
static <K, V> TComparator<TMap.Entry<K, V>> comparingByKey(TComparator<? super K> comp) {
return (a, b) -> comp.compare(a.getKey(), b.getKey());
}
static <K, V> TComparator<TMap.Entry<K, V>> comparingByValue(TComparator<? super V> comp) {
return (a, b) -> comp.compare(a.getValue(), b.getValue());
}
}
int size();