Example usage for java.util Set add

List of usage examples for java.util Set add

Introduction

In this page you can find the example usage for java.util Set add.

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:Main.java

public static <T> Set<T> newSet(T... args) {
    Set<T> r = new HashSet<T>();
    for (T e : args)
        r.add(e);
    return r;/*from www . j  a v  a  2  s  .co m*/
}

From source file:Main.java

public static <T> void fillSetFromArray(Set<T> set, final T[] array) {
    for (T t : array) {
        set.add(t);
    }//from   w  ww.j  a  v a2s .  co m
}

From source file:Main.java

public static <T> Set<T> listToSet(Collection<T> list) {
    Set<T> set = new TreeSet<T>();
    for (T t : list)
        set.add(t);
    return set;//w  ww . ja va 2 s .co  m
}

From source file:Main.java

private static Set<Class<?>> getWrapperTypes() {
    Set<Class<?>> ret = new HashSet<Class<?>>();
    ret.add(Boolean.class);
    ret.add(Character.class);
    ret.add(Byte.class);
    ret.add(Short.class);
    ret.add(Integer.class);
    ret.add(Long.class);
    ret.add(Float.class);
    ret.add(Double.class);
    ret.add(Void.class);
    ret.add(String.class);
    return ret;//from w w w  .j a va  2 s . c om
}

From source file:Main.java

public static <T> Set<T> toListSet(T... arr) {
    Set<T> set = new LinkedHashSet<T>();
    for (T t : arr)
        set.add(t);
    return set;//from  ww w  .j  av a 2 s  . com
}

From source file:Main.java

@SafeVarargs
public static <E> Set<E> $s(E... ee) {
    Set<E> set = new TreeSet<>();
    for (E e : ee) {
        set.add(e);
    }//  w  w w.j a  v  a  2 s .c o m
    return set;
}

From source file:Main.java

public static <T> Set<T> arrayToSet(T[] array) {
    Set<T> set = new HashSet<T>();

    for (T t : array)
        set.add(t);

    return set;/*from   w w w .ja  v  a 2s  . co  m*/
}

From source file:Main.java

public static <T> Set<T> asSet(T... arr) {
    Set<T> ret = new HashSet<T>();
    for (T t : arr) {
        ret.add(t);
    }//from www .  ja  v a  2  s.co  m
    return ret;
}

From source file:Main.java

public static <T> Set<T> asSet(T... obj) {
    Set<T> set = new HashSet<T>();
    for (T el : obj) {
        set.add(el);
    }//from   www  . j  ava 2  s .co m
    return set;
}

From source file:Main.java

@SafeVarargs
public static <T> Set<T> set(T... objects) {
    Set<T> set = new HashSet<>();
    for (T t : objects) {
        set.add(t);
    }/*  www.  j  av  a2 s  .com*/
    return set;
}