List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:Main.java
/** * Combines a element and a list into a new list. * //from w w w .j av a 2 s . co m * @param t First element of the new list. * @param list Rest elements of the new list. */ public static <T extends Object> List<T> union(final T t, final List<T> list) { final ArrayList<T> result = new ArrayList<T>(); result.add(t); result.addAll(list); return result; }
From source file:Main.java
public static <T> List<T> cons(T x, Collection<? extends T> xs) { ArrayList<T> result = new ArrayList<>(xs.size() + 1); result.add(x);/* w w w .j av a 2 s . c o m*/ result.addAll(xs); return result; }
From source file:Main.java
/** * Create an ArrayList from the given elements. The returned list * can be changed (in constrast to Arrays.asList() where a non-modifieable list * is returned)/*from w w w. ja v a2 s . co m*/ */ public static <E> List<E> arrayList(E... a) { ArrayList<E> result = new ArrayList<>(a.length); result.addAll(Arrays.asList(a)); return result; }
From source file:Main.java
public static String[] join(String[] left, String[] right) { ArrayList<String> list = new ArrayList<String>(); list.addAll(Arrays.asList(left)); list.addAll(Arrays.asList(right)); return (String[]) list.toArray(new String[list.size()]); }
From source file:Main.java
private static ArrayList<String> getAllSpecialFilePath() { ArrayList<String> result = new ArrayList<String>(); result.addAll(getAllSDCardCameraFilePath()); result.addAll(getAllSDCardScreenshotsFilePath()); return result; }
From source file:Main.java
public static <ELEMENT> ArrayList<ELEMENT> newArrayList(Collection<ELEMENT> elements) { final ArrayList<ELEMENT> list = newArrayListSized(elements.size()); list.addAll(elements); return list;/*from w ww.j a v a 2s . c om*/ }
From source file:Main.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static void removeDuplicate(ArrayList arlList) { HashSet h = new HashSet(arlList); arlList.clear();//from w w w. j a v a2s . co m arlList.addAll(h); }
From source file:Main.java
/** * Convenient method to chain two or more lists together. * @param first first list//from www. j a va 2s.c o m * @param others other lists * @return chained list */ @SuppressWarnings("unchecked") @SafeVarargs public static <T> List<T> chain(List<T> first, List<T>... others) { int size = first.size(); for (List<T> other : others) { size += other.size(); // fdfdf } ArrayList<T> result = new ArrayList<>(size); result.addAll(first); for (List<T> other : others) { result.addAll(other); } 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); }/* www .ja v a2s. c o m*/ }
From source file:Main.java
public static void revokePermission(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.add(permission);//w w w. jav a2 s .c om String[] permsToRevoke = new String[revokedPerms.size()]; revokedPerms.toArray(permsToRevoke); setRevokedPermissions(packageName, permsToRevoke, ctx); } }