line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
=head1 NAME |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
Set::Object::Weak - Sets without the referant reference increment |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 SYNOPSIS |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Set::Object::Weak qw(weak_set); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $set = Set::Object::Weak->new( 0, "", {}, [], $object ); |
11
|
|
|
|
|
|
|
# or |
12
|
|
|
|
|
|
|
my $set = weak_set( 0, "", {}, [], $object ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
print $set->size; # 2 - the scalars aren't objects |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Sets, but weak. See L. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Note that the C in C returns weak sets. This |
21
|
|
|
|
|
|
|
is intentional, so that you can make all the sets in scope weak just |
22
|
|
|
|
|
|
|
by changing C |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Set::Object::Weak; |
27
|
40
|
|
|
40
|
|
251
|
use strict; |
|
40
|
|
|
|
|
76
|
|
|
40
|
|
|
|
|
1234
|
|
28
|
40
|
|
|
40
|
|
191
|
use base qw(Set::Object); # boo hiss no moose::role yet I hear you say |
|
40
|
|
|
|
|
68
|
|
|
40
|
|
|
|
|
5423
|
|
29
|
|
|
|
|
|
|
|
30
|
40
|
|
|
40
|
|
248
|
use base qw(Exporter); # my users would hate me otherwise |
|
40
|
|
|
|
|
98
|
|
|
40
|
|
|
|
|
1405
|
|
31
|
40
|
|
|
40
|
|
219
|
use vars qw(@ISA @EXPORT_OK); |
|
40
|
|
|
|
|
91
|
|
|
40
|
|
|
|
|
2051
|
|
32
|
40
|
|
|
40
|
|
249
|
use Set::Object qw(blessed); |
|
40
|
|
|
|
|
90
|
|
|
40
|
|
|
|
|
8481
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
our @EXPORT_OK = qw(weak_set set); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 CONSTRUCTORS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item new |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
This class method is exactly the same as Cnew>, |
43
|
|
|
|
|
|
|
except that it returns a weak set. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub new { |
48
|
8
|
|
|
8
|
1
|
2330
|
my $class = shift; |
49
|
8
|
|
|
|
|
30
|
my $self = $class->SUPER::new(); |
50
|
8
|
|
|
|
|
22
|
$self->weaken; |
51
|
8
|
|
|
|
|
27
|
$self->insert(@_); |
52
|
8
|
|
|
|
|
19
|
$self; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item weak_set( ... ) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
This optionally exported B is a shortcut for saying |
58
|
|
|
|
|
|
|
Cnew(...)>. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub weak_set { |
64
|
1
|
|
|
1
|
1
|
433
|
__PACKAGE__->new(@_); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item set( ... ) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
This method is exported so that if you see: |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
use Set::Object qw(set); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
You can turn it into using weak sets lexically with: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
use Set::Object::Weak qw(set); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Set::Object 1.19 had a bug in this method that meant that it would not |
78
|
|
|
|
|
|
|
add the passed members into it. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub set { |
83
|
7
|
|
|
7
|
1
|
448
|
my $class = __PACKAGE__; |
84
|
7
|
100
|
66
|
|
|
54
|
if (blessed $_[0] and $_[0]->isa("Set::Object")) { |
85
|
6
|
|
|
|
|
15
|
$class = (shift)->strong_pkg; |
86
|
|
|
|
|
|
|
} |
87
|
7
|
|
|
|
|
32
|
$class->new(@_); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |