All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.dongliu.commons.collection.ExHashSet Maven / Gradle / Ivy

The newest version!
package net.dongliu.commons.collection;

import java.util.Collection;
import java.util.HashSet;

/**
 * Expanded hash set
 *
 * @author Liu Dong
 */
public class ExHashSet extends HashSet implements ExSet {
    private static final long serialVersionUID = 5933716561248724701L;

    public ExHashSet() {
    }

    public ExHashSet(Collection c) {
        super(c);
    }

    public ExHashSet(int initialCapacity, float loadFactor) {
        super(initialCapacity, loadFactor);
    }

    public ExHashSet(int initialCapacity) {
        super(initialCapacity);
    }


    /**
     * Create mutable set
     */
    public static  ExHashSet of() {
        return new ExHashSet<>();
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value) {
        ExHashSet list = new ExHashSet<>();
        list.add(value);
        return list;
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value1, T value2) {
        ExHashSet list = new ExHashSet<>();
        list.add(value1);
        list.add(value2);
        return list;
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value1, T value2, T value3) {
        ExHashSet list = new ExHashSet<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        return list;
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value1, T value2, T value3, T value4) {
        ExHashSet list = new ExHashSet<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        return list;
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value1, T value2, T value3, T value4, T value5) {
        ExHashSet list = new ExHashSet<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        list.add(value5);
        return list;
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value1, T value2, T value3, T value4, T value5,
                                              T value6) {
        ExHashSet list = new ExHashSet<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        list.add(value5);
        list.add(value6);
        return list;
    }

    /**
     * Create mutable set
     */
    public static  ExHashSet of(T value1, T value2, T value3, T value4, T value5,
                                              T value6, T value7) {
        ExHashSet list = new ExHashSet<>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        list.add(value4);
        list.add(value5);
        list.add(value6);
        list.add(value7);
        return list;
    }

    @SafeVarargs
    public static  ExHashSet of(T... values) {
        ExHashSet list = new ExHashSet<>();
        list.addAll(values);
        return list;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy