List of usage examples for java.util LinkedList add
public boolean add(E e)
From source file:Main.java
/** * Returns a list of the direct {@link Element} children of the given element whose names match * {@code tag}.//from w ww. ja va2s. c o m * * @param parent * The {@link Element} to get the children from. * @param tag * The element name of the children to look for. * @return A {@link LinkedList} of the children {@link Element}s. */ public static LinkedList<Element> getDirectChildren(Element parent, String tag) { LinkedList<Element> list = new LinkedList<>(); for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) { if (child instanceof Element && tag.equals(child.getNodeName())) { list.add((Element) child); } } return list; }
From source file:org.jboss.aerogear.sync.diffmatchpatch.client.DiffMatchPatchClientSynchronizer.java
private static LinkedList<DiffMatchPatch.Diff> asDiffUtilDiffs(final LinkedList<DiffMatchPatchDiff> diffs) { final LinkedList<DiffMatchPatch.Diff> dsf = new LinkedList<DiffMatchPatch.Diff>(); for (DiffMatchPatchDiff d : diffs) { dsf.add(DiffMatchPatch.diff(diffutilOp(d.operation()), d.text())); }/* w w w .j a v a2 s .com*/ return dsf; }
From source file:com.emacs.xpets.utils.Utils.java
public static LinkedList<String> parseJsonArrayToStringSet(JSONArray array) { LinkedList<String> values = new LinkedList<String>(); for (int i = 0; i < array.length(); i++) { try {/*from www .ja v a 2s .c o m*/ values.add(array.getString(i)); } catch (JSONException e) { e.printStackTrace(); } } return values; }
From source file:fi.smaa.libror.MaximalVectorComputation.java
private static LinkedList<Integer> matrixToListOfIndices(RealMatrix mat) { LinkedList<Integer> list = new LinkedList<Integer>(); for (int i = 0; i < mat.getRowDimension(); i++) { list.add(i); }//from www .ja v a 2s . com return list; }
From source file:Main.java
public static Collection extractField(Collection in, String fieldName, Class type) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Iterator<Object> it = in.iterator(); boolean isBoolean = (type == Boolean.class || type == boolean.class); String methodName = (isBoolean) ? "is" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1) //$NON-NLS-1$ : "get" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); //$NON-NLS-1$ LinkedList<Object> out = new LinkedList<Object>(); while (it.hasNext()) { Object obj = it.next();/*from www .j av a2 s . c o m*/ Method m = obj.getClass().getMethod(methodName, new Class[] {}); Object value2 = m.invoke(obj, null); out.add(value2); } return out; }
From source file:Main.java
public static LinkedList<Integer> retrieveIntegerFromCursor(Cursor cursor, String columnName) { if (null == cursor || 0 == cursor.getCount()) { return new LinkedList<Integer>(); }//from w w w . j a va 2s .co m LinkedList<Integer> ids = new LinkedList<Integer>(); try { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { int id = cursor.getInt(cursor.getColumnIndexOrThrow(columnName)); ids.add(new Integer(id)); } } catch (Exception e) { //do nothing. } finally { cursor.close(); } return ids; }
From source file:org.jboss.aerogear.sync.diffmatchpatch.client.DiffMatchPatchClientSynchronizer.java
private static LinkedList<DiffMatchPatchDiff> asAeroGearDiffs(final LinkedList<DiffMatchPatch.Diff> diffs) { final LinkedList<DiffMatchPatchDiff> syncDiffs = new LinkedList<DiffMatchPatchDiff>(); for (DiffMatchPatch.Diff diff : diffs) { syncDiffs.add(new DiffMatchPatchDiff(aerogearOp(diff.operation), diff.text)); }// w ww. j av a2 s .c o m return syncDiffs; }
From source file:fi.smaa.libror.MaximalVectorComputation.java
private static LinkedList<RealVector> matrixToListOfRows(RealMatrix mat) { LinkedList<RealVector> list = new LinkedList<RealVector>(); for (int i = 0; i < mat.getRowDimension(); i++) { list.add(mat.getRowVector(i)); }/*from w ww.j a va2 s . c om*/ return list; }
From source file:Main.java
public static Collection invokeForEach(Collection in, String methodName, Object[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Iterator<Object> it = in.iterator(); Class[] argsClasses = new Class[args.length]; for (int i = 0; i < args.length; i++) argsClasses[i] = args[i].getClass(); LinkedList<Object> out = new LinkedList<Object>(); while (it.hasNext()) { Object obj = it.next();//w w w .ja v a 2 s. c o m Method m = obj.getClass().getMethod(methodName, argsClasses); Object value2 = m.invoke(obj, args); out.add(value2); } return out; }
From source file:eu.stratosphere.test.operators.MapITCase.java
@Parameters public static Collection<Object[]> getConfigurations() throws FileNotFoundException, IOException { LinkedList<Configuration> testConfigs = new LinkedList<Configuration>(); Configuration config = new Configuration(); config.setInteger("MapTest#NoSubtasks", 4); testConfigs.add(config); return toParameterList(testConfigs); }