/** * 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 IdentityArrayList(final Collection<? extends K> c) { this(c.size()); size = ObjectIterators.unwrap(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 IdentityArrayList(final ObjectCollection<? extends K> c) { this(c.size()); size = ObjectIterators.unwrap(c.iterator(), a); }
@Override public <T> T[] toArray(T[] a) { if (size() <= a.length) { ObjectIterators.unwrap(iterator(), a); return a; } else { return delegate.toArray(a); } }
/** * 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 <K> K[] unwrap(final Iterator<? extends K> 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 <K> int unwrap(final Iterator<? extends K> i, final K 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 ReferenceArrayList(final Collection<? extends K> c) { this(c.size()); size = ObjectIterators.unwrap(c.iterator(), a); } /**
/** * 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 ObjectArrayList(final Collection<? extends K> c) { this(c.size()); size = ObjectIterators.unwrap(c.iterator(), a); } /**
/** 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 IdentityArrayList ( final Collection<? extends K> c ) { this( c.size() ); size = ObjectIterators.unwrap( c.iterator(), a ); } /** Creates a new array list and fills it with a given type-specific collection.
@Override public <T> T[] toArray(T[] a) { if (size() <= a.length) { ObjectIterators.unwrap(iterator(), a); return a; } else { return delegate.toArray(a); } }
final Object[] t = ObjectIterators.unwrap(anf.iterator()); final double a[][] = Arrays.copyOf(t, t.length, double[][].class);
@Override public <T> T[] toArray(T[] a) { if (size() <= a.length) { ObjectIterators.unwrap(iterator(), a); return a; } else { return delegate.toArray(a); } }
/** Evens out several approximate neighbourhood functions for the same * graph by extending them to the same length (by copying the last value). This is usually a * preparatory step for the {@linkplain Jackknife jackknife}. * * @param anf an iterable object returning arrays of doubles representing approximate neighbourhood functions. * @return a list containing the same approximate neighbourhood functions, extended to the same length. */ public static ObjectList<double[]> evenOut(final Iterable<double[]> anf) { final Object[] u = ObjectIterators.unwrap(anf.iterator()); final double t[][] = Arrays.copyOf(u, u.length, double[][].class); final int n = t.length; int max = 0; for(double[] a: t) max = Math.max(max, a.length); final ObjectArrayList<double[]> result = new ObjectArrayList<>(n); for(int i = 0; i < n; i++) { final double[] a = new double[max]; System.arraycopy(t[i], 0, a, 0, t[i].length); for(int j = t[i].length; j < max; j++) a[j] = a[j - 1]; result.add(a); } return result; }
/** 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 IdentityArrayList ( final ObjectCollection <? extends K> c ) { this( c.size() ); size = ObjectIterators.unwrap( c.iterator(), a ); } /** Creates a new array list and fills it with a given type-specific list.
/** * 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 ReferenceArrayList(final ReferenceCollection<? extends K> c) { this(c.size()); size = ObjectIterators.unwrap(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 ObjectArrayList(final ObjectCollection<? extends K> c) { this(c.size()); size = ObjectIterators.unwrap(c.iterator(), a); } /**
iterator.next(); SelectedInterval[] result = new SelectedInterval[ leftOrderedIntervals.size() - INIT.length ]; ObjectIterators.unwrap( iterator, result ); leftOrderedIntervals.clear(); return result;
iterator.next(); SelectedInterval[] result = new SelectedInterval[ leftOrderedIntervals.size() - INIT.length ]; ObjectIterators.unwrap( iterator, result ); leftOrderedIntervals.clear(); return result;
iterator.next(); SelectedInterval[] result = new SelectedInterval[ leftOrderedIntervals.size() - INIT.length ]; ObjectIterators.unwrap( iterator, result ); leftOrderedIntervals.clear(); return result;
iterator.next(); SelectedInterval[] result = new SelectedInterval[ leftOrderedIntervals.size() - INIT.length ]; ObjectIterators.unwrap( iterator, result ); leftOrderedIntervals.clear(); return result;