Interface InternalIterable<T>

    • Method Detail

      • forEach

        void forEach​(Procedure<? super T> procedure)
        The procedure is executed for each element in the iterable.

        Example using a Java 8 lambda:

         people.forEach(Procedures.cast(person -> LOGGER.info(person.getName())));
         

        Example using an anonymous inner class:

         people.forEach(new Procedure<Person>()
         {
             public void value(Person person)
             {
                 LOGGER.info(person.getName());
             }
         });
         
        NOTE: This method started to conflict with Iterable.forEach(java.util.function.Consumer) since Java 1.8. It is recommended to use RichIterable.each(Procedure) instead to avoid casting to Procedure.
        See Also:
        RichIterable.each(Procedure), Iterable.forEach(java.util.function.Consumer)
      • forEach

        default void forEach​(java.util.function.Consumer<? super T> consumer)
        Specified by:
        forEach in interface java.lang.Iterable<T>
      • forEachWithIndex

        @Deprecated
        void forEachWithIndex​(ObjectIntProcedure<? super T> objectIntProcedure)
        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());
             }
         });
         
      • forEachWith

        <P> void forEachWith​(Procedure2<? super T,​? super P> procedure,
                             P parameter)
        The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

        Example using a Java 8 lambda:

         people.forEachWith((Person person, Person other) ->
             {
                 if (person.isRelatedTo(other))
                 {
                      LOGGER.info(person.getName());
                 }
             }, fred);
         

        Example using an anonymous inner class:

         people.forEachWith(new Procedure2<Person, Person>()
         {
             public void value(Person person, Person other)
             {
                 if (person.isRelatedTo(other))
                 {
                      LOGGER.info(person.getName());
                 }
             }
         }, fred);