Tree::Simple(3pm)

πŸ“¦
version 1.34 Β· 6 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸŽ€ Tree::Simple(3pm) πŸŽ€

okay bestie, sit down, hydrate, and get comfy πŸ’– this is the manual page for Tree::Simple, and it lives in the User Contributed Perl Documentation corner of your system's man pages (so, like, Tree::Simple(3pm) β€” that's the whole citation, you've got it). it's a tree module. it's a vibe. we're doing all four parts together and part 1 starts right now 🌸


✨ NAME ✨

Tree::Simple β€” a simple tree object. that's the name, short and iconic, no notes πŸ‘‘


✨ SYNOPSIS ✨

here's the whole thing in action, bestie, just read it like a little poem πŸ¦‹

use Tree::Simple;

# make a tree root
my $tree = Tree::Simple->new("0", Tree::Simple->ROOT);

# explicitly add a child to it
$tree->addChild(Tree::Simple->new("1"));

# specify the parent when creating
# an instance and it adds the child implicitly
my $sub_tree = Tree::Simple->new("2", $tree);

# chain method calls
$tree->getChild(0)->addChild(Tree::Simple->new("1.1"));

# add more than one child at a time
$sub_tree->addChildren(
          Tree::Simple->new("2.1"),
          Tree::Simple->new("2.2")
          );

# add siblings
$sub_tree->addSibling(Tree::Simple->new("3"));

# insert children a specified index
$sub_tree->insertChild(1, Tree::Simple->new("2.1a"));

# clean up circular references
$tree->DESTROY();

and alternately</p>, so you don't have to keep typing Tree::Simple->new(...) just to add a node:

use Tree::Simple;
use Data::TreeDumper; # Provides DumpTree().

# ---------------

my($root) = Tree::Simple->new('Root', Tree::Simple->ROOT);

$root->generateChild('Child 1.0');
$root->generateChild('Child 2.0');
$root->getChild(0)->generateChild('Grandchild 1.1');

print DumpTree($root);

$root->DESTROY;

✨ DESCRIPTION ✨

so what is this? 🧚 it's a fully object-oriented implementation of a simple n-ary tree. it's built on the whole parent-child relationship concept, which means every single Tree::Simple object has both a parent and a set of children β€” and yes, those children can have their own children, forever, it's giving generational wealth πŸ˜­πŸ’… every Tree::Simple object also has siblings, because siblings are literally just the children of their immediate parent. no extra machinery. slay.

it can model hierarchal information like:

  • a file-system πŸ—‚οΈ
  • the organizational structure of a company 🏒
  • an object inheritance hierarchy 🧬
  • versioned files from a version control system πŸ“š
  • or even an abstract syntax tree for use in a parser 🌳

it makes zero assumptions about what you're going to do with it, bestie. it just hands you the structure and the ways to access and traverse said structure, and lets you be the main character.

this module uses exceptions and a minimal Design By Contract style. all method arguments are required unless it says otherwise in the docs, and if a required argument isn't defined, an exception will usually be thrown. a lot of arguments also have to be a specific type β€” for example, the $parent argument to the constructor must be a Tree::Simple object or an object derived from Tree::Simple, otherwise... exception, thrown, bye 🚨 this may seem harsh to some, but it means the author gets to have confidence that the code works exactly as intended, and you get to enjoy that same confidence when you use it 🫢

⚠️ important note tho: this module does not use any Exception or Error module. the exceptions are literally just strings thrown with die. no cap.

the author considers this module to be production stable πŸ‘‘ it's based on a module that's been in use on a few production systems for approx. 2 years now with no issue. the only difference is that the code has been cleaned up a bit, comments were added, and thorough tests were written for its public release. the author is confident it behaves as expected and is (as far as they know) bug-free. they have not stress-tested it under extreme duress, but they don't much intend for it to be used in that kind of situation either. and if this module can't keep up with your Tree needs? the author suggests switching to one of the modules listed in the "OTHER TREE MODULES" section below 🌈


✨ CONSTANTS ✨

🧱 ROOT

this class constant is the placeholder for the root of our tree, bestie. if a tree doesn't have a parent, then it's considered a root. that's the whole thing. it's the origin story. it's the opening scene 🌱


✨ METHODS ✨

🌟 Constructor

🍼 new ($node, $parent)

the constructor takes two arguments: a $node value and an optional $parent πŸ’–

  • the $node value can be any scalar value β€” and yes that absolutely includes references and objects. go wild.
  • the optional $parent value must be a Tree::Simple object, or an object derived from Tree::Simple. setting this value implies your new tree is a child of the parent tree, so it gets added to that parent's children. sneaky! convenient! iconic!
  • if $parent isn't specified, its value defaults to ROOT 🌿

πŸ’… Mutator Methods

setNodeValue ($node_value)

sets the node value to the scalar $node_value. if $node_value is not defined, an exception is thrown 🚨 no undefineds in this house.

setUID ($uid)

this lets you set your own unique ID for this specific Tree::Simple object ✨ a default value derived from the hex address of the object is provided for you automatically, so using this method is entirely optional. it is the user's responsibility to make sure the value is actually unique β€” all this method tests is that $uid is a true value (meaning it evaluates to true in a boolean context). for even more info about the Tree::Simple UID, go look at the getUID method πŸ’œ

addChild ($tree)

this method accepts only Tree::Simple objects or objects derived from Tree::Simple β€” otherwise, exception, thrown πŸ’€ it appends the given $tree to the end of the children list and sets up the correct parent-child relationships. and it's built to return its invocant so you can chain method calls together, like:

my $tree = Tree::Simple->new("root")->addChild(Tree::Simple->new("child one"));

or, if you're feeling extra ✨:

my $tree = Tree::Simple->new("root")->addChild(
                         Tree::Simple->new("1.0")->addChild(
                                     Tree::Simple->new("1.0.1")
                                     )
                         );

generateChild ($scalar)

this takes a scalar and calls addChild(Tree::Simple->new($scalar) ) β€” purely so you don't have to type Tree::Simple->new(...) as the parameter yourself. it's a little shortcut. a little treat πŸ“

addChildren (@trees)

this one takes an array of Tree::Simple objects and adds them all to the children list. and like addChild, it returns its invocant so the chaining can continue, bestie πŸ”—

insertChild ($index, $tree)

takes a numeric $index and a Tree::Simple object ($tree), and inserts the $tree into the children list at that specified $index. this shifts down all the children after the $index, so make room πŸ’… the $index gets bounds-checked against the child list β€” if it's out of bounds, an exception is thrown. the $tree argument is verified to be a Tree::Simple or Tree::Simple-derived object, and if that condition fails, exception, thrown 🚨

insertChildren ($index, @trees)

does pretty much exactly what insertChild does, except instead of inserting a single Tree::Simple, it inserts an array of Tree::Simple objects 🌈 it also bounds-checks the $index and type-checks everything in @trees, just like insertChild does. same energy, more nodes.

πŸšͺ removeChild ($child | $index)

accepts two different kinds of arguments, choose your fighter:

  • given a Tree::Simple object ($child) β€” it finds that specific $child by comparing it with all the other children until it finds a match, then the $child is removed. if no match is found, an exception is thrown. if a non-Tree::Simple object is given as the $child argument, an exception is thrown too 😭
  • given a numeric $index β€” it removes the child found at that index within the list of children. the $index is bounds-checked, and if that condition fails, an exception is thrown.

when a child gets removed, all the children after it shift up, and the removed child is returned to you. the removed child is properly disconnected from the tree and all its references to its old parent are removed.

⚠️ but bestie, in order to properly clean up any circular references the removed child might have, it is advised to call the DESTROY method. see the "CIRCULAR REFERENCES" section for more information πŸ’€

πŸ‘― addSibling ($tree)

πŸ‘― addSiblings (@trees)

πŸ‘― insertSibling ($index, $tree)

πŸ‘― insertSiblings ($index, @trees)

these four β€” addSibling, addSiblings, insertSibling and insertSiblings β€” pass their arguments along to the addChild, addChildren, insertChild and insertChildren methods of their parent object, respectively 🫢 this means subclasses don't have to overload these methods even if they have specialized versions of the *Child(ren) methods. the one exception: if you try to add or insert siblings onto the ROOT of the tree, an exception is thrown 🚫🌱

πŸ“Œ NOTE: there is no removeSibling method, because the author felt it was probably a bad idea. the same effect can be achieved by manual upwards traversal. do with that information what you will πŸ™ˆ

πŸ’– Accessor Methods

getNodeValue

returns the value stored in the node field of the object. simple. clean. exactly what it says πŸ’…

getUID

returns the unique ID associated with this particular tree πŸ†” this can be custom-set using the setUID method, or you can just use the default. the default is the hex-address extracted from the stringified Tree::Simple object. that may not be a universally unique identifier, but it should be adequate for at least the current instance of your perl interpreter. if you need a real UUID, one can be generated with an outside module (there are many to choose from on CPAN) plus the setUID method (see above) ✨

getChild ($index)

returns the child (a Tree::Simple object) found at the specified $index. note that we do use standard zero-based array indexing, so act accordingly 😌

getAllChildren

returns an array of all the children (all Tree::Simple objects). in scalar context, it hands you back an array reference instead πŸ‘‘

getSibling ($index)

getAllSiblings

much like addSibling and addSiblings, these two simply call getChild and getAllChildren on the parent of the invocant 🧬

see also getSiblingCount.

⚠️ warning: this method includes the invocant, so it is not really all siblings but rather all children of the parent! 😭

getSiblingCount

returns 0 if the invocant is the root node. otherwise it returns the count of siblings, which excludes the invocant πŸ‘€

see also getAllSiblings.

⚠️ warning: this differs from scalar(parent->getAllSiblings() ) just above, which for some reason includes the invocant. the author cannot change getAllSiblings() now, for a module first released in 2004 😭 respect the timeline.

getDepth

returns a number representing the depth of the invocant within the hierarchy of Tree::Simple objects 🌊

NOTE: a "ROOT" tree has a depth of -1. Why? Because Tree::Simple assumes a root node usually isn't carrying data, it's just an anchor for the branches that do. It's not the most intuitive thing in every single case, so bestie I'm telling you here πŸ’…

  • getParent β€” hands you the parent of the invocant, which could be either ROOT or a Tree::Simple object. Either way, that's your parent, periodt.
  • getHeight β€” returns a number, and that number is the length of the longest path from the current tree all the way down to the furthest leaf node. πŸŒ±βž‘οΈπŸƒ
  • getWidth β€” returns a number for the breadth of the current tree, which basically means it counts up all the leaf nodes. It's giving census energy πŸ¦‹
  • getChildCount β€” the number of children the invocant contains. How many little ones does this node have.
  • getIndex β€” returns the index of this tree inside its sibling list. And if the tree is the root? It returns -1. (root really said "I have no siblings, I am the sibling")

🌸 Predicate Methods 🌸

  • isLeaf β€” returns true (1) if the invocant has no children at all, false (0) otherwise. No kids = leaf = iconic lonely leaf behaviour πŸ“
  • isRoot β€” returns true (1) if the invocant has a "parent" of ROOT, false (0) otherwise.
  • isFistChild β€” yes that's spelled exactly like that, keep it, don't fix it, I said what I said πŸ™ˆ

Returns 0 if the invocant is the root node.

Returns 1 if the invocant is the first child in the parental list of children. Otherwise returns 0.

  • isLastChild β€” returns 0 if the invocant is the root node.

Returns 1 if the invocant is the last child in the parental list of children. Otherwise returns 0.

πŸ” Recursive Methods πŸ”

  • traverse ($func, ?$postfunc) β€” this one takes two things: a mandatory $func and an optional $postfunc. If $func isn't defined, it throws an exception no cap, it will yell at you. And if $func or $postfunc aren't actually CODE references? Also an exception. πŸ’€

Once that's sorted, $func gets applied recursively to all the children of the invocant β€” or until $func returns 'ABORT'. If $postfunc is given, it runs on each child after that child's own children have already been traversed. So it's the post-game show, not the pre-game ✨

Here's a traversal function that prints the hierarchy out as a tabbed-in list:

$tree->traverse(sub {
    my ($_tree) = @_;
    my $tag = $_tree->getNodeValue();
    print (("\t" x $_tree->getDepth()), $tag, "\n");
    return 'ABORT' if 'foo' eq $tag;
});

And here's one that prints the hierarchy in an XML-style format:

$tree->traverse(sub {
    my ($_tree) = @_;
    print ((' ' x $_tree->getDepth()),
            '<', $_tree->getNodeValue(),'>',"\n");
},
sub {
    my ($_tree) = @_;
    print ((' ' x $_tree->getDepth()),
            '</', $_tree->getNodeValue(),'>',"\n");
});
Lowkey important: aborting a traverse is not recommended when you're using $postfunc. Why? Because the post-function won't get called for any nodes after the abort, which can leave you with results that are less than predictable. It's giving chaos, and not the cute kind. 😭
  • size β€” returns the total number of nodes in the current tree and all its sub-trees. Everybody gets counted πŸ’–
  • height β€” this one has also been deprecated in favor of the "getHeight" method above. It still hangs around as an alias to "getHeight" purely for backwards compatibility. Living legend, but retired.
NOTE: this is also no longer a recursive method that computes its value on demand β€” it's now a value stored in the Tree::Simple object itself. Which hopefully makes it much more efficient and usable. Slay πŸ’…

🫢 Visitor Methods 🫢

  • accept ($visitor) β€” accepts either a Tree::Simple::Visitor object (and yes, that includes any classes derived from Tree::Simple::Visitor), or an object that has the "visit" method available. That gets tested with "$visitor->can('visit')". If those qualifications aren't met, an exception gets thrown immediately. Once it's all good, we run the Visitor's "visit" method and hand it the current tree as its argument. πŸŽ€

Also I've created a whole bunch of Visitor objects and packaged them up into the Tree::Simple::VisitorFactory. Go look, they're cute and useful.

🧚 Cloning Methods 🧚

Ok so cloning a tree can be an extremely expensive operation for large trees, lowkey brutal on your resources. That's why we give you two flavours: a deep clone and a shallow clone. Pick your fighter πŸ’œ

When a Tree::Simple object gets cloned, the node is deep-copied like this:

  • If we find a normal scalar value (non-reference), we simply copy it.
  • If we find an object, we attempt to call "clone" on it β€” otherwise we just copy the reference, since we assume that object does not want to be cloned.
  • If we find a SCALAR, REF reference, we copy the value contained within it.
  • If we find a HASH or ARRAY reference, we copy the reference and recursively copy all the elements inside it, following these exact guidelines.

We also do our best to make sure circular references get cloned only once, with their connections restored correctly. Obsessed with that, honestly.

But heads up: this cloning will not be able to copy CODE, RegExp and GLOB references, because those are pretty much impossible to clone. We also do not handle "tied" objects β€” they'll just get copied as plain references, and won't be re-"tied". 🫠
  • clone β€” does a full deep-copy clone of the object, calling "clone" recursively on all its children. It does not call "clone" on the parent tree, though. Doing that would result in a slowly degenerating spiral of recursive death πŸ’€πŸ’€πŸ’€, so it's not recommended and therefore not implemented. What actually happens: the tree instance that clone was called on gets detached from the tree and becomes a root node, and then all the cloned children get attached as children of that tree. I personally think this is more intuitive than having the cloning crawl back up the tree β€” which, ngl, is not what I think most people would expect. πŸ‘‘
  • cloneShallow β€” an alternate option to the plain "clone" method. This one lets you clone a single Tree::Simple object while retaining connections to the rest of the tree/hierarchy. Keep the friendships intact 🫢

πŸŽ€ Misc. Methods πŸŽ€

  • DESTROY β€” to avoid memory leaks through uncleaned-up circular references, we implement the "DESTROY" method. It will attempt to call "DESTROY" on each of its children (if it has any), which results in a cascade of "DESTROY" calls all the way down the tree. It also cleans up its parental relations too. 🌈

Because of perl's reference counting scheme and how that interacts with circular references, if you want an object to be properly reaped you should manually call "DESTROY". This is especially necessary if your object has any children. See the section on "CIRCULAR REFERENCES" for more info. Don't skip this one, bestie.

  • fixDepth β€” Tree::Simple will manage the depth field for you using this method. You should never need to call it on your own β€” but if you ever did need to, here it is. Running it will traverse all the sub-trees of the invocant, correcting the depth as it goes. ✨
  • fixHeight β€” Tree::Simple will manage the height field for you using this method. Again: you should never need to call it on your own, but here it is if you do. Running it corrects the heights of the current tree and all ancestors' heights too.
  • fixWidth β€” Tree::Simple will manage the width field for you using this method. You should never need to call it on your own, but here it is. Running it corrects the widths of the current tree and all ancestors' widths too. πŸ’…

πŸ‘‘ Private Methods πŸ‘‘

I would not normally document private methods, but in case you need to subclass Tree::Simple, here they are. Backstage pass, don't abuse it. πŸ™ˆ

  • _init ($node, $parent, $children) β€” this one's here largely to facilitate subclassing. It gets called by new to initialize the object, while new keeps the primary responsibility of creating the instance.
  • _setParent ($parent) β€” sets up the parental relationship. Internal use only, fr fr.
  • _setHeight ($child) β€” sets the height field based upon the height of the given $child.

πŸ’« CIRCULAR REFERENCES πŸ’«

okay so bestie, big glow-up moment: the whole model for how Tree::Simple deals with circular references got a revision. In the past, every single circular reference had to be manually destroyed by calling DESTROY. That DESTROY call would then call DESTROY on all the children, cascading down the tree. But that wasn't always what was needed, nor what made sense, so the model got revised to handle things in what I feel is a more consistent and sane way.

Circular refs are now managed with the simple idea that the parent makes the decisions for the child. That means child-to-parent references are weak, while parent-to-child references are strong. So if a parent is destroyed, it will force all the children to detach from it. But if a child is destroyed, it will not be detached from the parent. periodt πŸ’…

✨ Optional Weak References ✨

By default, you are still required to call DESTROY in order for things to happen. But now there's an option to use weak references, which removes the need for the manual DESTROY call and lets Tree::Simple manage this automatically. This is done with a compile time setting like this:

use Tree::Simple 'use_weak_refs';

And from that point on, Tree::Simple will use weak references to allow for reference counting to clean things up properly. slay ✨

For those who are unfamiliar with weak references and how they affect reference counts, here is a simple illustration. First is the normal model that Tree::Simple uses:

        +---------------+
        | Tree::Simple1 |<---------------------+
        +---------------+                      |
        | parent        |                      |
        | children      |-+                    |
        +---------------+ |                    |
                          |                    |
                          |  +---------------+ |
                          +->| Tree::Simple2 | |
                             +---------------+ |
                             | parent        |-+
                             | children      |
                             +---------------+

Here, Tree::Simple1 has a reference count of 2 (one for the original variable it is assigned to, and one for the parent reference in Tree::Simple2), and Tree::Simple2 has a reference count of 1 (for the child reference in Tree::Simple1).

Now, with weak references:

        +---------------+
        | Tree::Simple1 |.......................
        +---------------+                      :
        | parent        |                      :
        | children      |-+                    : <--[ weak reference ]
        +---------------+ |                    :
                          |                    :
                          |  +---------------+ :
                          +->| Tree::Simple2 | :
                             +---------------+ :
                             | parent        |..
                             | children      |
                             +---------------+

Now Tree::Simple1 has a reference count of 1 (for the variable it is assigned to) and 1 weakened reference (for the parent reference in Tree::Simple2). And Tree::Simple2 has a reference count of 1, just as before. no cap 🌱

πŸ› BUGS πŸ›

None that I am aware of. The code is pretty thoroughly tested (see "CODE COVERAGE" below) and is based on a (non-publicly released) module which I had used in production systems for about 3 years without incident. Of course, if you find a bug, let me know, and I will be sure to fix it. fr fr πŸ™ˆ

πŸ“Š CODE COVERAGE πŸ“Š

I use Devel::Cover to test the code coverage of my tests. Below is the Devel::Cover report on the test suite.

        ---------------------------- ------ ------ ------ ------ ------ ------ ------
        File                           stmt branch   cond    sub    pod   time  total
        ---------------------------- ------ ------ ------ ------ ------ ------ ------
        Tree/Simple.pm                 99.6   96.0   92.3  100.0   97.0   95.5   98.0
        Tree/Simple/Visitor.pm        100.0   96.2   88.2  100.0  100.0    4.5   97.7
        ---------------------------- ------ ------ ------ ------ ------ ------ ------
        Total                          99.7   96.1   91.1  100.0   97.6  100.0   97.9
        ---------------------------- ------ ------ ------ ------ ------ ------ ------

the numbers are giving obsessed πŸ’œ

πŸ‘€ SEE ALSO πŸ‘€

I have written a number of other modules which use or augment this module. They are described below and available on CPAN.

  • Tree::Parser β€” A module for parsing formatted files into Tree::Simple hierarchies
  • Tree::Simple::View β€” For viewing Tree::Simple hierarchies in various output formats
  • Tree::Simple::VisitorFactory β€” Useful Visitor objects for Tree::Simple objects
  • Tree::Binary β€” If you are looking for a binary tree, check this one out

Also, the author of Data::TreeDumper and I have worked together to make sure that Tree::Simple and his module work well together. If you need a quick and handy way to dump out a Tree::Simple hierarchy, this module does an excellent job (and plenty more as well).

I have also recently stumbled upon some packaged distributions of Tree::Simple for the various Unix flavors. Here are some links:

🌳 OTHER TREE MODULES 🌳

There are a few other Tree modules out there. Here is a quick comparison between Tree::Simple and them. Obviously I am biased, so take what I say with a grain of salt, and keep in mind, I wrote Tree::Simple because I could not find a Tree module that suited my needs. If Tree::Simple does not fit your needs, I recommend looking at these modules. Please note that I am only listing Tree::* modules I am familiar with here. If you think I have missed a module, please let me know. I have also seen a few tree-ish modules outside of the Tree::* namespace, but most of them are part of another distribution (HTML::Tree, Pod::Tree, etc) and are likely specialized in purpose.

🌲 Tree::DAG_Node

This module seems pretty stable and very robust with a lot of functionality. But it only comes with 1 sophisticated test, t/cut.and.paste.subtrees.t. While I am sure the author tested his code, I would feel better if I was able to see that. The module is approx. 3000 lines with POD, and 1,500 without the POD. The shear depth and detail of the documentation and the ratio of code to documentation is impressive, and not to be taken lightly. But given that it is a well known fact that the likeliness of bugs increases along side the size of the code, I do not feel comfortable with large modules like this which have no tests.

All this said, I am not a huge fan of the API either. I prefer the gender neutral approach in Tree::Simple to the mother/daughter style of Tree::DAG_Node. I also feel very strongly that Tree::DAG_Node is trying to do much more than makes sense in a single module, and is offering too many ways to do the same or similar things.

However, of all the Tree::* modules out there, Tree::DAG_Node seems to be one of the favorites, so it may be worth investigating.

🌲 Tree::MultiNode

I am not very familiar with this module, however, I have heard some good reviews of it, so I thought it deserved mention here. I believe it is based upon C++ code found in the book Algorithms in C++ by Robert Sedgwick. It uses a number of interesting ideas, such as a ::Handle object to traverse the tree with (similar to Visitors, but also seem to be to be kind of like a cursor). However, like Tree::DAG_Node, it is somewhat lacking in tests and has only 6 tests in its suite. It also has one glaring bug, which is that there is currently no way to remove a child node.

🌲 Tree::Nary

It is a (somewhat) direct translation of the N-ary tree from the GLIB library, and the API is based on that. GLIB is a C library, which means this is a very C-ish API. That does not appeal to me, it might to you, to each their own.

This module is similar in intent to Tree::Simple. It implements a tree with n branches and has polymorphic node containers. It implements much of the same methods as Tree::Simple and a few others on top of that, but being based on a C library, is not very OO. In most of the method calls the $self argument is not used and the second argument $node is. Tree::Simple is a much more OO module than Tree::Nary, so while they are similar in functionality they greatly differ in implementation style.

🌲 Tree

This module is pretty old, it has not been updated since Oct. 31, 1999 and is still on version 0.01. It also seems to be (from the limited documentation) a binary and a balanced binary tree. Tree::Simple is an n-ary tree, and makes no attempt to balance anything.

🌲 Tree::Ternary

This module is older than Tree, last update was Sept. 24th, 1999. It seems to be a special purpose tree, for storing and accessing strings, not general purpose like Tree::Simple.

🌲 Tree::Ternary_XS

This module is an XS implementation of the above tree type.

🌲 Tree::Trie

This too is a specialized tree type. It sounds similar to the Tree::Ternary, but it much newer (latest release in 2003). It seems specialized for the lookup and retrieval of information like a hash.

🌲 Tree::M

Is a wrapper for a C++ library, whereas Tree::Simple is pure-perl. It also seems to be a more specialized implementation of a tree, therefore not really the same as Tree::Simple.

🌲 Tree::Fat

Is a wrapper around a C library, again Tree::Simple is pure-perl. The author describes FAT-trees as a combination of a Tree and an array. It looks like a pretty mean and lean module, and good if you need speed and are implementing a custom data-store of some kind. The author points out too that the module is designed for embedding and there is not default embedding, so you cannot really use it "out of the box".

πŸ’– ACKNOWLEDGEMENTS πŸ’–

Thanks to Nadim Ibn Hamouda El Khemir for making Data::TreeDumper work with Tree::Simple.

Thanks to Brett Nuske for his idea for the getUID and setUID methods.

Thanks to whomever submitted the memory leak bug to RT (#7512).

Thanks to Mark Thomas for his insight into how to best handle the height and width properties without unnecessary recursion.

Thanks for Mark Lawrence for the &traverse post-func patch, tests and docs.

πŸ“¦ REPOSITORY πŸ“¦

https://github.com/ronsavage/Tree-Simple

πŸ†˜ SUPPORT πŸ†˜

Bugs should be reported via the CPAN bug tracker at

https://github.com/ronsavage/Tree-Simple/issues

πŸ‘‘ AUTHOR πŸ‘‘

Stevan Little, stevan@iinteractive.com

Rob Kinyon, rob@iinteractive.com

Ron Savage ron@savage.net.au has taken over maintenance as of V 1.19.

Okay bestie, legal era, but make it cute. Here's who owns this:

And the license? The good stuff. Listen:

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸŽ€

No cap β€” that's the whole vibe. Same terms as Perl itself, that's the deal, that's the energy, that's giving open source royalty. πŸ‘‘


And that's a wrap on the whole page, bestie!! 🌸 This one shipped as perl v5.36.0, dated 2022-10-13 β€” so if your perldoc is serving you this exact tea, you're reading the real one. Go build some trees, you absolute icon. πŸ’…πŸŒ³πŸ’œ

πŸ“¦ where this page comes from