/** * Unwraps an iterator, returning an array. * * <p> * This method iterates over the given type-specific iterator and returns an * array containing the elements returned by the iterator. * * @param i * a type-specific iterator. * @return an array containing the elements returned by the iterator. */ public static double[] unwrap(final DoubleIterator i) { return unwrap(i, Integer.MAX_VALUE); } /**
/** * Unwraps an iterator into an array. * * <p> * This method iterates over the given type-specific iterator and stores the * elements returned in the given array. The iteration will stop when the * iterator has no more elements or when the end of the array has been reached. * * @param i * a type-specific iterator. * @param array * an array to contain the output of the iterator. * @return the number of elements unwrapped. */ public static int unwrap(final DoubleIterator i, final double array[]) { return unwrap(i, array, 0, array.length); } /**
/** * Creates a new array list and fills it with a given collection. * * @param c * a collection that will be used to fill the array list. */ public DoubleArrayList(final Collection<? extends Double> c) { this(c.size()); size = DoubleIterators.unwrap(DoubleIterators.asDoubleIterator(c.iterator()), a); } /**
/** * Creates a new array list and fills it with a given type-specific collection. * * @param c * a type-specific collection that will be used to fill the array * list. */ public DoubleArrayList(final DoubleCollection c) { this(c.size()); size = DoubleIterators.unwrap(c.iterator(), a); } /**
@Override public double[] toArray(double a[]) { if (a == null || a.length < size()) a = new double[size()]; DoubleIterators.unwrap(iterator(), a); return a; } @Override