Algorithm-Dependency

 view release on metacpan or  search on metacpan

lib/Algorithm/Dependency/Ordered.pm  view on Meta::CPAN


sub schedule {
	my $self   = shift;
	my $source = $self->{source};
	my @items  = @_ or return undef;
	return undef if grep { ! $source->item($_) } @items;

	# The actual items to select will be the same as for the unordered
	# version, so we can simplify the algorithm greatly by using the
	# normal unordered ->schedule method to get the starting list.
	my $rv    = $self->SUPER::schedule( @items );
	my @queue = $rv ? @$rv : return undef;

	# Get a working copy of the selected index
	my %selected = %{ $self->{selected} };

	# If at any time we check every item in the stack without finding
	# a suitable candidate for addition to the schedule, we have found
	# a circular reference error. We need to create a marker to track this.
	my $error_marker = '';

lib/Algorithm/Dependency/Source.pm  view on Meta::CPAN

#pod until you need to use the items.
#pod
#pod Returns a new object on success, or C<undef> on error.
#pod
#pod =cut

sub new {
	my $class = shift;

	# This can't be created directly, it must be through
	# a SUPER::new call
	if ( $class eq __PACKAGE__ ) {
		die "Cannot directly instantiate Algorithm::Dependency::Source."
			. " You must use a subclass";
	}

	# Create the basic object
	my $self = bless {
		# Has the source been loaded
		loaded      => 0,

lib/Algorithm/Dependency/Source/File.pm  view on Meta::CPAN

#pod otherwise.
#pod
#pod =cut

sub new {
	my $class    = shift;
	my $filename = shift or return undef;
	return undef unless -r $filename;

	# Get the basic source object
	my $self = $class->SUPER::new() or return undef;

	# Add our arguments
	$self->{filename} = $filename;

	$self;
}




lib/Algorithm/Dependency/Source/HoA.pm  view on Meta::CPAN

#pod =cut

sub new {
	my $class = shift;
	my $hash  = _HASH(shift) or return undef;
	foreach my $deps ( values %$hash ) {
		_ARRAY0($deps) or return undef;
	}

	# Get the basic source object
	my $self = $class->SUPER::new() or return undef;

	# Add our arguments
	$self->{hash} = $hash;

	$self;
}




lib/Algorithm/Dependency/Source/Invert.pm  view on Meta::CPAN

	my %hoa   = map { $_->id => [ ] } @items;
	foreach my $item ( @items ) {
		my $id   = $item->id;
		my @deps = $item->depends;
		foreach my $dep ( @deps ) {
			push @{ $hoa{$dep} }, $id;
		}
	}

	# Hand off to the parent class
	$class->SUPER::new( \%hoa );
}

1;

__END__

=pod

=encoding UTF-8



( run in 0.895 second using v1.01-cache-2.11-cpan-49f99fa48dc )