List of usage examples for java.util LinkedList LinkedList
public LinkedList()
From source file:Main.java
public static LinkedList<String> uc_unserialize(String input) { LinkedList<String> result = new LinkedList<String>(); DOMParser parser = new DOMParser(); try {/*from w ww . j a v a 2 s .com*/ parser.parse(new InputSource(new StringReader(input))); Document doc = parser.getDocument(); NodeList nl = doc.getChildNodes().item(0).getChildNodes(); int length = nl.getLength(); for (int i = 0; i < length; i++) { if (nl.item(i).getNodeType() == Document.ELEMENT_NODE) result.add(nl.item(i).getNodeValue()); } } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result; }
From source file:Main.java
public static LinkedList<String> uc_unserialize(String input) { LinkedList<String> result = new LinkedList<String>(); DOMParser parser = new DOMParser(); try {/*from ww w .j a v a 2 s . c om*/ parser.parse(new InputSource(new StringReader(input))); Document doc = parser.getDocument(); NodeList nl = doc.getChildNodes().item(0).getChildNodes(); int length = nl.getLength(); for (int i = 0; i < length; i++) { if (nl.item(i).getNodeType() == Document.ELEMENT_NODE) result.add(nl.item(i).getTextContent()); } } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result; }
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]);/* www . java 2 s .c o m*/ } return result; }
From source file:Main.java
public static LinkedList<String> uc_unserialize(String input) { LinkedList<String> result = new LinkedList<String>(); DOMParser parser = new DOMParser(); try {/*from w ww .j ava 2s .com*/ parser.parse(new InputSource(new StringReader(input))); Document doc = parser.getDocument(); NodeList nl = doc.getChildNodes().item(0).getChildNodes(); int length = nl.getLength(); for (int i = 0; i < length; i++) { if (nl.item(i).getNodeType() == Document.ELEMENT_NODE) result.add(nl.item(i).getFirstChild().getNodeValue()); } } catch (SAXException e) { } catch (IOException e) { } return result; }
From source file:Main.java
public static List<String> javaClassToSmali(Class<?>[] classes) { List<String> smaliNames = new LinkedList<String>(); for (Class<?> klazz : classes) { smaliNames.add(javaClassToSmali(klazz)); }/*w w w . j a v a 2 s . com*/ return smaliNames; }
From source file:Main.java
public static String getUserEmailOnDevice(Context ctx) { AccountManager manager = AccountManager.get(ctx); Account[] accounts = manager.getAccountsByType("com.google"); List<String> possibleEmails = new LinkedList<String>(); for (Account account : accounts) { // TODO: Check possibleEmail against an email regex or treat // account.name as an email address only for certain account.type // values. possibleEmails.add(account.name); }/*from w ww .jav a2 s . c om*/ if (!possibleEmails.isEmpty() && possibleEmails.get(0) != null) { String email = possibleEmails.get(0); String[] parts = email.split("@"); if (parts.length > 0 && parts[0] != null) return email; else return null; } else return null; }
From source file:Main.java
public synchronized static float[] parseFloatList(String list) { if (list == null) return null; fpMatch.reset(list);/*from ww w. j av a 2 s .c o 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
/** * Find all descendant elements with a given name, for a parent element. * @param e/*from w w w.j a v a2s . com*/ * @param name * @return */ public static List<Element> findDescendantsByName(Element e, String name) { List<Element> result = new LinkedList<Element>(); findDescendantsByName(e, name, result); return result; }
From source file:Main.java
/** * Merge lists//from w ww. j a va 2 s . c om * @param first - List * @param second - List * @param <T> - Object class * @return - List */ public static <T> List<T> mergeLists(List<T> first, List<T> second) { Map<T, T> dataMap = listToMap(first); for (T object : second) { dataMap.put(object, object); } List<T> resultObject = new LinkedList<T>(); for (T object : dataMap.keySet()) { resultObject.add(object); } return resultObject; }
From source file:Main.java
/** * Get files of directory you passed. The files contains files of passed directory's sub directory by recursive exploring. *///from w w w.java2s.c om public static List<File> getAllFiles(File directory) { final List<File> fileList = new LinkedList<File>(); final File[] files = directory.listFiles(); if (files == null) return fileList; for (File file : files) { if (file.isDirectory()) fileList.addAll(getAllFiles(file)); else fileList.add(file); } return fileList; }