Tree::...versal(3pm)
π Tree::Simple::Visitor::PreOrderTraversal π
okay bestie, so this is the manual page for Tree::Simple::Visitor::PreOrderTraversal, which lives in the Tree::...versal(3pm) slot of your perl docs. yes the name got squished, it's giving "my username got truncated in the group chat" energy, we move. π
β¨ NAME β¨
Tree::Simple::Visitor::PreOrderTraversal β it's a Visitor that does a pre-order traversal of a Tree::Simple hierarchy. that's the whole job. she's focused. she's booked. π
πΈ SYNOPSIS πΈ
use Tree::Simple::Visitor::PreOrderTraversal;
# create an visitor
my $visitor = Tree::Simple::Visitor::PreOrderTraversal->new();
# pass our visitor to the tree
$tree->accept($visitor);
# print our results
print join ", " => $visitor->getResults();
# this will print this:
# 1 1.1 1.1.1 1.2 2 2.1 3 3.1
# assuming your tree is like this:
# 1
# 1.1
# 1.1.1
# 1.2
# 2
# 2.1
# 3
# 3.1
look at that little tree grow π¦ lowkey beautiful. (yes, the comment in the original says "create an visitor", we're keeping it exactly, that's a heritage artifact, no cap.)
π DESCRIPTION π
okay so pre-order traversal is a depth-first traversal method where the sub-tree's are processed after the parent. literally the parent goes first, always, main character energy, the kids follow. π
ngl it's essentially just a wrapper around the base Tree::Simple::Visitor class β this module exists separately here purely for completeness. and honestly? iconic reasoning. if you've got a post-order, you should have a pre-order too. periodt. π«Ά
π METHODS π
newβ there are no arguments to the constructor, so the object just vibes in its default state. you can use thesetNodeFiltermethod later to customize its behavior. she's chill like that. πincludeTrunk ($boolean)β based on the value of$boolean, this tells the visitor whether to include the trunk</> of the tree in the traversal as well. yes, the trunk. the whole root situation. sometimes you want the whole thing, sometimes you don't, and that's between you and your$boolean. πsetNodeFilter ($filter_function)β this one takes a CODE reference as its$filter_functionargument, and it will throw an exception if it's not a code reference. like, she will not be playing with you. π€ the code ref gets used to filter the tree nodes as they're collected, so you can customize output, or gather specific info from a more complex tree node. the filter function should accept a single argument, which is the currentTree::Simpleobject. one arg. that's it. she doesn't want more. πvisit ($tree)β this is the method thatTree::Simple'sacceptmethod calls behind the scenes. you can also just use it on its own if you're feeling independent β¨. it requires the$treeargument to be aTree::Simpleobject (or something derived from aTree::Simpleobject), and it will throw and exception otherwise β that's right, an exception, and yes the original page says "and exception", we're not fixing it, we're preserving it, that's the vibe. πgetResultsβ returns the accumulated results of the node filter being applied to the tree. the receipts. the haul. the final answer. π
π₯ Repository π₯
<https://github.com/ronsavage/Tree-Simple-VisitorFactory>
go look. star it. it's free. π
π SUPPORT π
bugs should be reported via the CPAN bug tracker at
<https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues>
found a bug? report it, bestie. don't just suffer in silence, that's not the vibe. π«Ά
β CODE COVERAGE β
see the CODE COVERAGE section in Tree::Simple::VisitorFactory for more information. iykyk. π
π§ SEE ALSO π§
these Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module. you should refer to that module for more information. go read the parent class, she raised them 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 doc came from perl v5.36.0, dated 2022-11-19 β vintage but still serving looks. mwah π go traverse some trees. π³β¨
π¦ 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