// 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);
// }


import java.util.Arrays;
import com.carrotsearch.hppc.cursors.KTypeCursor;
import com.carrotsearch.hppc.predicates.KTypePredicate;
package com.carrotsearch.hppc;



/**
 * Common superclass for collections. 
 */
/*! #if ($TemplateOptions.KTypeGeneric) !*/
@SuppressWarnings("unchecked")
/*! #end !*/
/*! ${TemplateOptions.generatedAnnotation} !*/
abstract class AbstractKTypeCollection<KType> 
  implements /*! #if ($templateonly) !*/ Intrinsics.EqualityFunction, /*! #end !*/
             KTypeCollection<KType>
{
  /**
   * Default implementation uses a predicate for removal.
   */
  @Override
  public int removeAll(final KTypeLookupContainer<? super KType> c) {
    return this.removeAll(c::contains);
  }

  /**
   * Default implementation uses a predicate for retaining.
   */
  @Override
  public int retainAll(final KTypeLookupContainer<? super KType> c) {
    // We know c holds sub-types of KType and we're not modifying c, so go unchecked.
    return this.removeAll(k -> !c.contains(k));
  }

  /**
   * Default implementation redirects to {@link #removeAll(KTypePredicate)} and
   * negates the predicate.
   */
  @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/AbstractKTypeCollection.java
import java.util.Arrays;
import com.carrotsearch.hppc.cursors.KTypeCursor;
import com.carrotsearch.hppc.predicates.KTypePredicate;

package com.carrotsearch.hppc;



/**
 * Common superclass for collections. 
 */
/*! #if ($TemplateOptions.KTypeGeneric) !*/
@SuppressWarnings("unchecked")
/*! #end !*/
/*! ${TemplateOptions.generatedAnnotation} !*/
abstract class AbstractKTypeCollection<KType> 
  implements /*! #if ($templateonly) !*/ Intrinsics.EqualityFunction, /*! #end !*/
             KTypeCollection<KType>
{
  /**
   * Default implementation uses a predicate for removal.
   */
  @Override
  public int removeAll(final KTypeLookupContainer<? super KType> c) {
    return this.removeAll(c::contains);
  }

  /**
   * Default implementation uses a predicate for retaining.
   */
  @Override
  public int retainAll(final KTypeLookupContainer<? super KType> c) {
    // We know c holds sub-types of KType and we're not modifying c, so go unchecked.
    return this.removeAll(k -> !c.contains(k));
  }

  /**
   * Default implementation redirects to {@link #removeAll(KTypePredicate)} and
   * negates the predicate.
   */
  @Override
  public int retainAll(final KTypePredicate<? super KType> predicate) {