Example #1
0
<?php

/*
*	Run in command line: php test.group.php
*/
require_once "group.php";
$input = array(10, 1, -20, 14, 99, 136, 19, 20, -15, 117, 22, 93, 120, 131);
print "\nInput:" . implode(",", $input);
print "\nOutput:";
print_r(GroupByInterval::withRangeAndSet(10, $input));
$input = array(10, 1, -20, 14, 99, 136, 19, 20, 117, 22, 93, 120, 131);
print "\nInput:" . implode(",", $input);
print "\nOutput:";
print_r(GroupByInterval::withRangeAndSet(15, $input));
try {
    $input = array(10, 1, "A", 14, 99, 133, 19, 20, 117, 22, 93, 120, 131);
    print "\nInput:" . implode(",", $input);
    print "\nOutput:";
    print_r(GroupByInterval::withRangeAndSet(15, $input));
} catch (Exception $e) {
    echo 'Caught exception: ', $e->getMessage(), "\n";
}
print "\nInput: NULL";
print "\nOutput:";
print_r(GroupByInterval::withRangeAndSet(null, array()));
Example #2
0
<?php

require 'GroupByInterval.php';
$teste = new GroupByInterval();
$input = array(10, 1, -20, 14, 99, 136, 19, 20, 117, 22, 93, 120, 131);
$range = 10;
$result_0 = $teste->execute($input, $range);
$input = array(10, 1, -20, 14, 99, 136, 19, 20, 117, 22, 93, 120, 131);
$range = 15;
$result_1 = $teste->execute($input, $range);
$input = array(10, 1, "A", 14, 99, 133, 19, 20, 117, 22, 93, 120, 131);
$range = 15;
$result_2 = $teste->execute($input, $range);
$input = array();
$range = NULL;
$result_3 = $teste->execute($input, $range);
?>
<!DOCTYPE HTML>
<html>
<head></head>
<body>
	<h1>Group By Interval</h1>

	<p class="input_0"><?php 
echo $result_0;
?>
</p>
	<p class="input_1"><?php 
echo $result_1;
?>
</p>