line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::CircularList::Cell; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
62
|
use 5.006; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
190
|
|
4
|
4
|
|
|
4
|
|
16
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
118
|
|
5
|
4
|
|
|
4
|
|
18
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
163
|
|
6
|
4
|
|
|
4
|
|
2156
|
use parent qw/Class::Accessor/; |
|
4
|
|
|
|
|
1224
|
|
|
4
|
|
|
|
|
20
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/next data/); |
8
|
4
|
|
|
4
|
|
9214
|
use Scalar::Util qw/blessed looks_like_number/; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
482
|
|
9
|
4
|
|
|
4
|
|
22
|
use Carp; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
1050
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Data::CircularList::Cell - a Cell of the CircularList. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.03 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
You can see Data::CircularList module's SYNOPSIS as a example. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 new |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
constructor. reguire one argument (not necessary) as data. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub new { |
37
|
79
|
|
|
79
|
1
|
72
|
my $class = shift; |
38
|
79
|
|
|
|
|
75
|
my $next = undef; |
39
|
79
|
|
|
|
|
60
|
my $data = shift; |
40
|
79
|
|
|
|
|
300
|
bless { next => $next, data => $data }, $class; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 data |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
accessor for data. |
46
|
|
|
|
|
|
|
data method is readble and writable as below. |
47
|
|
|
|
|
|
|
thid method is provided by Class::Accessor. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$self->data; # read |
50
|
|
|
|
|
|
|
$self->data('some data') # write |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 next |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
accessor for next cell of the CircularList. |
57
|
|
|
|
|
|
|
next method is readble and writable as below. |
58
|
|
|
|
|
|
|
thid method is provided by Class::Accessor. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
$self->next; # read |
61
|
|
|
|
|
|
|
$self->next($next_cell) # write |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
a user doesn't usually use this method directly. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 compare_to |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This method compares to value of self and it by argument. |
70
|
|
|
|
|
|
|
If self value is big, this method return 1 and if it isn't so return 0. |
71
|
|
|
|
|
|
|
Each cell is lined in the sorted state at the value in Data::CircularList. it's used for the sorting. |
72
|
|
|
|
|
|
|
You can use any data as value of cell. |
73
|
|
|
|
|
|
|
If scalar data you use, this method compares like dictionary. |
74
|
|
|
|
|
|
|
If object data you use, you have to make orignal class and implement compare_to method. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub compare_to { |
79
|
76
|
|
|
76
|
1
|
648
|
my $self = shift; |
80
|
76
|
|
|
|
|
53
|
my $cell = shift; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# some object case |
83
|
76
|
100
|
|
|
|
116
|
if (blessed($self->data)) { |
84
|
|
|
|
|
|
|
# you have to implement compare_to method in your obj |
85
|
32
|
50
|
|
|
|
233
|
if (!$cell->can('compare_to')) { |
86
|
0
|
|
|
|
|
0
|
croak "You have to implement compare_to method in your object(" . ref($cell) . ").\n"; |
87
|
|
|
|
|
|
|
} |
88
|
32
|
100
|
|
|
|
53
|
return $cell->compare_to($self->data) > 0 ? 1 : 0; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
44
|
100
|
66
|
|
|
278
|
if (looks_like_number($self->data) && looks_like_number($cell->data)) { |
92
|
|
|
|
|
|
|
# number case |
93
|
28
|
100
|
|
|
|
340
|
return $self->data > $cell->data ? 1 : 0; |
94
|
|
|
|
|
|
|
} else { |
95
|
|
|
|
|
|
|
# string case |
96
|
16
|
100
|
|
|
|
106
|
return $self->data gt $cell->data ? 1 : 0; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# other case (havn't implemented) |
100
|
0
|
|
|
|
|
|
return 1; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
shinchit, C<< >> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 BUGS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
110
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
111
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SUPPORT |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
perldoc Data::CircularList::Cell |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
You can also look for information at: |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=over 4 |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
L |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item * CPAN Ratings |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
L |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=item * Search CPAN |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
L |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=back |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Copyright 2014 shinchit. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
154
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
155
|
|
|
|
|
|
|
copy of the full license at: |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
L |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
160
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
161
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
162
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
165
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
166
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
169
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
172
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
173
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
174
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
175
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
176
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
177
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
178
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
181
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
182
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
183
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
184
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
185
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
186
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
187
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=cut |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; # End of Data::CircularList::Cell |