line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
57908
|
use 5.006; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
125
|
|
2
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
92
|
|
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
165
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Math::Random::OO::UniformInt; |
6
|
|
|
|
|
|
|
# ABSTRACT: Generates random integers with uniform probability |
7
|
|
|
|
|
|
|
our $VERSION = '0.22'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Required modules |
10
|
3
|
|
|
3
|
|
27
|
use Carp; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
252
|
|
11
|
3
|
|
|
3
|
|
1339
|
use Params::Validate ':all'; |
|
3
|
|
|
|
|
27919
|
|
|
3
|
|
|
|
|
734
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ISA |
14
|
3
|
|
|
3
|
|
19
|
use base qw( Class::Accessor::Fast ); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
2051
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
{ |
18
|
|
|
|
|
|
|
my $param_spec = { |
19
|
|
|
|
|
|
|
low => { type => SCALAR }, |
20
|
|
|
|
|
|
|
high => { type => SCALAR } |
21
|
|
|
|
|
|
|
}; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( keys %$param_spec ); |
24
|
|
|
|
|
|
|
#__PACKAGE__->mk_ro_accessors( keys %$param_spec ); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
11
|
|
|
11
|
1
|
3714
|
my $class = shift; |
28
|
11
|
100
|
|
|
|
77
|
my $self = bless {}, ref($class) ? ref($class) : $class; |
29
|
11
|
100
|
|
|
|
38
|
if ( @_ > 1 ) { |
|
|
100
|
|
|
|
|
|
30
|
5
|
|
|
|
|
26
|
my ( $low, $high ) = sort { $a <=> $b } @_[ 0, 1 ]; # DWIM |
|
5
|
|
|
|
|
16
|
|
31
|
5
|
|
|
|
|
21
|
$self->low( int($low) ); |
32
|
5
|
|
|
|
|
49
|
$self->high( int($high) ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ( @_ == 1 ) { |
35
|
2
|
|
|
|
|
8
|
$self->low(0); |
36
|
2
|
|
|
|
|
16
|
$self->high( int( $_[0] ) ); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
4
|
|
|
|
|
18
|
$self->low(0); |
40
|
4
|
|
|
|
|
55
|
$self->high(1); |
41
|
|
|
|
|
|
|
} |
42
|
11
|
|
|
|
|
71
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub seed { |
48
|
24
|
|
|
24
|
1
|
8213
|
my $self = shift; |
49
|
24
|
|
|
|
|
72
|
srand( $_[0] ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub next { |
54
|
40
|
|
|
40
|
1
|
371
|
my ($self) = @_; |
55
|
40
|
|
|
|
|
111
|
my $rnd = int( rand( $self->high - $self->low + 1 ) ) + $self->low; |
56
|
40
|
|
|
|
|
747
|
return $rnd; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |