| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Hash::StoredIterator; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
99498
|
use 5.010000; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
14
|
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
23
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
3
|
use base 'Exporter'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
83
|
|
|
8
|
1
|
|
|
1
|
|
42
|
use Carp qw/croak carp/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
45
|
|
|
9
|
1
|
|
|
1
|
|
3
|
use B; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
358
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
|
12
|
|
|
|
|
|
|
hmap |
|
13
|
|
|
|
|
|
|
eich |
|
14
|
|
|
|
|
|
|
eech |
|
15
|
|
|
|
|
|
|
iterator |
|
16
|
|
|
|
|
|
|
hash_get_iterator |
|
17
|
|
|
|
|
|
|
hash_set_iterator |
|
18
|
|
|
|
|
|
|
hash_init_iterator |
|
19
|
|
|
|
|
|
|
hkeys |
|
20
|
|
|
|
|
|
|
hvalues |
|
21
|
|
|
|
|
|
|
}; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
24
|
|
|
|
|
|
|
'all' => \@EXPORT_OK |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our $VERSION = '0.008'; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
require XSLoader; |
|
30
|
|
|
|
|
|
|
XSLoader::load( 'Hash::StoredIterator', $VERSION ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub eich(\%\$) { |
|
33
|
33
|
|
|
33
|
1
|
12921
|
carp "eich is deprecated, you should use iterator() instead"; |
|
34
|
33
|
|
|
|
|
1084
|
my ( $hash, $i_ref ) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
33
|
|
|
|
|
54
|
my $old_it = hash_get_iterator($hash); |
|
37
|
|
|
|
|
|
|
|
|
38
|
33
|
|
|
|
|
42
|
my ( $key, $val ); |
|
39
|
|
|
|
|
|
|
|
|
40
|
33
|
|
|
|
|
30
|
my $success = eval { |
|
41
|
33
|
100
|
|
|
|
46
|
if ( !defined $$i_ref ) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
9
|
|
|
|
|
15
|
hash_init_iterator($hash); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
else { |
|
46
|
24
|
|
|
|
|
33
|
hash_set_iterator( $hash, $$i_ref ); |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
33
|
|
|
|
|
47
|
( $key, $val ) = each(%$hash); |
|
50
|
|
|
|
|
|
|
|
|
51
|
33
|
|
|
|
|
58
|
$$i_ref = hash_get_iterator($hash); |
|
52
|
|
|
|
|
|
|
|
|
53
|
33
|
|
|
|
|
26
|
1; |
|
54
|
|
|
|
|
|
|
}; |
|
55
|
|
|
|
|
|
|
|
|
56
|
33
|
|
|
|
|
33
|
hash_set_iterator( $hash, $old_it ); |
|
57
|
33
|
50
|
|
|
|
56
|
die $@ unless $success; |
|
58
|
|
|
|
|
|
|
|
|
59
|
33
|
100
|
|
|
|
41
|
unless ( defined $key ) { |
|
60
|
8
|
|
|
|
|
5
|
$$i_ref = undef; |
|
61
|
8
|
|
|
|
|
14
|
return; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
25
|
|
|
|
|
42
|
return ( $key, $val ); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub iterator(\%) { |
|
68
|
10
|
|
|
10
|
1
|
18624
|
my ($hash) = @_; |
|
69
|
10
|
|
|
|
|
10
|
my $i = undef; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return sub { |
|
72
|
42
|
|
|
42
|
|
21286
|
my $old_it = hash_get_iterator($hash); |
|
73
|
|
|
|
|
|
|
|
|
74
|
42
|
|
|
|
|
35
|
my ( $key, $val ); |
|
75
|
|
|
|
|
|
|
|
|
76
|
42
|
|
|
|
|
34
|
my $success = eval { |
|
77
|
42
|
100
|
|
|
|
63
|
if ( !defined $i ) { |
|
78
|
11
|
|
|
|
|
12
|
hash_init_iterator( $hash ); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
else { |
|
81
|
31
|
|
|
|
|
41
|
hash_set_iterator( $hash, $i ); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
42
|
|
|
|
|
62
|
( $key, $val ) = each( %$hash ); |
|
85
|
|
|
|
|
|
|
|
|
86
|
42
|
|
|
|
|
51
|
$i = hash_get_iterator($hash); |
|
87
|
|
|
|
|
|
|
|
|
88
|
42
|
|
|
|
|
39
|
1; |
|
89
|
|
|
|
|
|
|
}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
42
|
|
|
|
|
44
|
hash_set_iterator( $hash, $old_it ); |
|
92
|
42
|
50
|
|
|
|
65
|
die $@ unless $success; |
|
93
|
|
|
|
|
|
|
|
|
94
|
42
|
100
|
|
|
|
66
|
unless ( defined $key ) { |
|
95
|
9
|
|
|
|
|
8
|
$i = undef; |
|
96
|
9
|
|
|
|
|
24
|
return; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
33
|
|
|
|
|
67
|
return ( $key, $val ); |
|
100
|
10
|
|
|
|
|
41
|
}; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub hmap(&\%) { |
|
104
|
9
|
|
|
9
|
1
|
25656
|
my ( $code, $hash ) = @_; |
|
105
|
|
|
|
|
|
|
|
|
106
|
9
|
|
|
|
|
24
|
my $old_it = hash_get_iterator($hash); |
|
107
|
9
|
|
|
|
|
13
|
hash_init_iterator($hash); |
|
108
|
|
|
|
|
|
|
|
|
109
|
9
|
|
|
|
|
9
|
my $success = eval { |
|
110
|
9
|
|
|
|
|
18
|
my $iter = iterator %$hash; |
|
111
|
|
|
|
|
|
|
|
|
112
|
9
|
|
|
|
|
15
|
while ( my ( $k, $v ) = $iter->() ) { |
|
113
|
29
|
|
|
|
|
23
|
local $_ = $k; |
|
114
|
|
|
|
|
|
|
# Can't use caller(), subref might be from a different package than |
|
115
|
|
|
|
|
|
|
# eech is called from. |
|
116
|
29
|
|
|
|
|
203
|
my $callback_package = B::svref_2object($code)->GV->STASH->NAME; |
|
117
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
204
|
|
|
118
|
29
|
|
|
|
|
36
|
local ${"$callback_package\::a"} = $k; |
|
|
29
|
|
|
|
|
51
|
|
|
119
|
29
|
|
|
|
|
21
|
local ${"$callback_package\::b"} = $v; |
|
|
29
|
|
|
|
|
37
|
|
|
120
|
29
|
|
|
|
|
42
|
$code->( $k, $v ); |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
8
|
|
|
|
|
35
|
1; |
|
124
|
|
|
|
|
|
|
}; |
|
125
|
|
|
|
|
|
|
|
|
126
|
9
|
|
|
|
|
29
|
hash_set_iterator( $hash, $old_it ); |
|
127
|
9
|
100
|
|
|
|
22
|
die $@ unless $success; |
|
128
|
8
|
|
|
|
|
11
|
return; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub eech(&\%) { |
|
132
|
0
|
|
|
0
|
1
|
0
|
carp "eech is deprecated, use hmap instead"; |
|
133
|
0
|
|
|
|
|
0
|
goto &hmap; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub hkeys(\%) { |
|
137
|
15
|
|
|
15
|
1
|
4186
|
my ($hash) = @_; |
|
138
|
15
|
50
|
|
|
|
23
|
croak "ARGH!" unless $hash; |
|
139
|
|
|
|
|
|
|
|
|
140
|
15
|
|
|
|
|
18
|
my $old_it = hash_get_iterator($hash); |
|
141
|
15
|
|
|
|
|
17
|
hash_init_iterator($hash); |
|
142
|
|
|
|
|
|
|
|
|
143
|
15
|
|
|
|
|
32
|
my @out = keys %$hash; |
|
144
|
|
|
|
|
|
|
|
|
145
|
15
|
|
|
|
|
17
|
hash_set_iterator( $hash, $old_it ); |
|
146
|
|
|
|
|
|
|
|
|
147
|
15
|
|
|
|
|
35
|
return @out; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub hvalues(\%) { |
|
151
|
1
|
|
|
1
|
1
|
3
|
my ($hash) = @_; |
|
152
|
|
|
|
|
|
|
|
|
153
|
1
|
|
|
|
|
3
|
my $old_it = hash_get_iterator($hash); |
|
154
|
1
|
|
|
|
|
3
|
hash_init_iterator($hash); |
|
155
|
|
|
|
|
|
|
|
|
156
|
1
|
|
|
|
|
2
|
my @out = values %$hash; |
|
157
|
|
|
|
|
|
|
|
|
158
|
1
|
|
|
|
|
2
|
hash_set_iterator( $hash, $old_it ); |
|
159
|
|
|
|
|
|
|
|
|
160
|
1
|
|
|
|
|
8
|
return @out; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
__END__ |