
solid.converters.ToPrimitiveDoubleArray Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solid Show documentation
Show all versions of solid Show documentation
Solid is an Android library, which provides lightweight data streams and immutable+parcelable collections.
package solid.converters;
import java.util.List;
import solid.functions.SolidFunc1;
import solid.stream.Copy;
public class ToPrimitiveDoubleArray implements SolidFunc1, double[]> {
private static final SolidFunc1, double[]> TO_PRIMITIVE_DOUBLE_ARRAY = new ToPrimitiveDoubleArray();
/**
* Returns a method that can be used with {@link solid.stream.Stream#collect(SolidFunc1)}
* to convert an iterable stream of {@link Double} type into a primitive double[] array.
*
* @return a method that converts an iterable stream of {@link Double} type into a primitive double[] array.
*/
public static SolidFunc1, double[]> toPrimitiveDoubleArray() {
return TO_PRIMITIVE_DOUBLE_ARRAY;
}
@Override
public double[] call(Iterable value) {
List objects = new Copy<>(value).collect(ToList.toList());
double[] primitives = new double[objects.size()];
int i = 0;
for (Double object : objects)
primitives[i++] = object;
return primitives;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy