private <T> T[] ensureIndex( T[] array, int index, T ... emptyArray )
    {
        if (array == null)
        {
            array = Arrays.copyOf( emptyArray, index + 1 );
        }
        else if (index >= array.length)
        {
            array = Arrays.copyOf( array, index + 1 );
        }

        return array;
    }