All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.unitn.disi.smatch.data.matrices.MatchMatrix Maven / Gradle / Ivy

The newest version!
package it.unitn.disi.smatch.data.matrices;

import it.unitn.disi.common.components.Configurable;
import it.unitn.disi.smatch.data.mappings.IMappingElement;

import java.util.Arrays;

/**
 * Default matrix for matching results.
 *
 * @author Mikalai Yatskevich [email protected]
 * @author 
 */
public class MatchMatrix extends Configurable implements IMatchMatrix, IMatchMatrixFactory {

    private int x = 0;
    private int y = 0;
    private char[][] matrix = null;

    public void init(int x, int y) {
        matrix = new char[x][y];
        this.x = x;
        this.y = y;

        for (char[] row : matrix) {
            Arrays.fill(row, IMappingElement.IDK);
        }
    }

    public char get(int x, int y) {
        return matrix[x][y];
    }

    public boolean set(int x, int y, final char value) {
        boolean result = value == matrix[x][y];
        matrix[x][y] = value;
        return result;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public IMatchMatrix getInstance() {
        return new MatchMatrix();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy