You are here

class MappedDiff in Diff 5.2

Same name and namespace in other branches
  1. 5 DiffEngine.php \MappedDiff
  2. 6.2 DiffEngine.php \MappedDiff
  3. 6 DiffEngine.php \MappedDiff
  4. 7.3 DiffEngine.php \MappedDiff
  5. 7.2 DiffEngine.php \MappedDiff

FIXME: bad name. @todo document @private @subpackage DifferenceEngine

Hierarchy

Expanded class hierarchy of MappedDiff

File

./DiffEngine.php, line 675

View source
class MappedDiff extends Diff {

  /**
   * Constructor.
   *
   * Computes diff between sequences of strings.
   *
   * This can be used to compute things like
   * case-insensitve diffs, or diffs which ignore
   * changes in white-space.
   *
   * @param $from_lines array An array of strings.
   *	(Typically these are lines from a file.)
   *
   * @param $to_lines array An array of strings.
   *
   * @param $mapped_from_lines array This array should
   *	have the same size number of elements as $from_lines.
   *	The elements in $mapped_from_lines and
   *	$mapped_to_lines are what is actually compared
   *	when computing the diff.
   *
   * @param $mapped_to_lines array This array should
   *	have the same number of elements as $to_lines.
   */
  function MappedDiff($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) {
    assert(sizeof($from_lines) == sizeof($mapped_from_lines));
    assert(sizeof($to_lines) == sizeof($mapped_to_lines));
    $this
      ->Diff($mapped_from_lines, $mapped_to_lines);
    $xi = $yi = 0;
    for ($i = 0; $i < sizeof($this->edits); $i++) {
      $orig =& $this->edits[$i]->orig;
      if (is_array($orig)) {
        $orig = array_slice($from_lines, $xi, sizeof($orig));
        $xi += sizeof($orig);
      }
      $closing =& $this->edits[$i]->closing;
      if (is_array($closing)) {
        $closing = array_slice($to_lines, $yi, sizeof($closing));
        $yi += sizeof($closing);
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Diff::$edits property
Diff::closing function * Get the closing set of lines. * * This reconstructs the $to_lines parameter passed to the * constructor. * * 1
Diff::Diff function * Constructor. * Computes diff between sequences of strings. * *
Diff::isEmpty function * Check for empty diff. * *
Diff::lcs function * Compute the length of the Longest Common Subsequence (LCS). * * This is mostly for diagnostic purposed. * *
Diff::orig function * Get the original set of lines. * * This reconstructs the $from_lines parameter passed to the * constructor. * * 1
Diff::reverse function * Compute reversed Diff. * * SYNOPSIS: * * $diff = new Diff($lines1, $lines2); * $rev = $diff->reverse(); *
Diff::_check function * Check a Diff for validity. * * This is here only for debugging purposes.
MappedDiff::MappedDiff function * Constructor. * * Computes diff between sequences of strings. * * This can be used to compute things like * case-insensitve diffs, or diffs which ignore * changes in white-space. * *