예제 #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);
 }
예제 #2
0
 /**
  * @param array|\Traversable $xs
  */
 public function __construct($xs)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->rewinded = false;
     $this->cache = array();
     $this->cacheSize = 0;
 }
예제 #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;
 }
예제 #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;
 }
예제 #5
0
파일: LookupGinq.php 프로젝트: gunjiro/ginq
 /**
  * @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);
 }
예제 #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;
 }
예제 #7
0
 /**
  * @param array|\Traversable $xs
  * @param EqualityComparer $eqComparer
  */
 public function __construct($xs, $eqComparer)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->eqComparer = $eqComparer;
 }
예제 #8
0
 /**
  * @param array|\Traversable $xs
  */
 public function __construct($xs)
 {
     $this->it = IteratorUtil::iterator($xs);
 }
예제 #9
0
 /**
  * @param array|\Traversable $xs
  * @param Predicate $predicate
  */
 public function __construct($xs, $predicate)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->predicate = $predicate;
 }
예제 #10
0
 /**
  * @param array|\Traversable $xs
  * @param Comparer $comparer
  */
 public function __construct($xs, $comparer)
 {
     $this->src = IteratorUtil::iterator($xs);
     $this->comparer = $comparer;
 }
예제 #11
0
 /**
  * @param array|\Traversable $xs
  * @param \Closure $fn
  */
 public function __construct($xs, $fn)
 {
     $this->it = IteratorUtil::iterator($xs);
     $this->fn = $fn;
 }
예제 #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;
 }
예제 #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();
     }
 }
예제 #14
0
 public function rewind()
 {
     $f = $this->sourceFactory;
     $this->it = IteratorUtil::iterator($f());
     $this->it->rewind();
 }
예제 #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;
     }
 }
예제 #16
0
파일: Ginq.php 프로젝트: gunjiro/ginq
 /**
  * @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;
 }
예제 #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);
 }