This commit is contained in:
2025-07-20 04:08:08 -04:00
commit e0ca63ebdf
48 changed files with 7913 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace SqrtSpace\SpaceTime\Streams\Iterators;
/**
* Iterator that applies a mapping function to each element
*/
class MapIterator extends \FilterIterator
{
private $callback;
public function __construct(\Iterator $iterator, callable $callback)
{
parent::__construct($iterator);
$this->callback = $callback;
}
public function accept(): bool
{
return true; // Accept all elements
}
public function current(): mixed
{
return ($this->callback)(parent::current());
}
}