Java HashSet Create hashSetFromArray(final T[] objs)

Here you can find the source of hashSetFromArray(final T[] objs)

Description

hash Set From Array

License

Open Source License

Declaration

public static <T> Set<T> hashSetFromArray(final T[] objs) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    public static <T> Set<T> hashSetFromArray(final T[] objs) {
        final Set<T> set = new HashSet<T>();
        for (final T obj : objs) {
            set.add(obj);/* ww  w .  j a  v a 2s  .c om*/
        }
        return set;
    }

    /**
     * Add objects to a collection... mostly used when an object instantiation is in the first paramter.
     */
    public static <T extends Object, C extends Collection<? super T>> C add(final C cxn, final T... objs) {
        if (objs != null) {
            for (final T obj : objs) {
                cxn.add(obj);
            }
        }
        return cxn;
    }

    public static <T extends Object, C extends Collection<? super T>> C add(final C cxn, Iterable<T> from) {
        if (from != null) {
            for (T obj : from) {
                cxn.add(obj);
            }
        }
        return cxn;
    }
}

Related

  1. convertHashSetIntoArray(HashSet cdsidsSet)
  2. createHashSet(T... arr)
  3. hashSet()
  4. hashSet()
  5. hashset_to_int_array(Set hs)
  6. hashSetOf(T... elements)
  7. hashSetOf(T... ts)
  8. identityHashSet()
  9. isValidTagException(HashSet tagExceptions, String buffer)