Java Code Examples for com.google.common.collect.Sets#newCopyOnWriteArraySet()
The following examples show how to use
com.google.common.collect.Sets#newCopyOnWriteArraySet() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaxeControllingCompletionContributor.java From intellij-haxe with Apache License 2.0 | 4 votes |
private static Set<CompletionResult> removeDuplicateCompletions(Set<CompletionResult> unfilteredCompletions) { // We sort the elements according to name, giving preference to compiler-provided results // if the two names are identical. CompletionResult sorted[] = unfilteredCompletions.toArray(new CompletionResult[]{}); Arrays.sort(sorted, new Comparator<CompletionResult>() { @Override public int compare(CompletionResult o1, CompletionResult o2) { LookupElement el1 = o1.getLookupElement(); LookupElement el2 = o2.getLookupElement(); String fnName1 = null != el1 ? el1.getLookupString() : null; String fnName2 = null != el2 ? el2.getLookupString() : null; // Can't really throw a null pointer exception... It would be thrown past sort. if (null == fnName1) return -1; if (null == fnName2) return 1; int comp = fnName1.compareTo(fnName2); if (0 == comp) { Object obj1 = el1.getObject(); Object obj2 = el2.getObject(); comp = obj1 instanceof HaxeCompilerCompletionItem ? (obj2 instanceof HaxeCompilerCompletionItem ? 0 : -1) : (obj2 instanceof HaxeCompilerCompletionItem ? 1 : 0); } return comp; } }); // Now remove duplicates by looping over the list, dropping any that match the entry prior. ArrayList<CompletionResult> deduped = new ArrayList<CompletionResult>(); String lastName = null; for (CompletionResult next: sorted) { String nextName = getFunctionName(next); // In the long run, it's probably not good enough just to check the name. Multiple argument types may // be present, and we may be able to filter based on the local variables available. if (null == lastName || !lastName.equals(nextName)) { deduped.add(next); } lastName = nextName; } return Sets.newCopyOnWriteArraySet(deduped); }
Example 2
Source File: VarExporter.java From util with Apache License 2.0 | 4 votes |
@Override public Set<Variable> get() { return Sets.newCopyOnWriteArraySet(); }