TUM CCSM Commons

edu.tum.cs.commons.algo
Class Diff.Delta<T>

java.lang.Object
  extended by edu.tum.cs.commons.algo.Diff.Delta<T>
Enclosing class:
Diff<T>

public static class Diff.Delta<T>
extends java.lang.Object

Objects of this class describe the additions and deletions used to transform between two words.


Method Summary
 java.util.List<T> backwardPatch(java.util.List<T> b)
          Applies the backward patch, i.e. if the second string is inserted, then the first string is returned.
 java.util.List<T> forwardPatch(java.util.List<T> a)
          Applies the forward patch, i.e. if the first string is inserted, then the second string is returned.
 int getM()
          Returns the size of the second word the delta was created for.
 int getN()
          Returns the size of the first word the delta was created for.
 int getPosition(int i)
          Returns the i-th element of the change positions.
 int getSize()
          Returns the size of the delta, i.e. the number of additions and deletions.
 T getT(int i)
          Returns the i-th element stored as addition or deletion.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getSize

public int getSize()
Returns the size of the delta, i.e. the number of additions and deletions.


getN

public int getN()
Returns the size of the first word the delta was created for.


getM

public int getM()
Returns the size of the second word the delta was created for.


getT

public T getT(int i)
Returns the i-th element stored as addition or deletion.


getPosition

public int getPosition(int i)
Returns the i-th element of the change positions. If it is positive, it indicates an addition (i.e. the position is for the second string). Otherwise it is a deletion (i.e. the (negated) position is for the first string). To allow storing a sign for position 0, all positions are incremented before (so this has to be compensated for).


forwardPatch

public java.util.List<T> forwardPatch(java.util.List<T> a)
Applies the forward patch, i.e. if the first string is inserted, then the second string is returned. The input word must be of length n, the output word will be of length m.


backwardPatch

public java.util.List<T> backwardPatch(java.util.List<T> b)
Applies the backward patch, i.e. if the second string is inserted, then the first string is returned. The input word must be of length m, the output word will be of length n.


toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

TUM CCSM Commons

TUM CCSM Commons - 2.7