Package com.landawn.abacus.util
Class Sheet<R,C,E>
java.lang.Object
com.landawn.abacus.util.Sheet<R,C,E>
- Type Parameters:
R
-C
-E
-
- All Implemented Interfaces:
Cloneable
R
= Row, C
= Column, H
= Horizontal, V
= Vertical.
- Since:
- 0.8
- Author:
- Haiyang Li
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionSheet()
Sheet
(Collection<R> rowKeySet, Collection<C> columnKeySet) Sheet
(Collection<R> rowKeySet, Collection<C> columnKeySet, Object[][] rows) -
Method Summary
Modifier and TypeMethodDescription<X extends Exception>
voidvoid
addColumn
(int columnIndex, C columnKey, Collection<? extends E> column) Adds the column.void
addColumn
(C columnKey, Collection<? extends E> column) Adds the column.void
addRow
(int rowIndex, R rowKey, Collection<? extends E> row) Adds the row.void
addRow
(R rowKey, Collection<? extends E> row) Adds the row.<T,
X extends Exception>
TcellsC()
cellsC
(int fromColumnIndex, int toColumnIndex) Stream<Sheet.Cell<R,
C, E>> cellsH()
Stream<Sheet.Cell<R,
C, E>> cellsH
(int rowIndex) Stream<Sheet.Cell<R,
C, E>> cellsH
(int fromRowIndex, int toRowIndex) cellsR()
cellsR
(int fromRowIndex, int toRowIndex) Stream<Sheet.Cell<R,
C, E>> cellsV()
Stream<Sheet.Cell<R,
C, E>> cellsV
(int columnIndex) Stream<Sheet.Cell<R,
C, E>> cellsV
(int fromColumnIndex, int toColumnIndex) void
clear()
Clear.clone()
Deeply copy each element in thisSheet
by Serialization/Deserialization.clone
(boolean freeze) Deeply copy each element in thisSheet
by Serialization/Deserialization.Column key set.int
Returns the size of column key set.columns()
columns
(int fromColumnIndex, int toColumnIndex) static <R,
C, E> Sheet<R, C, E> columns
(Collection<R> rowKeySet, Collection<C> columnKeySet, Object[][] columns) static <R,
C, E> Sheet<R, C, E> columns
(Collection<R> rowKeySet, Collection<C> columnKeySet, Collection<? extends Collection<? extends E>> columns) boolean
boolean
containsColumn
(C columnKey) boolean
containsRow
(R rowKey) boolean
containsValue
(Object value) copy()
copy
(Collection<R> rowKeySet, Collection<C> columnKeySet) boolean
<X extends Exception>
voidforEachH
(Throwables.TriConsumer<? super R, ? super C, ? super E, X> action) For each H.<X extends Exception>
voidforEachNonNullH
(Throwables.TriConsumer<? super R, ? super C, ? super E, X> action) For each H.<X extends Exception>
voidforEachNonNullV
(Throwables.TriConsumer<? super R, ? super C, ? super E, X> action) For each V.<X extends Exception>
voidforEachV
(Throwables.TriConsumer<? super R, ? super C, ? super E, X> action) For each V.void
freeze()
Freeze.get
(int rowIndex, int columnIndex) Gets the column.Gets the row.int
hashCode()
boolean
isFrozen()
merge
(Sheet<? extends R, ? extends C, ? extends E2> b, Throwables.BiFunction<? super E, ? super E2, ? extends E3, X> mergeFunction) void
moveColumn
(C columnKey, int newColumnIndex) Move the specified column to the new position.void
Move the specified row to the new position.pointsC()
pointsC
(int fromColumnIndex, int toColumnIndex) pointsH()
pointsH
(int rowIndex) pointsH
(int fromRowIndex, int toRowIndex) pointsR()
pointsR
(int fromRowIndex, int toRowIndex) pointsV()
pointsV
(int columnIndex) pointsV
(int fromColumnIndex, int toColumnIndex) void
println()
void
println
(Collection<R> rowKeySet, Collection<C> columnKeySet) <W extends Writer>
Wprintln
(W outputWriter) <W extends Writer>
Wprintln
(W outputWriter, Collection<R> rowKeySet, Collection<C> columnKeySet) void
remove
(int rowIndex, int columnIndex) void
removeColumn
(C columnKey) Removes the column.void
Removes the row.void
renameColumn
(C columnKey, C newColumnKey) void
<X extends Exception>
voidreplaceIf
(Throwables.IntBiPredicate<X> predicate, E newValue) Replace elements byPredicate.test(i, j)
based on points<X extends Exception>
voidreplaceIf
(Throwables.Predicate<? super E, X> predicate, E newValue) <X extends Exception>
voidReplace elements byPredicate.test(i, j)
based on pointsRow key set.int
Returns the size of row key set.rowMap()
rows()
rows
(int fromRowIndex, int toRowIndex) static <R,
C, E> Sheet<R, C, E> rows
(Collection<R> rowKeySet, Collection<C> columnKeySet, Object[][] rows) static <R,
C, E> Sheet<R, C, E> rows
(Collection<R> rowKeySet, Collection<C> columnKeySet, Collection<? extends Collection<? extends E>> rows) void
setColumn
(C columnKey, Collection<? extends E> column) Sets the column.void
setRow
(R rowKey, Collection<? extends E> row) Sets the row.int
size()
Returns the count of non-null values.void
void
sortByColumn
(Comparator<? super C> cmp) void
void
sortByRow
(Comparator<? super R> cmp) streamC()
streamC
(int fromColumnIndex, int toColumnIndex) streamH()
streamH
(int rowIndex) streamH
(int fromRowIndex, int toRowIndex) streamR()
streamR
(int fromRowIndex, int toRowIndex) streamV()
streamV
(int columnIndex) streamV
(int fromColumnIndex, int toColumnIndex) void
swapColumns
(C columnKeyA, C columnKeyB) Swap the positions of the two specified columns.void
Swap the positions of the two specified rows.Object[][]
toArrayH()
To array H.<T> T[][]
To array H.Object[][]
toArrayV()
To array V.<T> T[][]
To array V.To data set H.To data set V.toString()
void
Trim to size.<X extends Exception>
voidupdateAll
(Throwables.Function<? super E, ? extends E, X> func) <X extends Exception>
voidupdateAll
(Throwables.IntBiFunction<? extends E, X> func) Update all elements based on points.<X extends Exception>
voidUpdate all elements based on points.<X extends Exception>
voidupdateColumn
(C columnKey, Throwables.Function<? super E, ? extends E, X> func) <X extends Exception>
voidupdateRow
(R rowKey, Throwables.Function<? super E, ? extends E, X> func)
-
Constructor Details
-
Sheet
public Sheet() -
Sheet
- Parameters:
rowKeySet
-columnKeySet
-
-
Sheet
- Parameters:
rowKeySet
-columnKeySet
-rows
-
-
-
Method Details
-
rows
public static <R,C, Sheet<R,E> C, rowsE> (Collection<R> rowKeySet, Collection<C> columnKeySet, Object[][] rows) - Type Parameters:
R
-C
-E
-- Parameters:
rowKeySet
-columnKeySet
-rows
-- Returns:
-
rows
public static <R,C, Sheet<R,E> C, rowsE> (Collection<R> rowKeySet, Collection<C> columnKeySet, Collection<? extends Collection<? extends E>> rows) - Type Parameters:
R
-C
-E
-- Parameters:
rowKeySet
-columnKeySet
-rows
-- Returns:
-
columns
public static <R,C, Sheet<R,E> C, columnsE> (Collection<R> rowKeySet, Collection<C> columnKeySet, Object[][] columns) - Type Parameters:
R
-C
-E
-- Parameters:
rowKeySet
-columnKeySet
-columns
-- Returns:
-
columns
public static <R,C, Sheet<R,E> C, columnsE> (Collection<R> rowKeySet, Collection<C> columnKeySet, Collection<? extends Collection<? extends E>> columns) - Type Parameters:
R
-C
-E
-- Parameters:
rowKeySet
-columnKeySet
-columns
-- Returns:
-
rowKeySet
Row key set.- Returns:
-
columnKeySet
Column key set.- Returns:
-
get
- Parameters:
rowKey
-columnKey
-- Returns:
-
get
- Parameters:
rowIndex
-columnIndex
-- Returns:
-
get
- Parameters:
point
-- Returns:
-
put
- Parameters:
rowKey
-columnKey
-value
-- Returns:
- Throws:
IllegalArgumentException
- the illegal argument exception
-
put
- Parameters:
rowIndex
-columnIndex
-value
-- Returns:
-
put
- Parameters:
point
-value
-- Returns:
-
putAll
public void putAll(Sheet<? extends R, ? extends C, throws IllegalArgumentException? extends E> source) - Parameters:
source
-- Throws:
IllegalArgumentException
- the illegal argument exception
-
remove
- Parameters:
rowKey
-columnKey
-- Returns:
-
remove
- Parameters:
rowIndex
-columnIndex
-- Returns:
-
remove
- Parameters:
point
-- Returns:
-
contains
- Parameters:
rowKey
-columnKey
-- Returns:
-
containsValue
- Parameters:
value
-- Returns:
-
getRow
Gets the row.- Parameters:
rowKey
-- Returns:
-
setRow
Sets the row.- Parameters:
rowKey
-row
-
-
addRow
Adds the row.- Parameters:
rowKey
-row
-
-
addRow
Adds the row.- Parameters:
rowIndex
-rowKey
-row
-
-
updateRow
public <X extends Exception> void updateRow(R rowKey, Throwables.Function<? super E, ? extends E, throws XX> func) - Type Parameters:
X
-- Parameters:
rowKey
-func
-- Throws:
X
- the x
-
removeRow
Removes the row.- Parameters:
rowKey
-
-
moveRow
Move the specified row to the new position.- Parameters:
rowKey
-newRowIndex
-
-
swapRows
Swap the positions of the two specified rows.- Parameters:
rowKeyA
-rowKeyB
-
-
renameRow
- Parameters:
rowKey
-newRowKey
-
-
containsRow
- Parameters:
rowKey
-- Returns:
-
row
- Parameters:
rowKey
-- Returns:
-
rowMap
- Returns:
-
getColumn
Gets the column.- Parameters:
columnKey
-- Returns:
-
setColumn
Sets the column.- Parameters:
columnKey
-column
-
-
addColumn
Adds the column.- Parameters:
columnKey
-column
-
-
addColumn
Adds the column.- Parameters:
columnIndex
-columnKey
-column
-
-
updateColumn
public <X extends Exception> void updateColumn(C columnKey, Throwables.Function<? super E, ? extends E, throws XX> func) - Type Parameters:
X
-- Parameters:
columnKey
-func
-- Throws:
X
- the x
-
removeColumn
Removes the column.- Parameters:
columnKey
-
-
moveColumn
Move the specified column to the new position.- Parameters:
columnKey
-newColumnIndex
-
-
swapColumns
Swap the positions of the two specified columns.- Parameters:
columnKeyA
-columnKeyB
-
-
renameColumn
- Parameters:
columnKey
-newColumnKey
-
-
containsColumn
- Parameters:
columnKey
-- Returns:
-
column
- Parameters:
columnKey
-- Returns:
-
columnMap
- Returns:
-
rowLength
public int rowLength()Returns the size of row key set.- Returns:
-
columnLength
public int columnLength()Returns the size of column key set.- Returns:
-
updateAll
public <X extends Exception> void updateAll(Throwables.Function<? super E, ? extends E, throws XX> func) - Type Parameters:
X
-- Parameters:
func
-- Throws:
X
- the x
-
updateAll
Update all elements based on points.- Type Parameters:
X
-- Parameters:
func
-- Throws:
X
- the x
-
updateAll
public <X extends Exception> void updateAll(Throwables.TriFunction<? super R, ? super C, throws X? super E, ? extends E, X> func) Update all elements based on points.- Type Parameters:
X
-- Parameters:
func
-- Throws:
X
- the x
-
replaceIf
public <X extends Exception> void replaceIf(Throwables.Predicate<? super E, X> predicate, E newValue) throws X- Type Parameters:
X
-- Parameters:
predicate
-newValue
-- Throws:
X
- the x
-
replaceIf
public <X extends Exception> void replaceIf(Throwables.IntBiPredicate<X> predicate, E newValue) throws X Replace elements byPredicate.test(i, j)
based on points- Type Parameters:
X
-- Parameters:
predicate
-newValue
-- Throws:
X
- the x
-
replaceIf
public <X extends Exception> void replaceIf(Throwables.TriPredicate<? super R, ? super C, throws X? super E, X> predicate, E newValue) Replace elements byPredicate.test(i, j)
based on points- Type Parameters:
X
-- Parameters:
predicate
-newValue
-- Throws:
X
- the x
-
sortByRow
public void sortByRow() -
sortByRow
-
sortByColumn
public void sortByColumn() -
sortByColumn
-
copy
- Returns:
-
copy
- Parameters:
rowKeySet
-columnKeySet
-- Returns:
-
clone
Deeply copy each element in thisSheet
by Serialization/Deserialization.- Returns:
-
clone
Deeply copy each element in thisSheet
by Serialization/Deserialization.- Parameters:
freeze
-- Returns:
-
merge
public <E2,E3, Sheet<R,X extends Exception> C, mergeE3> (Sheet<? extends R, ? extends C, throws X? extends E2> b, Throwables.BiFunction<? super E, ? super E2, ? extends E3, X> mergeFunction) - Type Parameters:
E2
-E3
-X
-- Parameters:
b
-mergeFunction
-- Returns:
- Throws:
X
- the x
-
transpose
- Returns:
-
freeze
public void freeze()Freeze. -
isFrozen
public boolean isFrozen()- Returns:
-
clear
public void clear()Clear. -
size
public int size()Returns the count of non-null values.- Returns:
-
trimToSize
public void trimToSize()Trim to size. -
forEachH
public <X extends Exception> void forEachH(Throwables.TriConsumer<? super R, ? super C, throws X? super E, X> action) For each H.- Type Parameters:
X
-- Parameters:
action
-- Throws:
X
- the x
-
forEachV
public <X extends Exception> void forEachV(Throwables.TriConsumer<? super R, ? super C, throws X? super E, X> action) For each V.- Type Parameters:
X
-- Parameters:
action
-- Throws:
X
- the x
-
forEachNonNullH
public <X extends Exception> void forEachNonNullH(Throwables.TriConsumer<? super R, ? super C, throws X? super E, X> action) For each H.- Type Parameters:
X
-- Parameters:
action
-- Throws:
X
- the x
-
forEachNonNullV
public <X extends Exception> void forEachNonNullV(Throwables.TriConsumer<? super R, ? super C, throws X? super E, X> action) For each V.- Type Parameters:
X
-- Parameters:
action
-- Throws:
X
- the x
-
cellsH
- Returns:
- a stream of Cells based on the order of row.
-
cellsH
- Parameters:
rowIndex
-- Returns:
-
cellsH
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
- a stream of Cells based on the order of row.
-
cellsV
- Returns:
- a stream of Cells based on the order of column.
-
cellsV
- Parameters:
columnIndex
-- Returns:
-
cellsV
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
- a stream of Cells based on the order of column.
-
cellsR
- Returns:
- a stream based on the order of row.
-
cellsR
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
- a stream based on the order of row.
-
cellsC
- Returns:
- a stream based on the order of column.
-
cellsC
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
- a stream based on the order of column.
-
pointsH
- Returns:
-
pointsH
- Parameters:
rowIndex
-- Returns:
-
pointsH
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
-
pointsV
- Returns:
-
pointsV
- Parameters:
columnIndex
-- Returns:
-
pointsV
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
-
pointsR
- Returns:
-
pointsR
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
-
pointsC
- Returns:
-
pointsC
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
-
streamH
- Returns:
- a stream based on the order of row.
-
streamH
- Parameters:
rowIndex
-- Returns:
-
streamH
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
- a stream based on the order of row.
-
streamV
- Returns:
- a stream based on the order of column.
-
streamV
- Parameters:
columnIndex
-- Returns:
-
streamV
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
- a stream based on the order of column.
-
streamR
- Returns:
- a stream based on the order of row.
-
streamR
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
- a stream based on the order of row.
-
streamC
- Returns:
- a stream based on the order of column.
-
streamC
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
- a stream based on the order of column.
-
rows
- Returns:
- a stream based on the order of row.
-
rows
- Parameters:
fromRowIndex
-toRowIndex
-- Returns:
- a stream based on the order of row.
-
columns
- Returns:
- a stream based on the order of column.
-
columns
- Parameters:
fromColumnIndex
-toColumnIndex
-- Returns:
- a stream based on the order of column.
-
toDataSetH
To data set H.- Returns:
- a DataSet based on row.
-
toDataSetV
To data set V.- Returns:
- a DataSet based on column.
-
toArrayH
To array H.- Returns:
- a 2D array based on row.
-
toArrayH
To array H.- Type Parameters:
T
-- Parameters:
cls
-- Returns:
- a 2D array based on row.
-
toArrayV
To array V.- Returns:
- a 2D array based on column.
-
toArrayV
To array V.- Type Parameters:
T
-- Parameters:
cls
-- Returns:
- a 2D array based on column.
-
apply
public <T,X extends Exception> T apply(Throwables.Function<? super Sheet<R, C, throws XE>, T, X> func) - Type Parameters:
T
-X
-- Parameters:
func
-- Returns:
- Throws:
X
- the x
-
accept
public <X extends Exception> void accept(Throwables.Consumer<? super Sheet<R, C, throws XE>, X> action) - Type Parameters:
X
-- Parameters:
action
-- Throws:
X
- the x
-
println
- Throws:
UncheckedIOException
- the unchecked IO exception
-
println
public void println(Collection<R> rowKeySet, Collection<C> columnKeySet) throws UncheckedIOException - Parameters:
rowKeySet
-columnKeySet
-- Throws:
UncheckedIOException
- the unchecked IO exception
-
println
- Type Parameters:
W
-- Parameters:
outputWriter
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
println
public <W extends Writer> W println(W outputWriter, Collection<R> rowKeySet, Collection<C> columnKeySet) throws UncheckedIOException - Type Parameters:
W
-- Parameters:
outputWriter
-rowKeySet
-columnKeySet
-- Returns:
- Throws:
UncheckedIOException
- the unchecked IO exception
-
hashCode
public int hashCode() -
equals
-
toString
-