1Tree::Simple::Visitor::UPsoesrtOCrodnetrrTirbauTvtreeerdes:aP:leS(ri3lm)pDloec:u:mVeinstiattoiro:n:PostOrderTraversal(3)
2
3
4
6 Tree::Simple::Visitor::PostOrderTraversal - A Visitor for post-order
7 traversal a Tree::Simple hierarchy
8
10 use Tree::Simple::Visitor::PostOrderTraversal;
11
12 # create an visitor
13 my $visitor = Tree::Simple::Visitor::PostOrderTraversal->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.2 1 2.1 2 3.1 3
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 Post-order traversal is a variation of the depth-first traversal in
35 which the sub-tree's are processed before the parent. It is another
36 alternative to Tree::Simple's "traverse" method which implements a
37 depth-first, pre-order traversal.
38
40 new There are no arguments to the constructor the object will be in its
41 default state. You can use the "setNodeFilter" method to customize
42 its behavior.
43
44 includeTrunk ($boolean)
45 Based upon the value of $boolean, this will tell the visitor to
46 include the trunk of the tree in the traversal as well.
47
48 setNodeFilter ($filter_function)
49 This method accepts a CODE reference as its $filter_function
50 argument and throws an exception if it is not a code reference.
51 This code reference is used to filter the tree nodes as they are
52 collected. This can be used to customize output, or to gather
53 specific information from a more complex tree node. The filter
54 function should accept a single argument, which is the current
55 Tree::Simple object.
56
57 visit ($tree)
58 This is the method that is used by Tree::Simple's "accept" method.
59 It can also be used on its own, it requires the $tree argument to
60 be a Tree::Simple object (or derived from a Tree::Simple object),
61 and will throw and exception otherwise.
62
63 getResults
64 This method returns the accumulated results of the application of
65 the node filter to the tree.
66
68 <https://github.com/ronsavage/Tree-Simple-VisitorFactory>
69
71 Bugs should be reported via the CPAN bug tracker at
72
73 <https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
74
76 See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
77 information.
78
80 These Visitor classes are all subclasses of Tree::Simple::Visitor,
81 which can be found in the Tree::Simple module, you should refer to that
82 module for more information.
83
85 stevan little, <stevan@iinteractive.com>
86
88 Copyright 2004, 2005 by Infinity Interactive, Inc.
89
90 <http://www.iinteractive.com>
91
92 This library is free software; you can redistribute it and/or modify it
93 under the same terms as Perl itself.
94
95
96
97perl v5.36.0 2T0r2e2e-:0:7S-i2m2ple::Visitor::PostOrderTraversal(3)