List of usage examples for java.util ArrayList get
public E get(int index)
From source file:bookChapter.theoretical.AnalyzeTheoreticalMSMSCalculation.java
private static HashSet<Identify> getBestResult(ArrayList<Identify> results) { Collections.sort(results, Identify.ScoreDESC); double bestScore = results.get(0).getScore(); String pep = results.get(0).getPeptide().getSequence(); HashSet<Identify> selectedTops = new HashSet<Identify>(); selectedTops.add(results.get(0));/*from w ww.j ava2 s.co m*/ for (int i = 1; i < results.size(); i++) { Identify ind = results.get(i); double tmpScore = ind.getScore(); String tmpPep = ind.getPeptide().getSequence(); // making sure that non-redundant peptide would be only found if (tmpScore == bestScore && !pep.equals(tmpPep)) { bestScore = tmpScore; selectedTops.add(ind); } } return selectedTops; }
From source file:Main.java
public static void sortObjectArrayListsSimple(ArrayList masterList, String paramName, ArrayList... listsIn) { int count = masterList.size(); for (ArrayList al : listsIn) { if (al.size() != count || count == 0) { System.out.println("counts of lists are not the same, did not sort"); return; }/*from ww w .j a va 2 s.co m*/ } ArrayList<ArrayList> result = sortObjectArrayListSimpleMaster(masterList, paramName); masterList.clear(); for (Object o : result.get(0)) masterList.add(o); //masterList = result.get(0); ArrayList[] orderedLists = new ArrayList[listsIn.length]; for (int i = 0; i < listsIn.length; i++) orderedLists[i] = new ArrayList(); for (int i = 0; i < result.get(1).size(); i++) { int index = (Integer) result.get(1).get(i); for (int j = 0; j < listsIn.length; j++) { orderedLists[j].add(listsIn[j].get(index)); } } for (int i = 0; i < listsIn.length; i++) { listsIn[i].clear(); for (int j = 0; j < orderedLists[i].size(); j++) { listsIn[i].add(orderedLists[i].get(j)); } } }
From source file:com.testlinkrestapi.util.BeanUtils.java
/** * @param ArrayList<TestProjectBean>,ArrayList<TestProjectBean> * @return TestProjectBean./* w w w. j a v a 2 s . co m*/ */ public static final TestProjectBean getDeltaTestProject(ArrayList<TestProjectBean> before, ArrayList<TestProjectBean> after) { TestProjectBean bean = new TestProjectBean(); int detla = after.size() - before.size(); if (detla == 1) { bean = after.get(after.size() - 1); } return bean; }
From source file:cool.pandora.modeller.ui.handlers.iiif.PatchListHandler.java
private static RDFNode getResourceTarget(final String resourceURI) { final ResourceObjectNode resourceObjectNode = ResourceObjectNode.init().resourceURI(resourceURI) .resourceProperty(IIIFPredicates.ON).build(); final ArrayList<RDFNode> resourceTarget = resourceObjectNode.render(); if (resourceTarget.isEmpty()) { return null; }/* w w w. j ava 2s.c o m*/ return resourceTarget.get(0); }
From source file:Main.java
public static <T> ArrayList<T> rand(ArrayList<T> population, int nSamplesNeeded) { Random r = new Random(); ArrayList<T> ret = new ArrayList<T>(); if (nSamplesNeeded > population.size() / 2) { ArrayList<T> original = new ArrayList<T>(); original = population;/*from ww w . j a v a2 s . c om*/ while (nSamplesNeeded > 0) { int rand = r.nextInt(original.size()); if (rand < nSamplesNeeded) { ret.add(original.get(rand)); original.remove(rand); nSamplesNeeded--; } } original.clear(); } else ret = shuffle(population, nSamplesNeeded); return ret; }
From source file:ded.model.Inheritance.java
/** Return the value to which 'index' is mapped in 'integerToInheritance'. */ public static Inheritance fromJSONRef(ArrayList<Inheritance> integerToInheritance, long index) throws JSONException { if (0 <= index && index < integerToInheritance.size()) { return integerToInheritance.get((int) index); } else {//from ww w . j av a 2s . c o m throw new JSONException("invalid entity ref " + index); } }
From source file:Main.java
public static String[] generateArrayWithStringValuesInRange(int min, int max) { ArrayList<String> arrayList = new ArrayList<>(); for (int i = min; i < max; i++) { arrayList.add(Integer.toString(i)); }//from w w w . j av a 2s .c o m String[] stringArray = new String[arrayList.size()]; for (int i = 0; i < arrayList.size(); i++) { stringArray[i] = arrayList.get(i); } return stringArray; }
From source file:Main.java
public static boolean isLowestLevel(int level) { if (mLevelSet == null) mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET, null);//from w w w. j av a 2s .c om if (mLevelSet != null) { if (mLevelSet.size() < 5) // data is too few to judge lowest return false; ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet)); Collections.sort(array, mComparator); // TODO: may need check statistics to ensure the level is true lowest and not false alarm. if (level <= Integer.valueOf(array.get(0))) return true; } return false; }
From source file:hivemall.fm.FieldAwareFactorizationMachineUDTFTest.java
private static String[] toStringArray(ArrayList<StringFeature> x) { final int size = x.size(); final String[] ret = new String[size]; for (int i = 0; i < size; i++) { ret[i] = x.get(i).toString(); }/*from w w w . j a v a 2 s .co m*/ return ret; }
From source file:Main.java
private static void zipDir(String dir, ZipOutputStream out) throws IOException { File directory = new File(dir); URI base = directory.toURI(); ArrayList<File> filesToZip = new ArrayList<File>(); GetFiles(directory, filesToZip);// w ww . j a v a 2s .c om for (int i = 0; i < filesToZip.size(); ++i) { FileInputStream in = new FileInputStream(filesToZip.get(i)); String name = base.relativize(filesToZip.get(i).toURI()).getPath(); out.putNextEntry(new ZipEntry(name)); byte[] buf = new byte[4096]; int bytes = 0; while ((bytes = in.read(buf)) != -1) { out.write(buf, 0, bytes); } out.closeEntry(); in.close(); } out.finish(); out.flush(); }