line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Set::SegmentTree; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
112480
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
64
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use Carp qw/confess croak carp/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
284
|
|
9
|
1
|
|
|
1
|
|
508
|
use Set::SegmentTree::ValueLookup; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
51
|
|
10
|
1
|
|
|
1
|
|
12
|
use List::Util qw/uniq/; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
154
|
|
11
|
1
|
|
|
1
|
|
797
|
use File::Map qw/map_file/; |
|
1
|
|
|
|
|
9457
|
|
|
1
|
|
|
|
|
7
|
|
12
|
1
|
|
|
1
|
|
763
|
use Set::SegmentTree::Builder; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
53
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
14
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
15
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
569
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub new { |
18
|
0
|
|
|
0
|
1
|
0
|
croak 'There is no new. Do you mean Set::Interval::Builder->new(\$' |
19
|
|
|
|
|
|
|
. 'options)?'; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub from_file { |
23
|
1
|
|
|
1
|
1
|
1317
|
my ( $class, $filename ) = @_; |
24
|
1
|
|
|
|
|
12
|
map_file my $bin, $filename, '<'; |
25
|
|
|
|
|
|
|
return |
26
|
1
|
|
|
|
|
463
|
bless { |
27
|
|
|
|
|
|
|
flatbuffer => Set::SegmentTree::ValueLookup->deserialize($bin) }, |
28
|
|
|
|
|
|
|
$class; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub deserialize { |
32
|
1
|
|
|
1
|
1
|
8
|
my ( $class, $serialization ) = @_; |
33
|
|
|
|
|
|
|
return |
34
|
1
|
|
|
|
|
9
|
bless { flatbuffer => |
35
|
|
|
|
|
|
|
Set::SegmentTree::ValueLookup->deserialize($serialization) }, |
36
|
|
|
|
|
|
|
$class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub find { |
40
|
28
|
|
|
28
|
1
|
1448
|
my ( $self, $instant ) = @_; |
41
|
|
|
|
|
|
|
return uniq $self->find_segments( |
42
|
28
|
|
|
|
|
134
|
$self->node( $self->{flatbuffer}->root ), $instant ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub node { |
46
|
264
|
|
|
264
|
1
|
608
|
my ( $self, $offset ) = @_; |
47
|
264
|
|
|
|
|
777
|
return $self->{flatbuffer}->nodes->[$offset]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub find_segments { |
51
|
170
|
|
|
170
|
1
|
476
|
my ( $self, $node, $instant ) = @_; |
52
|
|
|
|
|
|
|
warn "instant $instant node " |
53
|
|
|
|
|
|
|
. $node->min . '->' |
54
|
|
|
|
|
|
|
. $node->max . q^: ^ |
55
|
0
|
0
|
|
|
|
0
|
. join( q^ ^, sort @{ $node->segments || [] } ) . "\n" |
56
|
170
|
50
|
|
|
|
465
|
if $self->{verbose}; |
57
|
170
|
100
|
|
|
|
585
|
return uniq @{ $node->segments || [] }, |
58
|
142
|
|
|
|
|
397
|
map { $self->find_segments( $_, $instant ) } |
59
|
236
|
100
|
|
|
|
1445
|
grep { $instant >= $_->{min} && $instant <= $_->{max} } |
60
|
170
|
100
|
|
|
|
471
|
map { $node->$_ ? $self->node( $node->$_ ) : () } qw/low high/; |
|
340
|
|
|
|
|
1370
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
__END__ |