예제 #1
0
파일: 439.php 프로젝트: badlamer/hhvm
 public function getIterator()
 {
     return getIter();
 }
예제 #2
0
    die("There sould be {$input} file with dir at each line.");
}
foreach ($inputFile as $line) {
    $files = array_merge($files, getFilesFromDir($line));
}
if (count($files) < 3) {
    die("There sould be more than 2 files.");
}
asort($files, SORT_STRING);
chdir($curDir);
// getFilesFromDir can change cDir. So rewind.
file_put_contents($output, "============================ Result ============================\r\n");
$files = new ArrayObject($files);
$iPrev = getIter($files, 0);
$iCurrent = getIter($files, 1);
$iNext = getIter($files, 2);
// Fisrt element
if ($iPrev->current() == $iCurrent->current()) {
    file_put_contents($output, 'S ' . $iPrev->key() . "\r\n", FILE_APPEND);
}
// Middle elements
while ($iNext->valid()) {
    if ($iCurrent->current() == $iPrev->current() || $iCurrent->current() == $iNext->current()) {
        file_put_contents($output, 'S ' . $iCurrent->key() . "\r\n", FILE_APPEND);
        if ($iCurrent->current() != $iNext->current()) {
            file_put_contents($output, "================================================================\r\n", FILE_APPEND);
        }
    }
    $iPrev->next();
    $iCurrent->next();
    $iNext->next();