Here you can find the source of inverseGet(Map
public static <K, V> Collection<K> inverseGet(Map<K, V> map, Object value)
//package com.java2s; /* /* w ww.j a va2 s . c om*/ Created on Mar 4, 2005 The Bungee View applet lets you search, browse, and data-mine an image collection. Copyright (C) 2006 Mark Derthick This program 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 2 of the License, or (at your option) any later version. See gpl.html. This program 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. You may also contact the author at mad@cs.cmu.edu, or at Mark Derthick Carnegie-Mellon University Human-Computer Interaction Institute Pittsburgh, PA 15213 */ import java.util.Collection; import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; public class Main { public static <K, V> Collection<K> inverseGet(Map<K, V> map, Object value) { Collection<K> result = new LinkedList<K>(); for (Iterator<Entry<K, V>> it = map.entrySet().iterator(); it.hasNext();) { Entry<K, V> name = it.next(); if (equalsNullOK(value, name.getValue())) { result.add(name.getKey()); } } return result; } /** * @param arg1 * @param arg2 * @return Whether both args are null, or the args are equal */ public static boolean equalsNullOK(Object arg1, Object arg2) { return arg1 == null ? arg2 == null : arg1.equals(arg2); } }