List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:Main.java
public static <T> LinkedList<T> toList(T[] array) { LinkedList<T> result = new LinkedList<T>(); for (int i = 0; i < array.length; i++) { result.add(array[i]); }//from www .java 2 s. c o m return result; }
From source file:Main.java
public static LinkedList<Byte> toList(byte[] array) { LinkedList<Byte> resList = new LinkedList<Byte>(); for (int i = 0; i < array.length; i++) { resList.add(array[i]); }/*from ww w . ja v a 2 s. c om*/ return resList; }
From source file:Main.java
public static LinkedList<byte[]> eatUpJavaHeap(LinkedList<byte[]> list, int eatUpSize, int atomSize) { try {// w ww .j a v a 2 s . c om while (list.size() * atomSize < eatUpSize) { list.add(new byte[atomSize]); } } catch (Throwable t) { t.printStackTrace(); } finally { } return list; }
From source file:Main.java
public static LinkedList<String> getAniosVigencia() { Calendar c = Calendar.getInstance(); int anio = c.get(Calendar.YEAR); LinkedList<String> anios = new LinkedList<String>(); int amount = anio + 7; for (int i = anio; i < amount; i++) { anios.add("" + i); }//from ww w .j a v a 2s. com return anios; }
From source file:net.codestory.http.templating.helpers.EachReverseHelperSource.java
private static <T> Iterator<T> reverse(Iterable<T> values) { LinkedList<T> reversed = new LinkedList<>(); for (T value : values) { reversed.add(value); }//w w w. j a v a2 s .c o m return reversed.descendingIterator(); }
From source file:Main.java
/** * Converts an Iterable into a List that can be navigated in ways other than * simple iteration. If the underlying implementation of the Iterable is a * List, it is cast to List and returned. Otherwise it is iterated and the * items placed, in order, into a new List. * /*from w ww. ja va 2s . c o m*/ * @param in * an Iterable to serve as the source for a List * @return either the Iterable itself if it is a List, or a new List with * the same elements */ public static <T> List<T> asList(Iterable<T> in) { if (in instanceof List<?>) return (List<T>) in; else { LinkedList<T> list = new LinkedList<T>(); for (T item : in) { list.add(item); } return list; } }
From source file:Main.java
public static <T, V extends T> LinkedList<T> createLinkedList(V... args) { LinkedList<T> list = new LinkedList<T>(); if (args != null) { for (V v : args) { list.add(v); }/*from w w w. j a v a 2 s . c om*/ } return list; }
From source file:Main.java
public synchronized static float[] parseFloatList(String list) { if (list == null) return null; fpMatch.reset(list);//from www .j av a 2 s .co m LinkedList<Float> floatList = new LinkedList<Float>(); while (fpMatch.find()) { String val = fpMatch.group(1); floatList.add(Float.valueOf(val)); } float[] retArr = new float[floatList.size()]; Iterator<Float> it = floatList.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = ((Float) it.next()).floatValue(); } return retArr; }
From source file:Main.java
public static int[] parseIntList(String list) { if (list == null) return null; intMatch.reset(list);/*www. ja va 2s . c o m*/ LinkedList<Integer> intList = new LinkedList<Integer>(); while (intMatch.find()) { String val = intMatch.group(); intList.add(Integer.valueOf(val)); } int[] retArr = new int[intList.size()]; Iterator<Integer> it = intList.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = ((Integer) it.next()).intValue(); } return retArr; }
From source file:Main.java
/** * Scans an input string for double values. For each value found, places * in a list. This method regards any characters not part of a floating * point value to be seperators. Thus this will parse whitespace seperated, * comma seperated, and many other separation schemes correctly. */// ww w. ja va 2s .c o m public synchronized static double[] parseDoubleList(String list) { if (list == null) return null; fpMatch.reset(list); LinkedList<Double> doubList = new LinkedList<Double>(); while (fpMatch.find()) { String val = fpMatch.group(1); doubList.add(Double.valueOf(val)); } double[] retArr = new double[doubList.size()]; Iterator<Double> it = doubList.iterator(); int idx = 0; while (it.hasNext()) { retArr[idx++] = ((Double) it.next()).doubleValue(); } return retArr; }