List of usage examples for java.util List iterator
Iterator<E> iterator();
From source file:cam.cl.kilo.RESTBarcode.java
/** * Simple pretty print for lists/* w w w . j a v a 2 s. c o m*/ * * @param l A List */ public static void ppList(List<String> l) { Iterator itr = l.iterator(); int i = 0; while (itr.hasNext()) { System.out.printf("[%d]\n%s\n", ++i, itr.next()); } }
From source file:Main.java
public static int hashCode(List list) { if (list == null) { return 0; }//www. j a va 2 s . c o m final int prime = 31; int result = 1; for (Iterator it = list.iterator(); it.hasNext();) { Object next = it.next(); result = prime * result + ((next == null) ? 0 : next.hashCode()); } return result; }
From source file:Main.java
/** * Compares the content of the two list, no matter how they are ordered * @param test the list containing items to check * @param control the list containing the expected values * @return {@code true}/*from w w w . java 2s. c o m*/ */ public static <T extends Comparable<? super T>> boolean containsInAnyOrder(final List<T> test, final List<T> control) { if (test == null || control == null) { return false; } if (test.size() != control.size()) { return false; } final List<T> orderedControl = new LinkedList<T>(control); Collections.sort(orderedControl); final List<T> orderedTest = new LinkedList<T>(test); Collections.sort(orderedTest); final Iterator<T> testIterator = orderedTest.iterator(); for (Iterator<T> controlIterator = orderedControl.iterator(); controlIterator.hasNext();) { T controlItem = controlIterator.next(); T testItem = testIterator.next(); if (testItem == null || !testItem.equals(controlItem)) { return false; } } return true; }
From source file:Main.java
/** * open another app/* w ww .j a v a 2 s .co m*/ * @param context * @param packageName * @throws NameNotFoundException */ public static void openApp(Context context, String packageName) throws NameNotFoundException { PackageInfo pi = context.getPackageManager().getPackageInfo(packageName, 0); Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(pi.packageName); List<ResolveInfo> apps = context.getPackageManager().queryIntentActivities(resolveIntent, 0); Iterator<ResolveInfo> iterator = apps.iterator(); while (iterator.hasNext()) { ResolveInfo ri = iterator.next(); if (ri != null) { packageName = ri.activityInfo.packageName; String className = ri.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName cn = new ComponentName(packageName, className); intent.setComponent(cn); context.startActivity(intent); } } }
From source file:Main.java
/** * @param packageName//from www. j a v a 2 s . co m * @param context */ public static void openApp(String packageName, Context context) { Intent resolveIntent = new Intent(Intent.ACTION_MAIN, null); resolveIntent.addCategory(Intent.CATEGORY_LAUNCHER); resolveIntent.setPackage(packageName); List<ResolveInfo> apps = context.getPackageManager().queryIntentActivities(resolveIntent, 0); ResolveInfo ri = apps.iterator().next(); if (ri != null) { String packageName_i = ri.activityInfo.packageName; String className_i = ri.activityInfo.name; Intent intent = new Intent(Intent.ACTION_MAIN); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addCategory(Intent.CATEGORY_LAUNCHER); ComponentName cn = new ComponentName(packageName_i, className_i); intent.setComponent(cn); context.startActivity(intent); } }
From source file:Main.java
@SuppressWarnings("unchecked") public static void filtrerDoublonsSurPlace(List<Map> objets, Object filter) { Map objetsDejaPresents = new HashMap(); Map filterDejaPresents = new HashMap(); for (Iterator i = objets.iterator(); i.hasNext();) { Map objet = (Map) i.next(); if (!objetsDejaPresents.containsKey(objet) && objet != null && !filterDejaPresents.containsKey(objet.get(filter))) { objetsDejaPresents.put(objet, null); filterDejaPresents.put(objet.get(filter), null); } else/*from w w w. j a v a 2s . c o m*/ i.remove(); } }
From source file:com.aimluck.eip.modules.actions.project.util.ProjectTestUtil.java
public static String join(List<String> list, String separator) { StringBuilder features = new StringBuilder(); Iterator<String> it = list.iterator(); while (it.hasNext()) { String word = it.next();//from w w w .ja v a 2 s. c om if (StringUtils.isEmpty(word)) { continue; } features.append(word); if (it.hasNext()) { features.append(separator); } } return features.toString(); }
From source file:com.fstx.stdlib2.author.SystemRights.java
public static SystemRights getRight(int id) { SystemRights ret = null;// w w w . ja v a 2 s.c om List l = getRights(); Iterator i = l.iterator(); while (i.hasNext()) { SystemRights r = (SystemRights) i.next(); if (r.getMyId() == id) { ret = r; break; } } return ret; }
From source file:cn.dreampie.FileUtilities.java
/** * Turn a list of Strings into a concatenated string of filenames *///from w w w . j av a 2 s. c o m public static String getCommaSeparatedList(List<String> list) { StringBuffer sb = new StringBuffer(); for (Iterator<String> i = list.iterator(); i.hasNext();) { sb.append(i.next()); if (i.hasNext()) { sb.append(","); } } return sb.toString(); }
From source file:cn.dreampie.FileUtilities.java
/** * Turn a list of files into a comma separated list of filenames */// w w w. ja v a 2 s . co m public static String getCommaSeparatedListOfFileNames(List<File> fileList) { StringBuffer sb = new StringBuffer(); for (Iterator<File> i = fileList.iterator(); i.hasNext();) { sb.append(i.next().getAbsolutePath()); if (i.hasNext()) { sb.append(","); } } return sb.toString(); }