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

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

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

import java.util.Collection;
import java.util.Comparator;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * Expanded tree set
 *
 * @author Liu Dong
 */
public class ExTreeSet extends TreeSet implements ExSet {
    private static final long serialVersionUID = 5134658584246179022L;

    public ExTreeSet() {
    }

    public ExTreeSet(Comparator comparator) {
        super(comparator);
    }

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

    public ExTreeSet(SortedSet s) {
        super(s);
    }


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

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

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

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

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

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

    /**
     * Create mutable set
     */
    public static  ExTreeSet of(T value1, T value2, T value3, T value4, T value5,
                                              T value6) {
        ExTreeSet list = new ExTreeSet<>();
        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  ExTreeSet of(T value1, T value2, T value3, T value4, T value5,
                                              T value6, T value7) {
        ExTreeSet list = new ExTreeSet<>();
        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  ExTreeSet of(T... values) {
        ExTreeSet list = new ExTreeSet<>();
        list.addAll(values);
        return list;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy