File Coverage

blib/lib/Lingua/YaTeA/IslandSet.pm
Criterion Covered Total %
statement 39 50 78.0
branch 5 6 83.3
condition n/a
subroutine 9 11 81.8
pod 9 9 100.0
total 62 76 81.5


line stmt bran cond sub pod time code
1             package Lingua::YaTeA::IslandSet;
2 5     5   28 use strict;
  5         9  
  5         119  
3 5     5   21 use warnings;
  5         7  
  5         2270  
4              
5             our $VERSION=$Lingua::YaTeA::VERSION;
6              
7             sub new
8             {
9 9     9 1 19 my ($class) = @_;
10 9         21 my $this = {};
11 9         16 bless ($this,$class);
12 9         36 $this->{ISLANDS} = {};
13 9         27 return $this;
14             }
15              
16             sub getIslands
17             {
18 208     208 1 282 my ($this) = @_;
19 208         519 return $this->{ISLANDS};
20             }
21              
22             sub existIsland
23             {
24 62     62 1 96 my ($this,$index_set) = @_;
25 62         107 my $key = $index_set->joinAll('-');
26 62 100       107 if(exists $this->getIslands->{$key})
27             {
28 2         7 return 1;
29             }
30 60         155 return 0;
31             }
32              
33             sub getIsland
34             {
35 0     0 1 0 my ($this,$index_set) = @_;
36 0         0 my $key = $index_set->joinAll('-');
37 0         0 return $this->getIslands->{$key};
38             }
39              
40             sub existLargerIsland
41             {
42 60     60 1 79 my ($this,$index) = @_;
43 60         98 my $key = $index->joinAll('-');
44 60         75 my $island;
45 60         71 foreach $island (values (%{$this->getIslands}))
  60         81  
46             {
47 60 100       119 if($index->isCoveredBy($island->getIndexSet))
48             {
49 16         60 return 1;
50             }
51             }
52 44         133 return 0;
53             }
54              
55             sub addIsland
56             {
57 9     9 1 20 my ($this,$island,$fh) = @_;
58 9         29 my $key = $island->getIndexSet->joinAll('-');
59             # print $fh " key: ". $key . " - ";
60 9         28 $this->getIslands->{$key} = $island;
61             # print $fh "\tilot ajoute";
62             }
63              
64             sub removeIsland
65             {
66 0     0 1 0 my ($this,$island,$fh) = @_;
67 0         0 my $key = $island->getIndexSet->joinAll('-');
68 0         0 delete($this->getIslands->{$key});
69             # print $fh "remove";
70 0         0 $island = undef;
71             }
72              
73              
74             sub size
75             {
76 33     33 1 68 my ($this) = @_;
77 33         44 return scalar (keys %{$this->getIslands});
  33         59  
78             }
79              
80             sub print
81             {
82 3     3 1 5 my ($this,$fh) = @_;
83 3         5 my $island;
84 3 50       5 if(defined $fh)
85             {
86 3         4 foreach $island (values (%{$this->getIslands}))
  3         5  
87             {
88 3         6 print $fh "\t";
89 3         7 $island->print($fh);
90             }
91             }
92             else
93             {
94 0           foreach $island (values (%{$this->getIslands}))
  0            
95             {
96 0           print "\t";
97 0           $island->print;
98             }
99             }
100             }
101              
102              
103             1;
104              
105             __END__