// Path: hppc/src/main/templates/com/carrotsearch/hppc/predicates/KTypePredicate.java
// public interface KTypePredicate<KType> {
//   public boolean apply(KType value);
// }
// 
// Path: hppc/src/main/java/com/carrotsearch/hppc/Containers.java
// public final class Containers {
//   /** The default number of expected elements for containers. */
//   public static final int DEFAULT_EXPECTED_ELEMENTS = 4;
// 
//   /**
//    * External initial seed value. We do not care about multiple assignments so not volatile.
//    *
//    * @see #randomSeed64()
//    */
//   private static String testsSeedProperty;
// 
//   /** Unique marker for {@link #testsSeedProperty}. */
//   private static final String NOT_AVAILABLE = new String();
// 
//   private Containers() {}
// 
//   /**
//    * Provides a (possibly) random initial seed for randomized stuff.
//    *
//    * <p>If <code>tests.seed</code> property is available and accessible, the returned value will be
//    * derived from the value of that property and will be constant to ensure reproducibility in
//    * presence of the randomized testing package.
//    *
//    * @see "https://github.com/carrotsearch/randomizedtesting"
//    */
//   @SuppressForbidden
//   public static long randomSeed64() {
//     if (testsSeedProperty == null) {
//       try {
//         testsSeedProperty =
//             java.security.AccessController.doPrivileged(
//                 new PrivilegedAction<String>() {
//                   @Override
//                   public String run() {
//                     return System.getProperty("tests.seed", NOT_AVAILABLE);
//                   }
//                 });
//       } catch (SecurityException e) {
//         // If failed on security exception, don't panic.
//         testsSeedProperty = NOT_AVAILABLE;
//         Logger.getLogger(Containers.class.getName())
//             .log(Level.INFO, "Failed to read 'tests.seed' property for initial random seed.", e);
//       }
//     }
// 
//     long initialSeed;
//     if (testsSeedProperty != NOT_AVAILABLE) {
//       initialSeed = testsSeedProperty.hashCode();
//     } else {
//       // Mix something that is changing over time (nanoTime)
//       // ... with something that is thread-local and relatively unique
//       //     even for very short time-spans (new Object's address from a TLAB).
//       initialSeed = System.nanoTime() ^ System.identityHashCode(new Object());
//     }
//     return BitMixer.mix64(initialSeed);
//   }
// 
//   /** Reset state for tests. */
//   static void test$reset() {
//     testsSeedProperty = null;
//   }
// }


import java.util.*;
import com.carrotsearch.hppc.cursors.*;
import com.carrotsearch.hppc.predicates.KTypePredicate;
import com.carrotsearch.hppc.procedures.*;
import static com.carrotsearch.hppc.Containers.*;
  public <T extends KTypeProcedure<? super KType>> T forEach(T procedure) {
    return forEach(procedure, 0, size());
  }

  /**
   * Applies <code>procedure</code> to a slice of the list,
   * <code>fromIndex</code>, inclusive, to <code>toIndex</code>, exclusive.
   */
  public <T extends KTypeProcedure<? super KType>> T forEach(T procedure, int fromIndex, final int toIndex) {
    assert (fromIndex >= 0 && fromIndex <= size()) :
        "Index " + fromIndex + " out of bounds [" + 0 + ", " + size() + ").";

    assert (toIndex >= 0 && toIndex <= size()) :
        "Index " + toIndex + " out of bounds [" + 0 + ", " + size() + "].";
    
    assert fromIndex <= toIndex : "fromIndex must be <= toIndex: "
        + fromIndex + ", " + toIndex;

    final KType [] buffer = Intrinsics.<KType[]> cast(this.buffer);
    for (int i = fromIndex; i < toIndex; i++) {
        procedure.apply(buffer[i]);
    }

    return procedure;
  }

  /**
   * {@inheritDoc}
   */
  @Override
// Path: hppc/src/main/templates/com/carrotsearch/hppc/predicates/KTypePredicate.java
// public interface KTypePredicate<KType> {
//   public boolean apply(KType value);
// }
// 
// Path: hppc/src/main/java/com/carrotsearch/hppc/Containers.java
// public final class Containers {
//   /** The default number of expected elements for containers. */
//   public static final int DEFAULT_EXPECTED_ELEMENTS = 4;
// 
//   /**
//    * External initial seed value. We do not care about multiple assignments so not volatile.
//    *
//    * @see #randomSeed64()
//    */
//   private static String testsSeedProperty;
// 
//   /** Unique marker for {@link #testsSeedProperty}. */
//   private static final String NOT_AVAILABLE = new String();
// 
//   private Containers() {}
// 
//   /**
//    * Provides a (possibly) random initial seed for randomized stuff.
//    *
//    * <p>If <code>tests.seed</code> property is available and accessible, the returned value will be
//    * derived from the value of that property and will be constant to ensure reproducibility in
//    * presence of the randomized testing package.
//    *
//    * @see "https://github.com/carrotsearch/randomizedtesting"
//    */
//   @SuppressForbidden
//   public static long randomSeed64() {
//     if (testsSeedProperty == null) {
//       try {
//         testsSeedProperty =
//             java.security.AccessController.doPrivileged(
//                 new PrivilegedAction<String>() {
//                   @Override
//                   public String run() {
//                     return System.getProperty("tests.seed", NOT_AVAILABLE);
//                   }
//                 });
//       } catch (SecurityException e) {
//         // If failed on security exception, don't panic.
//         testsSeedProperty = NOT_AVAILABLE;
//         Logger.getLogger(Containers.class.getName())
//             .log(Level.INFO, "Failed to read 'tests.seed' property for initial random seed.", e);
//       }
//     }
// 
//     long initialSeed;
//     if (testsSeedProperty != NOT_AVAILABLE) {
//       initialSeed = testsSeedProperty.hashCode();
//     } else {
//       // Mix something that is changing over time (nanoTime)
//       // ... with something that is thread-local and relatively unique
//       //     even for very short time-spans (new Object's address from a TLAB).
//       initialSeed = System.nanoTime() ^ System.identityHashCode(new Object());
//     }
//     return BitMixer.mix64(initialSeed);
//   }
// 
//   /** Reset state for tests. */
//   static void test$reset() {
//     testsSeedProperty = null;
//   }
// }


// Path: hppc/src/main/templates/com/carrotsearch/hppc/KTypeArrayList.java
import java.util.*;
import com.carrotsearch.hppc.cursors.*;
import com.carrotsearch.hppc.predicates.KTypePredicate;
import com.carrotsearch.hppc.procedures.*;
import static com.carrotsearch.hppc.Containers.*;

  public <T extends KTypeProcedure<? super KType>> T forEach(T procedure) {
    return forEach(procedure, 0, size());
  }

  /**
   * Applies <code>procedure</code> to a slice of the list,
   * <code>fromIndex</code>, inclusive, to <code>toIndex</code>, exclusive.
   */
  public <T extends KTypeProcedure<? super KType>> T forEach(T procedure, int fromIndex, final int toIndex) {
    assert (fromIndex >= 0 && fromIndex <= size()) :
        "Index " + fromIndex + " out of bounds [" + 0 + ", " + size() + ").";

    assert (toIndex >= 0 && toIndex <= size()) :
        "Index " + toIndex + " out of bounds [" + 0 + ", " + size() + "].";
    
    assert fromIndex <= toIndex : "fromIndex must be <= toIndex: "
        + fromIndex + ", " + toIndex;

    final KType [] buffer = Intrinsics.<KType[]> cast(this.buffer);
    for (int i = fromIndex; i < toIndex; i++) {
        procedure.apply(buffer[i]);
    }

    return procedure;
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public int removeAll(KTypePredicate<? super KType> predicate) {