Tree::...dByUID(3pm)

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

✨ NAME ✨

okay so bestie, this is Tree::Simple::Visitor::FindByUID β€” it's a Visitor (from the User Contributed Perl Documentation squad, 3pm girlies rise) and its whole job is finding one specific element in a Tree::Simple hierarchy by UID. yes. that's it. that's the gig. πŸ’…


🌸 SYNOPSIS 🌸

use Tree::Simple::Visitor::FindByUID;

# create a visitor object
my $visitor = Tree::Simple::Visitor::FindByUID->new();

# set the search path for our tree
$visitor->searchForUID("MyTreeUID");

# pass the visitor to a tree
$tree->accept($visitor);

# fetch the result, which will
# be the Tree::Simple object that
# we have found, or undefined
my $result = $visitor->getResult() || die "No Tree found";

no cap, that's the whole flow. make it, aim it, hand it to a tree, grab the result. πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

you give it a UID and a Tree::Simple hierarchy, and this Visitor will attempt to find the node with the same UID. that's the mission. it's giving search party but make it object-oriented. ✨


πŸŽ€ METHODS πŸŽ€

  • new β€” so there are literally no arguments to the constructor, and the object just starts off in its default state. if you wanna customize how it behaves, you've got setNodeFilter, setTraversalMethod, includeTrunk and searchForUID at your disposal. pick your fighter. πŸ‘‘
  • includeTrunk ($boolean) β€” based on the value of $boolean, this tells the visitor to include the trunk of the tree in the search too. so like, don't sleep on the trunk, bestie. 🌳
  • setTraversalMethod ($visitor) β€” by default we use Tree::Simple's built-in depth-first (pre-order) traverse method. iconic default, no notes. BUT if you want the tree searched in a different ordering, you can totally do that with a different traversal method β€” just hand this method a $visitor object that implements the traversal type you want. and like, which ones? see Tree::Simple::Visitor::BreadthFirstTraversal, Tree::Simple::Visitor::PreOrderTraversal and Tree::Simple::Visitor::PostOrderTraversal. pick your vibe. πŸ”₯
  • searchForUID ($UID) β€” this is the UID we will attempt to find within the tree. yes, that UID. 🎯
  • setNodeFilter ($filter_function) β€” this method accepts a CODE reference as its $filter_function argument, and it throws an exception if it is not a code reference. (so, actual code refs only, we don't do imposters. πŸ’€) this code reference is used to further check the tree nodes as they are searched, so it's perfect for customizing search behavior. for instance, you could check against the UID as well as some other criteria. the filter function should accept a single argument, which is the current Tree::Simple object, and return either true (1) on success, or false (0) on failure. simple. clean. slay. ✨
  • visit ($tree) β€” this is the method that Tree::Simple's accept method uses. it can also be used on its own! it requires the $tree argument to be a Tree::Simple object (or derived from a Tree::Simple object), and will throw an exception otherwise. so don't try it with anything else, it will not be nice about it. πŸ™ˆ
  • getResult β€” this method returns the tree found with the specified UID (set by the searchForUID method), or undef if no tree is found. bestie found or bestie not found, those are the options. 😭

🌈 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 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 it, it's the mothership. πŸ‘‘


🌸 ACKNOWLEDGEMENTS 🌸

thanks to Vitor Mori for the idea for this Visitor. absolute legend behavior. πŸ’–


✨ AUTHOR ✨

stevan little, <stevan@iinteractive.com>


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. periodt. πŸ’…


and that's the whole page bestie!! brought to you by perl v5.36.0, dated 2022-11-19, straight from the Tree::...dByUID(3pm) zone β€” go find your node, you got this πŸŽ€βœ¨πŸ¦‹
πŸ“¦ where this page comes from