Class ImmutableArrayList<T>

    • Field Detail

      • items

        private final T[] items
    • Constructor Detail

      • ImmutableArrayList

        ImmutableArrayList​(T[] newElements)
    • Method Detail

      • newList

        public static <E> ImmutableArrayList<E> newList​(java.lang.Iterable<? extends E> iterable)
      • hashCode

        public int hashCode()
        Description copied from interface: ListIterable
        Follows the same general contract as List.hashCode().
        Specified by:
        hashCode in interface java.util.Collection<T>
        Specified by:
        hashCode in interface java.util.List<T>
        Specified by:
        hashCode in interface ListIterable<T>
        Overrides:
        hashCode in class AbstractImmutableList<T>
      • equals

        public boolean equals​(java.lang.Object that)
        Description copied from interface: ListIterable
        Follows the same general contract as List.equals(Object).
        Specified by:
        equals in interface java.util.Collection<T>
        Specified by:
        equals in interface java.util.List<T>
        Specified by:
        equals in interface ListIterable<T>
        Overrides:
        equals in class AbstractImmutableList<T>
      • immutableArrayListEquals

        public boolean immutableArrayListEquals​(ImmutableArrayList<?> otherList)
      • notEmpty

        public boolean notEmpty()
        Description copied from interface: RichIterable
        The English equivalent of !this.isEmpty()
        Specified by:
        notEmpty in interface RichIterable<T>
      • getFirst

        public T getFirst()
        Description copied from interface: RichIterable
        Returns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.

        The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.

        Specified by:
        getFirst in interface ListIterable<T>
        Specified by:
        getFirst in interface OrderedIterable<T>
        Specified by:
        getFirst in interface RichIterable<T>
        Overrides:
        getFirst in class AbstractImmutableList<T>
      • getLast

        public T getLast()
        Description copied from interface: RichIterable
        Returns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.

        The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.

        Specified by:
        getLast in interface ListIterable<T>
        Specified by:
        getLast in interface OrderedIterable<T>
        Specified by:
        getLast in interface RichIterable<T>
        Overrides:
        getLast in class AbstractImmutableList<T>
      • each

        public void each​(Procedure<? super T> procedure)
        Description copied from interface: RichIterable
        The procedure is executed for each element in the iterable.

        Example using a Java 8 lambda expression:

         people.each(person -> LOGGER.info(person.getName()));
         

        Example using an anonymous inner class:

         people.each(new Procedure<Person>()
         {
             public void value(Person person)
             {
                 LOGGER.info(person.getName());
             }
         });
         
        This method is a variant of InternalIterable.forEach(Procedure) that has a signature conflict with Iterable.forEach(java.util.function.Consumer).
        Specified by:
        each in interface RichIterable<T>
        See Also:
        InternalIterable.forEach(Procedure), Iterable.forEach(java.util.function.Consumer)
      • forEachWithIndex

        public void forEachWithIndex​(ObjectIntProcedure<? super T> objectIntProcedure)
        Description copied from interface: InternalIterable
        Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

        Example using a Java 8 lambda:

         people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));
         

        Example using an anonymous inner class:

         people.forEachWithIndex(new ObjectIntProcedure<Person>()
         {
             public void value(Person person, int index)
             {
                 LOGGER.info("Index: " + index + " person: " + person.getName());
             }
         });
         
        Specified by:
        forEachWithIndex in interface InternalIterable<T>
        Specified by:
        forEachWithIndex in interface OrderedIterable<T>
        Overrides:
        forEachWithIndex in class AbstractImmutableList<T>
      • forEachWithIndex

        public void forEachWithIndex​(int from,
                                     int to,
                                     ObjectIntProcedure<? super T> objectIntProcedure)
        Description copied from interface: OrderedIterable
        Iterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.
        e.g.
         OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally)
         people.forEachWithIndex(0, 1, new ObjectIntProcedure<Person>()
         {
             public void value(Person person, int index)
             {
                  LOGGER.info(person.getName());
             }
         });
         

        This code would output ted and mary's names.

        Specified by:
        forEachWithIndex in interface OrderedIterable<T>
        Overrides:
        forEachWithIndex in class AbstractImmutableList<T>
      • select

        public ImmutableList<T> select​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter.

        Example using a Java 8 lambda expression:

         RichIterable<Person> selected =
             people.select(person -> person.getAddress().getCity().equals("London"));
         

        Example using an anonymous inner class:

         RichIterable<Person> selected =
             people.select(new Predicate<Person>()
             {
                 public boolean accept(Person person)
                 {
                     return person.getAddress().getCity().equals("London");
                 }
             });
         
        Specified by:
        select in interface ImmutableCollection<T>
        Specified by:
        select in interface ImmutableList<T>
        Specified by:
        select in interface ListIterable<T>
        Specified by:
        select in interface OrderedIterable<T>
        Specified by:
        select in interface ReversibleIterable<T>
        Specified by:
        select in interface RichIterable<T>
        Overrides:
        select in class AbstractImmutableList<T>
      • selectWith

        public <P,​R extends java.util.Collection<T>> R selectWith​(Predicate2<? super T,​? super P> predicate,
                                                                        P parameter,
                                                                        R target)
        Description copied from interface: RichIterable
        Similar to RichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.

        E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

        Example using a Java 8 lambda expression:

         MutableList<Person> selected =
             people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());
         

        Example using an anonymous inner class:

         MutableList<Person> selected =
             people.selectWith(new Predicate2<Person, Integer>()
             {
                 public boolean accept(Person person, Integer age)
                 {
                     return person.getAge()>= age;
                 }
             }, Integer.valueOf(18), Lists.mutable.empty());
         
        Specified by:
        selectWith in interface RichIterable<T>
        Overrides:
        selectWith in class AbstractImmutableList<T>
        Parameters:
        predicate - a Predicate2 to use as the select criteria
        parameter - a parameter to pass in for evaluation of the second argument P in predicate
        target - the Collection to append to for all elements in this RichIterable that meet select criteria predicate
        Returns:
        targetCollection, which contains appended elements as a result of the select criteria
        See Also:
        RichIterable.select(Predicate), RichIterable.select(Predicate, Collection)
      • reject

        public ImmutableList<T> reject​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)).

        Example using a Java 8 lambda expression:

         RichIterable<Person> rejected =
             people.reject(person -> person.person.getLastName().equals("Smith"));
         

        Example using an anonymous inner class:

         RichIterable<Person> rejected =
             people.reject(new Predicate<Person>()
             {
                 public boolean accept(Person person)
                 {
                     return person.person.getLastName().equals("Smith");
                 }
             });
         
        Specified by:
        reject in interface ImmutableCollection<T>
        Specified by:
        reject in interface ImmutableList<T>
        Specified by:
        reject in interface ListIterable<T>
        Specified by:
        reject in interface OrderedIterable<T>
        Specified by:
        reject in interface ReversibleIterable<T>
        Specified by:
        reject in interface RichIterable<T>
        Overrides:
        reject in class AbstractImmutableList<T>
        Parameters:
        predicate - a Predicate to use as the reject criteria
        Returns:
        a RichIterable that contains elements that cause Predicate.accept(Object) method to evaluate to false
      • rejectWith

        public <P,​R extends java.util.Collection<T>> R rejectWith​(Predicate2<? super T,​? super P> predicate,
                                                                        P parameter,
                                                                        R target)
        Description copied from interface: RichIterable
        Similar to RichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.

        E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

        Example using a Java 8 lambda expression:

         MutableList<Person> rejected =
             people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());
         

        Example using an anonymous inner class:

         MutableList<Person> rejected =
             people.rejectWith(new Predicate2<Person, Integer>()
             {
                 public boolean accept(Person person, Integer age)
                 {
                     return person.getAge() < age;
                 }
             }, Integer.valueOf(18), Lists.mutable.empty());
         
        Specified by:
        rejectWith in interface RichIterable<T>
        Overrides:
        rejectWith in class AbstractImmutableList<T>
        Parameters:
        predicate - a Predicate2 to use as the reject criteria
        parameter - a parameter to pass in for evaluation of the second argument P in predicate
        target - the Collection to append to for all elements in this RichIterable that cause Predicate#accept(Object) method to evaluate to false
        Returns:
        targetCollection, which contains appended elements as a result of the reject criteria
        See Also:
        RichIterable.reject(Predicate), RichIterable.reject(Predicate, Collection)
      • collect

        public <V> ImmutableList<V> collect​(Function<? super T,​? extends V> function)
        Description copied from interface: RichIterable
        Returns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.

        Example using a Java 8 lambda expression:

         RichIterable<String> names =
             people.collect(person -> person.getFirstName() + " " + person.getLastName());
         

        Example using an anonymous inner class:

         RichIterable<String> names =
             people.collect(new Function<Person, String>()
             {
                 public String valueOf(Person person)
                 {
                     return person.getFirstName() + " " + person.getLastName();
                 }
             });
         
        Specified by:
        collect in interface ImmutableCollection<T>
        Specified by:
        collect in interface ImmutableList<T>
        Specified by:
        collect in interface ListIterable<T>
        Specified by:
        collect in interface OrderedIterable<T>
        Specified by:
        collect in interface ReversibleIterable<T>
        Specified by:
        collect in interface RichIterable<T>
        Overrides:
        collect in class AbstractImmutableList<T>
      • collectWithIndex

        public <V,​R extends java.util.Collection<V>> R collectWithIndex​(ObjectIntToObjectFunction<? super T,​? extends V> function,
                                                                              R target)
        Description copied from interface: OrderedIterable
        Adds elements to the target Collection using results obtained by applying the specified function to each element and its corresponding index.
        Specified by:
        collectWithIndex in interface OrderedIterable<T>
        Since:
        9.1.
      • selectWithIndex

        public <R extends java.util.Collection<T>> R selectWithIndex​(ObjectIntPredicate<? super T> predicate,
                                                                     R target)
        Description copied from interface: OrderedIterable
        Adds all elements to the target Collection that return true when evaluating the specified predicate which is supplied each element and its relative index.
        Specified by:
        selectWithIndex in interface OrderedIterable<T>
        Since:
        11.0
      • rejectWithIndex

        public <R extends java.util.Collection<T>> R rejectWithIndex​(ObjectIntPredicate<? super T> predicate,
                                                                     R target)
        Description copied from interface: OrderedIterable
        Adds all elements to the target Collection that return false when evaluating the specified predicate which is supplied each element and its relative index.
        Specified by:
        rejectWithIndex in interface OrderedIterable<T>
        Since:
        11.0
      • collectIf

        public <V> ImmutableList<V> collectIf​(Predicate<? super T> predicate,
                                              Function<? super T,​? extends V> function)
        Description copied from interface: RichIterable
        Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function).

        Example using a Java 8 lambda and method reference:

         RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);
         

        Example using Predicates factory:

         RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
         
        Specified by:
        collectIf in interface ImmutableCollection<T>
        Specified by:
        collectIf in interface ImmutableList<T>
        Specified by:
        collectIf in interface ListIterable<T>
        Specified by:
        collectIf in interface OrderedIterable<T>
        Specified by:
        collectIf in interface ReversibleIterable<T>
        Specified by:
        collectIf in interface RichIterable<T>
        Overrides:
        collectIf in class AbstractImmutableList<T>
      • collectWith

        public <P,​V,​R extends java.util.Collection<V>> R collectWith​(Function2<? super T,​? super P,​? extends V> function,
                                                                                 P parameter,
                                                                                 R target)
        Description copied from interface: RichIterable
        Same as collectWith but with a targetCollection parameter to gather the results.

        Example using a Java 8 lambda expression:

         MutableSet<Integer> integers =
             Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());
         

        Example using an anonymous inner class:

         Function2<Integer, Integer, Integer> addParameterFunction =
             new Function2<Integer, Integer, Integer>()
             {
                 public Integer value(final Integer each, final Integer parameter)
                 {
                     return each + parameter;
                 }
             };
         MutableSet<Integer> integers =
             Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), Sets.mutable.empty());
         
        Specified by:
        collectWith in interface RichIterable<T>
        Overrides:
        collectWith in class AbstractImmutableList<T>
        Parameters:
        function - a Function2 to use as the collect transformation function
        parameter - a parameter to pass in for evaluation of the second argument P in function
        target - the Collection to append to for all elements in this RichIterable that meet select criteria function
        Returns:
        targetCollection, which contains appended elements as a result of the collect transformation
      • flatCollect

        public <V> ImmutableList<V> flatCollect​(Function<? super T,​? extends java.lang.Iterable<V>> function)
        Description copied from interface: RichIterable
        flatCollect is a special case of RichIterable.collect(Function). With collect, when the Function returns a collection, the result is a collection of collections. flatCollect outputs a single "flattened" collection instead. This method is commonly called flatMap.

        Consider the following example where we have a Person class, and each Person has a list of Address objects. Take the following Function:

         Function<Person, List<Address>> addressFunction = Person::getAddresses;
         RichIterable<Person> people = ...;
         
        Using collect returns a collection of collections of addresses.
         RichIterable<List<Address>> addresses = people.collect(addressFunction);
         
        Using flatCollect returns a single flattened list of addresses.
         RichIterable<Address> addresses = people.flatCollect(addressFunction);
         
        Specified by:
        flatCollect in interface ImmutableCollection<T>
        Specified by:
        flatCollect in interface ImmutableList<T>
        Specified by:
        flatCollect in interface ListIterable<T>
        Specified by:
        flatCollect in interface OrderedIterable<T>
        Specified by:
        flatCollect in interface ReversibleIterable<T>
        Specified by:
        flatCollect in interface RichIterable<T>
        Overrides:
        flatCollect in class AbstractImmutableList<T>
        Parameters:
        function - The Function to apply
        Returns:
        a new flattened collection produced by applying the given function
      • flatCollect

        public <V,​R extends java.util.Collection<V>> R flatCollect​(Function<? super T,​? extends java.lang.Iterable<V>> function,
                                                                         R target)
        Description copied from interface: RichIterable
        Same as flatCollect, only the results are collected into the target collection.
        Specified by:
        flatCollect in interface RichIterable<T>
        Overrides:
        flatCollect in class AbstractImmutableList<T>
        Parameters:
        function - The Function to apply
        target - The collection into which results should be added.
        Returns:
        target, which will contain a flattened collection of results produced by applying the given function
        See Also:
        RichIterable.flatCollect(Function)
      • detect

        public T detect​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find.

        Example using a Java 8 lambda expression:

         Person person =
             people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
         

        Example using an anonymous inner class:

         Person person =
             people.detect(new Predicate<Person>()
             {
                 public boolean accept(Person person)
                 {
                     return person.getFirstName().equals("John") && person.getLastName().equals("Smith");
                 }
             });
         
        Specified by:
        detect in interface RichIterable<T>
        Overrides:
        detect in class AbstractRichIterable<T>
      • detectWith

        public <P> T detectWith​(Predicate2<? super T,​? super P> predicate,
                                P parameter)
        Description copied from interface: RichIterable
        Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.

        Example using a Java 8 lambda expression:

         Person person =
             people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
         

        Example using an anonymous inner class:

         Person person =
             people.detectWith(new Predicate2<Person, String>()
             {
                 public boolean accept(Person person, String fullName)
                 {
                     return person.getFullName().equals(fullName);
                 }
             }, "John Smith");
         
        Specified by:
        detectWith in interface RichIterable<T>
        Overrides:
        detectWith in class AbstractRichIterable<T>
      • detectOptional

        public java.util.Optional<T> detectOptional​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.

        Example using a Java 8 lambda expression:

         Person person =
             people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));
         

        Specified by:
        detectOptional in interface RichIterable<T>
        Overrides:
        detectOptional in class AbstractRichIterable<T>
      • detectWithOptional

        public <P> java.util.Optional<T> detectWithOptional​(Predicate2<? super T,​? super P> predicate,
                                                            P parameter)
        Description copied from interface: RichIterable
        Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.

        Example using a Java 8 lambda expression:

         Optional<Person> person =
             people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");
         

        Specified by:
        detectWithOptional in interface RichIterable<T>
        Overrides:
        detectWithOptional in class AbstractRichIterable<T>
      • count

        public int count​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Return the total number of elements that answer true to the specified predicate.

        Example using a Java 8 lambda expression:

         int count =
             people.count(person -> person.getAddress().getState().getName().equals("New York"));
         

        Example using an anonymous inner class:

         int count =
             people.count(new Predicate<Person>()
             {
                 public boolean accept(Person person)
                 {
                     return person.getAddress().getState().getName().equals("New York");
                 }
             });
         
        Specified by:
        count in interface RichIterable<T>
        Overrides:
        count in class AbstractImmutableList<T>
      • corresponds

        public <S> boolean corresponds​(OrderedIterable<S> other,
                                       Predicate2<? super T,​? super S> predicate)
        Description copied from interface: OrderedIterable
        Returns true if both OrderedIterables have the same length and predicate returns true for all corresponding elements e1 of this OrderedIterable and e2 of other. The predicate is evaluated for each element at the same position of each OrderedIterable in a forward iteration order. This is a short circuit pattern.
        Specified by:
        corresponds in interface OrderedIterable<T>
        Overrides:
        corresponds in class AbstractImmutableList<T>
      • anySatisfy

        public boolean anySatisfy​(Predicate<? super T> predicate)
        Description copied from interface: RichIterable
        Returns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.
        Specified by:
        anySatisfy in interface RichIterable<T>
        Overrides:
        anySatisfy in class AbstractRichIterable<T>
      • summarizeInt

        public java.util.IntSummaryStatistics summarizeInt​(IntFunction<? super T> function)
        Description copied from interface: RichIterable
        Returns the result of summarizing the value returned from applying the IntFunction to each element of the iterable.
         IntSummaryStatistics stats =
             Lists.mutable.with(1, 2, 3).summarizeInt(Integer::intValue);
         
        Specified by:
        summarizeInt in interface RichIterable<T>
        Since:
        8.0
      • summarizeFloat

        public java.util.DoubleSummaryStatistics summarizeFloat​(FloatFunction<? super T> function)
        Description copied from interface: RichIterable
        Returns the result of summarizing the value returned from applying the FloatFunction to each element of the iterable.
         DoubleSummaryStatistics stats =
             Lists.mutable.with(1, 2, 3).summarizeFloat(Integer::floatValue);
         
        Specified by:
        summarizeFloat in interface RichIterable<T>
        Since:
        8.0
      • summarizeLong

        public java.util.LongSummaryStatistics summarizeLong​(LongFunction<? super T> function)
        Description copied from interface: RichIterable
        Returns the result of summarizing the value returned from applying the LongFunction to each element of the iterable.
         LongSummaryStatistics stats =
             Lists.mutable.with(1, 2, 3).summarizeLong(Integer::longValue);
         
        Specified by:
        summarizeLong in interface RichIterable<T>
        Since:
        8.0
      • summarizeDouble

        public java.util.DoubleSummaryStatistics summarizeDouble​(DoubleFunction<? super T> function)
        Description copied from interface: RichIterable
        Returns the result of summarizing the value returned from applying the DoubleFunction to each element of the iterable.
         DoubleSummaryStatistics stats =
             Lists.mutable.with(1, 2, 3).summarizeDouble(Integer::doubleValue);
         
        Specified by:
        summarizeDouble in interface RichIterable<T>
        Since:
        8.0
      • reduce

        public java.util.Optional<T> reduce​(java.util.function.BinaryOperator<T> accumulator)
        Description copied from interface: RichIterable
        This method produces the equivalent result as Stream.reduce(BinaryOperator).
        Specified by:
        reduce in interface RichIterable<T>
        Overrides:
        reduce in class AbstractImmutableCollection<T>
        Since:
        8.0
      • reduceInPlace

        public <R,​A> R reduceInPlace​(java.util.stream.Collector<? super T,​A,​R> collector)
        Description copied from interface: RichIterable
        This method produces the equivalent result as Stream.collect(Collector).
         MutableObjectLongMap<Integer> map2 =
             Lists.mutable.with(1, 2, 3, 4, 5).reduceInPlace(Collectors2.sumByInt(i -> Integer.valueOf(i % 2), Integer::intValue));
         
        Specified by:
        reduceInPlace in interface RichIterable<T>
        Since:
        8.0
      • reduceInPlace

        public <R> R reduceInPlace​(java.util.function.Supplier<R> supplier,
                                   java.util.function.BiConsumer<R,​? super T> accumulator)
        Description copied from interface: RichIterable
        This method produces the equivalent result as Stream.collect(Supplier, BiConsumer, BiConsumer). The combiner used in collect is unnecessary in the serial case, so is not included in the API.
        Specified by:
        reduceInPlace in interface RichIterable<T>
        Since:
        8.0
      • sumOfFloat

        public double sumOfFloat​(FloatFunction<? super T> function)
        Description copied from interface: RichIterable
        Returns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.
        Specified by:
        sumOfFloat in interface RichIterable<T>
        Overrides:
        sumOfFloat in class AbstractImmutableList<T>
      • sumOfDouble

        public double sumOfDouble​(DoubleFunction<? super T> function)
        Description copied from interface: RichIterable
        Returns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.
        Specified by:
        sumOfDouble in interface RichIterable<T>
        Overrides:
        sumOfDouble in class AbstractImmutableList<T>
      • injectInto

        public <IV> IV injectInto​(IV injectedValue,
                                  Function2<? super IV,​? super T,​? extends IV> function)
        Description copied from interface: RichIterable
        Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.
        Specified by:
        injectInto in interface RichIterable<T>
        Overrides:
        injectInto in class AbstractImmutableList<T>
      • size

        public int size()
        Description copied from interface: RichIterable
        Returns the number of items in this iterable.
        Specified by:
        size in interface BatchIterable<T>
        Specified by:
        size in interface java.util.Collection<T>
        Specified by:
        size in interface java.util.List<T>
        Specified by:
        size in interface RichIterable<T>
      • isEmpty

        public boolean isEmpty()
        Description copied from interface: RichIterable
        Returns true if this iterable has zero items.
        Specified by:
        isEmpty in interface java.util.Collection<T>
        Specified by:
        isEmpty in interface java.util.List<T>
        Specified by:
        isEmpty in interface RichIterable<T>
        Overrides:
        isEmpty in class AbstractRichIterable<T>
      • contains

        public boolean contains​(java.lang.Object o)
        Description copied from interface: RichIterable
        Returns true if the iterable has an element which responds true to element.equals(object).
        Specified by:
        contains in interface java.util.Collection<T>
        Specified by:
        contains in interface java.util.List<T>
        Specified by:
        contains in interface RichIterable<T>
        Overrides:
        contains in class AbstractRichIterable<T>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.util.Collection<T>
        Specified by:
        iterator in interface java.lang.Iterable<T>
        Specified by:
        iterator in interface java.util.List<T>
        Overrides:
        iterator in class AbstractImmutableList<T>
      • toArray

        public java.lang.Object[] toArray()
        Description copied from interface: RichIterable
        Converts this iterable to an array.
        Specified by:
        toArray in interface java.util.Collection<T>
        Specified by:
        toArray in interface java.util.List<T>
        Specified by:
        toArray in interface RichIterable<T>
        Overrides:
        toArray in class AbstractRichIterable<T>
        See Also:
        Collection.toArray()
      • toArray

        public <E> E[] toArray​(E[] a)
        Description copied from interface: RichIterable
        Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.
        Specified by:
        toArray in interface java.util.Collection<T>
        Specified by:
        toArray in interface java.util.List<T>
        Specified by:
        toArray in interface RichIterable<T>
        Overrides:
        toArray in class AbstractRichIterable<T>
        See Also:
        Collection.toArray(Object[])
      • toString

        public java.lang.String toString()
        Description copied from class: AbstractRichIterable
        Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.
         Assert.assertEquals("[]", Lists.mutable.empty().toString());
         Assert.assertEquals("[1]", Lists.mutable.with(1).toString());
         Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
         
        Specified by:
        toString in interface RichIterable<T>
        Overrides:
        toString in class AbstractRichIterable<T>
        Returns:
        a string representation of this collection.
        See Also:
        AbstractCollection.toString()
      • containsAll

        public boolean containsAll​(java.util.Collection<?> collection)
        Description copied from interface: RichIterable
        Returns true if all elements in source are contained in this collection.
        Specified by:
        containsAll in interface java.util.Collection<T>
        Specified by:
        containsAll in interface java.util.List<T>
        Specified by:
        containsAll in interface RichIterable<T>
        Overrides:
        containsAll in class AbstractRichIterable<T>
        See Also:
        Collection.containsAll(Collection)
      • get

        public T get​(int index)
        Description copied from interface: ListIterable
        Returns the item at the specified position in this list iterable.
        Specified by:
        get in interface java.util.List<T>
        Specified by:
        get in interface ListIterable<T>
      • indexOf

        public int indexOf​(java.lang.Object item)
        Description copied from interface: OrderedIterable
        Returns the index of the first occurrence of the specified item in this iterable, or -1 if this iterable does not contain the item.
        Specified by:
        indexOf in interface java.util.List<T>
        Specified by:
        indexOf in interface OrderedIterable<T>
        Overrides:
        indexOf in class AbstractImmutableList<T>
        See Also:
        List.indexOf(Object)
      • lastIndexOf

        public int lastIndexOf​(java.lang.Object item)
        Description copied from interface: ListIterable
        Returns the index of the last occurrence of the specified item in this list, or -1 if this list does not contain the item.
        Specified by:
        lastIndexOf in interface java.util.List<T>
        Specified by:
        lastIndexOf in interface ListIterable<T>
        Overrides:
        lastIndexOf in class AbstractImmutableList<T>
      • minBy

        public <V extends java.lang.Comparable<? super V>> T minBy​(Function<? super T,​? extends V> function)
        Description copied from interface: RichIterable
        Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.
        Specified by:
        minBy in interface RichIterable<T>
        Overrides:
        minBy in class AbstractImmutableList<T>
      • maxBy

        public <V extends java.lang.Comparable<? super V>> T maxBy​(Function<? super T,​? extends V> function)
        Description copied from interface: RichIterable
        Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.
        Specified by:
        maxBy in interface RichIterable<T>
        Overrides:
        maxBy in class AbstractImmutableList<T>
      • detectNotIndex

        private int detectNotIndex​(Predicate<? super T> predicate)
      • spliterator

        public java.util.Spliterator<T> spliterator()
        Specified by:
        spliterator in interface java.util.Collection<T>
        Specified by:
        spliterator in interface ImmutableCollection<T>
        Specified by:
        spliterator in interface java.lang.Iterable<T>
        Specified by:
        spliterator in interface java.util.List<T>
        Overrides:
        spliterator in class AbstractImmutableCollection<T>
        Since:
        9.0