// Path: unsafe-collection/src/main/java/net/bramp/unsafe/InplaceList.java
// public interface InplaceList<E> extends List<E> {
// 
//   /**
//    * Copies the element at index into dest.
//    *
//    * @param dest  the destination object
//    * @param index the index of the object to get
//    * @return the fetched object
//    */
//   E get(E dest, int index);
// 
//   /**
//    * Swaps two elements.
//    *
//    * @param i index of first element to swap
//    * @param j index of second element to swap
//    */
//   void swap(int i, int j);
// }


import net.bramp.unsafe.InplaceList;
/**
 * Taken from http://java67.blogspot.com/2014/07/quicksort-algorithm-in-java-in-place-example.html
 * Modified to work with my inplace list
 */

package net.bramp.unsafe.sort;


/**
 * Java program to Sort integer array using QuickSort algorithm using recursion.
 * Recursive QuickSort algorithm, partitioned list into two parts by a pivot,
 * and then recursively sorts each list.
 *
 * @author Javin Paul
 */
public class InplaceQuickSort {

  /**
   * Sorts given array using QuickSort
   *
   * @param array to be sorted.
   * @param <E>   generic type of list
   */
  public static <E extends Comparable<E>> void quickSort(InplaceList<E> array) {
    if (array.isEmpty()) {
      return;
    }
    recursiveQuickSort(array, 0, array.size() - 1);
  }

  /**
   * Recursive quicksort logic.
   *
   * @param array    input array
   * @param startIdx start index of the array
   * @param endIdx   end index of the array
   * @param <E>      generic type of list
   */
// Path: unsafe-collection/src/main/java/net/bramp/unsafe/InplaceList.java
// public interface InplaceList<E> extends List<E> {
// 
//   /**
//    * Copies the element at index into dest.
//    *
//    * @param dest  the destination object
//    * @param index the index of the object to get
//    * @return the fetched object
//    */
//   E get(E dest, int index);
// 
//   /**
//    * Swaps two elements.
//    *
//    * @param i index of first element to swap
//    * @param j index of second element to swap
//    */
//   void swap(int i, int j);
// }


// Path: unsafe-benchmark/src/main/java/net/bramp/unsafe/sort/InplaceQuickSort.java
import net.bramp.unsafe.InplaceList;

/**
 * Taken from http://java67.blogspot.com/2014/07/quicksort-algorithm-in-java-in-place-example.html
 * Modified to work with my inplace list
 */

package net.bramp.unsafe.sort;


/**
 * Java program to Sort integer array using QuickSort algorithm using recursion.
 * Recursive QuickSort algorithm, partitioned list into two parts by a pivot,
 * and then recursively sorts each list.
 *
 * @author Javin Paul
 */
public class InplaceQuickSort {

  /**
   * Sorts given array using QuickSort
   *
   * @param array to be sorted.
   * @param <E>   generic type of list
   */
  public static <E extends Comparable<E>> void quickSort(InplaceList<E> array) {
    if (array.isEmpty()) {
      return;
    }
    recursiveQuickSort(array, 0, array.size() - 1);
  }

  /**
   * Recursive quicksort logic.
   *
   * @param array    input array
   * @param startIdx start index of the array
   * @param endIdx   end index of the array
   * @param <E>      generic type of list
   */
  public static <E extends Comparable<E>> void recursiveQuickSort(InplaceList<E> array,