src/main/java/org/organicdesign/fp/collections/Cowry.java
public static int[][] splitArray(int[] orig, int splitIndex) {
        // This function started an exact duplicate of the one above, but for ints.
//        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");
//        }
        int rightLength = orig.length - splitIndex;
        int[][] split = new int[][] {new int[splitIndex],
                                     new int[rightLength]};
        // original array, offset, newArray, offset, length
        System.arraycopy(orig, 0, split[0], 0, splitIndex);
        System.arraycopy(orig, splitIndex, split[1], 0, rightLength);
        return split;
    }
public static int[][] splitArray(int[] orig, int splitIndex) {
        // This function started an exact duplicate of the one above, but for ints.
//        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");
//        }
        int rightLength = orig.length - splitIndex;
        int[][] split = new int[][] {new int[splitIndex],
                                     new int[rightLength]};
        // original array, offset, newArray, offset, length
        System.arraycopy(orig, 0, split[0], 0, splitIndex);
        System.arraycopy(orig, splitIndex, split[1], 0, rightLength);
        return split;
    }
public static int [ ] [ ] splitArray ( int [ ] orig , int splitIndex ) { // This function started an exact duplicate of the one above, but for ints. //        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"); //        } int rightLength = orig . length - splitIndex ; int [ ] [ ] split = new int [ ] [ ] { new int [ splitIndex ] , new int [ rightLength ] } ; // original array, offset, newArray, offset, length System . arraycopy ( orig , 0 , split [ 0 ] , 0 , splitIndex ) ; System . arraycopy ( orig , splitIndex , split [ 1 ] , 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 ) .