Дан текстовый файл размером 2ГБ. Напишите класс, реализующий интерфейс SeekableIterator, для чтения данного файла.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist jumper423/file-iterator
or add
"jumper423/yfile-iterator": "*"
to the require
section of your composer.json.
$fileIterator = new \jumper423\FileIterator(__DIR__ . '/file');
$fileIterator->rewind();
$fileIterator->next();
$fileIterator->next();
$fileIterator->seek(3);
$fileIterator->next();
echo $fileIterator->current();
$fileIterator->next();
echo $fileIterator->current();
$fileIterator->seek(9);
$fileIterator->next();
$fileIterator->next();
if ($fileIterator->valid()) {
...
}
vendor/bin/phpunit