<?php
$gt = new Greatest(function($a, $b){
return ($a - $b);
}, 0);
$gt->candidate(2);
$gt->candidate(21);
$gt->candidate(0);
$gt->candidate(-2);
$gt->candidate(7);
$gt->candidate(9);
$gt->candidate(101);
$gt->candidate(10);
$gt->candidate(1);
$gt->candidate(17);
echo "greatest is ".$gt->get()."\n";
$gt2 = new Greatest(function($a, $b){
return ($a['h']*$a['w'] - $b['h']*$b['w']);
}, array('h' => 0, 'w' => 0));
$gt2->candidate(array('h' => 3, 'w' => 12));
$gt2->candidate(array('h' => 10, 'w' => 8));
$gt2->candidate(array('h' => 1, 'w' => 20));
$gt2->candidate(array('h' => 3, 'w' => 12));
$gt2->candidate(array('h' => 7, 'w' => 4));
$gt2->candidate(array('h' => 9, 'w' => 8));
$gt2->candidate(array('h' => 12, 'w' => 1));
echo "greatest is ";
var_dump($gt2->get());
echo "\n";
|