line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::TagCloud::Extended::TagList; |
2
|
2
|
|
|
2
|
|
25220
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
2034
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
sub new { |
5
|
1
|
|
|
1
|
0
|
13
|
my $class = shift; |
6
|
1
|
|
|
|
|
5
|
my $self = bless { |
7
|
|
|
|
|
|
|
_tags => [], |
8
|
|
|
|
|
|
|
}, $class; |
9
|
1
|
|
|
|
|
4
|
return $self; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub add { |
13
|
3
|
|
|
3
|
0
|
15
|
my($self, $tag) = @_; |
14
|
3
|
|
|
|
|
4
|
push @{ $self->{_tags} }, $tag; |
|
3
|
|
|
|
|
13
|
|
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub count { |
18
|
23
|
|
|
23
|
0
|
34
|
my $self = shift; |
19
|
23
|
|
|
|
|
17
|
return scalar @{ $self->{_tags} }; |
|
23
|
|
|
|
|
88
|
|
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub get_tag_at { |
23
|
10
|
|
|
10
|
0
|
13
|
my ($self, $index) = @_; |
24
|
10
|
50
|
|
|
|
18
|
return $self->count > $index ? $self->{_tags}[$index] : undef; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub splice { |
28
|
0
|
|
|
0
|
0
|
0
|
my ($self, $index, $num) = @_; |
29
|
0
|
|
0
|
|
|
0
|
$index ||= 0; |
30
|
0
|
|
|
|
|
0
|
my @tags = splice( @{ $self->{_tags} }, $index, $num ); |
|
0
|
|
|
|
|
0
|
|
31
|
0
|
|
|
|
|
0
|
my $taglist = HTML::TagCloud::Extended::TagList->new; |
32
|
0
|
|
|
|
|
0
|
$taglist->add($_) for @tags; |
33
|
0
|
|
|
|
|
0
|
return $taglist; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub sort { |
37
|
2
|
|
|
2
|
0
|
7083
|
my ($self, $type) = @_; |
38
|
2
|
50
|
|
|
|
12
|
if ( $type eq 'name' ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
$self->{_tags} = [ sort { $a->name cmp $b->name } @{ $self->{_tags} } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
} elsif ( $type eq 'name_desc' ) { |
41
|
1
|
|
|
|
|
2
|
$self->{_tags} = [ sort { $b->name cmp $a->name } @{ $self->{_tags} } ]; |
|
2
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
8
|
|
42
|
|
|
|
|
|
|
} elsif ( $type eq 'count') { |
43
|
1
|
|
|
|
|
2
|
$self->{_tags} = [ sort { $a->count <=> $b->count } @{ $self->{_tags} } ]; |
|
3
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
5
|
|
44
|
|
|
|
|
|
|
} elsif ( $type eq 'count_desc' ) { |
45
|
0
|
|
|
|
|
0
|
$self->{_tags} = [ sort { $b->count <=> $a->count } @{ $self->{_tags} } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
46
|
|
|
|
|
|
|
} elsif ( $type eq 'timestamp' ) { |
47
|
0
|
|
|
|
|
0
|
$self->{_tags} = [ sort { $a->epoch <=> $b->epoch } @{ $self->{_tags} } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
48
|
|
|
|
|
|
|
} elsif ( $type eq 'timestamp_desc' ) { |
49
|
0
|
|
|
|
|
0
|
$self->{_tags} = [ sort { $b->epoch <=> $a->epoch } @{ $self->{_tags} } ]; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub iterator { |
54
|
3
|
|
|
3
|
0
|
3840
|
my $self = shift; |
55
|
3
|
|
|
|
|
17
|
return HTML::TagCloud::Extended::TagList::Iterator->new($self); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub min_count { |
59
|
1
|
|
|
1
|
0
|
999
|
my $self = shift; |
60
|
1
|
|
|
|
|
2
|
my @tags = sort { $a->count <=> $b->count } @{ $self->{_tags} }; |
|
3
|
|
|
|
|
19
|
|
|
1
|
|
|
|
|
4
|
|
61
|
1
|
50
|
|
|
|
12
|
return @tags > 0 ? $tags[0]->count : undef; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub max_count { |
65
|
1
|
|
|
1
|
0
|
2699
|
my $self = shift; |
66
|
1
|
|
|
|
|
2
|
my @tags = sort { $b->count <=> $a->count } @{ $self->{_tags} }; |
|
2
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
8
|
|
67
|
1
|
50
|
|
|
|
16
|
return @tags > 0 ? $tags[0]->count : undef; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub min_epoch { |
71
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
72
|
0
|
|
|
|
|
0
|
my @tags = sort { $a->epoch <=> $b->epoch } @{ $self->{_tags} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
73
|
0
|
0
|
|
|
|
0
|
return @tags > 0 ? $tags[0]->epoch : undef; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub max_epoch { |
77
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
78
|
0
|
|
|
|
|
0
|
my @tags = sort { $b->epoch <=> $a->epoch } @{ $self->{_tags} }; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
79
|
0
|
0
|
|
|
|
0
|
return @tags > 0 ? $tags[0]->epoch : undef; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
package HTML::TagCloud::Extended::TagList::Iterator; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub new { |
85
|
3
|
|
|
3
|
|
5
|
my ($class, $tags) = @_; |
86
|
3
|
|
|
|
|
18
|
my $self = bless { |
87
|
|
|
|
|
|
|
tags => $tags, |
88
|
|
|
|
|
|
|
_index => 0, |
89
|
|
|
|
|
|
|
}, $class; |
90
|
3
|
|
|
|
|
213
|
return $self; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub reset { |
94
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
95
|
0
|
|
|
|
|
0
|
$self->{_index} = 0; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub next { |
99
|
10
|
|
|
10
|
|
914
|
my $self = shift; |
100
|
10
|
100
|
|
|
|
25
|
return undef unless ( $self->{tags}->count > $self->{_index} ); |
101
|
9
|
|
|
|
|
22
|
my $tag = $self->{tags}->get_tag_at($self->{_index}); |
102
|
9
|
|
|
|
|
12
|
$self->{_index}++; |
103
|
9
|
|
|
|
|
20
|
return $tag; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub first { |
107
|
0
|
|
|
0
|
|
|
my $self = shift; |
108
|
0
|
|
|
|
|
|
return $self->{tags}->get_tag_at(0); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
112
|
|
|
|
|
|
|
__END__ |