List of usage examples for java.util ArrayList contains
public boolean contains(Object o)
From source file:Main.java
/** * Decides whether TCK should be present based in the ATR on the "T" values * found when parsing the ATR./* w ww .ja v a 2 s . c o m*/ * * From ISO/IEC 7816-3 8.2.5: "If only T=0 is indicated, possibly by * default, then TCK shall be absent. If T=0 and T=15 are present and in all * the other cases, TCK shall be present." * * @param tValues The values of "T" found when parsing the ATR. * * @return true if TCK should be present, false otherwise. */ private static boolean isTckPresent(ArrayList<Integer> tValues) { return !((tValues.size() == 1) && tValues.contains(0)); }
From source file:Main.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static ArrayList removeDuplicate(ArrayList arlList, ArrayList list) { for (Object object : list) { if (!arlList.contains(object)) { arlList.add(object);// www .j av a 2s . com } } return arlList; }
From source file:Main.java
public static ArrayList<String> deleteRepeat(ArrayList<String> list) { ArrayList<String> tmp = new ArrayList<String>(); for (String url : list) { if (!tmp.contains(url)) { tmp.add(url);/* w ww.j a v a2s . com*/ } } return tmp; }
From source file:Main.java
public static String getUniqueName(String name, ArrayList<String> existingNames) { boolean invalidName = existingNames.contains(name); while (invalidName) { int index = name.length() - 1; if ((int) name.charAt(index) < (int) '0' || (int) name.charAt(index) > (int) '9') { // name does not end with a number - attach a "2" name += "2"; } else {//from w w w.j av a 2 s . c om // Find the number the name ends with and increment it int numStartIndex = -1, numEndIndex = -1; while (index >= 0) { if ((int) name.charAt(index) >= (int) '0' && (int) name.charAt(index) <= (int) '9') { if (numEndIndex == -1) { numEndIndex = index; } } else if (numEndIndex != -1) { numStartIndex = index + 1; break; } index--; } int number = Integer.parseInt(name.substring(numStartIndex, numEndIndex + 1)); name = name.substring(0, numStartIndex) + (number + 1); } invalidName = existingNames.contains(name); } return name; }
From source file:Main.java
static public boolean isGestureExists(Context context, String name) { ArrayList<String> savedGestureNames = getSavedGestureNames(context); return savedGestureNames.contains(name); }
From source file:Main.java
public static <T> List<T> unique(List<T> list) { ArrayList<T> uniqueList = new ArrayList<T>(); for (T object : list) { boolean existsInResult = uniqueList.contains(object); if (!existsInResult) { uniqueList.add(object);/*w ww . j a v a 2 s.c o m*/ } } return uniqueList; }
From source file:Main.java
public static <T> boolean isContain(ArrayList<T> a, ArrayList<T> b) { boolean res = false; for (int i = 0; i < b.size(); i++) { if (!a.contains(b.get(i))) { break; }/*from w w w . j a v a 2 s . com*/ if (i == b.size() - 1) { res = true; } } return res; }
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 w w w. j ava 2 s. c o m*/ tempUniqueWords.add(words[i]); tempCounts.add(1); } } }
From source file:Main.java
/** * Brute force, for when HashSet and TreeSet won't work (e.g. #hashCode * implementation isn't appropriate). The original Collection is not * modified./* w w w . j av a 2 s . com*/ */ public static Collection removeDuplicates(Collection original) { ArrayList result = new ArrayList(); for (Iterator i = original.iterator(); i.hasNext();) { Object item = i.next(); if (!result.contains(item)) { result.add(item); } } return result; }
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 w w .j av a2 s . c o m*/ }