Java Map Reverse reverseMapLookup(Map map, V value)

Here you can find the source of reverseMapLookup(Map map, V value)

Description

reverse Map Lookup

License

Open Source License

Declaration

public final static <K, V> K reverseMapLookup(Map<K, V> map, V value) 

Method Source Code


//package com.java2s;
/* Copyright (C) 2016 Zach Ohara
 *
 * 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 3 of the License, or
 * (at your option) any later version./* w ww  .ja  va2s .  co m*/
 *
 * 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, see <http://www.gnu.org/licenses/>.
 */

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public final static <K, V> K reverseMapLookup(Map<K, V> map, V value) {
        for (Entry<K, V> entry : map.entrySet()) {
            if (entry.getValue() == value) {
                return entry.getKey();
            }
        }
        return null;
    }
}

Related

  1. reverseMap(Map map)
  2. reverseMap(Map map)
  3. reverseMap(Map origMap)
  4. reverseMap(Map map)
  5. reverseMap(Map keyIdMap, Map keyValueMap)
  6. reverseMapping(Map value2keys, Map map)
  7. reverseMapping(Map map)
  8. sort(Map> dataNodes, boolean reverse)
  9. sort(Map source, boolean reverse)