Package io.github.connellite.collections
Class TableUtils
java.lang.Object
io.github.connellite.collections.TableUtils
Utilities for transposing column-oriented and row-oriented tabular data represented as maps.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontransposeColumnsToRows(Map<K, ? extends Collection<T>> columns) TransposesMap<K, ? extends Collection<T>>intoList<Map<K, T>>.transposeRowsToColumns(List<Map<K, T>> rows) TransposesList<Map<K, T>>intoMap<K, Set<T>>.
-
Constructor Details
-
TableUtils
public TableUtils()
-
-
Method Details
-
transposeColumnsToRows
TransposesMap<K, ? extends Collection<T>>intoList<Map<K, T>>.Each map entry is treated as a column. Row
icontains thei-th element from every column (by iteration order within each collection). Columns shorter than the longest column are padded withnull.- Type Parameters:
K- column key typeT- cell value type- Parameters:
columns- column key to values;nullor empty yields an empty list- Returns:
- one map per row; keys are column keys and iteration order follows
columns
-
transposeRowsToColumns
TransposesList<Map<K, T>>intoMap<K, Set<T>>.Each distinct column key collects non-
nullcell values in row order.nullrows are skipped.- Type Parameters:
K- column key typeT- cell value type- Parameters:
rows- row maps;nullor empty yields an empty map- Returns:
- column key to ordered set of values
-