private static boolean canDisplayColumns ( List < TerminalString > displayList , int numRows , int terminalWidth ) { int numColumns = displayList . size ( ) / numRows ; if ( displayList . size ( ) % numRows > 0 ) { numColumns ++ ; } int [ ] columnSizes = calculateColumnSizes ( displayList , numColumns , numRows , terminalWidth ) ; int totalSize = 0 ; for ( int columnSize : columnSizes ) { totalSize += columnSize ; } return totalSize <= terminalWidth ; }
Decides if it s possible to format provided Strings into calculated number of columns while the output will not exceed terminal width