Example usage for java.util Map values

List of usage examples for java.util Map values

Introduction

In this page you can find the example usage for java.util Map values.

Prototype

Collection<V> values();

Source Link

Document

Returns a Collection view of the values contained in this map.

Usage

From source file:de.unisb.cs.st.javalanche.mutation.results.MutationCoverageFile.java

public static void saveCoverageData(Map<Long, Set<String>> coverageData) {
    COVERAGE_DIR.mkdirs();/*w  w  w.  jav a  2 s. c o m*/
    coveredMutations = new HashSet<Long>();
    BiMap<String, Integer> allTests = getAllTests(coverageData.values());
    SerializeIo.serializeToFile(allTests, FILE_MAP);

    Set<Entry<Long, Set<String>>> entrySet = coverageData.entrySet();
    for (Entry<Long, Set<String>> entry : entrySet) {
        Set<Integer> testIDs = new HashSet<Integer>();
        for (String testName : entry.getValue()) {
            if (testName != null) {
                testIDs.add(allTests.get(testName));
            }
        }
        Long id = entry.getKey();
        if (testIDs.size() > 0) {
            coveredMutations.add(id);
            logger.debug("Adding covered mutation" + id);
            Collection<Long> collection = baseMutations.get(id);
            if (collection.size() > 0) {
                logger.debug("Adding children of base mutation" + collection);
                coveredMutations.addAll(collection);
            }
        }
        SerializeIo.serializeToFile(testIDs, new File(COVERAGE_DIR, "" + id));
    }
    logger.info("Saving Ids of Covered Mutations " + coveredMutations.size());
    SerializeIo.serializeToFile(coveredMutations, COVERED_FILE);
}

From source file:com.qmetry.qaf.automation.testng.pro.DataProviderUtil.java

@SuppressWarnings("unchecked")
@DataProvider(name = "isfw_property")
public static final Object[][] getDataFromProp(Method method) {
    List<Object[]> mapData = getDataSetAsMap(getParameters(method).get(params.KEY.name()));
    Class<?> types[] = method.getParameterTypes();
    if ((types.length == 1) && Map.class.isAssignableFrom(types[0])) {
        return mapData.toArray(new Object[][] {});
    } else {/*  w w w. j  a va  2 s  .  c  o  m*/
        List<Object[]> data = new ArrayList<Object[]>();
        Iterator<Object[]> mapDataIter = mapData.iterator();
        while (mapDataIter.hasNext()) {
            Map<String, String> map = (Map<String, String>) mapDataIter.next()[0];
            data.add(map.values().toArray());
        }
        return data.toArray(new Object[][] {});
    }
}

From source file:com.ejoysoft.util.CacheSizes.java

/**
 * Returns the size in bytes of a Map object. All keys and
 * values <b>must be Strings</b>.
 *
 * @param map the Map object to determine the size of.
 * @return the size of the Map object./*from  ww w.  j  a v  a  2  s . c  o m*/
 */
public static int sizeOfMap(Map map) {
    if (map == null) {
        return 0;
    }
    //Base map object -- should be something around this size.
    int size = 36;
    //Add in size of each value
    Iterator iter = map.values().iterator();
    while (iter.hasNext()) {
        String value = (String) iter.next();
        size += sizeOfString(value);
    }
    //Add in each key
    iter = map.keySet().iterator();
    while (iter.hasNext()) {
        String key = (String) iter.next();
        size += sizeOfString(key);
    }
    return size;
}

From source file:com.github.sevntu.checkstyle.ordering.MethodOrder.java

private static List<Method> getInitialMethodOrdering(Map<String, Method> methods) {
    return methods.values().stream()
            .sorted((lhs, rhs) -> Integer.compare(lhs.getInitialIndex(), rhs.getInitialIndex()))
            .collect(Collectors.toList());
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadArmors(Map<Integer, Item> armorData) {
    final List<L2Item> list = loadData(armorData, listFiles("data/stats/armor"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());//from   w  w  w  .  j  a v a 2s . c  o m

    for (Item item : armorData.values())
        if (!xmlItem.contains(item.id))
            _log.warn("SkillsEngine: Missing XML side for L2Armor - id: " + item.id);

    return list;
}

From source file:de.bund.bfr.jung.JungUtils.java

private static double getDenominator(Map<?, Double> values) {
    if (values == null || values.isEmpty()) {
        return 1.0;
    }/*w  w  w .  j  a  v a 2  s. c  om*/

    double max = Collections.max(values.values());

    return max != 0.0 ? max : 1.0;
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadWeapons(Map<Integer, Item> weaponData) {
    final List<L2Item> list = loadData(weaponData, listFiles("data/stats/weapon"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());/*from   w w w.j  a v a 2  s . co m*/

    for (Item item : weaponData.values())
        if (!xmlItem.contains(item.id))
            _log.warn("SkillsEngine: Missing XML side for L2Weapon - id: " + item.id);

    return list;
}

From source file:com.wrmsr.wava.basic.BasicLoopInfo.java

public static Map<Name, Name> getLoopParents(SetMultimap<Name, Name> loopContents) {
    Map<Name, Name> loopParents = new HashMap<>();
    Map<Name, Set<Name>> map = loopContents.keySet().stream()
            .collect(toHashMap(identity(), loop -> new HashSet<>()));
    for (Name cur : loopContents.keySet()) {
        map.get(cur).add(ENTRY_NAME);//from   ww  w  .j av a2s .c  o  m
        Set<Name> children = loopContents.get(cur);
        for (Name child : children) {
            if (!cur.equals(child) && loopContents.containsKey(child)) {
                map.get(child).add(cur);
            }
        }
    }
    Map<Name, Integer> loopDepths = map.entrySet().stream()
            .collect(toHashMap(entry -> entry.getKey(), entry -> entry.getValue().size()));
    loopDepths.put(ENTRY_NAME, 0);
    int maxDepth = loopDepths.values().stream().mapToInt(Integer::intValue).max().orElse(0);
    List<List<Name>> depthLoopsLists = IntStream.range(0, maxDepth + 1).boxed()
            .<List<Name>>map(i -> new ArrayList<>()).collect(toArrayList());
    loopDepths.forEach((loop, depth) -> depthLoopsLists.get(depth).add(loop));
    Set<Name> seen = new HashSet<>();
    for (int depth = 1; depth < depthLoopsLists.size(); ++depth) {
        for (Name loop : depthLoopsLists.get(depth)) {
            Name parent = getOnlyElement(Sets.difference(map.get(loop), seen));
            checkState(loopDepths.get(parent) == depth - 1);
            loopParents.put(loop, parent);
        }
        seen.addAll(depthLoopsLists.get(depth - 1));
    }
    checkState(loopContents.keySet().equals(loopParents.keySet()));
    return loopParents;
}

From source file:com.l2jfree.gameserver.document.DocumentEngine.java

public static List<L2Item> loadItems(Map<Integer, Item> itemData) {
    final List<L2Item> list = loadData(itemData, listFiles("data/stats/etcitem"));

    Set<Integer> xmlItem = new HashSet<Integer>();

    for (L2Item item : list)
        xmlItem.add(item.getItemId());//  w  w w. j a  v a  2  s .  c o m

    for (Item item : itemData.values()) {
        if (!xmlItem.contains(item.id)) {
            try {
                list.add(new L2EtcItem((L2EtcItemType) item.type, item.set));
            } catch (RuntimeException e) {
                _log.warn("Error while parsing item id " + item.id, e);
            }
        }
    }

    return list;
}

From source file:com.tealcube.minecraft.bukkit.mythicdrops.utils.SocketGemUtil.java

public static SocketGem getRandomSocketGemWithChance() {
    Map<String, SocketGem> socketGemMap = MythicDropsPlugin.getInstance().getSockettingSettings()
            .getSocketGemMap();/* w  w w. j  a  v  a2s .  com*/
    if (socketGemMap == null || socketGemMap.isEmpty()) {
        return null;
    }
    double totalWeight = 0;
    for (SocketGem sg : socketGemMap.values()) {
        totalWeight += sg.getChance();
    }

    double chosenWeight = MythicDropsPlugin.getInstance().getRandom().nextDouble() * totalWeight;

    double currentWeight = 0;

    List<SocketGem> l = new ArrayList<>(socketGemMap.values());
    Collections.shuffle(l);

    for (SocketGem sg : socketGemMap.values()) {
        currentWeight += sg.getChance();

        if (currentWeight >= chosenWeight) {
            return sg;
        }
    }
    return null;
}