src/main/java/org/organicdesign/fp/collections/Cowry.java
public static <T> Tuple2<T[],T[]> splitArray(T[] orig, int splitIndex) { //, Class<T> tClass) {
//        if (splitIndex < 1) {
//            throw new IllegalArgumentException("Called split when splitIndex < 1");
//        }
//        if (splitIndex > orig.length - 1) {
//            throw new IllegalArgumentException("Called split when splitIndex > orig.length - 1");
//        }

        // NOTE:
        // I sort of suspect that generic 2D array creation where the two arrays are of a different
        // length is not possible in Java, or if it is, it's not likely to be much faster than
        // what we have here.  I'd just copy the Arrays.copyOf code everywhere this function is used
        // if you want more speed.
//        int rightLength = orig.length - splitIndex;
//        Class<T> tClass = (Class<T>) orig.getClass().getComponentType();
//        Tuple2<T[],T[]> split = Tuple2.of((T[]) Array.newInstance(tClass, splitIndex),
//                                          (T[]) Array.newInstance(tClass, rightLength));
//
        // Tuple2<T[],T[]> split =
        return Tuple2.of(Arrays.copyOf(orig, splitIndex),
                         Arrays.copyOfRange(orig, splitIndex, orig.length));

//        // original array, offset, newArray, offset, length
//        System.arraycopy(orig, 0, split._1(), 0, splitIndex);
//
//        System.arraycopy(orig, splitIndex, split._2(), 0, rightLength);
//        return split;
    }
public static <T> Tuple2<T[],T[]> splitArray(T[] orig, int splitIndex) { //, Class<T> tClass) {
//        if (splitIndex < 1) {
//            throw new IllegalArgumentException("Called split when splitIndex < 1");
//        }
//        if (splitIndex > orig.length - 1) {
//            throw new IllegalArgumentException("Called split when splitIndex > orig.length - 1");
//        }

        // NOTE:
        // I sort of suspect that generic 2D array creation where the two arrays are of a different
        // length is not possible in Java, or if it is, it's not likely to be much faster than
        // what we have here.  I'd just copy the Arrays.copyOf code everywhere this function is used
        // if you want more speed.
//        int rightLength = orig.length - splitIndex;
//        Class<T> tClass = (Class<T>) orig.getClass().getComponentType();
//        Tuple2<T[],T[]> split = Tuple2.of((T[]) Array.newInstance(tClass, splitIndex),
//                                          (T[]) Array.newInstance(tClass, rightLength));
//
        // Tuple2<T[],T[]> split =
        return Tuple2.of(Arrays.copyOf(orig, splitIndex),
                         Arrays.copyOfRange(orig, splitIndex, orig.length));

//        // original array, offset, newArray, offset, length
//        System.arraycopy(orig, 0, split._1(), 0, splitIndex);
//
//        System.arraycopy(orig, splitIndex, split._2(), 0, rightLength);
//        return split;
    }
public static < T > Tuple2 < T [ ] , T [ ] > splitArray ( T [ ] orig , int splitIndex ) { //, Class<T> tClass) { //        if (splitIndex < 1) { //            throw new IllegalArgumentException("Called split when splitIndex < 1"); //        } //        if (splitIndex > orig.length - 1) { //            throw new IllegalArgumentException("Called split when splitIndex > orig.length - 1"); //        } // NOTE: // I sort of suspect that generic 2D array creation where the two arrays are of a different // length is not possible in Java, or if it is, it's not likely to be much faster than // what we have here.  I'd just copy the Arrays.copyOf code everywhere this function is used // if you want more speed. //        int rightLength = orig.length - splitIndex; //        Class<T> tClass = (Class<T>) orig.getClass().getComponentType(); //        Tuple2<T[],T[]> split = Tuple2.of((T[]) Array.newInstance(tClass, splitIndex), //                                          (T[]) Array.newInstance(tClass, rightLength)); // // Tuple2<T[],T[]> split = return Tuple2 . of ( Arrays . copyOf ( orig , splitIndex ) , Arrays . copyOfRange ( orig , splitIndex , orig . length ) ) ; //        // original array, offset, newArray, offset, length //        System.arraycopy(orig, 0, split._1(), 0, splitIndex); // //        System.arraycopy(orig, splitIndex, split._2(), 0, rightLength); //        return split; }
Only call this if the array actually needs to be split (0 &lt; splitPoint &lt; orig.length).
@param orig array to split
@param splitIndex items less than this index go in the left, equal or greater in the right.
@return a 2D array of leftItems then rightItems
Only call this if the array actually needs to be split ( 0 &lt ; splitPoint &lt ; orig . length ) .