Commit 99af0e4c by Felix Lechner

### Provide recursive ancestor functions in Lintian::DepMap.

```This ancestor function makes some code that uses it more logical. In
one particular instance, we don't even need a unique list, so the
recursive function, which saves a call to uniq, is also exposed.

Gbp-Dch: ignore```
parent c9839131
 ... ... @@ -20,7 +20,8 @@ use warnings; use parent 'Clone'; use Carp qw(croak); use List::MoreUtils qw(any); use List::MoreUtils qw(uniq); use List::Util qw(any); use Lintian::Util qw(internal_error); ... ... @@ -458,6 +459,53 @@ sub parents { return keys %{\$self->{'nodes'}{\$node}{'parents'}}; } =item ancestors(node) Return an array with unique names of all ancestral nodes for the given C. E.g. \$map->add('A'); \$map->add('B', 'A'); # Prints 'A' print \$map->ancestors('B'); B: shall the requested node not exist this method die()s. =cut sub ancestors { my \$self = shift; my \$node = shift; return uniq +\$self->non_unique_ancestors(\$node); } =item non_unique_ancestors(node) Return an array with non-unique names of all ancestral nodes for the given C. E.g. \$map->add('A'); \$map->add('B', 'A'); # Prints 'A' print \$map->ancestors('B'); B: shall the requested node not exist this method die()s. =cut sub non_unique_ancestors { my \$self = shift; my \$node = shift; my @ancestors; push(@ancestors, \$self->non_unique_ancestors(\$_))for \$self->parents(\$node); return @ancestors; } =item pending() Return the number of nodes that can or have already been selected. E.g. ... ...
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!