NAME

Tree::MultiNode::Node -- a node in a Tree::MultiNode tree.

DESCRIPTION

Please note that the Node object is used internally by the MultiNode object. Though you have the ability to interact with the nodes, it is unlikely that you should need to. That being said, the interface is documented here anyway.

Tree::MultiNode::Node::new

new($)
  @param    package name or node object to clone [scalar]
  @returns  new node object

new($$)
  @param    key   [scalar]
  @param    value [scalar]
  @returns  new node object

Creates a new Node. There are three behaviors for new. A constructor with no arguments creates a new, empty node. A single argument of another node object will create a clone of the node object. If two arguments are passed, the first is stored as the key, and the second is stored as the value.

# clone an existing node
my $node = Tree::MultiNode::Node->new($oldNode);
# or
my $node = $oldNode->new();

# create a new node
my $node = Tree::MultiNode::Node->new;
my $node = Tree::MultiNode::Node->new("fname");
my $node = Tree::MultiNode::Node->new("fname","Larry");

Tree::MultiNode::Node::key

@param     key [scalar]
@returns   the key [scalar]

Used to set, or retrieve the key for a node. If a parameter is passed, it sets the key for the node. The value of the key member is always returned.

print $node3->key(), "\n";    # 'fname'

Tree::MultiNode::Node::value

@param    the value to set [scalar]
@returns  the value [scalar]

Used to set, or retrieve the value for a node. If a parameter is passed, it sets the value for the node (including undef and other falsy values like 0 or ""). The value of the value member is always returned.

print $node3->value(), "\n";   # 'Larry'
$node3->value(0);              # sets value to 0
$node3->value(undef);          # sets value to undef

Tree::MultiNode::Node::clear_key

@returns  the deleted key

Clears the key member by deleting it.

$node3->clear_key();

Tree::MultiNode::Node::clear_value

@returns  the deleted value

Clears the value member by deleting it.

$node3->clear_value();

Tree::MultiNode::Node::children

@returns  reference to children [array reference]

Returns a reference to the array that contains the children of the node object.

$array_ref = $node3->children();

Tree::MultiNode::Node::child_keys Tree::MultiNode::Node::child_values Tree::MultiNode::Node::child_kv_pairs

These functions return arrays consisting of the appropriate data from the child nodes.

my @keys     = $node->child_keys();
my @vals     = $node->child_values();
my %kv_pairs = $node->child_kv_pairs();

Tree::MultiNode::Node::child_key_positions

This function returns a hash table that consists of the child keys as the hash keys, and the position in the child array as the value. This allows for a quick and dirty way of looking up the position of a given key in the child list.

my %h = $node->child_key_positions();

Tree::MultiNode::Node::num_children

Returns the number of children for this node.

my $count = $node->num_children();

Tree::MultiNode::Node::parent

Returns a reference to the parent node of the current node.

$node_parent = $node3->parent();

Tree::MultiNode::Node::dump

Used for diagnostics, it prints out the members of the node.

$node3->dump();