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

com.ajjpj.afoundation.collection.immutable.ARedBlackTreeSet Maven / Gradle / Ivy

The newest version!
package com.ajjpj.afoundation.collection.immutable;

import com.ajjpj.afoundation.collection.AEquality;

import java.util.Arrays;
import java.util.Comparator;


/**
 * @author arno
 */
public class ARedBlackTreeSet extends MapAsSetWrapper> {
    @SuppressWarnings ("unchecked")
    public static  ARedBlackTreeSet empty (Comparator comparator) {
        return new ARedBlackTreeSet<> (ARedBlackTreeMap. empty (comparator));
    }

    @SuppressWarnings ("unchecked")
    public static  ARedBlackTreeSet create (Comparator comparator, T... elements) {
        return create (comparator, Arrays.asList (elements));
    }

    public static  ARedBlackTreeSet create (Comparator comparator, Iterable elements) {
        ARedBlackTreeSet result = empty (comparator);

        for (T el: elements) {
            result = result.added (el);
        }
        return result;
    }

    public static  ARedBlackTreeSet create (ARedBlackTreeMap inner) {
        return new ARedBlackTreeSet<> (inner);
    }

    private ARedBlackTreeSet (AMap inner) {
        super (inner);
    }

    @Override protected ARedBlackTreeSet wrapAsSet (AMap inner) {
        return new ARedBlackTreeSet<> (inner);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy