import "copyrightAndOthers.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveAPI.stg"
import "primitiveLiteral.stg"

targetPath() ::= "org/eclipse/collections/api/ordered/primitive"

fileName(primitive) ::= "Reversible<primitive.name>Iterable"

class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>

body(type, name) ::= <<
<copyrightAndOthers()>

package org.eclipse.collections.api.ordered.primitive;

import org.eclipse.collections.api.Lazy<name>Iterable;
import org.eclipse.collections.api.block.function.primitive.<name>IntToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.<name>ToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.Object<name>IntToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.<name>IntPredicate;
import org.eclipse.collections.api.block.predicate.primitive.<name>Predicate;
import org.eclipse.collections.api.ordered.ReversibleIterable;

/**
 * This file was automatically generated from template file reversiblePrimitiveIterable.stg.
 *
 * @since 5.0.
 */
public interface Reversible<name>Iterable extends Ordered<name>Iterable
{
    <type> getLast();

    Lazy<name>Iterable asReversed();

    <sharedAPI(fileName(primitive), name)>

    /**
     * Returns a new Reversible<name>Iterable including all elements with corresponding indexes matching the specified predicate.
     *
     * @since 11.1.
     */
    @Override
    default Reversible<name>Iterable selectWithIndex(<name>IntPredicate predicate)
    {
        int[] index = {0};
        return this.select(each -> predicate.accept(each, index[0]++));
    }

    /**
     * Returns a new Reversible<name>Iterable excluding all elements with corresponding indexes matching the specified predicate.
     *
     * @since 11.1.
     */
    @Override
    default Reversible<name>Iterable rejectWithIndex(<name>IntPredicate predicate)
    {
        int[] index = {0};
        return this.reject(each -> predicate.accept(each, index[0]++));
    }

    @Override
    \<V> ReversibleIterable\<V> collect(<name>ToObjectFunction\<? extends V> function);

    /**
     * Returns a new ReversibleIterable using results obtained by applying the specified function to each element
     * and its corresponding index.
     *
     * @since 9.1.
     */
    @Override
    default \<V> ReversibleIterable\<V> collectWithIndex(<name>IntToObjectFunction\<? extends V> function)
    {
        int[] index = {0};
        return this.collect(each -> function.value(each, index[0]++));
    }

    Reversible<name>Iterable toReversed();

    /**
     * @since 6.0.
     */
    Reversible<name>Iterable distinct();

    @Override
    \<T> T injectIntoWithIndex(T injectedValue, Object<name>IntToObjectFunction\<? super T, ? extends T> function);
}

>>
