line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tree::Interval::Fast::Interval; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
115284
|
use Tree::Interval::Fast; # load the XS |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
249
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
$Tree::Interval::Fast::Interval::VERSION = '0.0.1'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Tree::Interval::Fast::Interval - Represents an interval in an instance |
10
|
|
|
|
|
|
|
of Tree::Interval::Fast |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.0.1 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
An interval in an interval tree. It is meant to be used in conjuction with |
19
|
|
|
|
|
|
|
an instance of Tree::Interval::Fast. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SEE ALSO |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Tree::Interval::Fast - The interval tree storing instances of Tree::Interval::Fast::Interval |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 SYNOPSIS |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
You can create an interval by specifying the range and the data it holds. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Tree::Interval::Fast::Interval; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# create an interval representing the range (15.0, 20.0) which holds |
32
|
|
|
|
|
|
|
# a simple integer |
33
|
|
|
|
|
|
|
my $interval1 = Tree::Interval::Fast::Interval->new(15, 20, 10); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# another interval with more complicated data |
36
|
|
|
|
|
|
|
my $interval2 = Tree::Interval::Fast::Interval->new(10.0, 30.0, [1, 2, 3]); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# this one holds a hash instead |
39
|
|
|
|
|
|
|
my $interval2 = Tree::Interval::Fast::Interval->new(10.0, 30.0, { a=>1, b=>2 }); |
40
|
|
|
|
|
|
|
... |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# can get the left/right boundaries of each of the intervals |
43
|
|
|
|
|
|
|
printf "I1: (%.2f, %.2f)\n", $interval1->low, $interval1->high; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# can get the data associated with each interval |
46
|
|
|
|
|
|
|
use Data::Dumper; |
47
|
|
|
|
|
|
|
print Dumper $interval2->data; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 C |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Arg [1] : Float; the left boundary of the interval |
55
|
|
|
|
|
|
|
Arg [2] : Float; the right boundary of the interval |
56
|
|
|
|
|
|
|
Arg [3] : Anything; the data associated with the interval |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Example : my $i = Tree::Interval::Fast::Interval->new(10, 20, [1,2,3]); |
59
|
|
|
|
|
|
|
carp "Unable to instantiate tree" unless defined $i; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Description : Creates a new interval tree object which holds some data |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Returntype : An instance of Tree::Interval::Fast::Interval or undef |
64
|
|
|
|
|
|
|
Exceptions : None |
65
|
|
|
|
|
|
|
Caller : General |
66
|
|
|
|
|
|
|
Status : Stable |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 C |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Arg [...] : None |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Example : my $left = $tree->low; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Description : Get the left boundary of the interval. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Returntype : Float |
77
|
|
|
|
|
|
|
Exceptions : None |
78
|
|
|
|
|
|
|
Caller : General |
79
|
|
|
|
|
|
|
Status : Stable |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 C |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Arg [...] : None |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Example : my $right = $tree->high; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Description : Get the right boundary of the interval. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Returntype : Float |
90
|
|
|
|
|
|
|
Exceptions : None |
91
|
|
|
|
|
|
|
Caller : General |
92
|
|
|
|
|
|
|
Status : Stable |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 C |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Arg [...] : None |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Example : print Dumper $tree->data; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Description : Get the data associated to the interval. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Returntype : The type of the data stored in the interval |
103
|
|
|
|
|
|
|
Exceptions : None |
104
|
|
|
|
|
|
|
Caller : General |
105
|
|
|
|
|
|
|
Status : Stable |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 EXPORT |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
None |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Alessandro Vullo, C<< >> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 BUGS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
119
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
120
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
You can obtain the most recent development version of this module via the GitHub |
125
|
|
|
|
|
|
|
repository at https://github.com/avullo/AVLTree. Please feel free to submit bug |
126
|
|
|
|
|
|
|
reports, patches etc. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 SUPPORT |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
perldoc Tree::Interval::Fast::Interval |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
You can also look for information at: |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=over 4 |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
L |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * CPAN Ratings |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
L |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * Search CPAN |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
L |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Copyright 2018 Alessandro Vullo. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
162
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
163
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
See L for more information. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |