line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Number::Extreme; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
95404
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
110
|
|
4
|
3
|
|
|
3
|
|
80
|
use 5.008_001; |
|
3
|
|
|
|
|
27
|
|
|
3
|
|
|
|
|
623
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.29'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use overload |
8
|
0
|
|
|
0
|
|
0
|
'"0+"' => sub { $_[0]{current_value} }, |
9
|
1
|
|
|
1
|
|
98
|
'""' => sub { $_[0]{current_value} }, |
10
|
3
|
|
|
3
|
|
7480
|
fallback => 1; |
|
3
|
|
|
|
|
6021
|
|
|
3
|
|
|
|
|
105
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
2
|
|
|
2
|
0
|
16
|
my ($class, %args) = @_; |
14
|
2
|
|
|
|
|
11
|
bless \%args, __PACKAGE__; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub max { |
18
|
2
|
|
|
2
|
1
|
256
|
my $class = shift; |
19
|
2
|
|
|
|
|
6
|
my $extractor = shift; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return $class->new( |
22
|
198
|
|
|
198
|
|
945
|
cmp => sub { $_[1] > $_[0] }, |
23
|
2
|
|
|
|
|
20
|
extractor => $extractor, |
24
|
|
|
|
|
|
|
current_value => undef, |
25
|
|
|
|
|
|
|
current => undef, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub min { |
30
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
31
|
0
|
|
|
|
|
0
|
my $extractor = shift; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
return $class->new( |
34
|
0
|
|
|
0
|
|
0
|
cmp => sub { $_[1] < $_[0] }, |
35
|
0
|
|
|
|
|
0
|
extractor => $extractor, |
36
|
|
|
|
|
|
|
current_value => undef, |
37
|
|
|
|
|
|
|
current => undef, |
38
|
|
|
|
|
|
|
@_, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub amax { |
43
|
1
|
|
|
1
|
1
|
229
|
my ($class, $array) = @_; |
44
|
1
|
|
|
100
|
|
12
|
$class->max(sub { $array->[$_] }); |
|
100
|
|
|
|
|
154
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub amin { |
48
|
0
|
|
|
0
|
1
|
0
|
my ($class, $array) = @_; |
49
|
0
|
|
|
0
|
|
0
|
$class->min(sub { $array->[$_] }); |
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub test { |
53
|
200
|
|
|
200
|
1
|
635
|
my ($self, $object) = @_; |
54
|
200
|
|
|
|
|
222
|
local $_ = $object; |
55
|
200
|
50
|
|
|
|
607
|
my $value = $self->{extractor} ? $self->{extractor}->() : $_; |
56
|
|
|
|
|
|
|
|
57
|
200
|
100
|
100
|
|
|
870
|
if (!defined $self->{current_value} || |
58
|
|
|
|
|
|
|
$self->{cmp}->($self->{current_value}, $value)) { |
59
|
16
|
|
|
|
|
28
|
$self->{current} = $_; |
60
|
16
|
|
|
|
|
21
|
$self->{current_value} = $value; |
61
|
16
|
|
|
|
|
41
|
return 1; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
2
|
|
|
2
|
0
|
23
|
sub current_value { $_[0]->{current_value} } |
66
|
2
|
|
|
2
|
0
|
19
|
sub current { $_[0]->{current} } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |