bmsi.util
クラス Diff

java.lang.Object
  上位を拡張 bmsi.util.Diff

public class Diff
extends Object

A class to compare vectors of objects. The result of comparison is a list of change objects which form an edit script. The objects compared are traditionally lines of text from two files. Comparison options such as "ignore whitespace" are implemented by modifying the equals and hashcode methods for the objects compared.

The basic algorithm is described in:
"An O(ND) Difference Algorithm and its Variations", Eugene Myers, Algorithmica Vol. 1 No. 2, 1986, p 251.

This class outputs different results from GNU diff 1.15 on some inputs. Our results are actually better (smaller change list, smaller total size of changes), but it would be nice to know why. Perhaps there is a memory overwrite bug in GNU diff 1.15.

作成者:
Stuart D. Gathman, translated from GNU diff 1.15 Copyright (C) 2000 Business Management Systems, Inc.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


入れ子のクラスの概要
static class Diff.change
          The result of comparison is an "edit script": a chain of change objects.
static interface Diff.ScriptBuilder
           
 
フィールドの概要
static Diff.ScriptBuilder forwardScript
          Standard ScriptBuilders.
 boolean heuristic
          When set to true, the comparison uses a heuristic to speed it up.
 boolean no_discards
          When set to true, the algorithm returns a guarranteed minimal set of changes.
static Diff.ScriptBuilder reverseScript
          Standard ScriptBuilders.
 
コンストラクタの概要
Diff(Object[] a, Object[] b)
          Prepare to find differences between two arrays.
 
メソッドの概要
 Diff.change diff_2(boolean reverse)
           
 Diff.change diff(Diff.ScriptBuilder bld)
          Get the results of comparison as an edit script.
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

heuristic

public boolean heuristic
When set to true, the comparison uses a heuristic to speed it up. With this heuristic, for files with a constant small density of changes, the algorithm is linear in the file size.


no_discards

public boolean no_discards
When set to true, the algorithm returns a guarranteed minimal set of changes. This makes things slower, sometimes much slower.


forwardScript

public static final Diff.ScriptBuilder forwardScript
Standard ScriptBuilders.


reverseScript

public static final Diff.ScriptBuilder reverseScript
Standard ScriptBuilders.

コンストラクタの詳細

Diff

public Diff(Object[] a,
            Object[] b)
Prepare to find differences between two arrays. Each element of the arrays is translated to an "equivalence number" based on the result of equals. The original Object arrays are no longer needed for computing the differences. They will be needed again later to print the results of the comparison as an edit script, if desired.

メソッドの詳細

diff_2

public final Diff.change diff_2(boolean reverse)

diff

public Diff.change diff(Diff.ScriptBuilder bld)
Get the results of comparison as an edit script. The script is described by a list of changes. The standard ScriptBuilder implementations provide for forward and reverse edit scripts. Alternate implementations could, for instance, list common elements instead of differences.

パラメータ:
bld - an object to build the script from change flags
戻り値:
the head of a list of changes


Copyright © 2004-2011. All Rights Reserved.