List of usage examples for java.util Collections addAll
@SafeVarargs public static <T> boolean addAll(Collection<? super T> c, T... elements)
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);// ww w.j av 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); } }
From source file:Main.java
@Deprecated public static <T> Set<T> asSet(final T t, final T... ts) { final Set<T> set = new HashSet<T>(ts.length + 1); set.add(t);// w ww. ja v a 2s . com Collections.addAll(set, ts); return set; }
From source file:Main.java
@Deprecated public static <T> List<T> asList(final T t, final T... ts) { final ArrayList<T> list = new ArrayList<T>(ts.length + 1); list.add(t);/* w w w . j a v a 2 s . c o m*/ Collections.addAll(list, ts); return list; }
From source file:Lists.java
/** * Construct a new {@link ArrayList} with the provided elements, taking advantage of type inference to * avoid specifying the type on the rhs. *//* w ww. j ava2 s . co m*/ public static <E> ArrayList<E> newArrayList(E... elements) { ArrayList<E> set = newArrayList(); Collections.addAll(set, elements); return set; }
From source file:Main.java
/** * Create a {@link Set} of {@link E} and add {@code elements} to the {@link Set}. * * @param elements Elements to add to set. * @param <E> Element type./* w w w .ja v a 2 s. com*/ * @return {@link Set} of {@link E} with {@code elements}. */ @SafeVarargs public static <E> Set<E> setOf(E... elements) { Set<E> set = new HashSet<>(); Collections.addAll(set, elements); return set; }
From source file:Main.java
/** * Creates a {@link Set} from incoming {@literal "varargs"}. Currently uses * {@link LinkedHashSet} as the {@code Set} implementation (to preserve * ordering)./* www .j a v a 2 s . c o m*/ * * <p>Used like so:<pre> * for (String s : set("beep", "boop", "blorp")) { ... }</pre> * * @param elements Items that will appear within the returned {@code Set}. * Cannot be {@code null}, and (for now) the items should be of the * <i>same</i> type. * * @return A {@code Set} containing the items in {@code elements}. Remember * that {@code Set}s only contain <i>unique</i> elements! */ public static <E> Set<E> set(E... elements) { Set<E> newSet = new LinkedHashSet<>(elements.length); Collections.addAll(newSet, elements); return newSet; }
From source file:Main.java
/** * Create a {@link List} of {@link E} and add {@code elements} to the {@link List}. * * @param elements Elements to add to list. * @param <E> Element type./*from w w w.j a v a 2s .co m*/ * @return {@link List} of {@link E} with {@code elements}. */ @SafeVarargs public static <E> List<E> listOf(E... elements) { List<E> list = new ArrayList<>(); Collections.addAll(list, elements); return list; }
From source file:Main.java
/** * Create a {@link LinkedHashSet} of {@link E} and add {@code elements} to the {@link * LinkedHashSet}./* www.j a v a2s .com*/ * * @param elements Elements to add to set. * @param <E> Element type. * @return {@link LinkedHashSet} of {@link E} with {@code elements}. */ @SafeVarargs public static <E> LinkedHashSet<E> linkedSetOf(E... elements) { LinkedHashSet<E> set = new LinkedHashSet<>(); Collections.addAll(set, elements); return set; }
From source file:com.jkoolcloud.tnt4j.streams.utils.StreamsScriptingUtils.java
/** * Initiates default set of Java API imported packages. *//*from ww w. j a v a 2s . c o m*/ private static void initDefaultImportPackages() { try { Properties p = Utils.loadPropertiesResources("scripting.properties"); // NON-NLS for (String pName : p.stringPropertyNames()) { if (pName.endsWith(".scripting.import.packages")) { // NON-NLS String importPackages = p.getProperty(pName); if (StringUtils.isNotEmpty(importPackages)) { String[] pArray = importPackages.split(";"); Collections.addAll(DEFAULT_IMPORT_PACKAGES, pArray); } } } } catch (Exception exc) { } }
From source file:de.tor.tribes.util.VillageUtils.java
public static Village[] getVillages(Tribe[] pTribes) { List<Village> villageList = new LinkedList<>(); if (pTribes == null || pTribes.length == 0) { Set<Entry<Integer, Village>> entries = DataHolder.getSingleton().getVillagesById().entrySet(); for (Entry<Integer, Village> entry : entries) { villageList.add(entry.getValue()); }/* w w w . j a va 2 s. com*/ } else { for (Tribe t : pTribes) { Collections.addAll(villageList, t.getVillageList()); } } return villageList.toArray(new Village[villageList.size()]); }