Concatenates a number of Collections into a single Set

@param <T>
@param lists

@return
519540
public static <T> Set<T> union(final Collection<? extends T>... lists)
	{
		Set<T> s = new HashSet<T>();

		for (Collection<? extends T> list : lists)
			if (list != null)
				s.addAll(list);

		return s;
	}
1311284
public static <T> Iterable<T> merge(Iterable<T>... iterables)
    {
        return merge(null, iterables);
    }
1345541
public static <T> Set<T> intersection(Collection<Set<T>> sets) {
		Set<T> result = new HashSet<>();
		if (sets.isEmpty()) {
			return result;
		}
		Iterator<Set<T>> iter = sets.iterator();
		result.addAll(iter.next());
		while (iter.hasNext()) {
			result.retainAll(iter.next());
		}
		return result;
	}
1039352
public static <T> String join(Collection<T> collection, String delimiter) {
		StringBuilder sb = new StringBuilder();
		join(collection, delimiter, sb);
		return sb.toString();
	}
252775
public static <T> Set<T> intersection(Set<T>... sets) {
		return intersection(Arrays.asList(sets));
	}
1014031
public static <T> Collection<T> addAll(Collection<T> collection, Iterator<T> iterator) {
		if (null != collection && null != iterator) {
			while (iterator.hasNext()) {
				collection.add(iterator.next());
			}
		}
		return collection;
	}
550711
public static <T> Set<T> getSet(Collection<T> collection) {
    Set<T> set = new LinkedHashSet<T>();
    set.addAll(collection);

    return set;
  }
1059266
public static <T> Set<T> toSet(Iterable<T> items) {
    Set<T> set = new HashSet<T>();
    addAll(set, items);
    return set;
  }
217369
private ArrayList<List<?>> permute(List<?>... lists)
	{

		ArrayList<List<?>> output = new ArrayList<List<?>>();
		if (lists.length == 0)
		{
			output.add(new ArrayList<Object>());
			return output;
		}

		for (List<?> list : lists)
		{
			// We require that the result has as many elements as the number
			// of lists passed - so if a list is empty, add in a single null.
			if (list.size() == 0)
				list.add(null);
		}

		List<?> first = lists[0];
		List<?>[] rest = Arrays.copyOfRange(lists, 1, lists.length);

		for (Object x : first)
		{
			ArrayList<List<?>> permuted = permute(rest);
			for (List<?> tocombine : permuted)
			{
				ArrayList<Object> l = new ArrayList<Object>();
				l.add(x);
				l.addAll(tocombine);
				output.add(l);
			}
		}

		return output;
	}
859866
def combine_sets(*sets):
    
    combined = set()
    for s in sets:
        combined.update(s)
    return combined
471201
@SafeVarargs
    static <T> List<T> joinArrays(final T[]... arrays) {
        final List<T> all = new ArrayList<>();
        for (final T[] array : arrays) {
            for (int j = 0; j < array.length; j++) {
                all.add(array[j]);
            }
        }
        return all;
    }
1051269
public static <T> Set<T> newSet(T... values) {
    Set<T> set = new HashSet<>(values.length);
    Collections.addAll(set, values);
    return set;
  }
529300
public static <T> Set<List<T>> subsequences(List<T> items) {
        // items.inject([]){ ss, h -> ss.collect { it + [h] }  + ss + [[h]] }
        Set<List<T>> ans = new HashSet<List<T>>();
        for (T h : items) {
            Set<List<T>> next = new HashSet<List<T>>();
            for (List<T> it : ans) {
                List<T> sublist = new ArrayList<T>(it);
                sublist.add(h);
                next.add(sublist);
            }
            next.addAll(ans);
            List<T> hlist = new ArrayList<T>();
            hlist.add(h);
            next.add(hlist);
            ans = next;
        }
        return ans;
    }
395478
public static <T> List<T> toList(T[] array) {
        return new ArrayList<T>(Arrays.asList(array));
    }
1110861
public static <T> List<T> slice(List<T> list, int... indexes) {
		List<T> slice = new ArrayList<>(indexes.length);
		for (int i : indexes) {
			slice.add(list.get(i));
		}
		return slice;
	}
1094977
public static <T> Set<T> toSet(final Collection<T> collection) {

        if (isEmpty(collection)) {
            return new HashSet<T>(0);
        } else {
            return new HashSet<T>(collection);
        }
    }
1328136
@NonNull
  public static <E> ImmutableSet<E> concatSet(
      @NonNull ImmutableSet<E> set, @NonNull Iterable<E> toConcat) {
    return ImmutableSet.<E>builder().addAll(set).addAll(toConcat).build();
  }