public T[] nextCombinationAsArray(T[] destination)
    {
        if (destination.length != combinationIndices.length)
        {
            throw new IllegalArgumentException("Destination array must be the same length as combinations.");
        }
        generateNextCombinationIndices();
        for (int i = 0; i < combinationIndices.length; i++)
        {
            destination[i] = elements[combinationIndices[i]];
        }
        return destination;
    }
public T [ ] nextCombinationAsArray ( T [ ] destination ) { if ( destination . length != combinationIndices . length ) { throw new IllegalArgumentException ( "Destination array must be the same length as combinations." ) ; } generateNextCombinationIndices ( ) ; for ( int i = 0 ; i < combinationIndices . length ; i ++ ) { destination [ i ] = elements [ combinationIndices [ i ] ] ; } return destination ; }
Generate the next combination and return an array containing
the appropriate elements.  This overloaded method allows the caller
to provide an array that will be used and returned.
The purpose of this is to improve performance when iterating over
combinations.  If the {@link #nextCombinationAsArray()} method is
used it will create a new array every time.  When iterating over
combinations this will result in lots of short-lived objects that
have to be garbage collected.  This method allows a single array
instance to be reused in such circumstances.
@param destination Provides an array to use to create the
combination.  The specified array must be the same length as a
combination.
@return The provided array now containing the elements of the combination.