public class HMatrix extends Object
Constructor and Description |
---|
HMatrix(int distance,
int maxLength)
Allocates memory and initializes matrix (constructor).
|
Modifier and Type | Method and Description |
---|---|
int |
get(int i,
int j)
Provide an item of hMatrix indexed by indices.
|
void |
set(int i,
int j,
int val)
Set an item in hMatrix.
|
public HMatrix(int distance, int maxLength)
distance
- (int) max edit distance allowed for
candidates;maxLength
- (int) max length of words.
Remarks: See Oflazer. To save space, the matrix is
stored as a vector. To save time, additional rows and
columns are added. They are initialized to their distance in
the matrix, so that no bound checking is necessary during
access.public int get(int i, int j)
i
- - (int) row number;j
- - (int) column number.H[i][j]
. Remarks: H matrix is really simulated. What is needed is only
2 * edit_distance + 1
wide band around the diagonal. In fact
this diagonal has been pushed up to the upper border of the
matrix.
The matrix in the vector looks likes this:
+---------------------+ 0 |#####################| j=i-e-1 1 | | j=i-e : : e+1 | | j=i-1 +---------------------+ e+2 | | j=i +---------------------+ e+3 | | j=i+1 : : 2e+2| | j=i+e 2e+3|#####################| j=i+e+1 +---------------------+
public void set(int i, int j, int val)
i
- - (int) row number;j
- - (int) column number;val
- - (int) value to put there.Copyright © 2016. All rights reserved.