File Coverage

blib/lib/Algorithm/Heapify/XS.pm
Criterion Covered Total %
statement 8 14 57.1
branch 0 8 0.0
condition n/a
subroutine 3 6 50.0
pod 0 3 0.0
total 11 31 35.4


line stmt bran cond sub pod time code
1             package Algorithm::Heapify::XS;
2              
3 2     2   163974 use 5.018004;
  2         16  
4 2     2   11 use strict;
  2         4  
  2         39  
5 2     2   10 use warnings;
  2         3  
  2         844  
6              
7             require Exporter;
8              
9             our @ISA = qw(Exporter);
10              
11             # This allows declaration:
12             # use Algorithm::Heapify::XS ':all';
13              
14             our %EXPORT_TAGS = (
15             'all' => [
16             'heap_parent_idx',
17             'heap_left_child_idx',
18             'heap_right_child_idx',
19             map { ("min_$_", "max_$_","minstr_$_","maxstr_$_") }
20             (
21             'heapify',
22             'heap_shift',
23             'heap_push',
24             'heap_adjust_top',
25             'heap_adjust_item',
26             )
27             ]
28             );
29             our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
30              
31             foreach my $prefix (qw(max min maxstr minstr)) {
32             $EXPORT_TAGS{$prefix}= [ grep { /^${prefix}_/ } @EXPORT_OK ];
33             }
34             $EXPORT_TAGS{idx}= [ grep { /_idx\z/ } @EXPORT_OK ];
35              
36             our @EXPORT = qw();
37              
38             our $VERSION = '0.02';
39              
40             require XSLoader;
41             XSLoader::load('Algorithm::Heapify::XS', $VERSION);
42              
43             sub heap_parent_idx($) {
44 0 0   0 0   die "index must be non-negative" if $_[0] < 0;
45 0 0         return $_[0] ? int(($_[0] - 1) / 2) : undef;
46             }
47              
48             sub heap_left_child_idx($) {
49 0 0   0 0   die "index must be non-negative" if $_[0] < 0;
50 0           return 2*$_[0]+1;
51             }
52              
53             sub heap_right_child_idx($) {
54 0 0   0 0   die "index must be non-negative" if $_[0] < 0;
55 0           return 2*$_[0]+2;
56             }
57              
58              
59             1;
60             __END__