Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; public class Main { public static <K, V> boolean isDistinctValues(Map<K, V> in) { if (in == null) { return true; } return isDistinct(in.values()); } public static <T> boolean isDistinct(Collection<T> in) { if (in == null) { return true; } return in.size() == distinct(in).size(); } public static <T> List<T> distinct(Collection<T> in) { if (in == null) { return new ArrayList<T>(); } return new ArrayList<T>(new HashSet<T>(in)); } }