line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tree::Binary::Visitor::PreOrderTraversal; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1564
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
76
|
|
4
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
79
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
14
|
use Scalar::Util qw(blessed); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
155
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
821
|
use Tree::Binary::Visitor::Base; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
468
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.09'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Tree::Binary::Visitor::Base); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# visit routine |
15
|
|
|
|
|
|
|
sub visit { |
16
|
86
|
|
|
86
|
1
|
1054
|
my ($self, $tree) = @_; |
17
|
86
|
100
|
100
|
|
|
450
|
(blessed($tree) && $tree->isa("Tree::Binary")) |
18
|
|
|
|
|
|
|
|| die "Insufficient Arguments : You must supply a valid Tree::Binary object"; |
19
|
|
|
|
|
|
|
# get all things set up |
20
|
82
|
|
|
|
|
148
|
my @results; |
21
|
|
|
|
|
|
|
my $func; |
22
|
82
|
100
|
|
|
|
168
|
if ($self->{_filter_function}) { |
23
|
1
|
|
|
7
|
|
4
|
$func = sub { push @results => $self->{_filter_function}->(@_) }; |
|
7
|
|
|
|
|
12
|
|
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
else { |
26
|
81
|
|
|
4011
|
|
296
|
$func = sub { push @results => $_[0]->getNodeValue() }; |
|
4011
|
|
|
|
|
6306
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
# then recursively to all its children |
29
|
|
|
|
|
|
|
# if the object is configured that way |
30
|
82
|
|
|
|
|
271
|
$tree->traverse($func); |
31
|
|
|
|
|
|
|
# now store the results we got |
32
|
82
|
|
|
|
|
243
|
$self->setResults(@results); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
__END__ |