public class RowMajor<X> extends Object
| Modifier and Type | Field and Description |
|---|---|
protected ArrayList<ArrayList<X>> |
entries |
protected int |
height |
protected int |
width |
| Modifier | Constructor and Description |
|---|---|
protected |
RowMajor(int h,
int w,
ArrayList<ArrayList<X>> entries) |
|
RowMajor(int h,
int w,
Function<Tuple<Integer,Integer>,X> fill)
Creates new matrix of the specified size, with entries given by the function
entry. |
|
RowMajor(int h,
int w,
X defaultValue)
Creates new matrix of the specified size, with all entries set to a constant value.
|
| Modifier and Type | Method and Description |
|---|---|
X |
apply(int column)
Gets an entry in the zeroth row of this matrix.
|
X |
apply(int row,
int column)
Returns the entry at the specified position.
|
static <X> RowMajor<X> |
asColumnVector(ArrayList<X> list) |
static <X> RowMajor<X> |
asRowVector(ArrayList<X> list) |
<Y> RowMajor<Y> |
flatMap(Function<X,RowMajor<Y>> f)
A dense matrix flatMap, that is done about right: it
makes real effort not to calculate anything twice,
not to allocate more space than necessary, and not to use
dynamic memory allocation of arrayLists, which copies
entries under the hood.
|
int |
getHeight()
Returns height of this matrix
|
int |
getWidth()
Returns the width of this matrix
|
<Y> RowMajor<Y> |
map(Function<X,Y> f)
Creates new matrix, where each entry is mapped by the function f
|
<Y> RowMajor<Y> |
mapWithIndices(Function<Tuple<X,Tuple<Integer,Integer>>,Y> f)
Pointwise application of a function that can depend on the value and
the index.
|
Tuple<Integer,Integer> |
size()
Height and width of the matrix.
|
Image |
toImage(Function<X,Color> toColor)
Converts this matrix to image.
|
String |
toString() |
protected String |
toString(Function<Integer,Padding> columnToHorizontalPadding,
Function<Integer,Padding> rowToVerticalPadding) |
String |
toString(Padding padding,
String begin,
String end,
String columnSeparator,
String rowSeparator)
Creates string representation of this matrix, indenting the
entries horizontally, but ignoring the fact that some entries might contain
multiple lines: in such cases, the whole layout probably will be pretty botched.
|
void |
update(int row,
int column,
X value)
Overrides the entry at the specified position by a new value.
|
void |
update(int column,
X value)
Updates an entry in the zeroth row of this matrix.
|
public RowMajor(int h,
int w,
Function<Tuple<Integer,Integer>,X> fill)
entry.h - w - fill - public RowMajor(int h,
int w,
X defaultValue)
h - w - defaultValue - public X apply(int row, int column)
row - column - public X apply(int column)
column - public void update(int row,
int column,
X value)
row - column - value - public void update(int column,
X value)
column - value - public int getWidth()
public int getHeight()
public <Y> RowMajor<Y> map(Function<X,Y> f)
f - public <Y> RowMajor<Y> mapWithIndices(Function<Tuple<X,Tuple<Integer,Integer>>,Y> f)
f - public <Y> RowMajor<Y> flatMap(Function<X,RowMajor<Y>> f)
public String toString(Padding padding, String begin, String end, String columnSeparator, String rowSeparator)
padding - horizontal padding strategy applied to each entrybegin - prefix of the whole result stringend - suffix of the whole result stringcolumnSeparator - string that is inserted between the padded entries of same rowrowSeparator - string that separates rowsprotected String toString(Function<Integer,Padding> columnToHorizontalPadding, Function<Integer,Padding> rowToVerticalPadding)
public Image toImage(Function<X,Color> toColor)
toColor - function that maps entries to pixel colors.Copyright © 2015. All rights reserved.