line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Farly::Object::List;
|
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
25059
|
use 5.008008;
|
|
16
|
|
|
|
|
52
|
|
|
16
|
|
|
|
|
682
|
|
4
|
16
|
|
|
16
|
|
149
|
use strict;
|
|
16
|
|
|
|
|
35
|
|
|
16
|
|
|
|
|
517
|
|
5
|
16
|
|
|
16
|
|
77
|
use warnings;
|
|
16
|
|
|
|
|
27
|
|
|
16
|
|
|
|
|
544
|
|
6
|
16
|
|
|
16
|
|
186
|
use Carp;
|
|
16
|
|
|
|
|
39
|
|
|
16
|
|
|
|
|
14246
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.26';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new {
|
11
|
211
|
|
|
211
|
1
|
335
|
my ($class) = @_;
|
12
|
211
|
|
|
|
|
859
|
return bless [], $class;
|
13
|
|
|
|
|
|
|
}
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub add {
|
16
|
1157
|
|
|
1157
|
1
|
1624
|
my ( $self, $object ) = @_;
|
17
|
|
|
|
|
|
|
|
18
|
1157
|
50
|
|
|
|
4008
|
croak "Farly::Object object required"
|
19
|
|
|
|
|
|
|
unless ( $object->isa('Farly::Object') );
|
20
|
|
|
|
|
|
|
|
21
|
1157
|
|
|
|
|
7315
|
push @$self, $object;
|
22
|
|
|
|
|
|
|
}
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub iter {
|
25
|
153
|
|
|
153
|
1
|
227
|
return @{ $_[0] };
|
|
153
|
|
|
|
|
847
|
|
26
|
|
|
|
|
|
|
}
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub size {
|
29
|
28
|
|
|
28
|
1
|
2283
|
return scalar( @{ $_[0] } );
|
|
28
|
|
|
|
|
177
|
|
30
|
|
|
|
|
|
|
}
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub clone {
|
33
|
1
|
|
|
1
|
1
|
4
|
my ($self) = @_;
|
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
4
|
my $result = Farly::Object::List->new();
|
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
10
|
foreach my $object ( $self->iter() ) {
|
38
|
3
|
|
|
|
|
12
|
$result->add( $object->clone() );
|
39
|
|
|
|
|
|
|
}
|
40
|
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
4
|
return $result;
|
42
|
|
|
|
|
|
|
}
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub includes {
|
45
|
4
|
|
|
4
|
1
|
10
|
my ( $self, $other ) = @_;
|
46
|
|
|
|
|
|
|
|
47
|
4
|
|
|
|
|
9
|
foreach my $object ( $self->iter() ) {
|
48
|
6
|
100
|
|
|
|
17
|
if ( $object->matches($other) ) {
|
49
|
4
|
|
|
|
|
17
|
return 1;
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
}
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub matches {
|
55
|
21
|
|
|
21
|
1
|
43
|
my ( $self, $other, $result ) = @_;
|
56
|
|
|
|
|
|
|
|
57
|
21
|
|
|
|
|
80
|
$self->_validate( $other, $result );
|
58
|
|
|
|
|
|
|
|
59
|
21
|
|
|
|
|
60
|
foreach my $object ( $self->iter() ) {
|
60
|
589
|
100
|
|
|
|
1431
|
if ( $object->matches($other) ) {
|
61
|
131
|
|
|
|
|
453
|
$result->add($object);
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
}
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub contains {
|
67
|
1
|
|
|
1
|
1
|
11
|
my ( $self, $other, $result ) = @_;
|
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
|
|
30
|
$self->_validate( $other, $result );
|
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
3
|
foreach my $object ( $self->iter() ) {
|
72
|
3
|
100
|
|
|
|
10
|
if ( $object->contains($other) ) {
|
73
|
1
|
|
|
|
|
4
|
$result->add($object);
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
}
|
76
|
|
|
|
|
|
|
}
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub contained_by {
|
79
|
7
|
|
|
7
|
1
|
15
|
my ( $self, $other, $result ) = @_;
|
80
|
|
|
|
|
|
|
|
81
|
7
|
|
|
|
|
21
|
$self->_validate( $other, $result );
|
82
|
|
|
|
|
|
|
|
83
|
7
|
|
|
|
|
18
|
foreach my $object ( $self->iter() ) {
|
84
|
390
|
100
|
|
|
|
823
|
if ( $object->contained_by($other) ) {
|
85
|
4
|
|
|
|
|
9
|
$result->add($object);
|
86
|
|
|
|
|
|
|
}
|
87
|
|
|
|
|
|
|
}
|
88
|
|
|
|
|
|
|
}
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub intersects {
|
91
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $other, $result ) = @_;
|
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
0
|
$self->_validate( $other, $result );
|
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
0
|
foreach my $object ( $self->iter() ) {
|
96
|
0
|
0
|
|
|
|
0
|
if ( $object->intersects($other) ) {
|
97
|
0
|
|
|
|
|
0
|
$result->add($object);
|
98
|
|
|
|
|
|
|
}
|
99
|
|
|
|
|
|
|
}
|
100
|
|
|
|
|
|
|
}
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub search {
|
103
|
1
|
|
|
1
|
1
|
6
|
my ( $self, $other, $result ) = @_;
|
104
|
|
|
|
|
|
|
|
105
|
1
|
|
|
|
|
3
|
$self->_validate( $other, $result );
|
106
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
4
|
foreach my $object ( $self->iter() ) {
|
108
|
3
|
100
|
|
|
|
10
|
if ( $object->matches($other) ) {
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
109
|
1
|
|
|
|
|
11
|
$result->add($object);
|
110
|
|
|
|
|
|
|
}
|
111
|
|
|
|
|
|
|
elsif ( $object->contains($other) ) {
|
112
|
0
|
|
|
|
|
0
|
$result->add($object);
|
113
|
|
|
|
|
|
|
}
|
114
|
|
|
|
|
|
|
elsif ( $object->contained_by($other) ) {
|
115
|
0
|
|
|
|
|
0
|
$result->add($object);
|
116
|
|
|
|
|
|
|
}
|
117
|
|
|
|
|
|
|
elsif ( $object->intersects($other) ) {
|
118
|
0
|
|
|
|
|
0
|
$result->add($object);
|
119
|
|
|
|
|
|
|
}
|
120
|
|
|
|
|
|
|
}
|
121
|
|
|
|
|
|
|
}
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _validate {
|
124
|
30
|
|
|
30
|
|
49
|
my ( $self, $other, $result ) = @_;
|
125
|
|
|
|
|
|
|
|
126
|
30
|
50
|
|
|
|
100
|
confess "other not defined"
|
127
|
|
|
|
|
|
|
unless ( defined $other );
|
128
|
|
|
|
|
|
|
|
129
|
30
|
50
|
|
|
|
91
|
confess "container for result required"
|
130
|
|
|
|
|
|
|
unless ( defined $result );
|
131
|
|
|
|
|
|
|
|
132
|
30
|
50
|
|
|
|
125
|
confess "the search object must be an Farly::Object or Farly::Object::Ref"
|
133
|
|
|
|
|
|
|
unless ( $other->isa("Farly::Object") );
|
134
|
|
|
|
|
|
|
|
135
|
30
|
50
|
33
|
|
|
154
|
confess "the result container must be an Farly::Object::List or Farly::Object::Set"
|
136
|
|
|
|
|
|
|
unless ( $result->isa("Farly::Object::List") || $result->isa("Farly::Object::Set") );
|
137
|
|
|
|
|
|
|
}
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1;
|
140
|
|
|
|
|
|
|
__END__
|