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> set(T... elements) {
    Set<T> set = new HashSet<T>();
    for (T ele : elements) {
        set.add(ele);
    }//  w w  w  . j ava  2 s.c o m
    return set;
}

From source file:Main.java

public static <T> Set<T> asSet(T... as) {
    Set<T> set = new HashSet<T>(as.length);
    for (T a : as) {
        set.add(a);
    }/*from  www  .j  av  a 2s  .c o  m*/
    return set;
}

From source file:Main.java

/**
 *  Returns a set containing the passed elements.
 *//*from w w  w . j  a  v a2 s .com*/
public static <T> Set<T> asSet(T... elems) {
    Set<T> result = new HashSet<T>();
    for (T elem : elems)
        result.add(elem);
    return result;
}

From source file:Main.java

public static <T> Set<T> arrayToSet(T[] array) {
    if (array == null) {
        return new HashSet<T>();
    }//from w ww.j  a  v a  2s  .  c  o m
    Set<T> set = new HashSet<T>();
    for (T t : array) {
        set.add(t);
    }
    return set;
}

From source file:Main.java

public static <T> Set<T> set(T... objects) {
    Set<T> set = new HashSet<T>();
    for (T obj : objects) {
        set.add(obj);
    }/*from ww w . j a v  a2s . c  om*/

    return set;
}

From source file:Main.java

/**
 * @param <T>/*from   w w w .  ja v  a2 s  .  c  om*/
 * @param list
 * @return list
 */
public static <T> Set<T> list2Set(List<T> list) {
    Set<T> set = new HashSet<T>();
    for (T t : list) {
        set.add(t);
    }
    return set;
}

From source file:Main.java

/**
 * Returns a new Set containing the given values
 *///from   ww w .ja va  2  s  .  c  o m
public static <T> Set<T> setOf(T... values) {
    Set<T> set = newHashSet();
    for (T value : values)
        set.add(value);
    return set;
}

From source file:Main.java

public static <T> Set<T> newSet(T... values) {
    Set<T> set = new HashSet<T>();
    for (T value : values) {
        set.add(value);
    }/*from   w  w  w. j  a v a2 s  .  c om*/
    return set;
}

From source file:Main.java

/**
 * Returns an unmodifiable set that contains all scopes declared by this class.
 *
 * @since 1.16//  w w w  . ja v a 2  s.  co m
 */
public static java.util.Set<String> all() {
    java.util.Set<String> set = new java.util.HashSet<String>();
    set.add(USERINFO_EMAIL);
    return java.util.Collections.unmodifiableSet(set);
}

From source file:Main.java

public static <T> Set<T> asSet(T element) {
    Set<T> collectionSheetsForMeetingDate = new HashSet<T>();
    collectionSheetsForMeetingDate.add(element);
    return collectionSheetsForMeetingDate;
}