List of utility methods to do Collection Union
Collection | union(final Collection a, final Collection b) union ArrayList list = new ArrayList(); Map mapa = getCardinalityMap(a); Map mapb = getCardinalityMap(b); Set elts = new LinkedHashSet(a); elts.addAll(b); Iterator it = elts.iterator(); while (it.hasNext()) { Object obj = it.next(); ... |
Collection | union(final Collection c1, final Collection c2) union final List list = new ArrayList(); addAllUnique(list, c1); addAllUnique(list, c2); return list; |
Iterable | union(final Collection... sets) iterator over all elements contained in the union of the given sets return () -> new Iterator() { int which = 0; Iterator it = null; while (which < sets.length && !it.hasNext()) { it = sets[which++].iterator(); @Override public boolean hasNext() { return which < sets.length; @Override public Object next() { final Object result = it.next(); while (which < sets.length && !it.hasNext()) { it = sets[which++].iterator(); return result; }; |
List | union(final Collection union List<T> result = new ArrayList<T>(a); result.addAll(b); return result; |
void | unionAll(final Collection Unions the two given arrays in bag logic. int index1 = 0; int index2 = 0; while (true) { if (index1 >= a.length) { copyRemainder(b, index2, collector); break; } else if (index2 >= b.length) { copyRemainder(a, index1, collector); ... |