Example usage for java.util Map keySet

List of usage examples for java.util Map keySet

Introduction

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

Prototype

Set<K> keySet();

Source Link

Document

Returns a Set view of the keys contained in this map.

Usage

From source file:Main.java

public static int getKeyMaxSize(Map<String, ?> map) {

    int maxLength = 0;

    for (String key : map.keySet()) {

        if (key != null && key.length() > maxLength) {

            maxLength = key.length();//from   ww w .  j a  v  a2s. co m
        }
    }

    return maxLength;
}

From source file:Main.java

/***
 *
 * @param pressingLength model's length of pause between clicks (x)
 * @return Mx's values List, for My use ALPHA = 1
 *//*from  w w  w  . ja v a 2s.com*/
private static double M(Map<String, Long> pressingLength) {
    double x = 0;
    for (String key : pressingLength.keySet()) {
        x += pressingLength.get(key);
    }
    return x / pressingLength.size();
}

From source file:Main.java

public static String printMap(Map in) {
    StringBuilder sb = new StringBuilder();
    for (Iterator it = in.keySet().iterator(); it.hasNext();) {
        String key = (String) it.next();
        sb.append(key).append(" : ").append(in.get(key));
        sb.append("\n");
    }//from  w  w  w. j  a va2s  . c  om

    return sb.toString();
}

From source file:Main.java

public static String getKeyWithMaxValue(final Map<String, Double> pMap) {
    final Set<String> tempSet = pMap.keySet();
    final Iterator<String> iter = tempSet.iterator();
    double max = Integer.MIN_VALUE;
    String maxValsKey = "";
    String temp = "";
    while (iter.hasNext()) {
        temp = iter.next();//  w w w.  j a va2 s  .  c  om
        if (pMap.get(temp) > max) {
            max = pMap.get(temp);
            maxValsKey = temp;
        }
    }
    return maxValsKey + "\t" + max;
}

From source file:Main.java

public static Bundle mapToBundle(Map<String, String> map) {
    Bundle bundle = new Bundle();
    for (String key : map.keySet()) {
        bundle.putString(key, map.get(key));
    }//w  w  w  .j a  va 2  s. c  om
    return bundle;
}

From source file:Main.java

public static String suggest(Map map/*<String, Object>*/, String prefix, boolean key) {
    return suggest(key ? map.keySet() : map.values(), prefix);
}

From source file:Main.java

public static Bundle toBundle(Map<String, String> input) {
    Bundle output = new Bundle();
    for (String key : input.keySet()) {
        output.putString(key, input.get(key));
    }/*from  w w  w. ja  v a 2 s  .co  m*/
    return output;
}

From source file:Main.java

/**
 * @param mathExpectation math expectation for full list
 * @return dispersion on full array//from w ww . j av a2 s.  c om
 */
private static double dispersionForFull(double mathExpectation, Map<String, Long> pressingLength) {
    double sum = 0.0;
    for (String key : pressingLength.keySet()) {
        double x = pressingLength.get(key) - mathExpectation;
        sum += x * x;
    }
    return sqrt(sum / (pressingLength.size() - 1));
}

From source file:Main.java

public static void scaleBitmaps(Map<Integer, Bitmap> bitmapMap, float scale) {
    for (Integer key : bitmapMap.keySet()) {
        Bitmap bitmap = bitmapMap.get(key);
        bitmapMap.put(key, scaleBitmap(bitmap, scale));
    }/* w w w.  j av a  2 s.c  om*/
}

From source file:Main.java

public static <T> List<T> convertMapToList(Map<?, T> map) {
    List list = new ArrayList();
    for (Iterator localIterator = map.keySet().iterator(); localIterator.hasNext();) {
        Object o = localIterator.next();
        list.add(map.get(o));//w w  w  .  ja v  a  2  s  .c  o  m
    }
    return list;
}