| 1 | package List::Compare::Functional; | ||||||||||
| 2 | 51 | our $VERSION = '0.55'; | |||||||||
| 3 | 51 | our @ISA = qw(Exporter); | |||||||||
| 4 | 51 | our @EXPORT_OK = qw| | |||||||||
| 5 | get_intersection | ||||||||||
| 6 | get_intersection_ref | ||||||||||
| 7 | get_union | ||||||||||
| 8 | get_union_ref | ||||||||||
| 9 | get_unique | ||||||||||
| 10 | get_unique_ref | ||||||||||
| 11 | get_unique_all | ||||||||||
| 12 | get_complement | ||||||||||
| 13 | get_complement_ref | ||||||||||
| 14 | get_complement_all | ||||||||||
| 15 | get_symmetric_difference | ||||||||||
| 16 | get_symmetric_difference_ref | ||||||||||
| 17 | is_LsubsetR | ||||||||||
| 18 | is_RsubsetL | ||||||||||
| 19 | is_LequivalentR | ||||||||||
| 20 | is_LdisjointR | ||||||||||
| 21 | is_member_which | ||||||||||
| 22 | is_member_which_ref | ||||||||||
| 23 | are_members_which | ||||||||||
| 24 | is_member_any | ||||||||||
| 25 | are_members_any | ||||||||||
| 26 | print_subset_chart | ||||||||||
| 27 | print_equivalence_chart | ||||||||||
| 28 | get_shared | ||||||||||
| 29 | get_shared_ref | ||||||||||
| 30 | get_nonintersection | ||||||||||
| 31 | get_nonintersection_ref | ||||||||||
| 32 | get_symdiff | ||||||||||
| 33 | get_symdiff_ref | ||||||||||
| 34 | is_LeqvlntR | ||||||||||
| 35 | get_bag | ||||||||||
| 36 | get_bag_ref | ||||||||||
| 37 | get_version | ||||||||||
| 38 | |; | ||||||||||
| 39 | 51 | our %EXPORT_TAGS = ( | |||||||||
| 40 | main => [ qw( | ||||||||||
| 41 | get_intersection | ||||||||||
| 42 | get_union | ||||||||||
| 43 | get_unique | ||||||||||
| 44 | get_complement | ||||||||||
| 45 | get_symmetric_difference | ||||||||||
| 46 | is_LsubsetR | ||||||||||
| 47 | ) ], | ||||||||||
| 48 | mainrefs => [ qw( | ||||||||||
| 49 | get_intersection_ref | ||||||||||
| 50 | get_union_ref | ||||||||||
| 51 | get_unique_ref | ||||||||||
| 52 | get_complement_ref | ||||||||||
| 53 | get_symmetric_difference_ref | ||||||||||
| 54 | ) ], | ||||||||||
| 55 | originals => [ qw( | ||||||||||
| 56 | get_intersection | ||||||||||
| 57 | get_intersection_ref | ||||||||||
| 58 | get_union | ||||||||||
| 59 | get_union_ref | ||||||||||
| 60 | get_unique | ||||||||||
| 61 | get_unique_ref | ||||||||||
| 62 | get_unique_all | ||||||||||
| 63 | get_complement | ||||||||||
| 64 | get_complement_ref | ||||||||||
| 65 | get_complement_all | ||||||||||
| 66 | get_symmetric_difference | ||||||||||
| 67 | get_symmetric_difference_ref | ||||||||||
| 68 | get_shared | ||||||||||
| 69 | get_shared_ref | ||||||||||
| 70 | get_nonintersection | ||||||||||
| 71 | get_nonintersection_ref | ||||||||||
| 72 | is_LsubsetR | ||||||||||
| 73 | is_RsubsetL | ||||||||||
| 74 | is_LequivalentR | ||||||||||
| 75 | is_LdisjointR | ||||||||||
| 76 | is_member_which | ||||||||||
| 77 | is_member_which_ref | ||||||||||
| 78 | are_members_which | ||||||||||
| 79 | is_member_any | ||||||||||
| 80 | are_members_any | ||||||||||
| 81 | print_subset_chart | ||||||||||
| 82 | print_equivalence_chart | ||||||||||
| 83 | get_bag | ||||||||||
| 84 | get_bag_ref | ||||||||||
| 85 | get_version | ||||||||||
| 86 | ) ], | ||||||||||
| 87 | aliases => [ qw( | ||||||||||
| 88 | get_symdiff | ||||||||||
| 89 | get_symdiff_ref | ||||||||||
| 90 | is_LeqvlntR | ||||||||||
| 91 | ) ], | ||||||||||
| 92 | ); | ||||||||||
| 93 | 51 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 94 | 51 | local $^W = 1; | |||||||||
| 95 | 51 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 96 | 51 | ▶ | use List::Compare::Base::_Auxiliary qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 97 | _subset_subengine | ||||||||||
| 98 | _chart_engine_multiple | ||||||||||
| 99 | _equivalent_subengine | ||||||||||
| 100 | _calc_seen1 | ||||||||||
| 101 | 51 | ); | |||||||||
| 102 | 51 | ▶ | use List::Compare::Base::_Auxiliary qw(:calculate :checker :tester); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 103 | 51 | ▶ | use List::Compare::Base::_Engine qw( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 104 | _unique_all_engine | ||||||||||
| 105 | _complement_all_engine | ||||||||||
| 106 | 51 | ); | |||||||||
| 107 | |||||||||||
| 108 | |||||||||||
| 109 | 23 | ▶ | sub get_union { | ||||||||
|
Subroutine
get_union: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 110 | 23 | return @{ get_union_ref(@_) }; | |||||||||
| 111 | } | ||||||||||
| 112 | |||||||||||
| 113 | 45 | ▶ | sub get_union_ref { | ||||||||
|
Subroutine
get_union_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 114 | 45 | my ($argref, $unsorted) = _alt_construct_tester(@_); | |||||||||
| 115 | $unsorted | ||||||||||
| 116 | ? return _union_engine(_argument_checker($argref)) | ||||||||||
| 117 | 41 | ▶ | : return [ sort @{_union_engine(_argument_checker($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 118 | } | ||||||||||
| 119 | |||||||||||
| 120 | 33 | ▶ | sub _union_engine { | ||||||||
|
Subroutine
_union_engine: called CC=1 SCAR=0.0
| |||||||||||
| 121 | 33 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 122 | 33 | my $unionhashref = _calculate_union_only($seenrefsref); | |||||||||
| 123 | 33 | return [ keys %{$unionhashref} ]; | |||||||||
| 124 | } | ||||||||||
| 125 | |||||||||||
| 126 | 26 | ▶ | sub get_intersection { | ||||||||
|
Subroutine
get_intersection: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 127 | 26 | return @{ get_intersection_ref(@_) }; | |||||||||
| 128 | } | ||||||||||
| 129 | |||||||||||
| 130 | 52 | ▶ | sub get_intersection_ref { | ||||||||
|
Subroutine
get_intersection_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 131 | 52 | my ($argref, $unsorted) = _alt_construct_tester(@_); | |||||||||
| 132 | $unsorted | ||||||||||
| 133 | ? return _intersection_engine(_argument_checker($argref)) | ||||||||||
| 134 | 48 | ▶ | : return [ sort @{_intersection_engine(_argument_checker($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | 40 | ▶ | sub _intersection_engine { | ||||||||
|
Subroutine
_intersection_engine: called CC=2 SCAR=6.9
| |||||||||||
| 138 | 40 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 139 | 120 | my @vals = sort { scalar(keys(%{$a})) <=> scalar(keys(%{$b})) } | |||||||||
| 140 | 40 | @{$seenrefsref}; | |||||||||
| 141 | 40 | my %intersection = map { $_ => 1 } keys %{$vals[0]}; | |||||||||
| 142 | 40 | for my $l ( 1..$#vals ) { | |||||||||
| 143 | 288 | %intersection = map { $_ => 1 } | |||||||||
| 144 | 512 | grep { exists $intersection{$_} } | |||||||||
| 145 | 88 | keys %{$vals[$l]}; | |||||||||
| 146 | } | ||||||||||
| 147 | 40 | return [ keys %intersection ]; | |||||||||
| 148 | } | ||||||||||
| 149 | |||||||||||
| 150 | 29 | ▶ | sub get_unique { | ||||||||
|
Subroutine
get_unique: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 151 | 29 | return @{ get_unique_ref(@_) }; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | 58 | ▶ | sub get_unique_ref { | ||||||||
|
Subroutine
get_unique_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 155 | 58 | my ($argref, $unsorted) = _alt_construct_tester_3(@_); | |||||||||
| 156 | $unsorted | ||||||||||
| 157 | ? return _unique_engine(_argument_checker_3($argref)) | ||||||||||
| 158 | 54 | ▶ | : return [ sort @{_unique_engine(_argument_checker_3($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 159 | } | ||||||||||
| 160 | |||||||||||
| 161 | 17 | ▶ | sub get_unique_all { | ||||||||
|
Subroutine
get_unique_all: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 162 | 17 | my ($argref, $unsorted) = _alt_construct_tester_3(@_); | |||||||||
| 163 | # currently it doesn't appear that &_unique_all_engine can make use of | ||||||||||
| 164 | # $unsorted | ||||||||||
| 165 | 17 | return _unique_all_engine(_argument_checker_3a($argref)); | |||||||||
| 166 | } | ||||||||||
| 167 | |||||||||||
| 168 | 41 | ▶ | sub _unique_engine { | ||||||||
|
Subroutine
_unique_engine: called CC=6 SCAR=17.9
| |||||||||||
| 169 | 41 | my $index = pop(@_); | |||||||||
| 170 | 41 | my $seenref = _calculate_seen_only(_calc_seen1(@_)); | |||||||||
| 171 | |||||||||||
| 172 | 41 | my %seen_in_all_others = (); | |||||||||
| 173 | 41 | my @seenthis = (); | |||||||||
| 174 | 41 | for my $i (keys %{$seenref}) { | |||||||||
| 175 | 154 | ▶ | unless ($i == $index) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 176 | 113 | for my $k (keys %{$seenref->{$i}}) { | |||||||||
| 177 | 631 | $seen_in_all_others{$k}++; | |||||||||
| 178 | } | ||||||||||
| 179 | } | ||||||||||
| 180 | else { | ||||||||||
| 181 | 41 | @seenthis = keys %{$seenref->{$index}}; | |||||||||
| 182 | } | ||||||||||
| 183 | } | ||||||||||
| 184 | 41 | my @unique_to_this_index = (); | |||||||||
| 185 | 41 | for my $s (@seenthis) { | |||||||||
| 186 | push @unique_to_this_index, $s | ||||||||||
| 187 | 255 | ▶ | unless $seen_in_all_others{$s}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 188 | } | ||||||||||
| 189 | 41 | return \@unique_to_this_index; | |||||||||
| 190 | } | ||||||||||
| 191 | |||||||||||
| 192 | 32 | ▶ | sub get_complement { | ||||||||
|
Subroutine
get_complement: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 193 | 32 | return @{ get_complement_ref(@_) }; | |||||||||
| 194 | } | ||||||||||
| 195 | |||||||||||
| 196 | 65 | ▶ | sub get_complement_ref { | ||||||||
|
Subroutine
get_complement_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 197 | 65 | my ($argref, $unsorted) = _alt_construct_tester_3(@_); | |||||||||
| 198 | $unsorted | ||||||||||
| 199 | ? return _complement_engine(_argument_checker_3($argref)) | ||||||||||
| 200 | 61 | ▶ | : return [ sort @{_complement_engine(_argument_checker_3($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 201 | } | ||||||||||
| 202 | |||||||||||
| 203 | 17 | ▶ | sub get_complement_all { | ||||||||
|
Subroutine
get_complement_all: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 204 | 17 | my ($argref, $unsorted) = _alt_construct_tester_3(@_); | |||||||||
| 205 | 17 | return _complement_all_engine(_argument_checker_3a($argref), $unsorted); | |||||||||
| 206 | } | ||||||||||
| 207 | |||||||||||
| 208 | 48 | ▶ | sub _complement_engine { | ||||||||
|
Subroutine
_complement_engine: called CC=4 SCAR=13.9
| |||||||||||
| 209 | 48 | my $tested = pop(@_); | |||||||||
| 210 | 48 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 211 | 48 | my ($unionref, $seenref) = _calculate_union_seen_only($seenrefsref); | |||||||||
| 212 | |||||||||||
| 213 | # Calculate %xcomplement | ||||||||||
| 214 | # Inputs: $seenrefsref @union (keys %$unionref) | ||||||||||
| 215 | 48 | my (%xcomplement); | |||||||||
| 216 | 48 | ▶ | for (my $i = 0; $i <= $#{$seenrefsref}; $i++) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 217 | 192 | my @complementthis = (); | |||||||||
| 218 | 192 | foreach my $k (keys %{$unionref}) { | |||||||||
| 219 | 1856 | ▶ | push(@complementthis, $k) unless (exists $seenref->{$i}->{$k}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 220 | } | ||||||||||
| 221 | 192 | $xcomplement{$i} = \@complementthis; | |||||||||
| 222 | } | ||||||||||
| 223 | 48 | return [ @{$xcomplement{$tested}} ]; | |||||||||
| 224 | } | ||||||||||
| 225 | |||||||||||
| 226 | 44 | ▶ | sub get_symmetric_difference { | ||||||||
|
Subroutine
get_symmetric_difference: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 227 | 44 | return @{ get_symmetric_difference_ref(@_) }; | |||||||||
| 228 | } | ||||||||||
| 229 | |||||||||||
| 230 | 88 | ▶ | sub get_symmetric_difference_ref { | ||||||||
|
Subroutine
get_symmetric_difference_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 231 | 88 | my ($argref, $unsorted) = _alt_construct_tester(@_); | |||||||||
| 232 | $unsorted | ||||||||||
| 233 | ? return _symmetric_difference_engine(_argument_checker($argref)) | ||||||||||
| 234 | 80 | ▶ | : return [ sort @{_symmetric_difference_engine(_argument_checker($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 235 | } | ||||||||||
| 236 | |||||||||||
| 237 | 64 | ▶ | sub _symmetric_difference_engine { | ||||||||
|
Subroutine
_symmetric_difference_engine: called CC=3 SCAR=11.0
| |||||||||||
| 238 | # Get those items which do not appear in more than one of several lists (their symmetric_difference); | ||||||||||
| 239 | 64 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 240 | |||||||||||
| 241 | 64 | my $unionref = _calculate_union_only($seenrefsref); | |||||||||
| 242 | |||||||||||
| 243 | 64 | my $sharedref = _calculate_sharedref($seenrefsref); | |||||||||
| 244 | |||||||||||
| 245 | 64 | my (@symmetric_difference); | |||||||||
| 246 | 64 | for my $k (keys %{$unionref}) { | |||||||||
| 247 | 576 | ▶ | push(@symmetric_difference, $k) unless exists $sharedref->{$k}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 248 | } | ||||||||||
| 249 | 64 | return \@symmetric_difference; | |||||||||
| 250 | } | ||||||||||
| 251 | |||||||||||
| 252 | { | ||||||||||
| 253 | 51 | ▶ | no warnings 'once'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 254 | 51 | *get_symdiff = \&get_symmetric_difference; | |||||||||
| 255 | 51 | *get_symdiff_ref = \&get_symmetric_difference_ref; | |||||||||
| 256 | } | ||||||||||
| 257 | |||||||||||
| 258 | 22 | ▶ | sub get_shared { | ||||||||
|
Subroutine
get_shared: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 259 | 22 | return @{ get_shared_ref(@_) }; | |||||||||
| 260 | } | ||||||||||
| 261 | |||||||||||
| 262 | 44 | ▶ | sub get_shared_ref { | ||||||||
|
Subroutine
get_shared_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 263 | 44 | my ($argref, $unsorted) = _alt_construct_tester(@_); | |||||||||
| 264 | $unsorted | ||||||||||
| 265 | ? return _shared_engine(_argument_checker($argref)) | ||||||||||
| 266 | 40 | ▶ | : return [ sort @{_shared_engine(_argument_checker($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 267 | } | ||||||||||
| 268 | |||||||||||
| 269 | 32 | ▶ | sub _shared_engine { | ||||||||
|
Subroutine
_shared_engine: called CC=1 SCAR=0.0
| |||||||||||
| 270 | 32 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 271 | |||||||||||
| 272 | 32 | my $sharedref = _calculate_sharedref($seenrefsref); | |||||||||
| 273 | 32 | return [ keys %{$sharedref} ]; | |||||||||
| 274 | } | ||||||||||
| 275 | |||||||||||
| 276 | 22 | ▶ | sub get_nonintersection { | ||||||||
|
Subroutine
get_nonintersection: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 277 | 22 | return @{ get_nonintersection_ref(@_) }; | |||||||||
| 278 | } | ||||||||||
| 279 | |||||||||||
| 280 | 44 | ▶ | sub get_nonintersection_ref { | ||||||||
|
Subroutine
get_nonintersection_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 281 | 44 | my ($argref, $unsorted) = _alt_construct_tester(@_); | |||||||||
| 282 | $unsorted | ||||||||||
| 283 | ? return _nonintersection_engine(_argument_checker($argref)) | ||||||||||
| 284 | 40 | ▶ | : return [ sort @{_nonintersection_engine(_argument_checker($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 285 | } | ||||||||||
| 286 | |||||||||||
| 287 | 32 | ▶ | sub _nonintersection_engine { | ||||||||
|
Subroutine
_nonintersection_engine: called CC=4 SCAR=13.9
| |||||||||||
| 288 | 32 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 289 | 32 | my $unionref = | |||||||||
| 290 | _calculate_union_only($seenrefsref); | ||||||||||
| 291 | 112 | my @vals = sort { scalar(keys(%{$a})) <=> scalar(keys(%{$b})) } | |||||||||
| 292 | 32 | @{$seenrefsref}; | |||||||||
| 293 | 32 | my %intersection = map { $_ => 1 } keys %{$vals[0]}; | |||||||||
| 294 | 32 | for my $l ( 1..$#vals ) { | |||||||||
| 295 | 288 | %intersection = map { $_ => 1 } | |||||||||
| 296 | 480 | grep { exists $intersection{$_} } | |||||||||
| 297 | 80 | keys %{$vals[$l]}; | |||||||||
| 298 | } | ||||||||||
| 299 | # Calculate nonintersection | ||||||||||
| 300 | # Inputs: @union (keys %$unionref) %intersection | ||||||||||
| 301 | 32 | my (@nonintersection); | |||||||||
| 302 | 32 | for my $k (keys %{$unionref}) { | |||||||||
| 303 | 288 | ▶ | push(@nonintersection, $k) unless exists $intersection{$k}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 304 | } | ||||||||||
| 305 | 32 | return \@nonintersection; | |||||||||
| 306 | } | ||||||||||
| 307 | |||||||||||
| 308 | 44 | ▶ | sub is_LsubsetR { | ||||||||
|
Subroutine
is_LsubsetR: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 309 | 44 | my $argref = _alt_construct_tester_4(@_); | |||||||||
| 310 | 42 | return _is_LsubsetR_engine(_argument_checker_4($argref)); | |||||||||
| 311 | } | ||||||||||
| 312 | |||||||||||
| 313 | 38 | ▶ | sub _is_LsubsetR_engine { | ||||||||
|
Subroutine
_is_LsubsetR_engine: called CC=1 SCAR=0.0
| |||||||||||
| 314 | 38 | my $testedref = pop(@_); | |||||||||
| 315 | 38 | my $xsubsetref = _subset_engine(@_); | |||||||||
| 316 | 38 | return ${$xsubsetref}[${$testedref}[0]][${$testedref}[1]]; | |||||||||
| 317 | } | ||||||||||
| 318 | |||||||||||
| 319 | 22 | ▶ | sub is_RsubsetL { | ||||||||
|
Subroutine
is_RsubsetL: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 320 | 22 | my $argref = _alt_construct_tester_4(@_); | |||||||||
| 321 | 20 | return _is_RsubsetL_engine(_argument_checker_4($argref)); | |||||||||
| 322 | } | ||||||||||
| 323 | |||||||||||
| 324 | 18 | ▶ | sub _is_RsubsetL_engine { | ||||||||
|
Subroutine
_is_RsubsetL_engine: called CC=1 SCAR=0.0
| |||||||||||
| 325 | 18 | my $testedref = pop(@_); | |||||||||
| 326 | 18 | my $xsubsetref = _subset_engine(@_); | |||||||||
| 327 | 18 | return ${$xsubsetref}[${$testedref}[1]][${$testedref}[0]]; | |||||||||
| 328 | } | ||||||||||
| 329 | |||||||||||
| 330 | 56 | ▶ | sub _subset_engine { | ||||||||
|
Subroutine
_subset_engine: called CC=1 SCAR=0.0
| |||||||||||
| 331 | 56 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 332 | 56 | my $xsubsetref = _subset_subengine($seenrefsref); | |||||||||
| 333 | 56 | return $xsubsetref; | |||||||||
| 334 | } | ||||||||||
| 335 | |||||||||||
| 336 | 46 | ▶ | sub is_LequivalentR { | ||||||||
|
Subroutine
is_LequivalentR: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 337 | 46 | my $argref = _alt_construct_tester_4(@_); | |||||||||
| 338 | 42 | return _is_LequivalentR_engine(_argument_checker_4($argref)); | |||||||||
| 339 | } | ||||||||||
| 340 | |||||||||||
| 341 | 51 | ▶ | { no warnings 'once'; *is_LeqvlntR = \&is_LequivalentR; } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 342 | |||||||||||
| 343 | 36 | ▶ | sub _is_LequivalentR_engine { | ||||||||
|
Subroutine
_is_LequivalentR_engine: called CC=1 SCAR=0.0
| |||||||||||
| 344 | 36 | my $testedref = pop(@_); | |||||||||
| 345 | 36 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 346 | 36 | my $xequivalentref = _equivalent_subengine($seenrefsref); | |||||||||
| 347 | 36 | return ${$xequivalentref}[${$testedref}[1]][${$testedref}[0]]; | |||||||||
| 348 | } | ||||||||||
| 349 | |||||||||||
| 350 | 34 | ▶ | sub is_LdisjointR { | ||||||||
|
Subroutine
is_LdisjointR: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 351 | 34 | my $argref = _alt_construct_tester_4(@_); | |||||||||
| 352 | 32 | return _is_LdisjointR_engine(_argument_checker_4($argref)); | |||||||||
| 353 | } | ||||||||||
| 354 | |||||||||||
| 355 | 28 | ▶ | sub _is_LdisjointR_engine { | ||||||||
|
Subroutine
_is_LdisjointR_engine: called CC=3 SCAR=11.0
| |||||||||||
| 356 | 28 | my $testedref = pop(@_); | |||||||||
| 357 | 28 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 358 | 28 | my $disjoint = 1; # start out assuming disjoint status | |||||||||
| 359 | 28 | OUTER: for my $k (keys %{$seenrefsref->[$testedref->[0]]}) { | |||||||||
| 360 | 56 | ▶ | if ($seenrefsref->[$testedref->[1]]->{$k}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 361 | 20 | $disjoint = 0; | |||||||||
| 362 | 20 | last OUTER; | |||||||||
| 363 | } | ||||||||||
| 364 | } | ||||||||||
| 365 | 28 | return $disjoint; | |||||||||
| 366 | } | ||||||||||
| 367 | |||||||||||
| 368 | 11 | ▶ | sub print_subset_chart { | ||||||||
|
Subroutine
print_subset_chart: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 369 | 11 | my $argref = _alt_construct_tester_5(@_); | |||||||||
| 370 | 8 | _print_subset_chart_engine(_argument_checker($argref)); | |||||||||
| 371 | } | ||||||||||
| 372 | |||||||||||
| 373 | 8 | ▶ | sub _print_subset_chart_engine { | ||||||||
|
Subroutine
_print_subset_chart_engine: called CC=1 SCAR=0.0
| |||||||||||
| 374 | 8 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 375 | 8 | my $xsubsetref = _subset_subengine($seenrefsref); | |||||||||
| 376 | 8 | my $title = 'Subset'; | |||||||||
| 377 | 8 | _chart_engine_multiple($xsubsetref, $title); | |||||||||
| 378 | } | ||||||||||
| 379 | |||||||||||
| 380 | 11 | ▶ | sub print_equivalence_chart { | ||||||||
|
Subroutine
print_equivalence_chart: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 381 | 11 | my $argref = _alt_construct_tester_5(@_); | |||||||||
| 382 | 8 | _print_equivalence_chart_engine(_argument_checker($argref)); | |||||||||
| 383 | } | ||||||||||
| 384 | |||||||||||
| 385 | 8 | ▶ | sub _print_equivalence_chart_engine { | ||||||||
|
Subroutine
_print_equivalence_chart_engine: called CC=1 SCAR=0.0
| |||||||||||
| 386 | 8 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 387 | 8 | my $xequivalentref = _equivalent_subengine($seenrefsref); | |||||||||
| 388 | 8 | my $title = 'Equivalence'; | |||||||||
| 389 | 8 | _chart_engine_multiple($xequivalentref, $title); | |||||||||
| 390 | } | ||||||||||
| 391 | |||||||||||
| 392 | 92 | ▶ | sub is_member_which { | ||||||||
|
Subroutine
is_member_which: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 393 | 92 | return @{ is_member_which_ref(@_) }; | |||||||||
| 394 | } | ||||||||||
| 395 | |||||||||||
| 396 | 184 | ▶ | sub is_member_which_ref { | ||||||||
|
Subroutine
is_member_which_ref: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 397 | 184 | my $argref = _alt_construct_tester_1(@_); | |||||||||
| 398 | 178 | return _is_member_which_engine(_argument_checker_1($argref)); | |||||||||
| 399 | } | ||||||||||
| 400 | |||||||||||
| 401 | 176 | ▶ | sub _is_member_which_engine { | ||||||||
|
Subroutine
_is_member_which_engine: called CC=3 SCAR=11.0
| |||||||||||
| 402 | 176 | my $arg = pop(@_); | |||||||||
| 403 | 176 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 404 | 176 | my $seenref = _calculate_seen_only($seenrefsref); | |||||||||
| 405 | 176 | my (@found); | |||||||||
| 406 | 176 | foreach (sort keys %{$seenref}) { | |||||||||
| 407 | 616 | ▶ | push @found, $_ if (exists ${$seenref}{$_}{$arg}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 408 | } | ||||||||||
| 409 | 176 | return \@found; | |||||||||
| 410 | } | ||||||||||
| 411 | |||||||||||
| 412 | 92 | ▶ | sub is_member_any { | ||||||||
|
Subroutine
is_member_any: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 413 | 92 | my $argref = _alt_construct_tester_1(@_); | |||||||||
| 414 | 89 | return _is_member_any_engine(_argument_checker_1($argref)); | |||||||||
| 415 | } | ||||||||||
| 416 | |||||||||||
| 417 | 88 | ▶ | sub _is_member_any_engine { | ||||||||
|
Subroutine
_is_member_any_engine: called CC=3 SCAR=11.0
| |||||||||||
| 418 | 88 | my $tested = pop(@_); | |||||||||
| 419 | 88 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 420 | 88 | my $seenref = _calculate_seen_only($seenrefsref); | |||||||||
| 421 | 88 | my ($k); | |||||||||
| 422 | 88 | ▶ | while ( $k = each %{$seenref} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 423 | 165 | ▶ | return 1 if (defined ${$seenref}{$k}{$tested}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 424 | } | ||||||||||
| 425 | 16 | return 0; | |||||||||
| 426 | } | ||||||||||
| 427 | |||||||||||
| 428 | 13 | ▶ | sub are_members_which { | ||||||||
|
Subroutine
are_members_which: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 429 | 13 | my $argref = _alt_construct_tester_2(@_); | |||||||||
| 430 | 9 | return _are_members_which_engine(_argument_checker_2($argref)); | |||||||||
| 431 | } | ||||||||||
| 432 | |||||||||||
| 433 | 8 | ▶ | sub _are_members_which_engine { | ||||||||
|
Subroutine
_are_members_which_engine: called CC=5 SCAR=16.1
| |||||||||||
| 434 | 8 | my $testedref = pop(@_); | |||||||||
| 435 | 8 | my @tested = @{$testedref}; | |||||||||
| 436 | 8 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 437 | 8 | my $seenref = _calculate_seen_only($seenrefsref); | |||||||||
| 438 | 8 | my (%found); | |||||||||
| 439 | 8 | ▶ | for (my $i=0; $i<=$#tested; $i++) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 440 | 88 | my (@not_found); | |||||||||
| 441 | 88 | foreach (sort keys %{$seenref}) { | |||||||||
| 442 | 308 | exists ${${$seenref}{$_}}{$tested[$i]} | |||||||||
| 443 | 308 | ▶ | ? push @{$found{$tested[$i]}}, $_ | ||||||||
|
Branch: 1 branch
| |||||||||||
| 444 | : push @not_found, $_; | ||||||||||
| 445 | } | ||||||||||
| 446 | 88 | ▶ | $found{$tested[$i]} = [] if (@not_found == keys %{$seenref}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 447 | } | ||||||||||
| 448 | 8 | return \%found; | |||||||||
| 449 | } | ||||||||||
| 450 | |||||||||||
| 451 | 13 | ▶ | sub are_members_any { | ||||||||
|
Subroutine
are_members_any: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 452 | 13 | my $argref = _alt_construct_tester_2(@_); | |||||||||
| 453 | 9 | return _are_members_any_engine(_argument_checker_2($argref)); | |||||||||
| 454 | } | ||||||||||
| 455 | |||||||||||
| 456 | 8 | ▶ | sub _are_members_any_engine { | ||||||||
|
Subroutine
_are_members_any_engine: called CC=6 SCAR=17.9
| |||||||||||
| 457 | 8 | my $testedref = pop(@_); | |||||||||
| 458 | 8 | my @tested = @{$testedref}; | |||||||||
| 459 | 8 | my $seenrefsref = _calc_seen1(@_); | |||||||||
| 460 | 8 | my $seenref = _calculate_seen_only($seenrefsref); | |||||||||
| 461 | 8 | my (%present); | |||||||||
| 462 | 8 | ▶ | for (my $i=0; $i<=$#tested; $i++) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 463 | 88 | foreach (keys %{$seenref}) { | |||||||||
| 464 | 308 | ▶ | unless (defined $present{$tested[$i]}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 465 | 168 | ▶ | $present{$tested[$i]} = 1 if ${$seenref}{$_}{$tested[$i]}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 466 | } | ||||||||||
| 467 | } | ||||||||||
| 468 | 88 | ▶ | $present{$tested[$i]} = 0 if (! defined $present{$tested[$i]}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 469 | } | ||||||||||
| 470 | 8 | return \%present; | |||||||||
| 471 | } | ||||||||||
| 472 | |||||||||||
| 473 | 22 | ▶ | sub get_bag { | ||||||||
|
Subroutine
get_bag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 474 | 22 | return @{ get_bag_ref(@_) }; | |||||||||
| 475 | } | ||||||||||
| 476 | |||||||||||
| 477 | 44 | ▶ | sub get_bag_ref { | ||||||||
|
Subroutine
get_bag_ref: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 478 | 44 | my ($argref, $unsorted) = _alt_construct_tester(@_); | |||||||||
| 479 | $unsorted | ||||||||||
| 480 | ? return _bag_engine(_argument_checker($argref)) | ||||||||||
| 481 | 40 | ▶ | : return [ sort @{_bag_engine(_argument_checker($argref))} ]; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 482 | } | ||||||||||
| 483 | |||||||||||
| 484 | 32 | ▶ | sub _bag_engine { | ||||||||
|
Subroutine
_bag_engine: called CC=7 SCAR=19.5
| |||||||||||
| 485 | 32 | my @listrefs = @_; | |||||||||
| 486 | 32 | my (@bag); | |||||||||
| 487 | 32 | ▶ | if (ref($listrefs[0]) eq 'ARRAY') { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 488 | 16 | foreach my $lref (@listrefs) { | |||||||||
| 489 | 56 | foreach my $el (@{$lref}) { | |||||||||
| 490 | 384 | push(@bag, $el); | |||||||||
| 491 | } | ||||||||||
| 492 | } | ||||||||||
| 493 | } else { | ||||||||||
| 494 | 16 | foreach my $lref (@listrefs) { | |||||||||
| 495 | 56 | foreach my $key (keys %{$lref}) { | |||||||||
| 496 | 328 | ▶ | for (my $j=1; $j <= ${$lref}{$key}; $j++) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 497 | 384 | push(@bag, $key); | |||||||||
| 498 | } | ||||||||||
| 499 | } | ||||||||||
| 500 | } | ||||||||||
| 501 | } | ||||||||||
| 502 | 32 | return \@bag; | |||||||||
| 503 | } | ||||||||||
| 504 | |||||||||||
| 505 | 8 | ▶ | sub get_version { | ||||||||
|
Subroutine
get_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 506 | 8 | return $List::Compare::Functional::VERSION; | |||||||||
| 507 | } | ||||||||||
| 508 | |||||||||||
| 509 | 51 | 1; | |||||||||
| 510 | |||||||||||
| 511 | __END__ | ||||||||||