Algorithm-Heapify-XS
view release on metacpan or search on metacpan
lex_stuff_pvn||5.011002|
lex_stuff_pvs||5.013005|
lex_stuff_pv||5.013006|
lex_stuff_sv||5.011002|
lex_unstuff||5.011002|
listkids|||
list|||
load_module_nocontext|||vn
load_module|5.006000||pv
localize|||
looks_like_bool|||
looks_like_number|||
lop|||
mPUSHi|5.009002||p
mPUSHn|5.009002||p
mPUSHp|5.009002||p
mPUSHs|5.010001||p
mPUSHu|5.009002||p
mXPUSHi|5.009002||p
mXPUSHn|5.009002||p
mXPUSHp|5.009002||p
mXPUSHs|5.010001||p
t/max_heap.t view on Meta::CPAN
[10, 500],[20, 500],[40, 500],[80, 500], [100, 500], [ 500, 500],
[10,1000],[20,1000],[40,1000],[80,1000], [100,1000], [1000,1000],
)
);
plan tests => (@test_tuples * 3)+15;
my @n= 1..10;
my $top;
$top= max_heapify(@n);
is($n[0],10,"max_heapify works");
is($top,10,"... and top looks ok");
$top= max_heap_push(@n,100);
is($n[0],100,"max_heap_push works");
is($top,100,"... and top looks ok");
$top= max_heap_push(@n,99);
is($n[0],100,"max_heap_push works");
is($top,100,"... and top looks ok");
$top= max_heap_shift(@n);
is($n[0],99,"max_heap_shift works");
is($top,100,"... and top looks ok");
$n[5]=1000;
$top= max_heap_adjust_item(@n,5);
is($n[0],1000,"max_heap_adjust_item works");
is($top,1000,"... and top looks ok");
$n[5]=-1;
$top= max_heap_adjust_item(@n,5);
is($n[0],1000,"max_heap_adjust_item works");
is($top,1000,"... and top looks ok");
$n[0]= 0;
$top= max_heap_adjust_top(@n);
is($n[0],99,"max_heap_adjust_top works");
is($top,99,"... and top looks ok");
my @expect= sort { $b<=>$a } @n;
my @got;
push @got, max_heap_shift(@n) while @n;
is("@got","@expect","and everything looks as expected at the end");
my @res;
foreach my $tuple (@test_tuples) {
my $num_agents= $tuple->[0];
my $num_jobs= $tuple->[1];
my $agent_id= "AA";
my @agents= map { $agent_id++ } 1 .. $num_agents;
my $job_id= 1;
t/min_heap.t view on Meta::CPAN
[10, 500],[20, 500],[40, 500],[80, 500], [100, 500], [ 500, 500],
[10,1000],[20,1000],[40,1000],[80,1000], [100,1000], [1000,1000],
)
);
plan tests => (@test_tuples * 3)+15;
my @n= reverse 1..10;
my $top;
$top= min_heapify(@n);
is($n[0],1,"min_heapify works");
is($top,1,"... and top looks ok");
$top= min_heap_push(@n,0);
is($n[0],0,"min_heap_push works");
is($top,0,"... and top looks ok");
$top= min_heap_push(@n,0.5);
is($n[0],0,"min_heap_push works");
is($top,0,"... and top looks ok");
$top= min_heap_shift(@n);
is($n[0],0.5,"min_heap_shift works");
is($top,0,"... and top looks ok");
$n[5]=-1;
$top= min_heap_adjust_item(@n,5);
is($n[0],-1,"min_heap_adjust_item works");
is($top,-1,"... and top looks ok");
$n[5]=1000;
$top= min_heap_adjust_item(@n,5);
is($n[0],-1,"min_heap_adjust_item works");
is($top,-1,"... and top looks ok");
$n[0]= 100;
$top= min_heap_adjust_top(@n);
is($n[0],0.5,"min_heap_adjust_top works");
is($top,0.5,"... and top looks ok");
my @expect= sort { $a<=>$b } @n;
my @got;
push @got, min_heap_shift(@n) while @n;
is("@got","@expect","and everything looks as expected at the end");
my @res;
foreach my $tuple (@test_tuples) {
my $num_agents= $tuple->[0];
my $num_jobs= $tuple->[1];
my $agent_id= "AA";
my @agents= map { $agent_id++ } 1 .. $num_agents;
my $job_id= 1;
( run in 0.548 second using v1.01-cache-2.11-cpan-64827b87656 )