Java Utililty Methods Set Create

List of utility methods to do Set Create

Description

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

Method

SetasSet(Collection c)
as Set
return new LinkedHashSet<T>(c);
SetasSet(Collection c)
as Set
if (c instanceof Set) {
    return (Set<T>) c;
LinkedHashSet<T> set = new LinkedHashSet<T>(c);
return set;
HashSetasSet(Collection c)
as Set
HashSet<T> ret = new HashSet<T>();
ret.addAll(c);
return ret;
SetasSet(E... elements)
as Set
if (elements == null || elements.length == 0) {
    return Collections.emptySet();
LinkedHashSet<E> set = new LinkedHashSet<E>(elements.length * 4 / 3 + 1);
Collections.addAll(set, elements);
return set;
SetasSet(E... pEntities)
as Set
if (pEntities != null) {
    Set<E> entities = new HashSet<>();
    for (E entity : pEntities) {
        entities.add(entity);
    return entities;
return Collections.emptySet();
...
SetasSet(final E... elements)
Creates an immutable HashSet instance containing the given elements in unspecified order.
if (elements == null) {
    return new HashSet<>(0);
final Set<E> set = new HashSet<>(elements.length);
Collections.addAll(set, elements);
return Collections.unmodifiableSet(set);
SetasSet(final T t, final T... ts)
as Set
final Set<T> set = new HashSet<T>(ts.length + 1);
set.add(t);
Collections.addAll(set, ts);
return set;
SetasSet(final T... array)
Returns the specified array as a Set of elements.
Set<T> arraySet = new HashSet<T>(array.length);
Collections.addAll(arraySet, array);
return arraySet;
SetasSet(int... values)
as Set
Set<Integer> s = new HashSet<Integer>();
for (int v : values) {
    s.add(v);
return s;
SetasSet(Iterable iteratable)
as Set
final HashSet<T> set = new HashSet<>();
return asSet(iteratable, set);