private function getMatchingBlocks()
{
$aLength = count($this->a);
$bLength = count($this->b);
$queue = array(array(0, $aLength, 0, $bLength));
$matchingBlocks = array();
while (!empty($queue)) {
list($alo, $ahi, $blo, $bhi) = array_pop($queue);
$x = $this->findLongestMatch($alo, $ahi, $blo, $bhi);
list($i, $j, $k) = $x;
if ($k) {
$matchingBlocks[] = $x;
if ($alo < $i && $blo < $j) {
$queue[] = array($alo, $i, $blo, $j);
}
if ($i + $k < $ahi && $j + $k < $bhi) {
$queue[] = array($i + $k, $ahi, $j + $k, $bhi);
}
}
}
usort($matchingBlocks, array($this, 'tupleSort'));
$i1 = 0;
$j1 = 0;
$k1 = 0;
$nonAdjacent = array();
foreach ($matchingBlocks as $block) {
list($i2, $j2, $k2) = $block;
if ($i1 + $k1 === $i2 && $j1 + $k1 === $j2) {
$k1 += $k2;
} else {
if ($k1) {
$nonAdjacent[] = array($i1, $j1, $k1);
}
$i1 = $i2;
$j1 = $j2;
$k1 = $k2;
}
}
if ($k1) {
$nonAdjacent[] = array($i1, $j1, $k1);
}
$nonAdjacent[] = array($aLength, $bLength, 0);
return $nonAdjacent;
}