public static < T > List < T > interleave_all ( List < List < T > > splitup ) { ArrayList < T > rtn = new ArrayList <> ( ) ; int maxLength = 0 ; for ( List < T > e : splitup ) { int len = e . size ( ) ; if ( maxLength < len ) { maxLength = len ; } } for ( int i = 0 ; i < maxLength ; i ++ ) { for ( List < T > e : splitup ) { if ( e . size ( ) > i ) { rtn . add ( e . get ( i ) ) ; } } } return rtn ; }
balance all T