line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Tree::Binary::Visitor::Base; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
16436
|
use strict; |
|
5
|
|
|
|
|
3
|
|
|
5
|
|
|
|
|
104
|
|
5
|
5
|
|
|
5
|
|
14
|
use warnings; |
|
5
|
|
|
|
|
3
|
|
|
5
|
|
|
|
|
1265
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '1.08'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
### constructor |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
213
|
|
|
213
|
1
|
5481
|
my ($_class) = @_; |
13
|
213
|
|
33
|
|
|
613
|
my $class = ref($_class) || $_class; |
14
|
213
|
|
|
|
|
229
|
my $visitor = {}; |
15
|
213
|
|
|
|
|
238
|
bless($visitor, $class); |
16
|
213
|
|
|
|
|
345
|
$visitor->_init(); |
17
|
213
|
|
|
|
|
360
|
return $visitor; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
### methods |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _init { |
23
|
213
|
|
|
213
|
|
171
|
my ($self) = @_; |
24
|
213
|
|
|
|
|
320
|
$self->{_filter_function} = undef; |
25
|
213
|
|
|
|
|
328
|
$self->{_results} = []; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# node filter methods |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub getNodeFilter { |
31
|
5
|
|
|
5
|
1
|
9
|
my ($self) = @_; |
32
|
5
|
|
|
|
|
14
|
return $self->{_filter_function}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub clearNodeFilter { |
36
|
1
|
|
|
1
|
1
|
358
|
my ($self) = @_; |
37
|
1
|
|
|
|
|
2
|
$self->{_filter_function} = undef; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub setNodeFilter { |
41
|
8
|
|
|
8
|
1
|
3719
|
my ($self, $filter_function) = @_; |
42
|
8
|
100
|
100
|
|
|
63
|
(defined($filter_function) && ref($filter_function) eq "CODE") |
43
|
|
|
|
|
|
|
|| die "Insufficient Arguments : filter function argument must be a subroutine reference"; |
44
|
5
|
|
|
|
|
10
|
$self->{_filter_function} = $filter_function; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# results methods |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub setResults { |
50
|
210
|
|
|
210
|
1
|
690
|
my ($self, @results) = @_; |
51
|
210
|
|
|
|
|
1263
|
$self->{results} = \@results; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub getResults { |
55
|
210
|
|
|
210
|
1
|
1380
|
my ($self) = @_; |
56
|
|
|
|
|
|
|
return wantarray ? |
57
|
206
|
|
|
|
|
1066
|
@{$self->{results}} |
58
|
|
|
|
|
|
|
: |
59
|
210
|
100
|
|
|
|
321
|
$self->{results}; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# abstract method |
64
|
1
|
|
|
1
|
1
|
670
|
sub visit { die "Method Not Implemented" } |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |