package speiger.src.collections.PACKAGE.collections; #if !TYPE_OBJECT import java.util.Objects; import java.util.function.Consumer; import speiger.src.collections.PACKAGE.functions.CONSUMER; #endif /** * A Type-Specific {@link Iterable} that reduces (un)boxing */ public interface ITERABLE KEY_GENERIC_TYPE extends Iterable { /** * Returns an iterator over elements of type {@code T}. * * @return an Iterator. */ @Override ITERATOR KEY_GENERIC_TYPE iterator(); #if !TYPE_OBJECT /** * A Type Specific foreach function that reduces (un)boxing * * @implSpec *

The default implementation behaves as if: *

{@code
     *     iterator().forEachRemaining(action);
     * }
* * @param action The action to be performed for each element * @throws NullPointerException if the specified action is null * @see Iterable#forEach(Consumer) */ default void forEach(CONSUMER action) { Objects.requireNonNull(action); iterator().forEachRemaining(action); } /** {@inheritDoc} *

This default implementation delegates to the corresponding type-specific function. * @deprecated Please use the corresponding type-specific function instead. */ @Deprecated @Override default void forEach(Consumer action) { Objects.requireNonNull(action); iterator().forEachRemaining(action); } #endif }