List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:Main.java
private static List<Field> getClassFields(Class clazz) { ArrayList<Field> fields = new ArrayList<>(Arrays.asList(clazz.getDeclaredFields())); if (clazz.getSuperclass() != null) { fields.addAll(getClassFields(clazz.getSuperclass())); }/*w w w. ja v a 2 s .c o m*/ return fields; }
From source file:com.acme.spring.hibernate.Deployments.java
/** * <p>Retrieves the dependencies.</p> * * @return the array of the dependencies */// w w w . j a v a2 s .co m public static File[] springDependencies() { ArrayList<File> files = new ArrayList<File>(); files.addAll(resolveDependencies("org.springframework:spring-context:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.springframework:spring-orm:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.springframework:spring-tx:3.1.1.RELEASE")); files.addAll(resolveDependencies("org.hibernate:hibernate-core:3.6.0.Final")); files.addAll(resolveDependencies("org.hibernate:hibernate-annotations:3.4.0.GA")); files.addAll(resolveDependencies("javassist:javassist:3.6.0.GA")); return files.toArray(new File[files.size()]); }
From source file:Main.java
public static <E> ArrayList<E> asArrayList(E first, E second, E... other) { if (other == null) { throw new NullPointerException("other"); }//from w ww.ja va 2 s .c o m ArrayList<E> list = new ArrayList<>(1 + 1 + other.length); list.add(first); list.add(second); list.addAll(Arrays.asList(other)); return list; }
From source file:Main.java
private static List<Class> getClasses(String packageName) { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); String path = packageName.replace('.', '/'); Enumeration<URL> resources = null; try {//from w w w . j a v a 2 s .c om resources = classLoader.getResources(path); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<File> dirs = new ArrayList<File>(); while (resources.hasMoreElements()) { URL resource = resources.nextElement(); dirs.add(new File(resource.getFile())); } ArrayList<Class> classes = new ArrayList<Class>(); for (File directory : dirs) { classes.addAll(findClasses(directory, packageName)); } return classes; }
From source file:Main.java
public static <T> ArrayList<T> distinctList(ArrayList<T> arg) { ArrayList<T> distinct = new ArrayList<T>(); if (null != arg) { distinct = new ArrayList<T>(); distinct.addAll(arg); for (int i = 0; i < distinct.size(); i++) { T t1 = distinct.get(i);//from w ww . j av a 2 s .c o m for (int j = i + 1; j < distinct.size(); j++) { T t2 = distinct.get(j); if (t1.equals(t2)) { distinct.remove(j); j--; } } } } return distinct; }
From source file:Main.java
public static ArrayList<Integer> intersection(ArrayList<Integer> arrayList1, ArrayList<Integer> arrayList2) { ArrayList<Integer> intersectionList = new ArrayList<Integer>( arrayList1.size() > arrayList2.size() ? arrayList1.size() : arrayList2.size()); intersectionList.addAll(arrayList1); intersectionList.retainAll(arrayList2); return intersectionList; }
From source file:br.unicamp.cst.util.ChartViewerUtil.java
public static synchronized void updateValuesInChart(DefaultCategoryDataset dataset, List<? extends Codelet> codelets) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(codelets); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.addValue(co.getActivation(), co.getName(), "activation"); }/* www .j a v a 2 s . c om*/ } }
From source file:br.unicamp.cst.util.ChartViewerUtil.java
public static synchronized void updateValuesInXYLineChart(XYSeriesCollection dataset, List<? extends Codelet> codelets, long instant) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(codelets); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.getSeries(co.getName()).add(instant, co.getActivation()); }/* w ww . j a va2s . co m*/ } }
From source file:br.unicamp.cst.util.ChartViewerUtil.java
public static synchronized void updateValueInChartByMemory(DefaultCategoryDataset dataset, List<? extends Codelet> codelets, String memoryName) { ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>(); tempCodeletsList.addAll(codelets); synchronized (tempCodeletsList) { for (Codelet co : tempCodeletsList) { dataset.addValue(co.getOutput(memoryName).getEvaluation(), co.getName(), "activation"); }/* w w w.jav a 2s . c o m*/ } }
From source file:Main.java
public static void uniqe(ArrayList<String> queryDoc) { // add elements to al, including duplicates HashSet<String> hs = new HashSet<String>(); hs.addAll(queryDoc);//www. java2 s . co m queryDoc.clear(); queryDoc.addAll(hs); }