List of usage examples for java.util LinkedList LinkedList
public LinkedList(Collection<? extends E> c)
From source file:Main.java
public static List<Map.Entry<Long, Long>> sortEntrySetToList(Set<Map.Entry<Long, Long>> set) { List<Map.Entry<Long, Long>> list = new LinkedList<>(set); Collections.sort(list, new Comparator<Map.Entry<Long, Long>>() { @Override/* w ww.java 2 s .c o m*/ public int compare(Map.Entry<Long, Long> o1, Map.Entry<Long, Long> o2) { if (o1.getValue() > o2.getValue()) { return 1; } if (o1.getValue() < o2.getValue()) { return -1; } return 0; } }); return list; }
From source file:Main.java
public static List<Entry<Long, Long>> sortEntrySetToList(Set<Entry<Long, Long>> set) { List<Entry<Long, Long>> list = new LinkedList<>(set); Collections.sort(list, new Comparator<Entry<Long, Long>>() { @Override// www . j a va 2 s .c o m public int compare(Entry<Long, Long> o1, Entry<Long, Long> o2) { if (o1.getValue() > o2.getValue()) { return 1; } if (o1.getValue() < o2.getValue()) { return -1; } return 0; } }); return list; }
From source file:Main.java
public static <T> LinkedList<T> newLinkedList(Collection<T> initData) { return new LinkedList<T>(initData); }
From source file:Main.java
public static double getSumValue(HashMap<String, Double> map) { Double count = 0.0D;// ww w . ja va 2 s .c o m List list = new LinkedList(map.entrySet()); for (Iterator it = list.iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); count += map.get(entry.getKey()); } return count; }
From source file:Main.java
public static <E> LinkedList<E> getLinkedList(Collection<? extends E> collection) { return new LinkedList<E>(collection); }
From source file:Main.java
public static double readHashTopValue(HashMap<String, Integer> scores, int k) { List<Map.Entry<String, Integer>> list = new LinkedList<Map.Entry<String, Integer>>(scores.entrySet()); int count = 0; int value = 0; double res = 0; for (Iterator<Map.Entry<String, Integer>> it = list.iterator(); count < k && it.hasNext();) { Map.Entry<String, Integer> entry = (Map.Entry<String, Integer>) it.next(); value = (Integer) entry.getValue(); res += (double) value * Math.log(2) / Math.log(count + 2); // res += (Integer) entry.getValue(); count++;//from ww w .j a v a2 s .c o m } return res; }
From source file:Main.java
public static Map<String, Integer> sortByValue(Map<String, Integer> map) { List list = new LinkedList(map.entrySet()); Collections.sort(list, new Comparator() { @Override/* w w w . j ava 2 s. c om*/ public int compare(Object o1, Object o2) { return ((Comparable) ((Map.Entry) (o2)).getValue()).compareTo(((Map.Entry) (o1)).getValue()); } }); Map result = new LinkedHashMap(); for (Iterator it = list.iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); result.put(entry.getKey(), entry.getValue()); } return result; }
From source file:Main.java
/**** * LinkedList//from www . j av a 2 s .co m * @return */ public static <T> List<T> newLinkedList(Collection<T> collection) { return new LinkedList<T>(collection); }
From source file:Main.java
public static List<Integer> sort(List<Integer> aList) { List<Integer> tmp = new LinkedList<>(aList); Collections.sort(tmp);//from www . j a v a 2 s . co m return tmp; }
From source file:Main.java
public static List createList(Object[] items) { List list = new LinkedList(Arrays.asList(items)); return list; }