public function __construct($seq, $aSeq) { $iterator = null; $itAppend = new AppendIterator(); if (!is_null($seq)) { $iterator = Sloth::iter($seq); $itAppend->append($iterator); } foreach ($aSeq as $mSeq) { $itAppend->append(Sloth::iter($mSeq)); } $this->iterator = $itAppend; }
public function __construct($seq, $offset = 0, $count = -1) { $iterator = Sloth::iter($seq); $itLimit = new LimitIterator($iterator, $offset, $count); $this->iterator = $itLimit; }
public function __construct($seq) { $itNoRewind = new NoRewindIterator(Sloth::iter($seq)); $this->iterator = $itNoRewind; }
/** * iter * @param mixed $mFirst * @param func $fnCallback * @return object Sloth_Iterator */ public static function iter($mFirst, $fnCallback = null) { if (is_null($fnCallback)) { if (is_array($mFirst)) { return new Sloth_Iterator($mFirst); } else { if ($mFirst instanceof Sloth_IteratorInterface) { return $mFirst; } else { if ($mFirst instanceof Iterator) { return new Sloth_Iterator($mFirst); } else { if ($mFirst instanceof IteratorAggregate) { $iter = $mFirst->getIterator(); if ($iter instanceof Sloth_IteratorInterface) { return $iter; } else { if ($iter instanceof Iterator) { return new Sloth_Iterator($iter); } } } else { throw new InvalidArgumentException(); } } } } } else { if (is_int($fnCallback)) { return Sloth::ref(new Sloth_Follow($mFirst, Sloth::fn('$x+1')))->take($fnCallback); } else { return new Sloth_Follow($mFirst, $fnCallback); } } }
public function getIterator() { return Sloth::iter(new ArrayIterator($this->_data)); }
static function scanDirIter($path, $order = 0, $sort = 'name', $context = null) { $files = self::scandir($path, $order, $sort, $context); return Sloth::iter($files); }
return $this->is_valid; } function next() { $result = call_user_func($this->fn, $this->current_value, ++$this->key); if ($result === false) { $this->is_valid = false; } else { $this->current_value = $result; } } function current() { return $this->current_value; } function key() { return $this->key; } function rewind() { $this->key = 0; $this->current_value = $this->first; $this->is_valid = true; } } // // DocTest // !count(debug_backtrace()) and Sloth::doctest(__FILE__);
public function __construct($seq, $callback) { $iterator = Sloth::iter($seq); $itFilter = new Sloth_CallbackFilterIterator($iterator, $callback); $this->iterator = $itFilter; }
public function __construct($seq) { $iterator = Sloth::iter($seq); $itInfin = new InfiniteIterator($iterator); $this->iterator = $itInfin; }
function iter($sql, $params = null, $strict = null) { $strict = is_null($strict) ? $this->strict() : $strict; list($sql, $params) = $this->prepareSql($sql, $params); $this->log($sql, $params); return Sloth::iter(Gongo_Locator::get($this->iteratorClass(), $this->pdo(), $sql, $params, PDO::FETCH_ASSOC, $strict)); }
function parseFileIter($path) { return Sloth::iter(new SplFileObject($path))->map(array($this, 'parseLine')); }