Example usage for java.util LinkedHashMap LinkedHashMap

List of usage examples for java.util LinkedHashMap LinkedHashMap

Introduction

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

Prototype

public LinkedHashMap() 

Source Link

Document

Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

Usage

From source file:Main.java

public static <K, V> LinkedHashMap<K, V> linkedHashMap() {
    return new LinkedHashMap<K, V>();
}

From source file:Main.java

public static final <K, V> Map<K, V> newLinkedHashMap() {
    return new LinkedHashMap<K, V>();
}

From source file:Main.java

public static Map<String, String> getParamsMap() {
    Map<String, String> paramsmap = new LinkedHashMap<String, String>();
    return paramsmap;
}

From source file:Main.java

public static <E, V> Map<E, V> newBoundedMap(final int maxSize) {
    return new LinkedHashMap<E, V>() {
        private static final long serialVersionUID = 1L;

        protected boolean removeEldestEntry(Map.Entry eldest) {
            return this.size() > maxSize;
        }/*  ww w.  j a  v  a  2 s  . c o  m*/
    };
}

From source file:Main.java

public static <K, V> LinkedHashMap<K, V> createLinkedHashMap() {
    return new LinkedHashMap<K, V>();
}

From source file:Main.java

public static <T> LinkedHashMap<String, T> arraryToLinkedHashMap(T[] itemsArray) {
    LinkedHashMap<String, T> map = new LinkedHashMap<String, T>();
    T[] arrayOfObject = itemsArray;/*from   w ww .  j a va  2 s.  c o m*/
    int j = itemsArray.length;
    for (int i = 0; i < j; i++) {
        T s = arrayOfObject[i];
        map.put(s.toString(), s);
    }
    return map;
}

From source file:Main.java

@SuppressWarnings("unchecked")
static public LinkedHashMap invertOrdering(LinkedHashMap passedMap) {
    LinkedHashMap result = new LinkedHashMap();
    Object[] keys = passedMap.keySet().toArray();
    for (int i = keys.length - 1; i >= 0; i--)
        result.put(keys[i], passedMap.get(keys[i]));
    return result;
}

From source file:Main.java

public static Map<String, String> toMapOfStrings(final String[] tokens) {
    final Map<String, String> result = new LinkedHashMap<String, String>();
    if (null != tokens) {
        for (String token : tokens) {
            final String[] items = token.split("=");
            final String key;
            final String value;
            if (items.length == 1) {
                key = items[0].trim();/*  www  .  j  a v a  2 s. c o m*/
                value = "";
            } else if (items.length == 2) {
                key = items[0].trim();
                value = items[1].trim();
            } else {
                continue;
            }
            result.put(key, value);
        }
    }
    return result;
}

From source file:Main.java

static String getPinMapping(String pin) {
    if (pinMapping == null) {
        pinMapping = new LinkedHashMap<String, String>();
        pinMapping.put("4", "7");
        pinMapping.put("17", "0");
        pinMapping.put("18", "1");
        pinMapping.put("21", "2");
        pinMapping.put("22", "3");
        pinMapping.put("23", "4");
        pinMapping.put("24", "5");
        pinMapping.put("25", "6");
        pinMapping.put("27", "2");
        pinMapping.put("28", "17");
        pinMapping.put("29", "18");
        pinMapping.put("30", "19");
        pinMapping.put("31", "20");
    }//from w ww  . j a  v  a2s  .  com
    return pinMapping.get(pin);
}

From source file:Main.java

private static Map attrbiuteToMap(NamedNodeMap attributes) {
    if (attributes == null)
        return new LinkedHashMap();
    Map result = new LinkedHashMap();
    for (int i = 0; i < attributes.getLength(); i++) {
        result.put(attributes.item(i).getNodeName(), attributes.item(i).getNodeValue());
    }//from   ww w.  j a va  2  s.c  om
    return result;
}