projects
/
yaffs-website
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Yaffs site version 1.1
[yaffs-website]
/
vendor
/
sebastian
/
diff
/
src
/
LCS
/
TimeEfficientLongestCommonSubsequenceImplementation.php
diff --git
a/vendor/sebastian/diff/src/LCS/TimeEfficientLongestCommonSubsequenceImplementation.php
b/vendor/sebastian/diff/src/LCS/TimeEfficientLongestCommonSubsequenceImplementation.php
index 4fc9d3ecf62447e99290df13726b82d06e014058..f31db3eb8dfdae1096479f935db72e0cdfecaac4 100644
(file)
--- a/
vendor/sebastian/diff/src/LCS/TimeEfficientLongestCommonSubsequenceImplementation.php
+++ b/
vendor/sebastian/diff/src/LCS/TimeEfficientLongestCommonSubsequenceImplementation.php
@@
-1,6
+1,6
@@
<?php
/*
<?php
/*
- * This file is part of
the Diff package
.
+ * This file is part of
sebastian/diff
.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
@@
-26,8
+26,8
@@
class TimeEfficientImplementation implements LongestCommonSubsequence
public function calculate(array $from, array $to)
{
$common = array();
public function calculate(array $from, array $to)
{
$common = array();
- $fromLength = count($from);
- $toLength = count($to);
+ $fromLength =
\
count($from);
+ $toLength =
\
count($to);
$width = $fromLength + 1;
$matrix = new \SplFixedArray($width * ($toLength + 1));
$width = $fromLength + 1;
$matrix = new \SplFixedArray($width * ($toLength + 1));
@@
-42,7
+42,7
@@
class TimeEfficientImplementation implements LongestCommonSubsequence
for ($i = 1; $i <= $fromLength; ++$i) {
for ($j = 1; $j <= $toLength; ++$j) {
$o = ($j * $width) + $i;
for ($i = 1; $i <= $fromLength; ++$i) {
for ($j = 1; $j <= $toLength; ++$j) {
$o = ($j * $width) + $i;
- $matrix[$o] = max(
+ $matrix[$o] =
\
max(
$matrix[$o - 1],
$matrix[$o - $width],
$from[$i - 1] === $to[$j - 1] ? $matrix[$o - $width - 1] + 1 : 0
$matrix[$o - 1],
$matrix[$o - $width],
$from[$i - 1] === $to[$j - 1] ? $matrix[$o - $width - 1] + 1 : 0
@@
-54,12
+54,13
@@
class TimeEfficientImplementation implements LongestCommonSubsequence
$j = $toLength;
while ($i > 0 && $j > 0) {
$j = $toLength;
while ($i > 0 && $j > 0) {
- if ($from[$i
-1] === $to[$j-
1]) {
- $common[] = $from[$i
-
1];
+ if ($from[$i
- 1] === $to[$j -
1]) {
+ $common[] = $from[$i
-
1];
--$i;
--$j;
} else {
$o = ($j * $width) + $i;
--$i;
--$j;
} else {
$o = ($j * $width) + $i;
+
if ($matrix[$o - $width] > $matrix[$o - 1]) {
--$j;
} else {
if ($matrix[$o - $width] > $matrix[$o - 1]) {
--$j;
} else {
@@
-68,6
+69,6
@@
class TimeEfficientImplementation implements LongestCommonSubsequence
}
}
}
}
- return array_reverse($common);
+ return
\
array_reverse($common);
}
}
}
}