NAME
Role::TinyCommons::Tree::NodeMethods - Role that provides tree node methods
VERSION
This document describes version 0.120 of Role::TinyCommons::Tree::NodeMethods (from Perl distribution Role-TinyCommons-Tree), released on 2020-02-06.
DESCRIPTION
REQUIRED ROLES
PROVIDED METHODS
descendants => list
Return children and their children, recursively. See also: ancestors
.
ancestors => list
Return parent and parent's parent, recursively. See also: descendants
.
walk($code)
first_node($code) => obj|undef
is_first_child => bool
Return true if node is the first child of its parent.
is_last_child => bool
Return true if node is the last child of its parent.
is_only_child => bool
Return true if node is the only child of its parent.
is_nth_child($n) => bool
Return true if node is the nth child of its parent (starts from 1 not 0, so is_first_child
is equivalent to is_nth_child(1)
).
is_nth_last_child($n) => bool
Return true if node is the nth last child of its parent.
is_first_child_of_type => bool
Return true if node is the first child (of its type) of its parent. For example, if the parent's children are ():
node1(T1) node2(T2) node3(T1) node4(T2)
Both node1
and node2
are first children of their respective type.
is_last_child_of_type => bool
is_only_child_of_type => bool
is_nth_child_of_type($n) => bool
is_nth_last_child_of_type($n) => bool
prev_sibling => obj
prev_siblings => list
next_sibling => obj
next_siblings => list
remove
Remove node from its parent.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Role-TinyCommons-Tree.
SOURCE
Source repository is at https://github.com/perlancar/perl-Role-TinyCommons-Tree.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Role-TinyCommons-Tree
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
SEE ALSO
Code::Includable::Tree::FromStruct if you want to use the routines in this module without consuming a role.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2020, 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.