List of usage examples for java.util ArrayList get
public E get(int index)
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 av a2 s .c om "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); }
From source file:Main.java
private static boolean[] toBooleanArray(ArrayList<Boolean> arrayList) { boolean[] ret = new boolean[arrayList.size()]; for (int i = 0; i < ret.length; i++) { ret[i] = arrayList.get(i); }/*from w w w . j av a 2 s . c om*/ return ret; }
From source file:Main.java
static public int[] toIntArray(ArrayList list) { int[] result = new int[list.size()]; for (int i = 0; i < list.size(); i++) { Number n = (Number) list.get(i); result[i] = n.intValue();//w ww . j a va2 s.co m } return result; }
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);//from w w w . ja v a2 s .com } } return returnValue; }
From source file:Main.java
public static int countCommElmts(ArrayList<Integer> newScores1, ArrayList<Integer> newScores2) { int count = 0; for (int i = 0; i < newScores1.size(); i++) { if (newScores1.get(i) == newScores2.get(i)) count++;//from w ww . j a v a2s.c o m } return count; }
From source file:Main.java
public static String arrayListToCsv(ArrayList<String> values) { StringBuilder csv = new StringBuilder(); for (int i = 0; i < values.size(); i++) { csv.append(values.get(i)); if (i < values.size() - 1) { csv.append(","); }/* w ww . j a v a2 s. co m*/ } return csv.toString(); }
From source file:Main.java
public static <T> int floor(ArrayList<T> list, T key, Comparator<? super T> c) { if (c.compare(list.get(0), key) > 0) { return -1; }//www .j av a 2s . c om if (c.compare(list.get(list.size() - 1), key) <= 0) { return list.size() - 1; } int start = 0, end = list.size() - 1, res; T mid; while (start < end - 1) { mid = list.get((start + end) / 2); res = c.compare(mid, key); // System.out.println("res = " + res); // System.out.println("mid = " + mid); if (res > 0) { end = (start + end) / 2; } else { start = (start + end) / 2; } // System.out.println("start = " + start); // System.out.println("end = "+ end); } res = c.compare(list.get(end), key); if (res > 0) { return start; } else { if (res == 0) { return end; } else { 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:com.hackathon.gavin.currency.event.CurrencyEventCreater.java
/** * This method is used to create currency object from parser * return CurrencyEvent//ww w . j a v a 2s. co m */ public static CurrencyEvent createCurrencyEvent() throws ParseException { JSONArray jSONArray = CurrencyRateParser.httpGetCall(API_URL, "prices"); ArrayList arrayList = CurrencyRateParser.convertToArrayList(jSONArray); String INSTRUMENT = arrayList.get(0).toString(); Date CURRENTTIME = parseRFC3339Date(arrayList.get(1).toString()); double BID = Double.valueOf(arrayList.get(2).toString()); double ASK = Double.valueOf(arrayList.get(3).toString()); CurrencyEvent currencyEvent = new CurrencyEvent(INSTRUMENT, CURRENTTIME, BID, ASK); return currencyEvent; }
From source file:Main.java
public static float[] toFloatArray(ArrayList<Float> floats) { float returner[] = new float[floats.size()]; for (int i = 0; i < returner.length; i++) { returner[i] = floats.get(i); }/* w ww. j a va 2 s. co m*/ return returner; }