/usr/lib/perl5/ALTree/Foret.pm is in altree 1.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | package ALTree::Foret;
################################################################
################################################################
####################### Foret ########################
################################################################
################################################################
use base qw(ALTree::Base ALTree::SiteCollection);
sub New { # [classe]
my $class=shift;
my $self={};
bless($self, $class);
$self->InitSiteCollection();
$self->_init(@_);
$self->Debug("creating Foret\n");
return $self;
}
sub AddTree {
my $self=shift;
push @{$self->{"trees"}}, @_;
}
sub GetTree {
my $self=shift;
my $index=shift;
return $self->{"trees"}->[$index];
}
sub GetTreesList {
my $self=shift;
return @{$self->{"trees"}};
}
sub ProvideSite {
my $self=shift;
my $site_nb=shift;
if (not $self->HasSiteIndex($site_nb)) {
$self->AddSite(ALTree::SitePerForet->New($site_nb));
}
return $self->GetSite($site_nb);
}
sub CalculVi {
my $self=shift;
foreach my $tree ($self->GetTreesList()) {
foreach my $site ($tree->GetSitesList()) {
foreach my $sens ($site->GetSensList()) {
$self->ProvideSite($site->GetSiteNb())
->ProvideSens($sens->GetSensStruct())
->PlusVi($sens->GetVit());
}
}
}
}
sub _EnsureViMax {
my($self)=shift;
if (not exists ($self->{"V_i_max"})) {
my @tab_trie=sort {
$b->GetViMax() <=> $a->GetViMax()}
$self->GetSitesList();
$self->{"V_i_max"}=$tab_trie[0]->GetViMax();
$self->{"V_i_max_tab"}=\@tab_trie;
}
}
sub GetViMax {
my $self=shift;
$self->_EnsureViMax();
return $self->{"V_i_max"};
}
sub GetViMaxSite {
my($self)=shift;
my($index)=shift;
$self->_EnsureViMax();
return $self->{"V_i_max_tab"}->[$index];
}
sub GetViMaxSiteList {
my($self)=shift;
$self->_EnsureViMax();
return @{$self->{"V_i_max_tab"}};
}
sub NbViMaxSite {
my($self)=shift;
$self->_EnsureViMax();
return (scalar @{$self->{"V_i_max_tab"}});
}
sub _EnsureViMaxSens {
my($self)=shift;
if (not exists ($self->{"V_i_max_sens_tab"})) {
my @tab_trie=sort {
$b->GetVi() <=> $a->GetVi()
} map { $_->GetSensList(); } $self->GetSitesList();
#if ($tab_trie[0]->GetVi() != $self->GetViMax()) {
# die "Arghh\n";
#}
$self->{"V_i_max_sens_tab"}=\@tab_trie;
}
}
sub GetViMaxSens {
my($self)=shift;
my($index)=shift;
$self->_EnsureViMaxSens();
return $self->{"V_i_max_sens_tab"}->[$index];
}
sub GetViMaxSensList {
my($self)=shift;
$self->_EnsureViMaxSens();
return @{$self->{"V_i_max_sens_tab"}};
}
sub NbViMaxSens {
my($self)=shift;
$self->_EnsureViMaxSens();
return (scalar @{$self->{"V_i_max_sens_tab"}});
}
1;
|