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

solid.collectors.ToSolidSet Maven / Gradle / Ivy

Go to download

Solid is an Android library, which provides lightweight data streams and immutable+parcelable collections.

There is a newer version: 3.0.1
Show newest version
package solid.collectors;

import java.util.ArrayList;
import java.util.List;

import solid.collections.SolidSet;
import solid.functions.Func1;

public class ToSolidSet {

    private static final Func1 TO_SOLID_SET = toSolidSet(0);

    /**
     * Returns a method that can be used with {@link solid.stream.Stream#collect(Func1)}
     * to convert a stream into a {@link ArrayList}.
     *
     * @param  a type of {@link ArrayList} items.
     * @return a method that converts an iterable into {@link ArrayList}.
     */
    public static  Func1, SolidSet> toSolidSet() {
        return TO_SOLID_SET;
    }

    /**
     * Returns a method that can be used with {@link solid.stream.Stream#collect(Func1)}
     * to convert a stream into a {@link List}.
     * 

* Use this method instead of {@link #toSolidSet()} for better performance on * streams that can have more than 12 items. * * @param a type of {@link List} items. * @param initialCapacity initial capacity of the list. * @return a method that converts an iterable into {@link List}. */ public static Func1, SolidSet> toSolidSet(final int initialCapacity) { return new Func1, SolidSet>() { @Override public SolidSet call(Iterable iterable) { return new SolidSet<>(iterable, initialCapacity); } }; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy