Tree::...ndents(3pm)
π NAME π
okay so bestie, this is Tree::Simple::Visitor::GetAllDescendents β a whole Visitor whose entire job is fetching all the descendents of a Tree::Simple object. yes, all of them. the whole family tree. periodt. π³β¨
(this page lives in the Tree::...ndents(3pm) corner of your man pages, iykyk π
)
β¨ SYNOPSIS β¨
use Tree::Simple::Visitor::GetAllDescendents;
# create an instance of our visitor
my $visitor = Tree::Simple::Visitor::GetAllDescendents->new();
# pass the visitor to a Tree::Simple object
$tree->accept($visitor);
# you can also get the descendents
# back as an array of node values
my @descendents = $visitor->getDescendents();
# for more complex node objects, you can specify
# a node filter which will be used to extract the
# information desired from each node
$visitor->setNodeFilter(sub {
my ($t) = @_;
return $t->getNodeValue()->description();
});
look at her go π¦ that's literally the whole vibe right there.
πΈ DESCRIPTION πΈ
so basically: you hand this Visitor a Tree::Simple instance, and it will return all the descendents, recursively, all the way down the hierarchy. no cap, it goes down down. every branch, every leaf, the whole situation. π₯
π METHODS π
newβ there are no arguments to the constructor, so the object just spawns in its default state, fresh-faced and ready. if you wanna customize how it behaves, that's what thesetNodeFiltermethod is for. she's customizable but not demanding. πsetTraversalMethod ($visitor)β by default we useTree::Simple's built-in depth-first (pre-order) traverse method, which is iconic of her honestly. but if you desire the descendents to come back in a different ordering, bestie you can absolutely do that β just hand this method a$visitorobject that implements that traversal type. seeTree::Simple::Visitor::BreadthFirstTraversal,Tree::Simple::Visitor::PreOrderTraversalandTree::Simple::Visitor::PostOrderTraversal. pick your fighter. πsetNodeFilter ($filter_function)β this one accepts aCODEreference as its$filter_functionargument, and it will throw an exception if you hand it something that is not a code reference. (not me handing it a string π) the code reference filters the tree nodes as they're being collected β use it to customize output, or to gather specific info out of a more complex tree node. the filter function should accept a single argument, which is the currentTree::Simpleobject. one arg, that's it, keep it tight. β¨visit ($tree)β this is the methodTree::Simple'sacceptmethod calls, but you can also use it on its own. it requires the$treeargument to be aTree::Simpleobject (or something derived from aTree::Simpleobject) β otherwise it will throw an exception. so like, be normal about it. π«ΆgetAllDescendentsβ this method gives back an array of descendents in depth-first order (pre-order), or in whatever order you specified withsetTraversalMethod. called in scalar context it gives you an array reference; called in list context it returns a regular array. this method is the exact same as callinggetResults. two names, one queen. π
π Repository π
<https://github.com/ronsavage/Tree-Simple-VisitorFactory>
π SUPPORT π
bugs should be reported via the CPAN bug tracker at
<https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
π§ CODE COVERAGE π§
see the CODE COVERAGE section in Tree::Simple::VisitorFactory for more info. the details live over there, go peek. π
β SEE ALSO β
these Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module β refer to that module for more information. it's giving the parent module knows all. π
π AUTHOR π
stevan little, <stevan@iinteractive.com>
π COPYRIGHT AND LICENSE π
Copyright 2004, 2005 by Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie!! π«Ά this one's running on perl v5.36.0 and it was last touched on 2022-11-19 β go forth and fetch those descendents, you absolute main character. πβ¨πΈ
π¦ where this page comes from
- debian bookworm: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtree-simple-visitorfactory-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms