Tree::...dByUID(3pm)
β¨ 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 gotsetNodeFilter,setTraversalMethod,includeTrunkandsearchForUIDat 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$visitorobject that implements the traversal type you want. and like, which ones? seeTree::Simple::Visitor::BreadthFirstTraversal,Tree::Simple::Visitor::PreOrderTraversalandTree::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_functionargument, 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'sacceptmethod uses. it can also be used on its own! it requires the$treeargument 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 thesearchForUIDmethod), orundefif 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 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. periodt. π
and that's the whole page bestie!! brought to you byperl v5.36.0, dated2022-11-19, straight from theTree::...dByUID(3pm)zone β go find your node, you got this πβ¨π¦
π¦ 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