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
private static void logInConsole(ArrayList<Integer> timePoints) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < timePoints.size(); i++) { sb.append(timePoints.get(i)).append(" "); }//from w ww .ja v a 2 s . com Log.d(TAG, sb.toString()); }
From source file:Main.java
public static void sortAsDouble(ArrayList<String> mylist) { String min = new String(); int len = mylist.size(); for (int i = 0; i < len; i++) { min = mylist.get(i);//from w ww.j ava 2 s . c o m for (int j = i + 1; j < len; j++) { if (compareAsDouble(min, mylist.get(j)) == 1) { mylist.set(i, mylist.get(j)); mylist.set(j, min); min = mylist.get(i); } } } }
From source file:Main.java
public static Node getNodeWithKey(Node parent, String key, String value) { HashSet<String> values = new HashSet<String>(); values.add(value);//from www . j a v a 2 s .c o m ArrayList<Node> nodes = getNodesWithKey(parent, key, values, false); if (nodes.size() < 1) return null; return nodes.get(0); }
From source file:Main.java
/** * Returns a new <code>ArrayList</code> containing only those elements * in <code>origList</code> that are also present in <code>universe</code>. * This method is meant to be a faster alternative to <code>Collection.retainAll</code> * for <code>ArrayList</code> since removal operations take O(n) in <code>ArrayList</code>. * //from w w w. j a v a 2 s . c o m * @param <E> type of element * @param origList original element <code>ArrayList</code> * @param universe <code>Set</code> of all valid elements * @return new <code>ArrayList</code> containing only those elements * in <code>origList</code> that are also present in <code>universe</code> */ public static <E> ArrayList<E> retainAll(ArrayList<E> origList, Set<E> universe) { ArrayList<E> newElms = new ArrayList<E>(origList.size()); for (E elm : origList) { if (universe.contains(elm)) newElms.add(elm); } return newElms; }
From source file:Main.java
public static ArrayList<Double> matrixMinus(ArrayList<Double> a1, ArrayList<Double> a2) { ArrayList<Double> res = new ArrayList<Double>(); for (int i = 0; i < a1.size(); i++) { res.add(a1.get(i) - a2.get(i));/* ww w. ja v a2s . com*/ } return res; }
From source file:Main.java
public static double avg(ArrayList<Integer> list) { double sum = 0; for (int i : list) { sum += i;/*from w ww. j a v a 2 s. c o m*/ } return sum / list.size(); }
From source file:Main.java
public static String gettype(HashMap<String, Object> info) { if (info != null) { ArrayList replies_tree = (ArrayList) info.get("replies_tree"); if (replies_tree != null && replies_tree.size() > 0) { HashMap<String, Object> answers = (HashMap<String, Object>) replies_tree.get(0); if (answers != null) { ArrayList classes = (ArrayList) answers.get("answer"); if (classes != null) { HashMap<String, Object> class1 = (HashMap<String, Object>) classes.get(0); if (class1 != null) { return class1.get("type").toString(); }/* w ww. j a v a 2s . c o m*/ } } } } return null; }
From source file:Main.java
/** * Subtract to vectors.//from w ww . j a v a2 s.com * The size of v1 and v2 must be equal. * * @param v1 ArrayList with double values. * @param v2 ArrayList with double values. * @return new vector form v1 and v2. */ public static ArrayList<Double> subtractVector(ArrayList<Double> v1, ArrayList<Double> v2) { ArrayList<Double> returnValue = new ArrayList<>(); if (v1.size() == v2.size()) { for (int i = 0; i < v1.size(); i++) { returnValue.add(v1.get(i) - v2.get(i)); } } return returnValue; }
From source file:com.asual.summer.core.util.BeanUtils.java
public static <T> T getBeanOfType(ConfigurableListableBeanFactory beanFactory, Class<T> clazz) { Map<String, T> beans = beanFactory.getBeansOfType(clazz); ArrayList<T> values = new ArrayList<T>(beans.values()); if (values.size() != 0) { OrderComparator.sort(values);// www . j a va 2 s .co m return values.get(0); } return null; }
From source file:co.edu.UNal.ArquitecturaDeSoftware.Bienestar.Vista.Util.java
public static void errordeRespuesta(ArrayList r, PrintWriter out) { System.err.print(/*from w w w .j a va2 s . c o m*/ "Respuesta inesperada del control !! r.size:" + r.size() + "|r0:" + r.get(0) + "|r1:" + r.get(1)); JSONObject obj = new JSONObject(); obj.put("isError", true); obj.put("errorDescrip", "Error inesperado"); out.print(obj); }