NAME
Tree::RB::XS::Node
SYNOPSIS
my $node= $tree->get_node('x');
my $node= $tree->nth(4);
$node->value(7);
$node->value++;
$node->mark_newest if $node->recent_tracked;
$node->prune if $node->tree && $node->key =~ /foo/;
DESCRIPTION
Node objects represent an internal node of the Red/Black tree. Tree nodes exists as lightweight C structs until you access it from Perl, at which time it inflates to become a blessed hashref object. This object does not hold a strong reference to the tree; if the tree goes out of scope, the nodes remain but no longer have a relation to eachother.
Nodes can only be created by a tree, and cannot be re-inserted once pruned.
NAME
Tree::RB::XS::Node
ATTRIBUTES
key
The sort key. Read-only. (but if you supplied a reference and you modify what it points to, you will break the sorting of the tree, so don't do that)
value
The data associated with the node. Read/Write.
index
The integer position of this node within its tree, as if the tree were an array.
prev
The previous node in the sequence of keys. Alias predecessor
for Tree::RB::Node
compat.
next
The next node in the sequence of keys. Alias successor
for Tree::RB::Node
compat.
recent_tracked
Returns whether node has its insertion order tracked, or not. This attribute can also be written. Disabling recent_tracked removes it from the list of insertion order. Enabling recent_tracked causes the node to be placed as the newest inserted node, the same as "mark_newest".
mark_newest
Promote this node to the end of the insertion-order tracking list as if it has just been inserted.
older
$older= $node->older;
$node->older($insert_before);
The previous node in insertion-order. Always undef
unless node is "recent_tracked". When written, it places that node before this node in the "recent" list.
newer
$older= $node->newer;
$node->newer($insert_after);
The next node in insertion-order. Always undef
unless node is "recent_tracked". When written, it places that node after this node in the "recent" list.
tree
The tree this node belongs to. This becomes undef
if the tree is freed or if the node is pruned from the tree.
left
The left sub-tree.
left_leaf
The left-most leaf of the sub-tree. Alias min
for Tree::RB::Node
compat.
right
The right sub-tree.
right_leaf
The right-most child of the sub-tree. Alias max
for Tree::RB::Node
compat.
parent
The parent node, if any.
color
0 = black, 1 = red.
count
The number of items in the tree rooted at this node (inclusive). This becomes 0 if the node is no longer in the tree.
METHODS
prune
Remove this single node from the tree. The node will still have its key and value, but all attributes linking to other nodes will become undef
.
strip
Remove all children of this node, optionally calling a callback for each. For compat with "strip" in Tree::RB::Node.
as_lol
Return sub-tree as list-of-lists. (array of arrays rather?) For compat with "as_lol" in Tree::RB::Node.
iter
Shortcut for $node->tree->iter($node)
.
rev_iter
Shortcut for $node->tree->rev_iter($node)
.
iter_newer
Shortcut for $node->tree->iter_old_to_new($node)
.
iter_older
Shortcut for $node->tree->iter_new_to_old($node)
.
VERSION
version 0.13
AUTHOR
Michael Conrad <mike@nrdvana.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.