Class RandomAccessListIterate


  • public final class RandomAccessListIterate
    extends java.lang.Object
    The ListIterate class provides a few of the methods from the Smalltalk Collection Protocol for use with ArrayLists. This includes do:, select:, reject:, collect:, inject:into:, detect:, detect:ifNone:, anySatisfy: and allSatisfy:
    • Constructor Detail

      • RandomAccessListIterate

        private RandomAccessListIterate()
    • Method Detail

      • toArray

        public static <T> void toArray​(java.util.List<T> list,
                                       T[] target,
                                       int startIndex,
                                       int sourceSize)
      • countWith

        public static <T,​IV> int countWith​(java.util.List<T> list,
                                                 Predicate2<? super T,​? super IV> predicate,
                                                 IV injectedValue)
      • collectWithIndex

        public static <T,​A,​R extends java.util.Collection<A>> R collectWithIndex​(java.util.List<T> list,
                                                                                             ObjectIntToObjectFunction<? super T,​? extends A> function,
                                                                                             R targetCollection)
        Since:
        9.1
      • getLast

        public static <T> T getLast​(java.util.List<T> collection)
        Returns the last element of a list.
      • forEach

        public static <T> void forEach​(java.util.List<T> list,
                                       int from,
                                       int to,
                                       Procedure<? super T> procedure)
        Iterates over the section of the list covered by the specified indexes. The indexes are both inclusive. If the from is less than the to, the list is iterated in forward order. If the from is greater than the to, then the list is iterated in the reverse order.
        e.g.
         MutableList<People> people = FastList.newListWith(ted, mary, bob, sally);
         ListIterate.forEach(people, 0, 1, new Procedure<Person>()
         {
             public void value(Person person)
             {
                  LOGGER.info(person.getName());
             }
         });
         

        This code would output ted and mary's names.

      • forEachWithIndex

        public static <T> void forEachWithIndex​(java.util.List<T> list,
                                                int from,
                                                int to,
                                                ObjectIntProcedure<? super T> objectIntProcedure)
        Iterates over the section of the list covered by the specified indexes. The indexes are both inclusive. If the from is less than the to, the list is iterated in forward order. If the from is greater than the to, then the list is iterated in the reverse order. The index passed into the ObjectIntProcedure is the actual index of the range.
        e.g.
         MutableList<People> people = FastList.newListWith(ted, mary, bob, sally);
         ListIterate.forEachWithIndex(people, 0, 1, new ObjectIntProcedure<Person>()
         {
             public void value(Person person, int index)
             {
                  LOGGER.info(person.getName() + " at index: " + index);
             }
         });
         

        This code would output ted and mary's names.

      • forEachInBoth

        public static <T1,​T2> void forEachInBoth​(java.util.List<T1> list1,
                                                       java.util.List<T2> list2,
                                                       Procedure2<? super T1,​? super T2> procedure)
        For each element in both of the Lists, operation is evaluated with both elements as parameters.
      • forEachWithIndex

        public static <T> void forEachWithIndex​(java.util.List<T> list,
                                                ObjectIntProcedure<? super T> objectIntProcedure)
        Iterates over a collection passing each element and the current relative int index to the specified instance of ObjectIntProcedure.
      • injectInto

        public static <T,​IV> IV injectInto​(IV injectValue,
                                                 java.util.List<T> list,
                                                 Function2<? super IV,​? super T,​? extends IV> function)
      • injectInto

        public static <T> int injectInto​(int injectValue,
                                         java.util.List<T> list,
                                         IntObjectToIntFunction<? super T> function)
      • injectInto

        public static <T> long injectInto​(long injectValue,
                                          java.util.List<T> list,
                                          LongObjectToLongFunction<? super T> function)
      • injectInto

        public static <T> double injectInto​(double injectValue,
                                            java.util.List<T> list,
                                            DoubleObjectToDoubleFunction<? super T> function)
      • injectInto

        public static <T> float injectInto​(float injectValue,
                                           java.util.List<T> list,
                                           FloatObjectToFloatFunction<? super T> function)
      • sumOfInt

        public static <T> long sumOfInt​(java.util.List<T> list,
                                        IntFunction<? super T> function)
      • sumOfLong

        public static <T> long sumOfLong​(java.util.List<T> list,
                                         LongFunction<? super T> function)
      • sumOfFloat

        public static <T> double sumOfFloat​(java.util.List<T> list,
                                            FloatFunction<? super T> function)
      • sumOfDouble

        public static <T> double sumOfDouble​(java.util.List<T> list,
                                             DoubleFunction<? super T> function)
      • sumOfBigDecimal

        public static <T> java.math.BigDecimal sumOfBigDecimal​(java.util.List<T> list,
                                                               Function<? super T,​java.math.BigDecimal> function)
      • sumOfBigInteger

        public static <T> java.math.BigInteger sumOfBigInteger​(java.util.List<T> list,
                                                               Function<? super T,​java.math.BigInteger> function)
      • sumByBigDecimal

        public static <V,​T> MutableMap<V,​java.math.BigDecimal> sumByBigDecimal​(java.util.List<T> list,
                                                                                           Function<? super T,​? extends V> groupBy,
                                                                                           Function<? super T,​java.math.BigDecimal> function)
      • sumByBigInteger

        public static <V,​T> MutableMap<V,​java.math.BigInteger> sumByBigInteger​(java.util.List<T> list,
                                                                                           Function<? super T,​? extends V> groupBy,
                                                                                           Function<? super T,​java.math.BigInteger> function)
      • shortCircuit

        public static <T> boolean shortCircuit​(java.util.List<T> list,
                                               Predicate<? super T> predicate,
                                               boolean expected,
                                               boolean onShortCircuit,
                                               boolean atEnd)
      • shortCircuitWith

        public static <T,​P> boolean shortCircuitWith​(java.util.List<T> list,
                                                           Predicate2<? super T,​? super P> predicate2,
                                                           P parameter,
                                                           boolean expected,
                                                           boolean onShortCircuit,
                                                           boolean atEnd)
      • corresponds

        public static <T,​P> boolean corresponds​(java.util.List<T> list,
                                                      OrderedIterable<P> other,
                                                      Predicate2<? super T,​? super P> predicate)
      • anySatisfy

        public static <T> boolean anySatisfy​(java.util.List<T> list,
                                             Predicate<? super T> predicate)
      • anySatisfyWith

        public static <T,​P> boolean anySatisfyWith​(java.util.List<T> list,
                                                         Predicate2<? super T,​? super P> predicate,
                                                         P parameter)
      • allSatisfy

        public static <T> boolean allSatisfy​(java.util.List<T> list,
                                             Predicate<? super T> predicate)
      • allSatisfyWith

        public static <T,​P> boolean allSatisfyWith​(java.util.List<T> list,
                                                         Predicate2<? super T,​? super P> predicate,
                                                         P parameter)
      • noneSatisfy

        public static <T> boolean noneSatisfy​(java.util.List<T> list,
                                              Predicate<? super T> predicate)
      • noneSatisfyWith

        public static <T,​P> boolean noneSatisfyWith​(java.util.List<T> list,
                                                          Predicate2<? super T,​? super P> predicate,
                                                          P parameter)
      • detect

        public static <T> T detect​(java.util.List<T> list,
                                   Predicate<? super T> predicate)
      • detectWith

        public static <T,​P> T detectWith​(java.util.List<T> list,
                                               Predicate2<? super T,​? super P> predicate,
                                               P parameter)
      • detectOptional

        public static <T> java.util.Optional<T> detectOptional​(java.util.List<T> list,
                                                               Predicate<? super T> predicate)
      • detectWithOptional

        public static <T,​P> java.util.Optional<T> detectWithOptional​(java.util.List<T> list,
                                                                           Predicate2<? super T,​? super P> predicate,
                                                                           P parameter)
      • selectAndRejectWith

        public static <T,​IV> Twin<MutableList<T>> selectAndRejectWith​(java.util.List<T> list,
                                                                            Predicate2<? super T,​? super IV> predicate,
                                                                            IV injectedValue)
      • partitionWith

        public static <T,​P> PartitionMutableList<T> partitionWith​(java.util.List<T> list,
                                                                        Predicate2<? super T,​? super P> predicate,
                                                                        P parameter)
      • removeIf

        public static <T> boolean removeIf​(java.util.List<T> list,
                                           Predicate<? super T> predicate)
      • removeIfWith

        public static <T,​P> boolean removeIfWith​(java.util.List<T> list,
                                                       Predicate2<? super T,​? super P> predicate,
                                                       P parameter)
      • removeIf

        public static <T> boolean removeIf​(java.util.List<T> list,
                                           Predicate<? super T> predicate,
                                           Procedure<? super T> procedure)
      • removeIfWith

        public static <T,​P> boolean removeIfWith​(java.util.List<T> list,
                                                       Predicate2<? super T,​? super P> predicate,
                                                       P parameter,
                                                       Procedure<? super T> procedure)
      • detectLastIndex

        public static <T> int detectLastIndex​(java.util.List<T> list,
                                              Predicate<? super T> predicate)
      • injectIntoWith

        public static <T,​IV,​P> IV injectIntoWith​(IV injectedValue,
                                                             java.util.List<T> list,
                                                             Function3<? super IV,​? super T,​? super P,​? extends IV> function,
                                                             P parameter)
      • forEachWith

        public static <T,​P> void forEachWith​(java.util.List<T> list,
                                                   Procedure2<? super T,​? super P> procedure,
                                                   P parameter)
      • collectWith

        public static <T,​P,​A,​R extends java.util.Collection<A>> R collectWith​(java.util.List<T> list,
                                                                                                Function2<? super T,​? super P,​? extends A> function,
                                                                                                P parameter,
                                                                                                R targetCollection)
      • distinct

        @Deprecated
        public static <T,​R extends java.util.List<T>> R distinct​(java.util.List<T> list,
                                                                       R targetList)
        Deprecated.
        in 7.0.
      • distinct

        public static <T> MutableList<T> distinct​(java.util.List<T> list)
        Since:
        7.0.
      • distinct

        public static <T> MutableList<T> distinct​(java.util.List<T> list,
                                                  HashingStrategy<? super T> hashingStrategy)
        Since:
        7.0.
      • take

        public static <T,​R extends java.util.Collection<T>> R take​(java.util.List<T> list,
                                                                         int count,
                                                                         R targetList)
        See Also:
        Iterate.take(Iterable, int)
      • drop

        public static <T,​R extends java.util.Collection<T>> R drop​(java.util.List<T> list,
                                                                         int count,
                                                                         R targetList)
        See Also:
        Iterate.drop(Iterable, int)
      • groupByEach

        public static <T,​V> FastListMultimap<V,​T> groupByEach​(java.util.List<T> list,
                                                                          Function<? super T,​? extends java.lang.Iterable<V>> function)
      • groupByEach

        public static <T,​V,​R extends MutableMultimap<V,​T>> R groupByEach​(java.util.List<T> list,
                                                                                           Function<? super T,​? extends java.lang.Iterable<V>> function,
                                                                                           R target)
      • groupByUniqueKey

        public static <K,​T> MutableMap<K,​T> groupByUniqueKey​(java.util.List<T> list,
                                                                         Function<? super T,​? extends K> function)
      • groupByUniqueKey

        public static <K,​T,​R extends MutableMapIterable<K,​T>> R groupByUniqueKey​(java.util.List<T> list,
                                                                                                   Function<? super T,​? extends K> function,
                                                                                                   R target)
      • minBy

        public static <T,​V extends java.lang.Comparable<? super V>> T minBy​(java.util.List<T> list,
                                                                                  Function<? super T,​? extends V> function)
      • maxBy

        public static <T,​V extends java.lang.Comparable<? super V>> T maxBy​(java.util.List<T> list,
                                                                                  Function<? super T,​? extends V> function)
      • min

        public static <T> T min​(java.util.List<T> list,
                                java.util.Comparator<? super T> comparator)
      • max

        public static <T> T max​(java.util.List<T> list,
                                java.util.Comparator<? super T> comparator)
      • min

        public static <T> T min​(java.util.List<T> list)
      • max

        public static <T> T max​(java.util.List<T> list)
      • zip

        public static <X,​Y> MutableList<Pair<X,​Y>> zip​(java.util.List<X> list,
                                                                   java.lang.Iterable<Y> iterable)
      • zip

        public static <X,​Y,​R extends java.util.Collection<Pair<X,​Y>>> R zip​(java.util.List<X> list,
                                                                                              java.lang.Iterable<Y> iterable,
                                                                                              R target)
      • zipWithIndex

        public static <T> MutableList<Pair<T,​java.lang.Integer>> zipWithIndex​(java.util.List<T> list)
      • zipWithIndex

        public static <T,​R extends java.util.Collection<Pair<T,​java.lang.Integer>>> R zipWithIndex​(java.util.List<T> list,
                                                                                                               R target)
      • aggregateInPlaceBy

        public static <T,​K,​V> MutableMap<K,​V> aggregateInPlaceBy​(java.util.List<T> list,
                                                                                   Function<? super T,​? extends K> groupBy,
                                                                                   Function0<? extends V> zeroValueFactory,
                                                                                   Procedure2<? super V,​? super T> mutatingAggregator)
      • aggregateBy

        public static <T,​K,​V> MutableMap<K,​V> aggregateBy​(java.util.List<T> list,
                                                                            Function<? super T,​? extends K> groupBy,
                                                                            Function0<? extends V> zeroValueFactory,
                                                                            Function2<? super V,​? super T,​? extends V> nonMutatingAggregator)
      • takeWhile

        public static <T> MutableList<T> takeWhile​(java.util.List<T> list,
                                                   Predicate<? super T> predicate)
      • dropWhile

        public static <T> MutableList<T> dropWhile​(java.util.List<T> list,
                                                   Predicate<? super T> predicate)
      • sumByInt

        public static <V,​T> ObjectLongMap<V> sumByInt​(java.util.List<T> list,
                                                            Function<? super T,​? extends V> groupBy,
                                                            IntFunction<? super T> function)
      • sumByLong

        public static <V,​T> ObjectLongMap<V> sumByLong​(java.util.List<T> list,
                                                             Function<? super T,​? extends V> groupBy,
                                                             LongFunction<? super T> function)