line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
### RB.pm --- Tree::Range::RB: range tree based on Tree::RB -*- Perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
### Copyright (C) 2013 Ivan Shmakov |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
## Permission to copy this software, to modify it, to redistribute it, |
6
|
|
|
|
|
|
|
## to distribute modified versions, and to use it for any purpose is |
7
|
|
|
|
|
|
|
## granted, subject to the following restrictions and understandings. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## 1. Any copy made of this software must include this copyright notice |
10
|
|
|
|
|
|
|
## in full. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
## 2. I have made no warranty or representation that the operation of |
13
|
|
|
|
|
|
|
## this software will be error-free, and I am under no obligation to |
14
|
|
|
|
|
|
|
## provide any services, by way of maintenance, update, or otherwise. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
## 3. In conjunction with products arising from the use of this |
17
|
|
|
|
|
|
|
## material, there shall be no use of my name in any advertising, |
18
|
|
|
|
|
|
|
## promotional, or sales literature without prior written consent in |
19
|
|
|
|
|
|
|
## each case. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
### Code: |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Tree::Range::RB; |
24
|
|
|
|
|
|
|
|
25
|
7
|
|
|
7
|
|
5167
|
use strict; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
493
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = 0.22; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
require Carp; |
30
|
|
|
|
|
|
|
require Tree::Range::base; |
31
|
|
|
|
|
|
|
|
32
|
7
|
|
|
7
|
|
6745
|
use Tree::RB qw (LUGTEQ LULTEQ); |
|
7
|
|
|
|
|
98145
|
|
|
7
|
|
|
|
|
5174
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
push (our @ISA, qw (Tree::Range::base)); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub backend { |
37
|
|
|
|
|
|
|
## . |
38
|
843
|
|
|
843
|
0
|
11720
|
$_[0]->{"backend"}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub cmp_fn { |
42
|
|
|
|
|
|
|
## . |
43
|
73
|
|
|
73
|
1
|
253
|
$_[0]->{"cmp"}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub value_equal_p_fn { |
47
|
|
|
|
|
|
|
## . |
48
|
58
|
|
|
58
|
1
|
170
|
$_[0]->{"equal-p"}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub leftmost_value { |
52
|
|
|
|
|
|
|
## . |
53
|
89
|
|
|
89
|
1
|
325
|
$_[0]->{"leftmost"}; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub delete { |
57
|
|
|
|
|
|
|
## . |
58
|
74
|
|
|
74
|
1
|
174
|
$_[0]->backend ()->delete ($_[1]); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub lookup_geq { |
62
|
64
|
|
|
64
|
1
|
182
|
my ($value, $node) |
63
|
|
|
|
|
|
|
= $_[0]->backend ()->lookup ($_[1], LUGTEQ ()); |
64
|
|
|
|
|
|
|
## . |
65
|
64
|
|
|
|
|
2793
|
$node; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub lookup_leq { |
69
|
553
|
|
|
553
|
1
|
1264
|
my ($value, $node) |
70
|
|
|
|
|
|
|
= $_[0]->backend ()->lookup ($_[1], LULTEQ ()); |
71
|
|
|
|
|
|
|
## . |
72
|
553
|
|
|
|
|
39975
|
$node; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub min_node { |
76
|
|
|
|
|
|
|
## . |
77
|
2
|
|
|
2
|
1
|
9
|
$_[0]->backend ()->min (); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub max_node { |
81
|
|
|
|
|
|
|
## . |
82
|
2
|
|
|
2
|
1
|
17
|
$_[0]->backend ()->max (); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub put { |
86
|
|
|
|
|
|
|
## . |
87
|
114
|
|
|
114
|
1
|
264
|
$_[0]->backend ()->put (@_[1 .. 2]); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub new { |
91
|
6
|
|
|
6
|
1
|
2911
|
my ($class, $options) = @_; |
92
|
6
|
50
|
|
|
|
597
|
my ($cmp, $equal_p, $leftmost) |
93
|
|
|
|
|
|
|
= (defined ($options) |
94
|
|
|
|
|
|
|
? @$options{qw (cmp equal-p leftmost)} |
95
|
|
|
|
|
|
|
: ()); |
96
|
|
|
|
|
|
|
$cmp |
97
|
6
|
|
50
|
0
|
|
33
|
//= sub { $_[0] cmp $_[1] }; |
|
0
|
|
|
|
|
0
|
|
98
|
6
|
50
|
|
|
|
652
|
my $backend |
99
|
|
|
|
|
|
|
= Tree::RB->new ($cmp) |
100
|
|
|
|
|
|
|
or Carp::croak (); |
101
|
|
|
|
|
|
|
my $self = { |
102
|
|
|
|
|
|
|
"backend" => $backend, |
103
|
|
|
|
|
|
|
"cmp" => $cmp, |
104
|
60
|
|
|
60
|
|
447
|
"equal-p" => $equal_p // sub { 0; }, |
105
|
6
|
|
100
|
|
|
189
|
"leftmost" => $leftmost, |
106
|
|
|
|
|
|
|
}; |
107
|
6
|
|
|
|
|
582
|
bless ($self, $class); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
## . |
110
|
6
|
|
|
|
|
24
|
$self; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
### Emacs trailer |
116
|
|
|
|
|
|
|
## Local variables: |
117
|
|
|
|
|
|
|
## coding: us-ascii |
118
|
|
|
|
|
|
|
## fill-column: 72 |
119
|
|
|
|
|
|
|
## indent-tabs-mode: nil |
120
|
|
|
|
|
|
|
## ispell-local-dictionary: "american" |
121
|
|
|
|
|
|
|
## End: |
122
|
|
|
|
|
|
|
### RB.pm ends here |