1Tree::Simple::Visitor::UBsreeradCtohnFtirTrirsbetueTt:re:adSviePmrepsrlalel:(D:3oV)ciusmietnotra:t:iBorneadthFirstTraversal(3)
2
3
4

NAME

6       Tree::Simple::Visitor::BreadthFirstTraversal - A Visitor for
7       breadth-first traversal a Tree::Simple hierarchy
8

SYNOPSIS

10         use Tree::Simple::Visitor::BreadthFirstTraversal;
11
12         # create an visitor
13         my $visitor = Tree::Simple::Visitor::BreadthFirstTraversal->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, 2, 3, 1.1, 1.2, 2.1, 3.1, 1.1.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

DESCRIPTION

34       This implements a breadth-first traversal of a Tree::Simple hierarchy.
35       This can be an alternative to the built in depth-first traversal of the
36       Tree::Simple "traverse" method.
37

METHODS

39       new There are no arguments to the constructor the object will be in its
40           default state. You can use the  "setNodeFilter" method to customize
41           its behavior.
42
43       includeTrunk ($boolean)
44           Based upon the value of $boolean, this will tell the visitor to
45           include the trunk of the tree in the traversal as well.
46
47       setNodeFilter ($filter_function)
48           This method accepts a CODE reference as its $filter_function argu‐
49           ment and throws an exception if it is not a code reference. This
50           code reference is used to filter the tree nodes as they are col‐
51           lected. This can be used to customize output, or to gather specific
52           information from a more complex tree node. The filter function
53           should accept a single argument, which is the current Tree::Simple
54           object.
55
56       visit ($tree)
57           This is the method that is used by Tree::Simple's "accept" method.
58           It can also be used on its own, it requires the $tree argument to
59           be a Tree::Simple object (or derived from a Tree::Simple object),
60           and will throw and exception otherwise.
61
62       getResults
63           This method returns the accumulated results of the application of
64           the node filter to the tree.
65

BUGS

67       None that I am aware of. Of course, if you find a bug, let me know, and
68       I will be sure to fix it.
69

CODE COVERAGE

71       See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
72       inforamtion.
73

SEE ALSO

75       These Visitor classes are all subclasses of Tree::Simple::Visitor,
76       which can be found in the Tree::Simple module, you should refer to that
77       module for more information.
78

AUTHOR

80       stevan little, <stevan@iinteractive.com>
81
83       Copyright 2004, 2005 by Infinity Interactive, Inc.
84
85       <http://www.iinteractive.com>
86
87       This library is free software; you can redistribute it and/or modify it
88       under the same terms as Perl itself.
89
90
91
92perl v5.8.8                    Tre2e0:0:5S-i0m7p-l1e3::Visitor::BreadthFirstTraversal(3)
Impressum