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

solid.converters.Doubles 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: 1.0.14
Show newest version
package solid.converters;

import java.util.Iterator;

import solid.stream.ReadOnlyIterator;
import solid.stream.Stream;

public class Doubles extends Stream {

    private double[] doubles;

    /**
     * Creates a new stream of {@link Double} type that contains all items of a given array.
     *
     * @param doubles an array to get items from.
     * @return a new stream of {@link Double} type that contains all items of a given array.
     */
    public static Stream doubles(double[] doubles) {
        return new Doubles(doubles);
    }

    public Doubles(double[] doubles) {
        this.doubles = doubles;
    }

    @Override
    public Iterator iterator() {
        return new ReadOnlyIterator() {

            int i;

            @Override
            public boolean hasNext() {
                return i < doubles.length;
            }

            @Override
            public Double next() {
                return doubles[i++];
            }
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy