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 Process runWithEnv(String command, ArrayList<String> customAddedEnv, String baseDirectory) throws IOException { Map<String, String> environment = System.getenv(); String[] envArray = new String[environment.size() + (customAddedEnv != null ? customAddedEnv.size() : 0)]; int i = 0;//from ww w . ja v a 2 s. c o m for (Map.Entry<String, String> entry : environment.entrySet()) { envArray[i++] = entry.getKey() + "=" + entry.getValue(); } if (customAddedEnv != null) { for (String entry : customAddedEnv) { envArray[i++] = entry; } } Process process; if (baseDirectory == null) { process = Runtime.getRuntime().exec(command, envArray, null); } else { process = Runtime.getRuntime().exec(command, envArray, new File(baseDirectory)); } return process; }
From source file:Main.java
public static Node[] findNodesByTagName(Document document, String tagName) { ArrayList<Node> nodes = new ArrayList<Node>(); NodeList foundNodes = document.getElementsByTagName(tagName); for (int i = 0; i < foundNodes.getLength(); i++) nodes.add(foundNodes.item(i));/*w w w. jav a2s. c om*/ Node[] returnNodes = new Node[nodes.size()]; return nodes.toArray(returnNodes); }
From source file:io.lqd.sdk.model.LQNetworkRequest.java
public static void saveQueue(Context context, ArrayList<LQNetworkRequest> queue, String fileName) { LQLog.data("Saving queue with " + queue.size() + " items to disk"); LQModel.save(context, fileName + ".queue", queue); }
From source file:test.GanttDemo1.java
/** * Creates a sample dataset for a Gantt chart. * * @return The dataset.//from w w w . jav a 2 s . c o m */ public static IntervalCategoryDataset createDataset(ArrayList<proceso> lista_imprimir) { String nameProcess; TimePeriod periodProcess; final TaskSeries s1 = new TaskSeries("Scheduled"); for (int i = 0; i < lista_imprimir.size(); i++) { nameProcess = "Proceso " + lista_imprimir.get(i).getId_proceso(); s1.add(new Task(nameProcess, new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), date(5, Calendar.APRIL, 2001)))); } // s1.add(new Task("Proceso 1", // new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), // date(5, Calendar.APRIL, 2001)))); // s1.add(new Task("Proceso 2", // new SimpleTimePeriod(date(5, Calendar.APRIL, 2001), // date(9, Calendar.APRIL, 2001)))); // s1.add(new Task("Proceso 3", // new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), // date(15, Calendar.MAY, 2001)))); final TaskSeriesCollection collection = new TaskSeriesCollection(); collection.add(s1); return collection; }
From source file:edu.mit.genecircuits.GcUtils.java
/** Return true if the given array is an ordered list of positive doubles, given in increasing order */ public static boolean posDoubleIncreasing(ArrayList<Double> x) { if (x == null || x.size() == 0) return true; for (int i = 0; i < x.size(); i++) { if (x.get(i) <= 0) return false; if (i > 0 && x.get(i) <= x.get(i - 1)) return false; }//from w w w . ja v a 2s .c om return true; }
From source file:com.cloudmade.api.Utils.java
static Polygon polygonFromJson(JSONArray coords) { ArrayList<Line> lines = linesFromJson(coords); return new Polygon(lines.remove(0), lines.size() > 0 ? lines : null); }
From source file:edu.mit.genecircuits.GcUtils.java
/** Return true if the given array is an ordered list of positive integers, given in increasing order */ public static boolean posIntIncreasing(ArrayList<Integer> x) { if (x == null || x.size() == 0) return true; for (int i = 0; i < x.size(); i++) { if (x.get(i) < 1) return false; if (i > 0 && x.get(i) <= x.get(i - 1)) return false; }/*from w ww . j a v a 2 s . co m*/ return true; }
From source file:com.dnielfe.manager.utils.SortUtils.java
public static ArrayList<String> sortList(ArrayList<String> content, String current) { int len = content != null ? content.size() : 0; int index = 0; String[] items = new String[len]; content.toArray(items);//from w ww .j a v a 2s .c o m switch (Settings.mSortType) { case SORT_ALPHA: Arrays.sort(items, Comparator_ALPH); content.clear(); for (String a : items) { content.add(a); } break; case SORT_SIZE: Arrays.sort(items, Comparator_SIZE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add((String) a); } break; case SORT_TYPE: Arrays.sort(items, Comparator_TYPE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; case SORT_DATE: Arrays.sort(items, Comparator_DATE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; } return content; }
From source file:Main.java
public static void unRevokePermission(String packageName, String permission, Context ctx) { String[] rPerms = getRevokedPerms(packageName, ctx); if (rPerms == null) rPerms = new String[0]; ArrayList<String> revokedPerms = new ArrayList<String>(); revokedPerms.addAll(Arrays.asList(rPerms)); if (revokedPerms.contains(permission)) { revokedPerms.remove(permission); String[] permsToRevoke = new String[revokedPerms.size()]; revokedPerms.toArray(permsToRevoke); setRevokedPermissions(packageName, permsToRevoke, ctx); }// w ww .j av a 2 s . co m }
From source file:com.lovejoy777sarootool.rootool.utils.SortUtils.java
public static void sortList(ArrayList<String> content, String current) { int len = content != null ? content.size() : 0; int index = 0; String[] items = new String[len]; content.toArray(items);//w w w. j a v a2 s. c o m switch (Settings.mSortType) { case SORT_ALPHA: Arrays.sort(items, Comparator_ALPH); content.clear(); Collections.addAll(content, items); break; case SORT_SIZE: Arrays.sort(items, Comparator_SIZE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; case SORT_TYPE: Arrays.sort(items, Comparator_TYPE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; case SORT_DATE: Arrays.sort(items, Comparator_DATE); content.clear(); for (String a : items) { if (new File(current + "/" + a).isDirectory()) content.add(index++, a); else content.add(a); } break; } if (Settings.reverseListView()) { Collections.reverse(content); } }