Tree::...aversal(3pm)

πŸ“¦
version 0.16 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 the setNodeFilter method. 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_function argument 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 current Tree::Simple object. One arg. That's it. Don't overthink it.
  • visit ($tree) β€” this is the method that Tree::Simple's accept method uses. You can also use it on its own! It requires the $tree argument to be a Tree::Simple object (or something derived from a Tree::Simple object), 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 2004, 2005 by Infinity Interactive, Inc.

http://www.iinteractive.com

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