1Tree::Simple::Visitor::UPsreerOrCdoenrtTrriabvuetTrersdeaelP:(e:3rS)limDpolceu:m:eVnitsaittioorn::PreOrderTraversal(3)
2
3
4
6 Tree::Simple::Visitor::PreOrderTraversal - A Visitor for pre-order
7 traversal a Tree::Simple hierarchy
8
10 use Tree::Simple::Visitor::PreOrderTraversal;
11
12 # create an visitor
13 my $visitor = Tree::Simple::Visitor::PreOrderTraversal->new();
14
15 # pass our visitor to the tree
16 $tree->accept($visitor);
17
18 # print our results
19 print join ", " => $visitor->getResults();
20
21 # this will print this:
22 # 1 1.1 1.1.1 1.2 2 2.1 3 3.1
23 # assuming your tree is like this:
24 # 1
25 # 1.1
26 # 1.1.1
27 # 1.2
28 # 2
29 # 2.1
30 # 3
31 # 3.1
32
34 Pre-order traversal is a depth-first traversal method in which the sub-
35 tree's are processed after the parent. It is essentially a wrapper
36 around the base Tree::Simple::Visitor class, and is a separate module
37 here for completeness. (If you have a post-order, you should have a
38 pre-order too).
39
41 new There are no arguments to the constructor the object will be in its
42 default state. You can use the "setNodeFilter" method to customize
43 its behavior.
44
45 includeTrunk ($boolean)
46 Based upon the value of $boolean, this will tell the visitor to
47 include the trunk of the tree in the traversal as well.
48
49 setNodeFilter ($filter_function)
50 This method accepts a CODE reference as its $filter_function
51 argument and throws an exception if it is not a code reference.
52 This code reference is used to filter the tree nodes as they are
53 collected. This can be used to customize output, or to gather
54 specific information from a more complex tree node. The filter
55 function should accept a single argument, which is the current
56 Tree::Simple object.
57
58 visit ($tree)
59 This is the method that is used by Tree::Simple's "accept" method.
60 It can also be used on its own, it requires the $tree argument to
61 be a Tree::Simple object (or derived from a Tree::Simple object),
62 and will throw and exception otherwise.
63
64 getResults
65 This method returns the accumulated results of the application of
66 the node filter to the tree.
67
69 <https://github.com/ronsavage/Tree-Simple-VisitorFactory>
70
72 Bugs should be reported via the CPAN bug tracker at
73
74 <https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
75
77 See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
78 information.
79
81 These Visitor classes are all subclasses of Tree::Simple::Visitor,
82 which can be found in the Tree::Simple module, you should refer to that
83 module for more information.
84
86 stevan little, <stevan@iinteractive.com>
87
89 Copyright 2004, 2005 by Infinity Interactive, Inc.
90
91 <http://www.iinteractive.com>
92
93 This library is free software; you can redistribute it and/or modify it
94 under the same terms as Perl itself.
95
96
97
98perl v5.36.0 20T2r3e-e0:1:-S2i0mple::Visitor::PreOrderTraversal(3)