public String pickGoodStarterWord() { String word; ArrayList<String> wordsOfCurrentSize = (ArrayList) wordList.clone(); wordsOfCurrentSize.retainAll(sizeToWord.get(wordlength)); // ArrayList<String> wordsOfCurrentSize = sizeToWord.get(wordlength); Integer startingPoint = random.nextInt(wordsOfCurrentSize.size()); // Log.d("numberOfWords: ", String.valueOf(wordsOfCurrentSize.size())); do { word = wordsOfCurrentSize.get(startingPoint); if (startingPoint == (wordsOfCurrentSize.size() - 1)) { startingPoint = 0; } else { startingPoint++; } } while (lettersToWord.get(sortLetters(word)).size() < MIN_NUM_ANAGRAMS); if (wordlength <= MAX_WORD_LENGTH) { wordlength++; } Log.d("pickGoodStarterWord", "Chosen Starter Word is: " + word); return word; }
private static boolean allSuperMethodsSelectedToDelete( List<PsiMethod> unselectedMethods, PsiMethod method) { final ArrayList<PsiMethod> superMethods = new ArrayList<>(Arrays.asList(method.findSuperMethods())); superMethods.retainAll(unselectedMethods); return superMethods.isEmpty(); }
public boolean iterate(ArrayList<String> value) { if (value == null) { return true; } if (intersection == null) { intersection = value; } intersection.retainAll(value); return true; }
public boolean merge(ArrayList<String> other) { if (other == null) { return true; } if (intersection == null) { intersection = other; } intersection.retainAll(other); return true; }
public static <T> ArrayList<T> Intersection(ArrayList<ArrayList<T>> lists) { ArrayList<T> result = new ArrayList<T>(); if (lists != null && !lists.isEmpty()) { result.addAll(lists.get(0)); } for (ArrayList<T> list : lists) { result.retainAll(list); } return result; }
private EventDescriptor( @NotNull VirtualFilePointerListener listener, @NotNull List<VirtualFilePointer> pointers) { myListener = listener; synchronized (VirtualFilePointerManagerImpl.this) { Collection<VirtualFilePointerImpl> set = myUrlToPointerMaps.get(listener).values(); ArrayList<VirtualFilePointer> result = new ArrayList<VirtualFilePointer>(pointers); result.retainAll(set); myPointers = result.isEmpty() ? VirtualFilePointer.EMPTY_ARRAY : result.toArray(new VirtualFilePointer[result.size()]); } }
public boolean areSynoynyms(String word1, String word2) { boolean synonyms = false; List synoymList = getSynonyms(word1); List synoym1List = getSynonyms(word2); ArrayList word1List = new ArrayList(); ArrayList word2List = new ArrayList(); for (int i = 0; i < synoymList.size(); i++) { IWord word = (IWord) synoymList.get(i); word1List.add(word.getLemma()); } for (int i = 0; i < synoym1List.size(); i++) { IWord word = (IWord) synoym1List.get(i); word2List.add(word.getLemma()); } word1List.retainAll(word2List); if (word1List.size() > 0) synonyms = true; return synonyms; }
public static void main(String[] args) { ArrayList<String> collection1 = new ArrayList<>(); collection1.add("New York"); collection1.add("Atlanta"); collection1.add("Dallas"); collection1.add("Madison"); System.out.println("A list of cities in collection1:"); System.out.println(collection1); System.out.println("\nIs Dallas in collection1? " + collection1.contains("Dallas")); Collection<String> collection2 = new ArrayList<>(); collection2.add("Seattle"); collection2.add("Portland"); collection2.add("Los Angeles"); collection2.add("Atlanta"); System.out.println("\nA list of citites in collection2:"); System.out.println(collection2); ArrayList<String> c1 = (ArrayList<String>) (collection1.clone()); c1.addAll(collection2); System.out.println("\nCities in collection or colletion2:"); System.out.println(c1); c1 = (ArrayList<String>) (collection1.clone()); c1.retainAll(collection2); System.out.println("\nCities in collection1 and collection2"); System.out.println(c1); c1 = (ArrayList<String>) (collection1.clone()); c1.removeAll(collection2); System.out.println("\nCities in collection1, but not in 2:"); System.out.println(c1); }
public <T> void assertContainsOrdered( Collection<? extends T> collection, Collection<T> expected) { ArrayList<T> copy = new ArrayList<T>(collection); copy.retainAll(expected); assertOrderedEquals(toString(collection), copy, expected); }
public <T> void assertContainsElements( Collection<? extends T> collection, Collection<T> expected) { ArrayList<T> copy = new ArrayList<T>(collection); copy.retainAll(expected); assertSameElements(toString(collection), copy, expected); }
/** Processes parsed text and templates from the API */ private void procText() { ArrayList<Template> masterTPL = root.getTemplateR(); // Normalize license and special template titles for (Template t : masterTPL) { String tp = enwp.whichNS(t.title).equals(NS.TEMPLATE) ? enwp.nss(t.title) : t.title; if (mtc.tpMap.containsKey(tp)) t.title = mtc.tpMap.get(tp); } ArrayList<Template> tpl = new ArrayList<>(masterTPL); // Filter Templates which are not on Commons HashSet<String> ncomT = FL.toSet( MQuery.exists(com, false, FL.toAL(tpl.stream().map(t -> "Template:" + t.title))) .stream() .map(com::nss)); for (Template t : new ArrayList<>(tpl)) if (ncomT.contains(t.title)) tpl.remove(t.drop()); // Process special Templates Template info = null; for (Template t : new ArrayList<>(tpl)) switch (t.title) { case "Information": info = t; tpl.remove(t.drop()); break; case "Self": if (!t.has("author")) t.put("author", String.format("{{User at project|%s|w|en}}", uploader)); break; case "PD-self": t.title = "PD-user-en"; t.put("1", uploader); break; case "GFDL-self-with-disclaimers": t.title = "GFDL-user-en-with-disclaimers"; t.put("1", uploader); break; case "GFDL-self": t.title = "GFDL-self-en"; t.put("author", String.format("{{User at project|%s|w|en}}", uploader)); break; case "Copy to Wikimedia Commons": tpl.remove(t.drop()); break; default: break; } // Add any Commons-compatible top-level templates to License section. tpl.retainAll(root.tplates); for (Template t : tpl) licSection += String.format("%s%n", t); // Create and fill in missing {{Information}} fields with default values. info = filterFillInfo(info == null ? new Template("Information") : info); // Append any additional Strings to the description. if (!root.contents.isEmpty()) info.append("Description", "\n" + String.join("\n", root.contents)); // Convert {{Information}} to String and save result. sumSection += info.toString(true) + "\n"; // Extract the first caption table and move it to the end of the sumSection String x = ""; Matcher m = captionRegex.matcher(sumSection); if (m.find()) { x = m.group().trim(); sumSection = m.reset().replaceAll(""); sumSection += x + "\n"; } }
@Override public boolean retainAll(Collection<?> c) { return children.retainAll(c); }
protected void trimToSize(int amount) { particles.retainAll(particles.subList(0, particles.size() - amount)); }
@Override public boolean retainAll(@Nonnull Collection<?> c) { beforeSet(); return list.retainAll(c); }
@Override public boolean retainAll(Collection<?> c) { return original.retainAll(c); }
public boolean retainAll(Collection<?> trees) { return list.retainAll(trees); }
public boolean retainAll(Collection c) { return myList.retainAll(c); }
public boolean retainAll(Collection<?> c) { return selections.retainAll(c); }
private ArrayList<Node> removeInferiorNodes(ArrayList<Node> candidates) { candidates.retainAll(ptChildren_); return candidates; }