Exemplo n.º 1
0
 /**
  * @param array|\Traversable $xs
  * @param array|\Traversable $ys
  * @param JoinSelector $valueJoinSelector
  * @param JoinSelector $keyJoinSelector
  */
 public function __construct($xs, $ys, $valueJoinSelector, $keyJoinSelector)
 {
     $this->valueJoinSelector = $valueJoinSelector;
     $this->keyJoinSelector = $keyJoinSelector;
     $this->it0 = IteratorUtil::iterator($xs);
     $this->it1 = IteratorUtil::iterator($ys);
 }
Exemplo n.º 2
0
 /**
  * @param array|\Traversable $xs
  */
 public function __construct($xs)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->rewinded = false;
     $this->cache = array();
     $this->cacheSize = 0;
 }
Exemplo n.º 3
0
 /**
  * @param array|\Traversable $xs
  * @param Selector $groupingKeySelector
  * @param Selector $elementSelector
  * @param EqualityComparer $eqComparer
  */
 public function __construct($xs, $groupingKeySelector, $elementSelector, $eqComparer)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->groupingKeySelector = $groupingKeySelector;
     $this->elementSelector = $elementSelector;
     $this->eqComparer = $eqComparer;
 }
Exemplo n.º 4
0
 /**
  * @param array|\Traversable $xs
  * @param int                $chunkSize
  * @throws \InvalidArgumentException
  */
 public function __construct($xs, $chunkSize)
 {
     if ($chunkSize < 1) {
         throw new \InvalidArgumentException("chunkSize must be greater than 0");
     }
     $this->it = IteratorUtil::iterator($xs);
     $this->chunkSize = $chunkSize;
 }
Exemplo n.º 5
0
 /**
  * @param mixed $key
  * @return GroupingGinq
  */
 public function get($key)
 {
     /**
      * @var \ArrayObject $xs
      */
     $xs = $this->dict->get($key, array());
     return new GroupingGinq(IteratorUtil::iterator($xs), $key);
 }
Exemplo n.º 6
0
 /**
  * @param array|\Traversable $outer
  * @param array|\Traversable $inner
  * @param Selector $outerKeySelector
  * @param Selector $innerKeySelector
  * @param JoinSelector $valueJoinSelector
  * @param JoinSelector $keyJoinSelector
  * @param EqualityComparer $eqComparer
  */
 public function __construct($outer, $inner, $outerKeySelector, $innerKeySelector, $valueJoinSelector, $keyJoinSelector, $eqComparer)
 {
     $this->outer = IteratorUtil::iterator($outer);
     $this->inner = IteratorUtil::iterator($inner);
     $this->outerKeySelector = $outerKeySelector;
     $this->innerKeySelector = $innerKeySelector;
     $this->valueJoinSelector = $valueJoinSelector;
     $this->keyJoinSelector = $keyJoinSelector;
     $this->eqComparer = $eqComparer;
 }
Exemplo n.º 7
0
 /**
  * @param array|\Traversable $xs
  * @param EqualityComparer $eqComparer
  */
 public function __construct($xs, $eqComparer)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->eqComparer = $eqComparer;
 }
Exemplo n.º 8
0
 /**
  * @param array|\Traversable $xs
  */
 public function __construct($xs)
 {
     $this->it = IteratorUtil::iterator($xs);
 }
Exemplo n.º 9
0
 /**
  * @param array|\Traversable $xs
  * @param Predicate $predicate
  */
 public function __construct($xs, $predicate)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->predicate = $predicate;
 }
Exemplo n.º 10
0
 /**
  * @param array|\Traversable $xs
  * @param Comparer $comparer
  */
 public function __construct($xs, $comparer)
 {
     $this->src = IteratorUtil::iterator($xs);
     $this->comparer = $comparer;
 }
Exemplo n.º 11
0
 /**
  * @param array|\Traversable $xs
  * @param \Closure $fn
  */
 public function __construct($xs, $fn)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->fn = $fn;
 }
Exemplo n.º 12
0
 /**
  * @param array|\Traversable $xs
  * @param Selector $valueSelector
  * @param Selector $keySelector
  */
 public function __construct($xs, $valueSelector, $keySelector)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->valueSelector = $valueSelector;
     $this->keySelector = $keySelector;
 }
Exemplo n.º 13
0
 protected function fetchIfValid()
 {
     if ($this->outer->valid()) {
         $outerV = $this->outer->current();
         $outerK = $this->outer->key();
         $compareKey = $this->outerCompareKeySelector->select($outerV, $outerK);
         $inners = $this->lookup->get($compareKey);
         $inners = new GroupingGinq(IteratorUtil::iterator($inners), $compareKey);
         $this->v = $this->resultValueSelector->select($outerV, $inners, $outerK, $compareKey);
         $this->k = $this->outer->key();
     }
 }
Exemplo n.º 14
0
 public function rewind()
 {
     $f = $this->sourceFactory;
     $this->it = IteratorUtil::iterator($f());
     $this->it->rewind();
 }
Exemplo n.º 15
0
 protected function fetchOuter()
 {
     if ($this->outer->valid()) {
         $this->outerV = $this->outer->current();
         $this->outerK = $this->outer->key();
         $this->inner = IteratorUtil::iterator($this->manySelector->select($this->outerV, $this->outerK));
         $this->inner->rewind();
     } else {
         $this->inner = null;
     }
 }
Exemplo n.º 16
0
 /**
  * @param array|\Iterator|\IteratorAggregate $rhs
  * @return bool
  */
 public function sequenceEquals($rhs)
 {
     $eqComparer = EqualityComparerResolver::resolve(null, EqualityComparer::getDefault());
     $lhs = $this->getIterator();
     $rhs = IteratorUtil::iterator($rhs);
     if ($lhs instanceof \Countable && $rhs instanceof \Countable) {
         if ($lhs->count() !== $rhs->count()) {
             return false;
         }
     }
     $lhs->rewind();
     $rhs->rewind();
     while ($lhs->valid()) {
         $v0 = $lhs->current();
         if ($rhs->valid()) {
             $v1 = $rhs->current();
             if (!$eqComparer->equals($v0, $v1)) {
                 return false;
             }
             $rhs->next();
         } else {
             return false;
         }
         $lhs->next();
     }
     return true;
 }
Exemplo n.º 17
0
 /**
  * @param array|\Traversable $xs
  * @param array|\Traversable $ys
  */
 public function __construct($xs, $ys)
 {
     $this->it0 = IteratorUtil::iterator($xs);
     $this->it1 = IteratorUtil::iterator($ys);
 }