| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- Mode: Perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright (c) 2001, Bryan Jurish. All rights reserved. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# This package is free software. You may redistribute it |
|
7
|
|
|
|
|
|
|
# and/or modify it under the same terms as Perl itself. |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
############################################################### |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# File: Math::PartialOrder::LRUCaching.pm |
|
13
|
|
|
|
|
|
|
# Author: Bryan Jurish |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# Description: Math::PartialOrder class using hashrefs |
|
16
|
|
|
|
|
|
|
# objects to store hierarchy information, |
|
17
|
|
|
|
|
|
|
# caches inheritance- and operation-lookups |
|
18
|
|
|
|
|
|
|
# using Tie::Cache. |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
############################################################### |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package Math::PartialOrder::LRUCaching; |
|
24
|
|
|
|
|
|
|
# System modules |
|
25
|
7
|
|
|
7
|
|
6670
|
use Carp; |
|
|
7
|
|
|
|
|
12
|
|
|
|
7
|
|
|
|
|
481
|
|
|
26
|
|
|
|
|
|
|
#require Exporter; |
|
27
|
|
|
|
|
|
|
# 3rd party exstensions |
|
28
|
7
|
|
|
7
|
|
37
|
use Tie::Cache; |
|
|
7
|
|
|
|
|
39
|
|
|
|
7
|
|
|
|
|
153
|
|
|
29
|
|
|
|
|
|
|
# user extension modules |
|
30
|
7
|
|
|
7
|
|
36
|
use Math::PartialOrder::Caching qw($CACHE_KEY_SEP); |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
2507
|
|
|
31
|
|
|
|
|
|
|
@ISA = qw(Math::PartialOrder::Caching); |
|
32
|
|
|
|
|
|
|
@EXPORT = qw(); |
|
33
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
############################################################### |
|
36
|
|
|
|
|
|
|
# Package-Globals |
|
37
|
|
|
|
|
|
|
############################################################### |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
our $VERSION = 0.01; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# $CACHE_KEY_SEP : imported from Math::PartialOrder::Caching |
|
42
|
|
|
|
|
|
|
our $IN_CACHE_ATTRS = { MaxCount => 5000 }; |
|
43
|
|
|
|
|
|
|
our $OP_CACHE_ATTRS = { MaxCount => 5000 }; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
############################################################### |
|
47
|
|
|
|
|
|
|
# Initialization |
|
48
|
|
|
|
|
|
|
# + object structure: |
|
49
|
|
|
|
|
|
|
# { |
|
50
|
|
|
|
|
|
|
# # --- INHERITED --- |
|
51
|
|
|
|
|
|
|
# types => Set::Hashed |
|
52
|
|
|
|
|
|
|
# root => scalar |
|
53
|
|
|
|
|
|
|
# parents => { type1 => {p1a=>p1a,...}, ... } |
|
54
|
|
|
|
|
|
|
# children => { type1 => {c1a=>c1a,...}, ... } |
|
55
|
|
|
|
|
|
|
# attributes => { type1 => { attr1.1 => val1.1, ... }, ... } |
|
56
|
|
|
|
|
|
|
# # --- NEW --- |
|
57
|
|
|
|
|
|
|
# _incache => { 'type1,type2' => $has_anc_bool, ... } |
|
58
|
|
|
|
|
|
|
# _opcache => { 'op,type1,type2' => \@results } |
|
59
|
|
|
|
|
|
|
# } |
|
60
|
|
|
|
|
|
|
############################################################### |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
63
|
|
|
|
|
|
|
# new( \%args ) |
|
64
|
|
|
|
|
|
|
# + initialization routine: returns the object |
|
65
|
|
|
|
|
|
|
# + keys of \%args |
|
66
|
|
|
|
|
|
|
# + inherited: |
|
67
|
|
|
|
|
|
|
# root => $typ |
|
68
|
|
|
|
|
|
|
# + new |
|
69
|
|
|
|
|
|
|
# incache_attrs => \%attrs |
|
70
|
|
|
|
|
|
|
# opcache_attrs => \%attrs |
|
71
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
72
|
|
|
|
|
|
|
sub new ($;$) { |
|
73
|
11
|
|
|
11
|
1
|
368
|
my ($proto,$args) = @_; |
|
74
|
11
|
|
|
|
|
74
|
my $self = $proto->SUPER::new($args); |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# tie up caches |
|
77
|
11
|
|
33
|
|
|
22
|
tie %{$self->{incache}}, Tie::Cache, $args{incache_attrs}||$IN_CACHE_ATTRS; |
|
|
11
|
|
|
|
|
165
|
|
|
78
|
11
|
|
33
|
|
|
352
|
tie %{$self->{opcache}}, Tie::Cache, $args{opcache_attrs}||$OP_CACHE_ATTRS; |
|
|
11
|
|
|
|
|
76
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
11
|
|
|
|
|
315
|
return $self; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
############################################################### |
|
86
|
|
|
|
|
|
|
# Hierarchy Maintainance: Type Operations |
|
87
|
|
|
|
|
|
|
############################################################### |
|
88
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
89
|
|
|
|
|
|
|
# types : inherited from Math::PartialOrder::Std |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
92
|
|
|
|
|
|
|
# add : inherited from Math::PartialOrder::Caching |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
95
|
|
|
|
|
|
|
# has_type : inherited from Math::PartialOrder::Std |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
98
|
|
|
|
|
|
|
# add_parents : inherited from Math::PartialOrder::Caching |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
101
|
|
|
|
|
|
|
# move : inherited from Math::PartialOrder::Caching |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
104
|
|
|
|
|
|
|
# remove : inherited from Math::PartialOrder::Caching |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
107
|
|
|
|
|
|
|
# parents : inherited from Math::PartialOrder::Std |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
110
|
|
|
|
|
|
|
# children : inherited from Math::PartialOrder::Std |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
113
|
|
|
|
|
|
|
# has_parent : inherited from Math::PartialOrder::Std |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
116
|
|
|
|
|
|
|
# has_child : inherited from Math::PartialOrder::Std |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
119
|
|
|
|
|
|
|
# has_ancestor : inherited from Math::PartialOrder::Caching |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
123
|
|
|
|
|
|
|
# has_descendant : inherited from Math::PartialOrder::Caching |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
126
|
|
|
|
|
|
|
# get_attributes : inherited from Math::PartialOrder::Std |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
129
|
|
|
|
|
|
|
# get_attribute : inherited from Math::PartialOrder::Std |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
132
|
|
|
|
|
|
|
# set_attribute : inherited from Math::PartialOrder::Std |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
135
|
|
|
|
|
|
|
# assign : inherited from Math::PartialOrder::Caching |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
139
|
|
|
|
|
|
|
# merge : inherited from Math::PartialOrder::Caching |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
142
|
|
|
|
|
|
|
# clear : inherited from Math::PartialOrder::Caching |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
############################################################### |
|
145
|
|
|
|
|
|
|
# Additional Hierarchy Maintainence Operations |
|
146
|
|
|
|
|
|
|
############################################################### |
|
147
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
148
|
|
|
|
|
|
|
# ensure_types : inherited from Math::PartialOrder::Std |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
151
|
|
|
|
|
|
|
# _ancestors($type) => $hashref : inherited from Math::PartialOrder::Std |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
154
|
|
|
|
|
|
|
# _descendants($type) => $hashref : inherited from Math::PartialOrder::Std |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
157
|
|
|
|
|
|
|
# _minimize : inherited from Math::PartialOrder:Set |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
160
|
|
|
|
|
|
|
# _maximize : inherited from Math::PartialOrder:Set |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
############################################################### |
|
164
|
|
|
|
|
|
|
# Hierarchy Operations |
|
165
|
|
|
|
|
|
|
############################################################### |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
168
|
|
|
|
|
|
|
# _lub : inherited from Math::PartialOrder::Caching |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
171
|
|
|
|
|
|
|
# _glb : inherited from Math::PartialOrder::Caching |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
############################################################### |
|
175
|
|
|
|
|
|
|
# Hierarchy operation utilities |
|
176
|
|
|
|
|
|
|
############################################################### |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
############################################################### |
|
179
|
|
|
|
|
|
|
# Accessors/manipulators |
|
180
|
|
|
|
|
|
|
############################################################### |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
183
|
|
|
|
|
|
|
# _types : inherited from Math::PartialOrder::Std |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
186
|
|
|
|
|
|
|
# _root, root : inherited from Math::PartialOrder::Caching |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
189
|
|
|
|
|
|
|
# _parents : inherited from Math::PartialOrder::Std |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
192
|
|
|
|
|
|
|
# _children : inherited from Math::PartialOrder::Std |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
195
|
|
|
|
|
|
|
# _attributes : inherited from Math::PartialOrder::Std |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
199
|
|
|
|
|
|
|
# _incache : inherited from Math::PartialOrder::Caching |
|
200
|
|
|
|
|
|
|
# _get_cached_in : inherited from Math::PartialOrder::Caching |
|
201
|
|
|
|
|
|
|
# _set_cached_in : inherited from Math::PartialOrder::Caching |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
205
|
|
|
|
|
|
|
# _opcache : inherited from Math::PartialOrder::Caching |
|
206
|
|
|
|
|
|
|
# _get_cached_op : inherited from Math::PartialOrder::Caching |
|
207
|
|
|
|
|
|
|
# _set_cached_op : inherited from Math::PartialOrder::Caching |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
#-------------------------------------------------------------- |
|
211
|
|
|
|
|
|
|
# _clear_cached, _clear_cache : inherited from Math::PartialOrder::Caching |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
1; |
|
215
|
|
|
|
|
|
|
__END__ |