line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Set::SegmentTree; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
113859
|
use 5.006; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
5
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
8
|
use Carp qw/confess croak carp/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
76
|
|
10
|
1
|
|
|
1
|
|
511
|
use Set::SegmentTree::ValueLookup; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
50
|
|
11
|
1
|
|
|
1
|
|
12
|
use List::Util qw/uniq/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
156
|
|
12
|
1
|
|
|
1
|
|
837
|
use File::Map qw/map_file/; |
|
1
|
|
|
|
|
8383
|
|
|
1
|
|
|
|
|
7
|
|
13
|
1
|
|
|
1
|
|
797
|
use Set::SegmentTree::Builder; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
18
|
|
16
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
380
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub new { |
19
|
0
|
|
|
0
|
1
|
0
|
croak 'There is no new. Do you mean Set::Interval::Builder->new(\$' |
20
|
|
|
|
|
|
|
. 'options)?'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub from_file { |
24
|
1
|
|
|
1
|
1
|
573
|
my ( $class, $filename ) = @_; |
25
|
1
|
|
|
|
|
10
|
map_file my $bin, $filename, '<'; |
26
|
|
|
|
|
|
|
return |
27
|
1
|
|
|
|
|
326
|
bless { |
28
|
|
|
|
|
|
|
flatbuffer => Set::SegmentTree::ValueLookup->deserialize($bin) }, |
29
|
|
|
|
|
|
|
$class; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub deserialize { |
33
|
1
|
|
|
1
|
1
|
5
|
my ( $class, $serialization ) = @_; |
34
|
|
|
|
|
|
|
return |
35
|
1
|
|
|
|
|
8
|
bless { flatbuffer => |
36
|
|
|
|
|
|
|
Set::SegmentTree::ValueLookup->deserialize($serialization) }, |
37
|
|
|
|
|
|
|
$class; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub find { |
41
|
28
|
|
|
28
|
1
|
563
|
my ( $self, $instant ) = @_; |
42
|
|
|
|
|
|
|
return uniq $self->find_segments( |
43
|
28
|
|
|
|
|
124
|
$self->node( $self->{flatbuffer}->root ), $instant ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub node { |
47
|
264
|
|
|
264
|
1
|
517
|
my ( $self, $offset ) = @_; |
48
|
264
|
|
|
|
|
676
|
return $self->{flatbuffer}->nodes->[$offset]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub find_segments { |
52
|
170
|
|
|
170
|
1
|
329
|
my ( $self, $node, $instant ) = @_; |
53
|
|
|
|
|
|
|
warn "instant $instant node " |
54
|
|
|
|
|
|
|
. $node->min . '->' |
55
|
|
|
|
|
|
|
. $node->max . q^: ^ |
56
|
0
|
0
|
|
|
|
0
|
. join( q^ ^, sort @{ $node->segments || [] } ) . "\n" |
57
|
170
|
50
|
|
|
|
397
|
if $self->{verbose}; |
58
|
170
|
100
|
|
|
|
439
|
return uniq @{ $node->segments || [] }, |
59
|
142
|
|
|
|
|
343
|
map { $self->find_segments( $_, $instant ) } |
60
|
236
|
100
|
|
|
|
1137
|
grep { $instant >= $_->{min} && $instant <= $_->{max} } |
61
|
170
|
100
|
|
|
|
311
|
map { $node->$_ ? $self->node( $node->$_ ) : () } qw/low high/; |
|
340
|
|
|
|
|
988
|
|
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
__END__ |