1Tree::Simple::Visitor::UGseetrAlCloDnetsrciebnudtTeerndetesP:(e:3rS)limDpolceu:m:eVnitsaittioorn::GetAllDescendents(3)
2
3
4

NAME

6       Tree::Simple::Visitor::GetAllDescendents - A Visitor for fetching all
7       the descendents of a Tree::Simple object
8

SYNOPSIS

10         use Tree::Simple::Visitor::GetAllDescendents;
11
12         # create an instance of our visitor
13         my $visitor = Tree::Simple::Visitor::GetAllDescendents->new();
14
15         # pass the visitor to a Tree::Simple object
16         $tree->accept($visitor);
17
18         # you can also get the descendents
19         # back as an array of node values
20         my @descendents = $visitor->getDescendents();
21
22         # for more complex node objects, you can specify
23         # a node filter which will be used to extract the
24         # information desired from each node
25         $visitor->setNodeFilter(sub {
26                       my ($t) = @_;
27                       return $t->getNodeValue()->description();
28                       });
29

DESCRIPTION

31       Given a Tree::Simple instance this Visitor will return all the descen‐
32       dents recursively on down the hierarchy.
33

METHODS

35       new There are no arguments to the constructor the object will be in its
36           default state. You can use the "setNodeFilter" method to customize
37           its behavior.
38
39       setTraversalMethod ($visitor)
40           By default we will use Tree::Simple's built in depth-first
41           (pre-order) traverse method. If however, you desire the descendents
42           to be returned in a different ordering, this can be accomplished
43           using a different traversal method, you can supply a $visitor
44           object implementing that traversal type to this method (See
45           Tree::Simple::Visitor::BreadthFirstTraversal, Tree::Simple::Visi‐
46           tor::PreOrderTraversal and Tree::Simple::Visitor::PostOrderTraver‐
47           sal).
48
49       setNodeFilter ($filter_function)
50           This method accepts a CODE reference as its $filter_function argu‐
51           ment and throws an exception if it is not a code reference. This
52           code reference is used to filter the tree nodes as they are col‐
53           lected. This can be used to customize output, or to gather specific
54           information from a more complex tree node. The filter function
55           should accept a single argument, which is the current Tree::Simple
56           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       getAllDescendents
65           This method will give back and array of descendents in depth-first
66           order (pre-order) or in the order specified by the "setTraversal‐
67           Method". If called in scalar context it will give an array refer‐
68           ence, in list context it will return a regular array. This method
69           is the same as calling "getResults".
70

BUGS

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

CODE COVERAGE

76       See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more
77       inforamtion.
78

SEE ALSO

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

AUTHOR

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.8.8                       20T0r5e-e0:7:-S1i3mple::Visitor::GetAllDescendents(3)
Impressum