PageIterator
in package
This class provides the same interface as an iterator over crawl mixes, but simply iterates over an array.
This is used to gather all of the pages for a training set in one go (using a crawl mix iterator), then repeatedly iterate over them in memory, as though they were coming from the original crawl mix iterator.
Tags
Table of Contents
- $end_of_iterator : bool
- Whether or not the last page has been reached.
- $length : int
- The total number of pages.
- $pages : array<string|int, mixed>
- The array of pages to repeatedly iterate over.
- $pos : int
- The current offset into the wrapped array.
- __construct() : mixed
- Establishes a new iterator over a (potentially empty) array of pages.
- nextPage() : array<string|int, mixed>
- Behaves like nextPages, but returns just the next page (not wrapped in an array) if there is one, and null otherwise.
- nextPages() : array<string|int, mixed>
- Returns up to the requested number of next pages, potentially an empty array if there are no pages left. This method updates the `end_of_iterator' flag according to whether the last page has been returned.
- reset() : mixed
- Resets the iterator so that the next page will be the first.
Properties
$end_of_iterator
Whether or not the last page has been reached.
public
bool
$end_of_iterator
$length
The total number of pages.
public
int
$length
$pages
The array of pages to repeatedly iterate over.
public
array<string|int, mixed>
$pages
$pos
The current offset into the wrapped array.
public
int
$pos
Methods
__construct()
Establishes a new iterator over a (potentially empty) array of pages.
public
__construct(array<string|int, mixed> $pages) : mixed
Parameters
- $pages : array<string|int, mixed>
-
standard array of pages to iterate over
Return values
mixed —nextPage()
Behaves like nextPages, but returns just the next page (not wrapped in an array) if there is one, and null otherwise.
public
nextPage() : array<string|int, mixed>
Return values
array<string|int, mixed> —next page if available, and null otherwise
nextPages()
Returns up to the requested number of next pages, potentially an empty array if there are no pages left. This method updates the `end_of_iterator' flag according to whether the last page has been returned.
public
nextPages([int $n = -1 ]) : array<string|int, mixed>
Parameters
- $n : int = -1
-
maximum number of pages to return, or -1 to return all remaining pages
Return values
array<string|int, mixed> —next $n pages, or less if there are fewer than $n pages remaining
reset()
Resets the iterator so that the next page will be the first.
public
reset() : mixed