Login   Register  
PHP Classes
elePHPant
Icontem

File: test_greatest.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of hernan saab  >  Greatest  >  test_greatest.php  >  Download  
File: test_greatest.php
Role: Example script
Content type: text/plain
Description: script that tests and shows how Greatest.php works
Class: Greatest
Keep track of the greatest of several values
Author: By
Last change:
Date: 2012-04-03 16:55
Size: 820 bytes
 

Contents

Class file image Download
<?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";