Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * This file is part of the DiffX library.
  * For licensing information please see the file license.txt included in the release.
  * A copy of this licence can also be found at
 package com.topologi.diffx.algorithm;

A matrix implementation which backbone is a matrix of integers.

Christophe Lauret (Allette Systems)
7 April 2005
public final class MatrixInt implements Matrix {
  //	 TODO: this class should probably not be public

The actual matrix storing the values.
  private int[][] matrix;

  public void setup(int widthint height) {
    this. = new int[width][height];

  public void set(int iint jint x) {
    this.[i][j] = x;

  public int get(int iint j) {
    return this.[i][j];

  public void incrementPathBy(int iint jint n) {
    this.[i][j] = this.[i+1][j+1] + n;

  public void incrementByMaxPath(int iint j) {
    this.[i][j] = Math.max(this.[i+1][j], this.[i][j+1]);

  public boolean isGreaterX(int iint j) {
    return this.[i+1][j] > this.[i][j+1];

  public boolean isGreaterY(int iint j) {
    return this.[i+1][j] < this.[i][j+1];

  public boolean isSameXY(int iint j) {
    return this.[i+1][j] == this.[i][j+1];

Gets rid of the underlying matrix so that garbage collector can do its work.

  public void release() {
    this. = null;
New to GrepCode? Check out our FAQ X