// Path: unsafe-helper/src/main/java/net/bramp/unsafe/Preconditions.java
// public static void checkArgument(boolean expression,
//     @Nullable String errorMessageTemplate,
//     @Nullable Object... errorMessageArgs) {
//   if (!expression) {
//     throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
//   }
// }
// 
// Path: unsafe-helper/src/main/java/net/bramp/unsafe/Preconditions.java
// public static <T> T checkNotNull(T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }


import com.google.common.base.Throwables;
import sun.misc.Unsafe;
import java.util.AbstractList;
import java.util.Collection;
import java.util.RandomAccess;
import static net.bramp.unsafe.Preconditions.checkArgument;
import static net.bramp.unsafe.Preconditions.checkNotNull;
    addAll(c);
  }

  public UnsafeArrayList(Class<T> type, int initialCapacity) {
    this.type = type;
    this.unsafe = UnsafeHelper.getUnsafe();
    this.firstFieldOffset = UnsafeHelper.firstFieldOffset(type);

    this.elementSize = UnsafeHelper.sizeOf(type) - firstFieldOffset;
    this.elementSpacing = Math.max(8, this.elementSize); // TODO(bramp) Do we need to pad to 8 bytes.

    try {
      copier = new UnrolledUnsafeCopierBuilder().of(type).build(this.unsafe);

      // Temp working space
      tmp = newInstance();

    } catch (Exception e) {
      throw Throwables.propagate(e);
    }

    setCapacity(initialCapacity);
  }

  @SuppressWarnings("unchecked")
  private T newInstance() throws InstantiationException {
    return (T) unsafe.allocateInstance(type);
  }

  private void setCapacity(int capacity) {
// Path: unsafe-helper/src/main/java/net/bramp/unsafe/Preconditions.java
// public static void checkArgument(boolean expression,
//     @Nullable String errorMessageTemplate,
//     @Nullable Object... errorMessageArgs) {
//   if (!expression) {
//     throw new IllegalArgumentException(format(errorMessageTemplate, errorMessageArgs));
//   }
// }
// 
// Path: unsafe-helper/src/main/java/net/bramp/unsafe/Preconditions.java
// public static <T> T checkNotNull(T reference) {
//   if (reference == null) {
//     throw new NullPointerException();
//   }
//   return reference;
// }


// Path: unsafe-collection/src/main/java/net/bramp/unsafe/UnsafeArrayList.java
import com.google.common.base.Throwables;
import sun.misc.Unsafe;
import java.util.AbstractList;
import java.util.Collection;
import java.util.RandomAccess;
import static net.bramp.unsafe.Preconditions.checkArgument;
import static net.bramp.unsafe.Preconditions.checkNotNull;

    addAll(c);
  }

  public UnsafeArrayList(Class<T> type, int initialCapacity) {
    this.type = type;
    this.unsafe = UnsafeHelper.getUnsafe();
    this.firstFieldOffset = UnsafeHelper.firstFieldOffset(type);

    this.elementSize = UnsafeHelper.sizeOf(type) - firstFieldOffset;
    this.elementSpacing = Math.max(8, this.elementSize); // TODO(bramp) Do we need to pad to 8 bytes.

    try {
      copier = new UnrolledUnsafeCopierBuilder().of(type).build(this.unsafe);

      // Temp working space
      tmp = newInstance();

    } catch (Exception e) {
      throw Throwables.propagate(e);
    }

    setCapacity(initialCapacity);
  }

  @SuppressWarnings("unchecked")
  private T newInstance() throws InstantiationException {
    return (T) unsafe.allocateInstance(type);
  }

  private void setCapacity(int capacity) {
    checkArgument(capacity >= 0, "Capacity must be greater than or equal to zero");