Tree::...aversal(3pm)
π NAME π
Tree::Simple::Visitor::PostOrderTraversal β bestie, it's a Visitor for doing a post-order traversal of a Tree::Simple hierarchy. That's the whole vibe. Periodt.
β¨ SYNOPSIS β¨
Okay so here's literally how you use it:
use Tree::Simple::Visitor::PostOrderTraversal;
# create an visitor
my $visitor = Tree::Simple::Visitor::PostOrderTraversal->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.2 1 2.1 2 3.1 3
# assuming your tree is like this:
# 1
# 1.1
# 1.1.1
# 1.2
# 2
# 2.1
# 3
# 3.1
no cap, that output order is the whole point of the post-order thing π¦
πΈ DESCRIPTION πΈ
So post-order traversal is a lil variation of the depth-first traversal where the sub-trees get processed before the parent. It's giving "children first, always." It's another alternative to Tree::Simple's own traverse method β except that one does a depth-first, pre-order traversal instead. iykyk π
π METHODS π
newβ bestie, there are no arguments to this constructor, the object just starts out in its default state. If you wanna customize its behavior you can use thesetNodeFiltermethod. Easy.includeTrunk ($boolean)β depending on the value of$boolean, this tells the visitor to also include the trunk of the tree in the traversal. Yes queen, the actual trunk.setNodeFilter ($filter_function)β this one accepts a CODE reference as its$filter_functionargument and throws an exception if it is not a code reference π (she does not play). This code reference 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. Don't overthink it.visit ($tree)β this is the method thatTree::Simple'sacceptmethod uses. You can also use it on its own! It requires the$treeargument to be aTree::Simpleobject (or something derived from aTree::Simpleobject), and it will throw and exception otherwise. So like, feed her the right thing please πgetResultsβ this method returns the accumulated results of the application of the node filter to the tree. The receipts, basically. π§Ύβ¨
π«Ά Repository π«Ά
https://github.com/ronsavage/Tree-Simple-VisitorFactory
(go look, it's right there)
π SUPPORT π
Bugs should be reported via the CPAN bug tracker at
https://github.com/ronsavage/Tree-Simple-VisitorFactory/issues
bestie if you find a bug, report it, don't just suffer in silence. we support each other here π₯Ί
π CODE COVERAGE π
See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more information. (She's got the tea, go read her.)
π 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 β that's the mothership, the main character, the source. β
π AUTHOR π
stevan little, <stevan@iinteractive.com>
(shoutout stevan, iconic behavior)
π 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. Same terms as Perl, fr fr. No extra drama.
And that's the whole page, bestie π this was Tree::...aversal(3pm) from perl v5.36.0, dated 2022-11-19 β mwah, love that for us, go traverse something pretty πΈπ¦β¨
π¦ 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