Java Utililty Methods Set Copy

List of utility methods to do Set Copy

Description

The list of methods to do Set Copy are organized into topic(s).

Method

voidcopy(Set source, Set target)
copy
target.addAll(source);
Setcopy(Set data)
Copies the given Set into a new Set .
final int size = data.size();
switch (size) {
case 0:
    return Collections.emptySet();
case 1:
    return Collections.singleton(data.iterator().next());
default:
    return Collections.unmodifiableSet(new HashSet<T>(data));
...
SetcopyFeatureSet(Set o)
copy Feature Set
Set<String> res = new HashSet<>();
for (String s : o) {
    res.add(s);
return res;
voidcopySet(Set src, Set dest)
copy Set
for (Iterator<E> it = src.iterator(); it.hasNext();) {
    dest.add(it.next());
SetcopyToSet(Iterable elements)
copy To Set
Set<E> set = new LinkedHashSet<E>();
addAll(set, elements);
return set;