Java Map Reverse toReverseIndex( Map> forwardIndex)

Here you can find the source of toReverseIndex( Map> forwardIndex)

Description

to Reverse Index

License

Apache License

Parameter

Parameter Description
forwardIndex a parameter

Declaration

public static Map<String, Map<Integer, String>> toReverseIndex(
        Map<String, Map<String, Integer>> forwardIndex) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

import java.util.Map;

import java.util.Map.Entry;

public class Main {
    /**/*from   w  ww . ja v a 2s  .c  o m*/
     *
     * @param forwardIndex
     * @return
     */
    public static Map<String, Map<Integer, String>> toReverseIndex(
            Map<String, Map<String, Integer>> forwardIndex) {
        Map<String, Map<Integer, String>> reverseForwardIndex = new HashMap<String, Map<Integer, String>>();
        for (String dimensionName : forwardIndex.keySet()) {
            Map<String, Integer> map = forwardIndex.get(dimensionName);
            reverseForwardIndex.put(dimensionName,
                    new HashMap<Integer, String>());
            for (Entry<String, Integer> entry : map.entrySet()) {
                reverseForwardIndex.get(dimensionName).put(
                        entry.getValue(), entry.getKey());
            }
        }
        return reverseForwardIndex;
    }
}

Related

  1. sort(Map> dataNodes, boolean reverse)
  2. sort(Map source, boolean reverse)
  3. sortByUsedSpace(Map> dataNodes, boolean reverse)
  4. sortByValue(Map map, boolean reverse)
  5. sortByValue(Map map, boolean doReverse)