ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Array-Heap/Heap.pm
(Generate patch)

Comparing Array-Heap/Heap.pm (file contents):
Revision 1.5 by root, Fri Apr 19 20:53:56 2013 UTC vs.
Revision 1.8 by root, Tue Jul 14 23:28:10 2015 UTC

1=head1 NAME 1=head1 NAME
2 2
3Array::Heap - treat perl arrays as heaps (priority queues) 3Array::Heap - treat perl arrays as binary heaps/priority queues
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use Array::Heap; 7 use Array::Heap;
8 8
28=cut 28=cut
29 29
30package Array::Heap; 30package Array::Heap;
31 31
32BEGIN { 32BEGIN {
33 $VERSION = '3.0'; 33 $VERSION = 3.2;
34 34
35 require XSLoader; 35 require XSLoader;
36 XSLoader::load ("Array::Heap", $VERSION); 36 XSLoader::load ("Array::Heap", $VERSION);
37} 37}
38 38
160will sort according to the first element of the arrays, i.e. C<1,2,3>. 160will sort according to the first element of the arrays, i.e. C<1,2,3>.
161 161
162The custom comparison functions work similar to how C<sort> works: C<$a> 162The custom comparison functions work similar to how C<sort> works: C<$a>
163and C<$b> are set to the elements to be compared, and the result should be 163and C<$b> are set to the elements to be compared, and the result should be
164greater than zero then $a is greater than $b, C<0> otherwise. This means 164greater than zero then $a is greater than $b, C<0> otherwise. This means
165that you cna use the same function as for sorting the array, but you could 165that you can use the same function as for sorting the array, but you could
166also use a simpler function that just does C<< $a > $b >>. 166also use a simpler function that just does C<< $a > $b >>.
167 167
168The first example above corresponds to this comparison "function": 168The first example above corresponds to this comparison "function":
169 169
170 { $a <=> $b } 170 { $a <=> $b }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines