List of usage examples for java.util ArrayList size
int size
To view the source code for java.util ArrayList size.
Click Source Link
From source file:Main.java
public static int indexOf(Object o, ArrayList<Object> elementData) { if (o == null) { for (int i = 0; i < elementData.size(); i++) if (elementData.get(i) == null) return i; } else {//from w w w .j ava 2 s . c o m for (int i = 0; i < elementData.size(); i++) if (o.equals(elementData.get(i))) return i; } return -1; }
From source file:Main.java
public static Node getNodeWithName(Node parent, String name) { ArrayList<Node> nodes = getNodesWithName(parent, name, false); if (nodes.size() < 1) return null; return nodes.get(0); }
From source file:Main.java
public static double computeDistance(ArrayList<Double> d1, ArrayList<Double> d2) { double squareSum = 0; for (int i = 0; i < d1.size() - 1; i++) { squareSum += (d1.get(i) - d2.get(i)) * (d1.get(i) - d2.get(i)); }/*from w w w . j a v a 2 s.c o m*/ return Math.sqrt(squareSum); }
From source file:Main.java
public static String getCommaSeparatedStringFromArray(ArrayList list) { StringBuilder result = new StringBuilder(); for (int i = 0; i < list.size(); i++) { result.append(list.get(i));/*from w w w .ja v a2 s.c o m*/ result.append(","); } return result.length() > 0 ? result.substring(0, result.length() - 1) : ""; }
From source file:Main.java
/** *//* www .j a v a2 s . co m*/ public static Element getElement(String name, int index, Element parent) { ArrayList<Element> toReturn = getElementsByTag(name, parent); if (index > toReturn.size() - 1) { return null; } return toReturn.get(index); }
From source file:Main.java
/** * Devuelve true si las dos ArrayList que se le pasan como parametro son * iguales./*w ww. j a v a2 s . com*/ * * @param n * lista anterior * @param l * lista actual * * @return true si los ArrayList son iguales. */ public static boolean isEqualList(ArrayList n, ArrayList l) { if (n.size() != l.size()) { return false; } for (int i = 0; i < n.size(); i++) { if (l.get(i) != n.get(i)) { return false; } } return true; }
From source file:Main.java
public static Element getChildElement(Element parent, String childName) { ArrayList<Element> childElements = getChildElements(parent, childName); return childElements.size() > 0 ? childElements.get(0) : null; }
From source file:Main.java
public static ArrayList<Double> normalizeVector(ArrayList<Double> vector) { ArrayList<Double> returnValue = new ArrayList<>(); if (vector.size() > 0) { Double first = vector.get(0); for (Double d : vector) { returnValue.add(d - first);/* www. j a va 2 s.c o m*/ } } return returnValue; }
From source file:Main.java
private static <T> boolean removeAllFromArrayList(ArrayList<T> collection, Collection<?> toRemove) { boolean result = false; for (int i = collection.size(); --i >= 0;) if (toRemove.contains(collection.get(i))) { collection.remove(i);/*from www . j a v a 2s .c o m*/ result = true; } return result; }
From source file:Main.java
public static String getCommandList(ArrayList<String> commands) { if (commands == null || commands.size() == 0) { return ""; }//from ww w.j ava 2 s.c o m StringBuilder sb = new StringBuilder(); for (String commandPattern : commands) { String[] cmdSplit = commandPattern.split("~"); if (cmdSplit.length != 3) { Log.e("DebugGhost", "Cannot read command pattern '" + commandPattern + "', skipping ..."); continue; } if (cmdSplit[2].contains("[") == true && cmdSplit[2].contains("]") == true) { continue; } sb.append( "<button type=\"button\" style=\"margin-bottom: 5px;\" class=\"btn btn-default\" onclick=\"postCommand('/commands/"); sb.append(cmdSplit[1]); sb.append("','"); sb.append(cmdSplit[2]); sb.append("');\">"); sb.append(cmdSplit[0]); sb.append("</button>"); } return sb.toString(); }