line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::RandomPerson::Choice; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
691
|
use strict; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
185
|
|
4
|
6
|
|
|
6
|
|
20
|
use warnings; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
1265
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub new { |
7
|
55
|
|
|
55
|
1
|
401
|
my ($class) = @_; |
8
|
|
|
|
|
|
|
|
9
|
55
|
|
|
|
|
318
|
return bless {}, $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub add { |
13
|
80
|
|
|
80
|
1
|
424
|
my ( $self, $value, $count ) = @_; |
14
|
|
|
|
|
|
|
|
15
|
80
|
|
100
|
|
|
197
|
$count ||= 1; |
16
|
|
|
|
|
|
|
|
17
|
80
|
|
|
|
|
111
|
push @{ $self->{data} }, $value foreach ( 1 .. $count ); |
|
600
|
|
|
|
|
757
|
|
18
|
80
|
|
|
|
|
157
|
$self->{size} += $count; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub add_list { |
22
|
35
|
|
|
35
|
1
|
16877
|
my ( $self, @list ) = @_; |
23
|
|
|
|
|
|
|
|
24
|
35
|
|
|
|
|
45
|
push @{ $self->{data} }, @list; |
|
35
|
|
|
|
|
23627
|
|
25
|
35
|
|
|
|
|
7513
|
$self->{size} += scalar(@list); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub size { |
29
|
34
|
|
|
34
|
1
|
41
|
my ($self) = @_; |
30
|
|
|
|
|
|
|
|
31
|
34
|
|
|
|
|
98
|
return $self->{size}; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub pick { |
35
|
2562
|
|
|
2562
|
1
|
3120
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
2562
|
100
|
|
|
|
3340
|
die "No data has been added to the list" unless $self->{size}; |
38
|
|
|
|
|
|
|
|
39
|
2561
|
|
|
|
|
5020
|
return $self->{data}[ int( rand( $self->{size} ) ) ]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__END__ |