- or download this
sub add_node {
my $self = shift;
...
return if is_duplicate( $node ); # do nothing for dups
# proceed to add node to the set of nodes for this tree
}
- or download this
sub add_node {
my $self = shift;
my $node = shift;
return $self->{ N }{ $node->id } ||= $node;
}
- or download this
$tree->add_node( Node->new( $some_random_object, $id ) );
- or download this
sub { my $node = shift; return "$node" }
- or download this
sub add_node {
my $self = shift;
...
my $id_fxn = $self->id_fxn;
return $id_fxn( $node );
}
- or download this
sub get_id {
my $self = shift;
...
ref $node && $node->can( 'id' ) ? $node->id
: $self->id_fxn->( $node );
}