line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Sudoku::Component::Controller::History;
|
2
|
|
|
|
|
|
|
{
|
3
|
4
|
|
|
4
|
|
20364
|
use strict;
|
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
204
|
|
4
|
4
|
|
|
4
|
|
21
|
use warnings;
|
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
134
|
|
5
|
4
|
|
|
4
|
|
109
|
use Carp;
|
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1682
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.01';
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new {
|
10
|
7
|
|
|
7
|
1
|
764
|
my $class = shift;
|
11
|
7
|
|
33
|
|
|
48
|
my $this = bless {}, (ref $class || $class);
|
12
|
|
|
|
|
|
|
|
13
|
7
|
|
|
|
|
28
|
$this->{history} = [];
|
14
|
|
|
|
|
|
|
|
15
|
7
|
|
|
|
|
23
|
$this;
|
16
|
|
|
|
|
|
|
}
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub push {
|
19
|
464
|
|
|
464
|
1
|
1290
|
my ($this, $item) = @_;
|
20
|
464
|
|
|
|
|
588
|
push @{ $this->{history} }, $item;
|
|
464
|
|
|
|
|
1597
|
|
21
|
|
|
|
|
|
|
}
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub pop {
|
24
|
207
|
|
|
207
|
1
|
1539
|
my $this = shift;
|
25
|
207
|
|
|
|
|
211
|
pop @{ $this->{history} };
|
|
207
|
|
|
|
|
626
|
|
26
|
|
|
|
|
|
|
}
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub clear {
|
29
|
6
|
|
|
6
|
1
|
223
|
my $this = shift;
|
30
|
6
|
|
|
|
|
46
|
$this->{history} = [];
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub count {
|
34
|
9
|
|
|
9
|
1
|
1051
|
my $this = shift;
|
35
|
|
|
|
|
|
|
|
36
|
9
|
50
|
|
|
|
26
|
return 0 unless defined $this->{history};
|
37
|
|
|
|
|
|
|
|
38
|
9
|
|
|
|
|
11
|
scalar @{ $this->{history} };
|
|
9
|
|
|
|
|
38
|
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub latest {
|
42
|
7
|
|
|
7
|
1
|
1501
|
my ($this, $count) = @_;
|
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
10
|
my @history = @{ $this->{history} };
|
|
7
|
|
|
|
|
16
|
|
45
|
|
|
|
|
|
|
|
46
|
7
|
100
|
66
|
|
|
24
|
$count = @history if !$count || $count > @history;
|
47
|
|
|
|
|
|
|
|
48
|
7
|
|
|
|
|
36
|
my @latest = reverse @history[-$count..-1];
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1;
|
53
|
|
|
|
|
|
|
__END__
|