Java tutorial
//package com.java2s; /* * This file is part of WebLookAndFeel library. * * WebLookAndFeel library is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * WebLookAndFeel library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with WebLookAndFeel library. If not, see <http://www.gnu.org/licenses/>. */ import java.util.*; public class Main { /** * Returns map values summary list with unique elements only. * * @param map map to process * @param <K> key object type * @param <V> value object type * @return map values summary list with unique elements only */ public static <K, V> ArrayList<V> valuesSummaryList(final Map<K, List<V>> map) { final ArrayList<V> summary = new ArrayList<V>(0); for (final Map.Entry<K, List<V>> entry : map.entrySet()) { final List<V> list = entry.getValue(); summary.ensureCapacity(summary.size() + list.size()); for (final V value : list) { if (!summary.contains(value)) { summary.add(value); } } } return summary; } }