indexBy() public method

{@inheritDoc}
public indexBy ( callable $function ) : pinq\ICollection
$function callable
return pinq\ICollection
Example #1
0
 /**
  * @dataProvider oneToTen
  */
 public function testGroupJoinApplyToSelfWithInnerIndexBy(\Pinq\ICollection $collection)
 {
     $inner = $collection->indexBy(function ($i) {
         return $i - 1;
     })->select(function ($i) {
         return (int) $i;
     });
     $collection->groupJoin($inner)->on(function ($outer, $inner) {
         return $outer > $inner;
     })->apply(function (&$outer, \Pinq\ITraversable $group) {
         $outer .= ':' . $group->implode(',');
     });
     $this->assertMatches($collection, [0 => '1:', 1 => '2:1', 2 => '3:1,2', 3 => '4:1,2,3', 4 => '5:1,2,3,4', 5 => '6:1,2,3,4,5', 6 => '7:1,2,3,4,5,6', 7 => '8:1,2,3,4,5,6,7', 8 => '9:1,2,3,4,5,6,7,8', 9 => '10:1,2,3,4,5,6,7,8,9']);
 }