|
1 | 1 | Examples |
2 | 2 | ======== |
3 | 3 |
|
4 | | -Explore real-world usage in the `examples/` directory. Each file demonstrates a specific iterator or pattern: |
| 4 | +The ``examples/`` directory is one of the fastest ways to understand the |
| 5 | +library. Each script is small, focused, and easy to run in isolation. |
5 | 6 |
|
6 | | -- `chain-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/chain-iterator.php>`_ |
7 | | -- `chunked-iterator-aggregate.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/chunked-iterator-aggregate.php>`_ |
8 | | -- `closure-factory-iterator-aggregate.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/closure-factory-iterator-aggregate.php>`_ |
9 | | -- `closure-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/closure-iterator-iterator.php>`_ |
10 | | -- `consecutive-group-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/consecutive-group-iterator.php>`_ |
11 | | -- `file-extension-filter-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/file-extension-filter-iterator.php>`_ |
12 | | -- `generator-caching-iterator-aggregate.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/generator-caching-iterator-aggregate.php>`_ |
13 | | -- `generator-rewindable-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/generator-rewindable-iterator.php>`_ |
14 | | -- `group-by-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/group-by-iterator-iterator.php>`_ |
15 | | -- `interleave-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/interleave-iterator-iterator.php>`_ |
16 | | -- `lookahead-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/lookahead-iterator.php>`_ |
17 | | -- `range-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/range-iterator.php>`_ |
18 | | -- `repeatable-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/repeatable-iterator-iterator.php>`_ |
19 | | -- `sliding-window-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/sliding-window-iterator-iterator.php>`_ |
20 | | -- `trim-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/trim-iterator-iterator.php>`_ |
21 | | -- `unique-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/unique-iterator-iterator.php>`_ |
22 | | -- `zip-iterator-iterator.php`: `View on GitHub <https://github.com/php-fast-forward/iterators/blob/main/examples/zip-iterator-iterator.php>`_ |
| 7 | +Suggested reading map |
| 8 | +--------------------- |
23 | 9 |
|
24 | | -Browse these files for hands-on demonstrations of each feature and pattern. |
| 10 | +.. list-table:: What each example teaches |
| 11 | + :header-rows: 1 |
| 12 | + :widths: 38 62 |
| 13 | + |
| 14 | + * - Example file |
| 15 | + - What to look for |
| 16 | + * - `chain-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/chain-iterator.php>`_ |
| 17 | + - sequential combination of multiple iterables |
| 18 | + * - `chunked-iterator-aggregate.php <https://github.com/php-fast-forward/iterators/blob/main/examples/chunked-iterator-aggregate.php>`_ |
| 19 | + - fixed-size batching with different chunk sizes |
| 20 | + * - `closure-factory-iterator-aggregate.php <https://github.com/php-fast-forward/iterators/blob/main/examples/closure-factory-iterator-aggregate.php>`_ |
| 21 | + - factory-based lazy iterable creation |
| 22 | + * - `closure-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/closure-iterator-iterator.php>`_ |
| 23 | + - value transformation with closures |
| 24 | + * - `consecutive-group-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/consecutive-group-iterator.php>`_ |
| 25 | + - grouping adjacent runs |
| 26 | + * - `file-extension-filter-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/file-extension-filter-iterator.php>`_ |
| 27 | + - filtering filesystem entries by extension |
| 28 | + * - `generator-caching-iterator-aggregate.php <https://github.com/php-fast-forward/iterators/blob/main/examples/generator-caching-iterator-aggregate.php>`_ |
| 29 | + - replaying generator-backed aggregates |
| 30 | + * - `generator-rewindable-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/generator-rewindable-iterator.php>`_ |
| 31 | + - rewinding generator output and repeating it |
| 32 | + * - `group-by-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/group-by-iterator-iterator.php>`_ |
| 33 | + - full-dataset grouping by computed keys |
| 34 | + * - `interleave-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/interleave-iterator-iterator.php>`_ |
| 35 | + - round-robin traversal and mixed key behavior |
| 36 | + * - `lookahead-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/lookahead-iterator.php>`_ |
| 37 | + - peeking ahead and behind without consuming values |
| 38 | + * - `range-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/range-iterator.php>`_ |
| 39 | + - integer, float, and boundary-aware ranges |
| 40 | + * - `repeatable-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/repeatable-iterator-iterator.php>`_ |
| 41 | + - controlled repetition with limits and offsets |
| 42 | + * - `sliding-window-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/sliding-window-iterator-iterator.php>`_ |
| 43 | + - overlapping windows of different sizes |
| 44 | + * - `trim-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/trim-iterator-iterator.php>`_ |
| 45 | + - whitespace trimming and custom character masks |
| 46 | + * - `unique-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/unique-iterator-iterator.php>`_ |
| 47 | + - strict and non-strict deduplication |
| 48 | + * - `zip-iterator-iterator.php <https://github.com/php-fast-forward/iterators/blob/main/examples/zip-iterator-iterator.php>`_ |
| 49 | + - lockstep combination of several iterables |
| 50 | + |
| 51 | +Recommended order |
| 52 | +----------------- |
| 53 | + |
| 54 | +If you are new to the package, a friendly order is: |
| 55 | + |
| 56 | +1. ``chunked-iterator-aggregate.php`` |
| 57 | +2. ``sliding-window-iterator-iterator.php`` |
| 58 | +3. ``closure-iterator-iterator.php`` |
| 59 | +4. ``unique-iterator-iterator.php`` |
| 60 | +5. ``chain-iterator.php`` |
| 61 | +6. ``interleave-iterator-iterator.php`` |
| 62 | +7. ``zip-iterator-iterator.php`` |
0 commit comments