File Coverage

blib/lib/List/Compare/Base/_Engine.pm
Criterion Covered Total %
statement 41 41 100.0
branch 8 8 100.0
condition n/a
subroutine 5 5 100.0
pod n/a
total 54 54 100.0


line stmt bran cond sub pod time code
1             package List::Compare::Base::_Engine;
2             $VERSION = 0.53;
3             # Holds subroutines used within
4             # List::Compare::Base::Accelerated and List::Compare::Functional
5 52     52   246 use Carp;
  52         206  
  52         3380  
6 52         3969 use List::Compare::Base::_Auxiliary qw(
7             _equiv_engine
8             _calculate_union_seen_only
9             _calculate_seen_only
10 52     52   249 );
  52         61  
11             @ISA = qw(Exporter);
12             @EXPORT_OK = qw|
13             _unique_all_engine
14             _complement_all_engine
15             |;
16 52     52   265 use strict;
  52         75  
  52         17904  
17             local $^W = 1;
18              
19             sub _unique_all_engine {
20 96     96   292 my $aref = shift;
21 96         256 my $seenref = _calculate_seen_only($aref);
22              
23 96         166 my @all_uniques = ();
24 96         101 for my $i (sort {$a <=> $b} keys %{$seenref}) {
  704         757  
  96         404  
25 456         488 my %seen_in_all_others = ();
26 456         364 for my $j (keys %{$seenref}) {
  456         842  
27 2232 100       3599 unless ($i == $j) {
28 1776         1231 for my $k (keys %{$seenref->{$j}}) {
  1776         3048  
29 9616         10039 $seen_in_all_others{$k}++;
30             }
31             }
32              
33             }
34 456         581 my @these_uniques = ();
35 456         354 for my $l (keys %{$seenref->{$i}}) {
  456         893  
36 2488 100       3865 push @these_uniques, $l
37             unless $seen_in_all_others{$l};
38             }
39 456         1218 $all_uniques[$i] = \@these_uniques;
40             }
41 96         565 return \@all_uniques;
42             }
43              
44             sub _complement_all_engine {
45 112     112   160 my ($aref, $unsortflag) = @_;
46 112         286 my ($unionref, $seenref) = _calculate_union_seen_only($aref);
47 112 100       228 my @union = $unsortflag ? keys %{$unionref} : sort(keys %{$unionref});
  48         209  
  64         420  
48              
49             # Calculate @xcomplement
50             # Inputs: $aref @union %seen
51 112         187 my (@xcomplement);
52 112         157 for (my $i = 0; $i <= $#{$aref}; $i++) {
  648         1153  
53 536         489 my @complementthis = ();
54 536         505 foreach my $el (@union) {
55 5328 100       8730 push(@complementthis, $el) unless (exists $seenref->{$i}->{$el});
56             }
57 536         865 $xcomplement[$i] = \@complementthis;
58             }
59 112         707 return \@xcomplement;
60             }
61              
62             1;
63              
64              
65             __END__