List of usage examples for java.util ArrayList get
public E get(int index)
From source file:com.acmeair.loader.FlightLoader.java
static private boolean alreadyInCollection(String airportCode, ArrayList<AirportCodeMapping> airports) { for (int ii = 0; ii < airports.size(); ii++) { if (airports.get(ii).getAirportCode().equals(airportCode)) { return true; }// w w w .ja v a2 s. com } return false; }
From source file:br.edu.ufcg.supervisor.engine.Simulation.java
private static String getShortestPath(ArrayList<String> array) { if (array.size() == 0) { return ""; }// w w w. j av a 2 s . co m int minimo = array.get(0).split(".").length; int qtd; int indexMenorCaminho = 0; for (int i = 1; i < array.size(); i++) { qtd = array.get(i).split(".").length; if (qtd < minimo) { minimo = qtd; indexMenorCaminho = i; } } return array.get(indexMenorCaminho); }
From source file:com.readystatesoftware.simpl3r.utils.SharedPreferencesUtils.java
public static void setStringArrayPref(SharedPreferences prefs, String key, ArrayList<String> values) { SharedPreferences.Editor editor = prefs.edit(); JSONArray a = new JSONArray(); for (int i = 0; i < values.size(); i++) { a.put(values.get(i)); }/* w ww .ja v a 2 s .c o m*/ if (!values.isEmpty()) { editor.putString(key, a.toString()); } else { editor.putString(key, null); } SharedPreferencesCompat.apply(editor); }
From source file:Main.java
/** * Subtract to vectors.//from ww w . j a v a2 s . co m * 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:src.Piechart.java
private static PieDataset createDataset(ArrayList<String> ColumnNames, ArrayList<Double> Values) { DefaultPieDataset dataset = new DefaultPieDataset(); for (int i = 0; i < ColumnNames.size(); i++) { dataset.setValue(ColumnNames.get(i), Values.get(i)); }//from w w w.ja va 2 s . co m return dataset; }
From source file:Main.java
public static boolean isServiceRunning(Context context, String service) { ActivityManager actManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ArrayList<ActivityManager.RunningServiceInfo> serviceList = (ArrayList<ActivityManager.RunningServiceInfo>) actManager .getRunningServices(50);//w w w .j av a 2 s. c o m for (int n = 0; n < serviceList.size(); n++) { if (serviceList.get(n).service.getClassName().toString().equals(service)) { return true; } } return false; }
From source file:Main.java
/** * gets the first value on the first AL that is equal to another in the second * /* ww w . j a va2s . c o m*/ * @param alFirst * @param alSecond * @return the string value equal between the two AL, or null if such value doesn't exist */ public static String getFirstSameValue(ArrayList<String> alFirst, ArrayList<String> alSecond) { // cycles of the first AL for (int j = 0; j < alFirst.size(); j++) { // gets the j-th value String strValue = alFirst.get(j); // cycles of the second AL for (int i = 0; i < alSecond.size(); i++) { // if the two values are equal, return the value if (strValue.equals(alSecond.get(i))) return strValue; } } // hasn't found nothing, so returns null return null; }
From source file:fr.bmartel.android.notti.service.bluetooth.events.BluetoothObject.java
public static BluetoothObject parseArrayList(Intent intent) { ArrayList<String> actionsStr = intent.getStringArrayListExtra(""); if (actionsStr.size() > 0) { try {//from w ww . j ava 2s .co m JSONObject mainObject = new JSONObject(actionsStr.get(0)); if (mainObject.has(BluetoothConst.DEVICE_ADDRESS) && mainObject.has(BluetoothConst.DEVICE_NAME)) { return new BluetoothObject(mainObject.get(BluetoothConst.DEVICE_ADDRESS).toString(), mainObject.get(BluetoothConst.DEVICE_NAME).toString()); } } catch (JSONException e) { e.printStackTrace(); } } return null; }
From source file:Main.java
private static float[] toFloatArray(ArrayList<Float> arrayList) { float[] ret = new float[arrayList.size()]; for (int i = 0; i < ret.length; i++) { ret[i] = arrayList.get(i); }//from w w w . j a va 2 s .c om return ret; }
From source file:Main.java
public static void uniqe(int[] words, ArrayList<Integer> tempUniqueWords, ArrayList<Integer> tempCounts) { for (int i = 0; i < words.length; i++) { if (tempUniqueWords.contains(words[i])) { int index = tempUniqueWords.indexOf(words[i]); tempCounts.set(index, tempCounts.get(index) + 1); } else {/*from www . j a v a 2 s . c om*/ tempUniqueWords.add(words[i]); tempCounts.add(1); } } }