@Override public void each(Procedure<? super T> procedure) { ArrayListIterate.forEach(this.delegate, procedure); }
@Override public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure) { ArrayListIterate.forEachWithIndex(this.delegate, objectIntProcedure); }
@Override public boolean allSatisfy(Predicate<? super T> predicate) { return ArrayListIterate.allSatisfy(this.delegate, predicate); }
public static <T> void toArray(ArrayList<T> list, T[] target, int startIndex, int sourceSize) { if (ArrayListIterate.canAccessInternalArray(list)) { System.arraycopy(ArrayListIterate.getInternalArray(list), 0, target, startIndex, sourceSize); } else { RandomAccessListIterate.toArray(list, target, startIndex, sourceSize); } }
/** * @see Iterate#collect(Iterable, Function) */ public static <T, A> ArrayList<A> collect( ArrayList<T> list, Function<? super T, ? extends A> function) { return ArrayListIterate.collect(list, function, new ArrayList<A>(list.size())); }
@Override public boolean anySatisfy(Predicate<? super T> predicate) { return ArrayListIterate.anySatisfy(this.delegate, predicate); }
/** * Returns true if the predicate2 and parameter evaluates to true for any element of the iterable. * Returns false if the iterable is empty or if no elements return true for the predicate2. */ public static <T, P> boolean anySatisfyWith( Iterable<T> iterable, Predicate2<? super T, ? super P> predicate, P parameter) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).anySatisfyWith(predicate, parameter); } if (iterable instanceof ArrayList) { return ArrayListIterate.anySatisfyWith((ArrayList<T>) iterable, predicate, parameter); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.anySatisfyWith((List<T>) iterable, predicate, parameter); } if (iterable != null) { return IterableIterate.anySatisfyWith(iterable, predicate, parameter); } throw new IllegalArgumentException("Cannot perform an anySatisfyWith on null"); }
/** * Returns true if the predicate evaluates to true for every element of the iterable, or returns false. */ public static <T, P> boolean allSatisfyWith( Iterable<T> iterable, Predicate2<? super T, ? super P> predicate, P parameter) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).allSatisfyWith(predicate, parameter); } if (iterable instanceof ArrayList) { return ArrayListIterate.allSatisfyWith((ArrayList<T>) iterable, predicate, parameter); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.allSatisfyWith((List<T>) iterable, predicate, parameter); } if (iterable != null) { return IterableIterate.allSatisfyWith(iterable, predicate, parameter); } throw new IllegalArgumentException("Cannot perform an allSatisfyWith on null"); }
/** * @see RichIterable#aggregateBy(Function, Function0, Function2) */ public static <T, K, V> MutableMap<K, V> aggregateBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } if (iterable instanceof ArrayList) { return ArrayListIterate.aggregateBy((ArrayList<T>) iterable, groupBy, zeroValueFactory, nonMutatingAggregator); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.aggregateBy((List<T>) iterable, groupBy, zeroValueFactory, nonMutatingAggregator); } if (iterable != null) { return IterableIterate.aggregateBy(iterable, groupBy, zeroValueFactory, nonMutatingAggregator); } throw new IllegalArgumentException("Cannot perform an aggregateBy on null"); }
/** * @see RichIterable#aggregateInPlaceBy(Function, Function0, Procedure2) */ public static <T, K, V> MutableMap<K, V> aggregateInPlaceBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } if (iterable instanceof ArrayList) { return ArrayListIterate.aggregateInPlaceBy((ArrayList<T>) iterable, groupBy, zeroValueFactory, mutatingAggregator); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.aggregateInPlaceBy((List<T>) iterable, groupBy, zeroValueFactory, mutatingAggregator); } if (iterable != null) { return IterableIterate.aggregateInPlaceBy(iterable, groupBy, zeroValueFactory, mutatingAggregator); } throw new IllegalArgumentException("Cannot perform an aggregateInPlaceBy on null"); }
/** * Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList. */ public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator) { int size = list.size(); if (ArrayListIterate.canAccessInternalArray(list)) { Arrays.sort(ArrayListIterate.getInternalArray(list), 0, size, comparator); } else { Collections.sort(list, comparator); } return list; }
@Override public <V> ArrayListAdapter<V> collect(Function<? super T, ? extends V> function) { return this.wrap(ArrayListIterate.collect(this.delegate, function)); }
/** * Returns true if the predicate evaluates to true for any element of the iterable. * Returns false if the iterable is empty or if no elements return true for the predicate. */ public static <T> boolean anySatisfy(Iterable<T> iterable, Predicate<? super T> predicate) { if (iterable instanceof RichIterable) { return ((RichIterable<T>) iterable).anySatisfy(predicate); } if (iterable instanceof ArrayList) { return ArrayListIterate.anySatisfy((ArrayList<T>) iterable, predicate); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.anySatisfy((List<T>) iterable, predicate); } if (iterable != null) { return IterableIterate.anySatisfy(iterable, predicate); } throw new IllegalArgumentException("Cannot perform an anySatisfy on null"); }
/** * Returns true if the predicate2 and parameter evaluates to true for any element of the iterable. * Returns false if the iterable is empty or if no elements return true for the predicate2. */ public static <T, P> boolean anySatisfyWith( Iterable<T> iterable, Predicate2<? super T, ? super P> predicate, P parameter) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).anySatisfyWith(predicate, parameter); } if (iterable instanceof ArrayList) { return ArrayListIterate.anySatisfyWith((ArrayList<T>) iterable, predicate, parameter); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.anySatisfyWith((List<T>) iterable, predicate, parameter); } if (iterable != null) { return IterableIterate.anySatisfyWith(iterable, predicate, parameter); } throw new IllegalArgumentException("Cannot perform an anySatisfyWith on null"); }
/** * Returns true if the predicate evaluates to true for every element of the iterable, or returns false. */ public static <T, P> boolean allSatisfyWith( Iterable<T> iterable, Predicate2<? super T, ? super P> predicate, P parameter) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).allSatisfyWith(predicate, parameter); } if (iterable instanceof ArrayList) { return ArrayListIterate.allSatisfyWith((ArrayList<T>) iterable, predicate, parameter); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.allSatisfyWith((List<T>) iterable, predicate, parameter); } if (iterable != null) { return IterableIterate.allSatisfyWith(iterable, predicate, parameter); } throw new IllegalArgumentException("Cannot perform an allSatisfyWith on null"); }
/** * @see RichIterable#aggregateBy(Function, Function0, Function2) */ public static <T, K, V> MutableMap<K, V> aggregateBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).aggregateBy(groupBy, zeroValueFactory, nonMutatingAggregator); } if (iterable instanceof ArrayList) { return ArrayListIterate.aggregateBy((ArrayList<T>) iterable, groupBy, zeroValueFactory, nonMutatingAggregator); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.aggregateBy((List<T>) iterable, groupBy, zeroValueFactory, nonMutatingAggregator); } if (iterable != null) { return IterableIterate.aggregateBy(iterable, groupBy, zeroValueFactory, nonMutatingAggregator); } throw new IllegalArgumentException("Cannot perform an aggregateBy on null"); }
/** * @see RichIterable#aggregateInPlaceBy(Function, Function0, Procedure2) */ public static <T, K, V> MutableMap<K, V> aggregateInPlaceBy( Iterable<T> iterable, Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator) { if (iterable instanceof MutableCollection) { return ((MutableCollection<T>) iterable).aggregateInPlaceBy(groupBy, zeroValueFactory, mutatingAggregator); } if (iterable instanceof ArrayList) { return ArrayListIterate.aggregateInPlaceBy((ArrayList<T>) iterable, groupBy, zeroValueFactory, mutatingAggregator); } if (iterable instanceof RandomAccess) { return RandomAccessListIterate.aggregateInPlaceBy((List<T>) iterable, groupBy, zeroValueFactory, mutatingAggregator); } if (iterable != null) { return IterableIterate.aggregateInPlaceBy(iterable, groupBy, zeroValueFactory, mutatingAggregator); } throw new IllegalArgumentException("Cannot perform an aggregateInPlaceBy on null"); }
public void forEach(int fromIndex, int toIndex, Procedure<? super T> procedure) { ArrayListIterate.forEach(this.delegate, fromIndex, toIndex, procedure); }
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super T> objectIntProcedure) { ArrayListIterate.forEachWithIndex(this.delegate, fromIndex, toIndex, objectIntProcedure); }
/** * Mutates the internal array of the ArrayList by sorting it and then returns the same ArrayList. */ public static <T> ArrayList<T> sortThis(ArrayList<T> list, Comparator<? super T> comparator) { int size = list.size(); if (ArrayListIterate.canAccessInternalArray(list)) { Arrays.sort(ArrayListIterate.getInternalArray(list), 0, size, comparator); } else { Collections.sort(list, comparator); } return list; }