public function min_max_sum_average_and_count_for_non_empty()
 {
     Sequence::of([1, 2, 3, 4])->collecting($min, Aggregations::min())->collecting($max, Aggregations::max())->collecting($average, Aggregations::average())->collecting($sum, Aggregations::sum())->collecting($count, Aggregations::count())->each();
     $this->assertEquals(1, $min);
     $this->assertEquals(4, $max);
     $this->assertEquals(2.5, $average);
     $this->assertEquals(10, $sum);
     $this->assertEquals(4, $count);
 }
Esempio n. 2
0
 /**
  * Returns the largest element.
  *
  * @param  var $comparator default NULL Either a Comparator or a closure to compare.
  * @return var
  * @throws lang.IllegalArgumentException if streamed and invoked more than once
  */
 public function max($comparator = null)
 {
     return $this->collect(Aggregations::max($comparator));
 }