// Path: hppc/src/main/templates/com/carrotsearch/hppc/cursors/KTypeCursor.java
// public final class KTypeCursor<KType> {
//   /**
//    * The current value's index in the container this cursor belongs to. The
//    * meaning of this index is defined by the container (usually it will be an
//    * index in the underlying storage buffer).
//    */
//   public int index;
// 
//   /**
//    * The current value.
//    */
//   public KType value;
// 
//   @Override
//   public String toString() {
//     return "[cursor, index: " + index + ", value: " + value + "]";
//   }
// }
// 
// Path: hppc/src/main/templates/com/carrotsearch/hppc/predicates/KTypePredicate.java
// public interface KTypePredicate<KType> {
//   public boolean apply(KType value);
// }
// 
// Path: hppc/src/main/templates/com/carrotsearch/hppc/procedures/KTypeProcedure.java
// public interface KTypeProcedure<KType> {
//   public void 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.KTypeCursor;
import com.carrotsearch.hppc.predicates.KTypePredicate;
import com.carrotsearch.hppc.procedures.KTypeProcedure;
import static com.carrotsearch.hppc.Containers.*;
   */
  @Override
  public <T extends KTypePredicate<? super KType>> T descendingForEach(T predicate) {
    descendingForEach(predicate, head, tail);
    return predicate;
  }

  /**
   * Applies <code>predicate</code> to a slice of the deque,
   * <code>toIndex</code>, exclusive, down to <code>fromIndex</code>, inclusive
   * or until the predicate returns <code>false</code>.
   */
  private void descendingForEach(KTypePredicate<? super KType> predicate, int fromIndex, final int toIndex) {
    if (fromIndex == toIndex)
      return;

    final KType[] buffer = Intrinsics.<KType[]> cast(this.buffer);
    int i = toIndex;
    do {
      i = oneLeft(i, buffer.length);
      if (!predicate.apply(buffer[i])) {
        break;
      }
    } while (i != fromIndex);
  }

  /**
   * {@inheritDoc}
   */
  @Override
// Path: hppc/src/main/templates/com/carrotsearch/hppc/cursors/KTypeCursor.java
// public final class KTypeCursor<KType> {
//   /**
//    * The current value's index in the container this cursor belongs to. The
//    * meaning of this index is defined by the container (usually it will be an
//    * index in the underlying storage buffer).
//    */
//   public int index;
// 
//   /**
//    * The current value.
//    */
//   public KType value;
// 
//   @Override
//   public String toString() {
//     return "[cursor, index: " + index + ", value: " + value + "]";
//   }
// }
// 
// Path: hppc/src/main/templates/com/carrotsearch/hppc/predicates/KTypePredicate.java
// public interface KTypePredicate<KType> {
//   public boolean apply(KType value);
// }
// 
// Path: hppc/src/main/templates/com/carrotsearch/hppc/procedures/KTypeProcedure.java
// public interface KTypeProcedure<KType> {
//   public void 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/KTypeArrayDeque.java
import java.util.*;
import com.carrotsearch.hppc.cursors.KTypeCursor;
import com.carrotsearch.hppc.predicates.KTypePredicate;
import com.carrotsearch.hppc.procedures.KTypeProcedure;
import static com.carrotsearch.hppc.Containers.*;

   */
  @Override
  public <T extends KTypePredicate<? super KType>> T descendingForEach(T predicate) {
    descendingForEach(predicate, head, tail);
    return predicate;
  }

  /**
   * Applies <code>predicate</code> to a slice of the deque,
   * <code>toIndex</code>, exclusive, down to <code>fromIndex</code>, inclusive
   * or until the predicate returns <code>false</code>.
   */
  private void descendingForEach(KTypePredicate<? super KType> predicate, int fromIndex, final int toIndex) {
    if (fromIndex == toIndex)
      return;

    final KType[] buffer = Intrinsics.<KType[]> cast(this.buffer);
    int i = toIndex;
    do {
      i = oneLeft(i, buffer.length);
      if (!predicate.apply(buffer[i])) {
        break;
      }
    } while (i != fromIndex);
  }

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