List of usage examples for java.util TreeMap TreeMap
public TreeMap()
From source file:Main.java
public static String getBuildInformationAsString() { SortedMap<String, String> keysToValues = new TreeMap<String, String>(); for (String buildField : BUILD_FIELDS) { putKeyValue(Build.class, buildField, keysToValues); }/*w w w.j a v a 2s . c o m*/ for (String buildVersionField : BUILD_VERSION_FIELDS) { putKeyValue(Build.VERSION.class, buildVersionField, keysToValues); } StringBuilder stringBuilder = new StringBuilder(); for (Entry<String, String> entry : keysToValues.entrySet()) { stringBuilder.append(entry.getKey()).append(": ").append(entry.getValue()).append('\n'); } return stringBuilder.toString(); }
From source file:edu.csun.ecs.cs.multitouchj.application.whiteboard.Whiteboard.java
public static void main(String[] args) { LinkedList<String> arguments = new LinkedList<String>(); for (String argument : args) { arguments.add(argument);//from w w w . ja v a 2 s . c o m } TreeMap<String, String> parameters = new TreeMap<String, String>(); if (arguments.contains("-ix")) { parameters.put(ObjectObserverMoteJ.Parameter.InverseX.toString(), ""); } if (arguments.contains("-iy")) { parameters.put(ObjectObserverMoteJ.Parameter.InverseY.toString(), ""); } Whiteboard whiteboard = new Whiteboard(); whiteboard.run(parameters); }
From source file:Main.java
/** * @deprecated Will be removed in Scout 5.0. Use {@link #copySortedMap(SortedMap)} if required. */// w w w . j a v a 2 s . c o m @Deprecated public static <T, U> SortedMap<T, U> getEmptySortedMap(SortedMap<T, U> m) { return new TreeMap<T, U>(); }
From source file:Main.java
public static <T extends Comparable, U> SortedMap<T, U> putAllObjectsSortedMap(SortedMap<T, U> targetMap, Map<T, U> sourceMap) { if (targetMap == null && sourceMap == null) { return new TreeMap<T, U>(); }//from ww w.j a va 2s . c o m if (targetMap == null) { return new TreeMap<T, U>(sourceMap); } if (sourceMap == null) { return targetMap; // nothing to add } targetMap.putAll(sourceMap); return targetMap; }
From source file:Main.java
public static <K, V> Map<K, V> newTreeMap() { return new TreeMap<K, V>(); }
From source file:Main.java
public static <K, V> TreeMap<K, V> newTreeMap() { return new TreeMap<K, V>(); }
From source file:Main.java
/** * Converts the given pair of arrays into a map that maps each keys[i] to * the corresponding values[i]./* w w w . ja va2s . c om*/ * @return the map (empty map if keys == null or values == null) */ public static <K extends Comparable<? super K>, V> Map<K, V> asMapSorted(List<K> keys, List<V> values) { Map<K, V> map = new TreeMap<K, V>(); if (keys == null || values == null) { return map; } for (int i = 0, len = Math.min(keys.size(), values.size()); i < len; i++) { map.put(keys.get(i), values.get(i)); } return map; }
From source file:com.kixeye.chassis.bootstrap.configuration.Configurations.java
public static Map<String, ?> asMap(Configuration configuration) { Map<String, Object> config = new TreeMap<>(); Iterator<String> keys = configuration.getKeys(); while (keys.hasNext()) { String key = keys.next(); config.put(key, configuration.getProperty(key)); }//from ww w . j a va 2 s .c om return config; }
From source file:Main.java
public static <T, K, V> TreeMap<K, List<V>> groupToTreeMap(Collection<T> collection, Function<T, K> keyFunc, Function<T, V> valueFunc) { TreeMap<K, List<V>> map = new TreeMap<>(); groupToMap(map, collection, keyFunc, valueFunc); return map;/*w ww.j av a2 s . c o m*/ }
From source file:Main.java
/** * Gather all the namespaces defined on a node * * @return/* ww w . j a va2s .co m*/ */ public static Iterable<Entry<String, String>> getNamespaces(Element element) { TreeMap<String, String> map = new TreeMap<String, String>(); do { NamedNodeMap attributes = element.getAttributes(); for (int i = 0; i < attributes.getLength(); i++) { Attr attr = (Attr) attributes.item(i); final String name = attr.getLocalName(); if (attr.getPrefix() != null) { if ("xmlns".equals(attr.getPrefix())) if (!map.containsKey(name)) map.put(name, attr.getValue()); } else if ("xmlns".equals(name)) { if (!map.containsKey("")) map.put("", attr.getValue()); } } if (element.getParentNode() == null || element.getParentNode().getNodeType() != Node.ELEMENT_NODE) break; element = (Element) element.getParentNode(); } while (true); return map.entrySet(); }