| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package DataStructure::LinkedList::Cell; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
54
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings FATAL => 'all'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
51
|
|
|
6
|
1
|
|
|
1
|
|
848
|
use parent qw/Class::Accessor/; |
|
|
1
|
|
|
|
|
432
|
|
|
|
1
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/next data/); |
|
8
|
1
|
|
|
1
|
|
3423
|
use Scalar::Util qw/blessed looks_like_number/; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
146
|
|
|
9
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
309
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
|
12
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
13
|
0
|
|
|
|
|
|
my $next = undef; |
|
14
|
0
|
|
|
|
|
|
my $data = shift; |
|
15
|
0
|
|
|
|
|
|
bless { next => $next, data => $data }, $class; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub compare_to { |
|
19
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
20
|
0
|
|
|
|
|
|
my $cell = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# some object case |
|
23
|
0
|
0
|
|
|
|
|
if (blessed($self->data)) { |
|
24
|
|
|
|
|
|
|
# you have to implement compare_to method in your obj |
|
25
|
0
|
0
|
|
|
|
|
if (!$cell->can('compare_to')) { |
|
26
|
0
|
|
|
|
|
|
croak "You have to implement compare_to method in your object(" . ref($cell) . ").\n"; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
0
|
0
|
|
|
|
|
return $cell->compare_to($self->data) > 0 ? 1 : 0; |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if (looks_like_number($self->data)) { |
|
32
|
|
|
|
|
|
|
# number case |
|
33
|
0
|
0
|
|
|
|
|
return $self->data > $cell->data ? 1 : 0; |
|
34
|
|
|
|
|
|
|
} else { |
|
35
|
|
|
|
|
|
|
# string case |
|
36
|
0
|
0
|
|
|
|
|
return $self->data gt $cell->data ? 1 : 0; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# other case (havn't implemented) |
|
40
|
0
|
|
|
|
|
|
return 1; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |