extract-curves 0.1.1-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Changelog +21 -0
- data/bin/ec_rect2polar +22 -0
- data/bin/ec_rect2polar.rb +22 -0
- data/bin/ec_rev_lines +5 -0
- data/bin/ec_rev_lines.rb +5 -0
- data/bin/ec_sph_area +30 -0
- data/bin/ec_sph_area.rb +30 -0
- data/bin/extract_curves +1670 -0
- data/bin/extract_curves.rb +1670 -0
- data/ruby_ext/pav/extconf.rb +22 -0
- data/ruby_ext/pav/pav.dll +0 -0
- data/ruby_libs/pav/attr_cache.rb +211 -0
- data/ruby_libs/pav/attr_cache.t1.rb +32 -0
- data/ruby_libs/pav/cache.rb +31 -0
- data/ruby_libs/pav/collection/std.rb +58 -0
- data/ruby_libs/pav/dbg_log.rb +458 -0
- data/ruby_libs/pav/floatsio.rb +53 -0
- data/ruby_libs/pav/generator_cache.rb +165 -0
- data/ruby_libs/pav/graph/node.rb +602 -0
- data/ruby_libs/pav/graph/node_grp.rb +865 -0
- data/ruby_libs/pav/gtk.rb +6 -0
- data/ruby_libs/pav/gtk/button.rb +118 -0
- data/ruby_libs/pav/gtk/dialog.rb +29 -0
- data/ruby_libs/pav/gtk/guiobj.rb +772 -0
- data/ruby_libs/pav/gtk/icons.rb +124 -0
- data/ruby_libs/pav/gtk/rulers.rb +264 -0
- data/ruby_libs/pav/gtk/toolbar.rb +189 -0
- data/ruby_libs/pav/guiobj.rb +2 -0
- data/ruby_libs/pav/guiobj/info_asm.rb +41 -0
- data/ruby_libs/pav/guiobj/method.rb +211 -0
- data/ruby_libs/pav/guiobj/obj.rb +134 -0
- data/ruby_libs/pav/guiobj/signals.rb +9 -0
- data/ruby_libs/pav/heap.rb +54 -0
- data/ruby_libs/pav/icons/alt_handle.xpm +3832 -0
- data/ruby_libs/pav/icons/alt_handle_hover.xpm +3368 -0
- data/ruby_libs/pav/icons/alt_handle_pressed.xpm +3828 -0
- data/ruby_libs/pav/icons/blob.gif +0 -0
- data/ruby_libs/pav/icons/contour.gif +0 -0
- data/ruby_libs/pav/icons/contour_carpet.gif +0 -0
- data/ruby_libs/pav/icons/curve.gif +0 -0
- data/ruby_libs/pav/icons/curve_carpet.gif +0 -0
- data/ruby_libs/pav/icons/expand_closed.xpm +1791 -0
- data/ruby_libs/pav/icons/expand_closed_hover.xpm +1775 -0
- data/ruby_libs/pav/icons/expand_open.xpm +1788 -0
- data/ruby_libs/pav/icons/expand_open_hover.xpm +1752 -0
- data/ruby_libs/pav/icons/extract_curves/extract_curves-icon-rgb.ppm +14 -0
- data/ruby_libs/pav/icons/extract_curves/extract_curves-logo-rgb.gif +0 -0
- data/ruby_libs/pav/icons/extract_curves/trace_mark.xpm +38 -0
- data/ruby_libs/pav/icons/handle.xpm +213 -0
- data/ruby_libs/pav/icons/loop.gif +0 -0
- data/ruby_libs/pav/icons/loop_carpet.gif +0 -0
- data/ruby_libs/pav/icons/next.xpm +29 -0
- data/ruby_libs/pav/icons/next_hover.xpm +315 -0
- data/ruby_libs/pav/icons/next_pressed.xpm +144 -0
- data/ruby_libs/pav/icons/prev.xpm +29 -0
- data/ruby_libs/pav/icons/prev_hover.xpm +315 -0
- data/ruby_libs/pav/icons/prev_pressed.xpm +144 -0
- data/ruby_libs/pav/icons/shaved-core.gif +0 -0
- data/ruby_libs/pav/icons/vnext.xpm +29 -0
- data/ruby_libs/pav/icons/vprev.xpm +29 -0
- data/ruby_libs/pav/numeric/ext.rb +21 -0
- data/ruby_libs/pav/patterns/hsep.gif +0 -0
- data/ruby_libs/pav/patterns/tnode.gif +0 -0
- data/ruby_libs/pav/patterns/tnode_w_link.gif +0 -0
- data/ruby_libs/pav/patterns/vlink.gif +0 -0
- data/ruby_libs/pav/patterns/vsep.gif +0 -0
- data/ruby_libs/pav/patterns/yg_hrope.xpm +492 -0
- data/ruby_libs/pav/patterns/yg_hrope_thick.xpm +1904 -0
- data/ruby_libs/pav/patterns/yg_hrope_thin.xpm +130 -0
- data/ruby_libs/pav/patterns/yg_tnode.xpm +180 -0
- data/ruby_libs/pav/patterns/yg_tnode_thick.xpm +615 -0
- data/ruby_libs/pav/patterns/yg_tnode_thin.xpm +55 -0
- data/ruby_libs/pav/patterns/yg_tnode_w_link.xpm +190 -0
- data/ruby_libs/pav/patterns/yg_tnode_w_link_thick.xpm +676 -0
- data/ruby_libs/pav/patterns/yg_tnode_w_link_thin.xpm +62 -0
- data/ruby_libs/pav/patterns/yg_vrope.xpm +563 -0
- data/ruby_libs/pav/patterns/yg_vrope_thick.xpm +2047 -0
- data/ruby_libs/pav/patterns/yg_vrope_thin.xpm +166 -0
- data/ruby_libs/pav/pav_find.rb +90 -0
- data/ruby_libs/pav/pix.rb +402 -0
- data/ruby_libs/pav/pix/aapix.rb +378 -0
- data/ruby_libs/pav/pix/blob.rb +678 -0
- data/ruby_libs/pav/pix/circle.rb +73 -0
- data/ruby_libs/pav/pix/contour.rb +676 -0
- data/ruby_libs/pav/pix/contour/calc_situations.rb +9 -0
- data/ruby_libs/pav/pix/contour/carp_calc.rb +212 -0
- data/ruby_libs/pav/pix/contour/situations.dmp +0 -0
- data/ruby_libs/pav/pix/contour/situations.rb +21 -0
- data/ruby_libs/pav/pix/curve.rb +1544 -0
- data/ruby_libs/pav/pix/img_obj.rb +865 -0
- data/ruby_libs/pav/pix/node.rb +159 -0
- data/ruby_libs/pav/pix/shaved_core.rb +697 -0
- data/ruby_libs/pav/pix/subpix.rb +212 -0
- data/ruby_libs/pav/rand_accessible.rb +16 -0
- data/ruby_libs/pav/rangeset.rb +63 -0
- data/ruby_libs/pav/search.rb +210 -0
- data/ruby_libs/pav/set.rb +130 -0
- data/ruby_libs/pav/string/bits.rb +523 -0
- data/ruby_libs/pav/string/ext.rb +58 -0
- data/ruby_libs/pav/string/observable.rb +155 -0
- data/ruby_libs/pav/string/text.rb +79 -0
- data/ruby_libs/pav/string/words.rb +42 -0
- data/ruby_libs/pav/sub_arr.rb +56 -0
- data/ruby_libs/pav/traced_obj.rb +79 -0
- data/web/index.html +280 -0
- data/web/media/icons/alt_handle.xpm +3832 -0
- data/web/media/icons/alt_handle_hover.xpm +3368 -0
- data/web/media/icons/alt_handle_pressed.xpm +3828 -0
- data/web/media/icons/blob.gif +0 -0
- data/web/media/icons/contour.gif +0 -0
- data/web/media/icons/contour_carpet.gif +0 -0
- data/web/media/icons/curve.gif +0 -0
- data/web/media/icons/curve_carpet.gif +0 -0
- data/web/media/icons/expand_closed.xpm +1791 -0
- data/web/media/icons/expand_closed_hover.xpm +1775 -0
- data/web/media/icons/expand_open.xpm +1788 -0
- data/web/media/icons/expand_open_hover.xpm +1752 -0
- data/web/media/icons/extract_curves/extract_curves-icon-rgb.ppm +14 -0
- data/web/media/icons/extract_curves/extract_curves-logo-rgb.gif +0 -0
- data/web/media/icons/extract_curves/trace_mark.xpm +38 -0
- data/web/media/icons/handle.xpm +213 -0
- data/web/media/icons/loop.gif +0 -0
- data/web/media/icons/loop_carpet.gif +0 -0
- data/web/media/icons/next.xpm +29 -0
- data/web/media/icons/next_hover.xpm +315 -0
- data/web/media/icons/next_pressed.xpm +144 -0
- data/web/media/icons/prev.xpm +29 -0
- data/web/media/icons/prev_hover.xpm +315 -0
- data/web/media/icons/prev_pressed.xpm +144 -0
- data/web/media/icons/shaved-core.gif +0 -0
- data/web/media/icons/vnext.xpm +29 -0
- data/web/media/icons/vprev.xpm +29 -0
- data/web/media/title.jpeg +0 -0
- data/web/stylesheets/default.css +20 -0
- metadata +192 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'pav/search'
|
2
|
+
|
3
|
+
module PGuiObj
|
4
|
+
|
5
|
+
class ObjInfoStrAssembler
|
6
|
+
def initialize(impl_obj)
|
7
|
+
@impl_obj = impl_obj
|
8
|
+
@attrs = []
|
9
|
+
@cmp_f = proc { |a,b|
|
10
|
+
if (res = (a[0] <=> b[0]))
|
11
|
+
res
|
12
|
+
else
|
13
|
+
a[1] <=> b[1]
|
14
|
+
end
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def set_attr(idx, key, value)
|
19
|
+
attr = [idx, key, value]
|
20
|
+
if (i = PSearch.bsearch(@attrs, attr, &@cmp_f)) >= 0
|
21
|
+
if @attrs[i][2] != value
|
22
|
+
@attrs[i][2] = value
|
23
|
+
self.rebuild
|
24
|
+
end
|
25
|
+
else
|
26
|
+
@attrs[-i-1, 0] = [attr]
|
27
|
+
self.rebuild
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def rebuild
|
32
|
+
@impl_obj.pguiobj_info_str = @attrs.collect { |a| a[2]+'.' }.
|
33
|
+
join("\n")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
module MObj
|
38
|
+
attr_accessor :pguiobj_info_str_asm
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'pav/guiobj/signals'
|
3
|
+
|
4
|
+
module PGuiObj
|
5
|
+
|
6
|
+
class Bool
|
7
|
+
end
|
8
|
+
|
9
|
+
class Enum < Array
|
10
|
+
def initialize(*args)
|
11
|
+
super()
|
12
|
+
while !args.empty?
|
13
|
+
unless (name = args.shift).kind_of?(String)
|
14
|
+
raise ArgumentError,
|
15
|
+
"Invalid Enumeration member name: #{name.inspect}!"
|
16
|
+
end
|
17
|
+
self << [name, args.shift]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def each_triplet
|
22
|
+
self.each_with_index { |k, m| yield(k, m[0], m[1]) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def each_member
|
26
|
+
self.each { |m| yield(m[0], m[1]) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def each_name
|
30
|
+
self.each { |m| yield(m[0]) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def value(k)
|
34
|
+
self.at(k)[1]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module MArgument
|
39
|
+
attr_accessor :pguiobj_type_class, :pguiobj_type_constraints,
|
40
|
+
:pguiobj_contraint_func, :pguiobj_default,
|
41
|
+
:pguiobj_name, :pguiobj_descr, :pguiobj_config,
|
42
|
+
:pguiobj_value_changed_flag
|
43
|
+
|
44
|
+
def pguiobj_init(klass, constraints=OpenStruct.new, constraint_func=nil,
|
45
|
+
default=nil, name=nil, descr=nil, config=OpenStruct.new)
|
46
|
+
@pguiobj_type_class = klass
|
47
|
+
@pguiobj_type_constraints = constraints
|
48
|
+
@pguiobj_constraint_func = constraint_func
|
49
|
+
@pguiobj_default = default
|
50
|
+
@pguiobj_name = name
|
51
|
+
@pguiobj_descr = descr
|
52
|
+
@pguiobj_config = config || OpenStruct.new
|
53
|
+
@pguiobj_value_changed_flag = Flag.new
|
54
|
+
raise ArgumentError, "Invalid constraints: #{
|
55
|
+
@pguiobj_type_constraints}/#{@pguiobj_type_constraints.class
|
56
|
+
}!" unless @pguiobj_type_constraints.kind_of?(OpenStruct) ||
|
57
|
+
@pguiobj_type_constraints.kind_of?(PGuiObj::Enum) ||
|
58
|
+
@pguiobj_type_constraints.kind_of?(PGuiObj::Bool) ||
|
59
|
+
@pguiobj_type_constraints.nil?
|
60
|
+
raise ArgumentError, "Invalid name: #{@pguiobj_name}/#{
|
61
|
+
@pguiobj_name.class}" unless @pguiobj_name.kind_of?(String)
|
62
|
+
raise ArgumentError, "Default value inconsistent with " +
|
63
|
+
"argument type: #{@pguiobj_default}/#{@pguiobj_default.class
|
64
|
+
} vs. #{@pguiobj_type_class}" unless @pguiobj_default.nil? ||
|
65
|
+
@pguiobj_default.kind_of?(@pguiobj_type_class) ||
|
66
|
+
(@pguiobj_type_class == Bool && (@pguiobj_default.
|
67
|
+
equal?(true) || @pguiobj_default.equal?(false))) ||
|
68
|
+
@pguiobj_type_class == Enum &&
|
69
|
+
@pguiobj_default.kind_of?(Integer)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
class Argument
|
74
|
+
include MArgument
|
75
|
+
|
76
|
+
alias_method :initialize, :pguiobj_init
|
77
|
+
end
|
78
|
+
|
79
|
+
class CancelCall < RuntimeError
|
80
|
+
end
|
81
|
+
|
82
|
+
module PMMethod
|
83
|
+
attr_accessor :pguiobj_implementation, :pguiobj_args,
|
84
|
+
:pguiobj_pre_call_flag, :pguiobj_cancel_call_flag,
|
85
|
+
:pguiobj_post_call_pre_gui_flag, :pguiobj_post_call_flag,
|
86
|
+
:pguiobj_name, :pguiobj_descr, :pguiobj_config,
|
87
|
+
:pguiobj_parent_meth, :pguiobj_children, :pguiobj_obj
|
88
|
+
|
89
|
+
def pguiobj_init(implementation, input_args, name=nil, descr=nil,
|
90
|
+
config=OpenStruct.new, pre_call_flag=nil, cancel_call_flag=nil,
|
91
|
+
pre_gui_flag=nil, post_call_flag=nil)
|
92
|
+
@pguiobj_implementation = implementation
|
93
|
+
@pguiobj_args = input_args
|
94
|
+
@pguiobj_name = name
|
95
|
+
@pguiobj_descr = descr
|
96
|
+
@pguiobj_config = config
|
97
|
+
@pguiobj_pre_call_flag = pre_call_flag || Flag.new
|
98
|
+
@pguiobj_cancel_call_flag = cancel_call_flag || Flag.new
|
99
|
+
@pguiobj_post_call_pre_gui_flag = pre_gui_flag || Flag.new
|
100
|
+
@pguiobj_post_call_flag = post_call_flag || Flag.new
|
101
|
+
raise ArgumentError,"Invalid config: #{@pguiobj_config}!" unless
|
102
|
+
@pguiobj_config.kind_of?(OpenStruct)
|
103
|
+
end
|
104
|
+
|
105
|
+
def pguiobj_remove_child(child)
|
106
|
+
return unless self.pguiobj_children
|
107
|
+
#$PDbgLog.sig_call(self)
|
108
|
+
#$PDbgLog.puts_msg "Children: #{self.pguiobj_children.inspect}"
|
109
|
+
i = nil
|
110
|
+
self.pguiobj_children.each_with_index { |c,i|
|
111
|
+
break if child.equal?(c) }
|
112
|
+
if i
|
113
|
+
self.pguiobj_children.delete_at(i)
|
114
|
+
else
|
115
|
+
warn("#{self.class.name}.remove_child: Child not " +
|
116
|
+
"found: #{child}!")
|
117
|
+
end
|
118
|
+
#$PDbgLog.sig_return
|
119
|
+
end
|
120
|
+
|
121
|
+
def pguiobj_clear_children
|
122
|
+
return unless self.pguiobj_children
|
123
|
+
self.pguiobj_children.clear
|
124
|
+
end
|
125
|
+
|
126
|
+
def pguiobj_instantiate(obj)
|
127
|
+
if (impl = @pguiobj_implementation).kind_of?(Symbol) ||
|
128
|
+
impl.kind_of?(String)
|
129
|
+
impl = obj.method(impl)
|
130
|
+
end
|
131
|
+
meth = PMethod.new(impl, @pguiobj_args, @pguiobj_name,
|
132
|
+
@pguiobj_descr, @pguiobj_config.dup,
|
133
|
+
@pguiobj_pre_call_flag.dup,
|
134
|
+
@pguiobj_cancel_call_flag.dup,
|
135
|
+
@pguiobj_post_call_pre_gui_flag.dup,
|
136
|
+
@pguiobj_post_call_flag.dup)
|
137
|
+
meth.pguiobj_obj = obj
|
138
|
+
meth
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
class PMethod
|
143
|
+
include PMMethod
|
144
|
+
|
145
|
+
alias_method :initialize, :pguiobj_init
|
146
|
+
end
|
147
|
+
|
148
|
+
class ObjDeathObserverInstcMeth
|
149
|
+
attr_reader :instc_meth
|
150
|
+
|
151
|
+
def initialize(instc_meth)
|
152
|
+
@instc_meth = instc_meth
|
153
|
+
end
|
154
|
+
|
155
|
+
def update(gui_obj, obj)
|
156
|
+
if @instc_meth.kind_of?(Symbol) || @instc_meth.kind_of?(String)
|
157
|
+
obj.method(@instc_meth).call
|
158
|
+
else
|
159
|
+
@instc_meth.call
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
class MethObserverChildrenNoDeleteBtn
|
165
|
+
def self.observe(meth)
|
166
|
+
meth.pguiobj_post_call_pre_gui_flag.add_observer(self)
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.update(obj, meth, child)
|
170
|
+
child.pguiobj_config.destroy_btn = false if
|
171
|
+
child.class <= PGuiObj::MObj
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
class MethObserverCachedAttr
|
176
|
+
def self.observe(meth)
|
177
|
+
meth.pguiobj_post_call_flag.add_observer(self)
|
178
|
+
end
|
179
|
+
|
180
|
+
def self.update(obj, meth, child, gui_child)
|
181
|
+
if child.class <= PGuiObj::MObj
|
182
|
+
meth.disable
|
183
|
+
child.pguiobj_post_destroy_flag.add_observer(
|
184
|
+
ObserverCallMeth.new(meth.method(:enable)))
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
class MethObserverCall
|
190
|
+
def self.create
|
191
|
+
self
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.update(obj, meth, *args)
|
195
|
+
meth.call
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
class ObserverCallMeth
|
200
|
+
attr_reader :meth
|
201
|
+
|
202
|
+
def initialize(meth)
|
203
|
+
@meth = meth
|
204
|
+
end
|
205
|
+
|
206
|
+
def update(*args)
|
207
|
+
@meth.call
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'pav/guiobj/method'
|
2
|
+
require 'pav/guiobj/signals'
|
3
|
+
|
4
|
+
module PGuiObj
|
5
|
+
|
6
|
+
module MObj
|
7
|
+
attr_accessor :pguiobj_methods, :pguiobj_config, :pguiobj_parent_meth,
|
8
|
+
:pguiobj_impl_obj
|
9
|
+
attr_reader :pguiobj_pre_destroy_flag, :pguiobj_post_destroy_flag,
|
10
|
+
:pguiobj_changed_flag
|
11
|
+
|
12
|
+
def pguiobj_init(methods=nil, config=nil)
|
13
|
+
@pguiobj_methods = methods ||
|
14
|
+
PGuiObj::MObj.pguiobj_get_methods_of(self.class) ||
|
15
|
+
[]
|
16
|
+
raise ArgumentError, "Invalid 'methods' argument: #{
|
17
|
+
@pguiobj_methods}!" unless
|
18
|
+
@pguiobj_methods.kind_of?(Array)
|
19
|
+
raise ArgumentError, "Invalid config: #{config}!" unless
|
20
|
+
config.kind_of?(OpenStruct)
|
21
|
+
@pguiobj_methods = @pguiobj_methods.collect { |meth|
|
22
|
+
meth.pguiobj_instantiate(self) }
|
23
|
+
@pguiobj_config = config || OpenStruct.new
|
24
|
+
@pguiobj_pre_destroy_flag = Flag.new
|
25
|
+
@pguiobj_post_destroy_flag = Flag.new
|
26
|
+
@pguiobj_changed_flag = Flag.new
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_pguiobj
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.pguiobj_get_methods_of(klass)
|
34
|
+
if (meths = klass.instance_variable_get(:@pguiobj_methods))
|
35
|
+
return meths
|
36
|
+
end
|
37
|
+
begin
|
38
|
+
if (meths = self.pguiobj_get_methods_of(klass.superclass))
|
39
|
+
klass.instance_variable_set(:@pguiobj_methods,
|
40
|
+
meths=meths.dup)
|
41
|
+
return meths
|
42
|
+
end
|
43
|
+
rescue NoMethodError
|
44
|
+
end
|
45
|
+
klass.instance_variable_set(:@pguiobj_methods, meths=[])
|
46
|
+
meths
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.pguiobj_add_methods_to(klass, *args)
|
50
|
+
#$PDbgLog.sig_call(self)
|
51
|
+
#$PDbgLog.puts_msg "args: #{args.inspect}"
|
52
|
+
#res=
|
53
|
+
self.pguiobj_get_methods_of(klass).concat(args)
|
54
|
+
#$PDbgLog.puts_msg caller[0,5].join('\n')
|
55
|
+
#$PDbgLog.sig_return(res.inspect)
|
56
|
+
#res
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
module MObjCollection
|
61
|
+
def pguiobj_length
|
62
|
+
self.length
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
class ObjCollection
|
67
|
+
attr_reader :collection
|
68
|
+
include PGuiObj::MObj
|
69
|
+
|
70
|
+
def self.create(collection, *args)
|
71
|
+
self.new(collection, *args)
|
72
|
+
end
|
73
|
+
|
74
|
+
def initialize(collection, *args)
|
75
|
+
@collection = collection
|
76
|
+
pguiobj_init(*args)
|
77
|
+
end
|
78
|
+
|
79
|
+
def pguiobj_length
|
80
|
+
@collection.length
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
module MObjArray
|
85
|
+
include MObj
|
86
|
+
include MObjCollection
|
87
|
+
|
88
|
+
def pguiobj_each_key_value
|
89
|
+
self.each_with_index { |obj, i|
|
90
|
+
yield(i, obj) if obj.kind_of?(PGuiObj::MObj)
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def pguiobj_each_value(&block)
|
95
|
+
self.each(&block)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
class ObjArray < ObjCollection
|
100
|
+
def pguiobj_each_key_value
|
101
|
+
@collection.each_with_index { |obj, i|
|
102
|
+
yield(i, obj) if obj.kind_of?(PGuiObj::MObj)
|
103
|
+
}
|
104
|
+
end
|
105
|
+
|
106
|
+
def pguiobj_each_value(&block)
|
107
|
+
@collection.each(&block)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
module MObjHash
|
112
|
+
include MObj
|
113
|
+
include MObjCollection
|
114
|
+
|
115
|
+
def pguiobj_each_key_value
|
116
|
+
self.each_pair { |k, obj|
|
117
|
+
yield(k, obj) if obj.kind_of?(PGuiObj::MObj)
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
class ObjHash < ObjCollection
|
123
|
+
def pguiobj_each_key_value
|
124
|
+
@collection.each_pair { |k, obj|
|
125
|
+
yield(k, obj) if obj.kind_of?(PGuiObj::MObj)
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
def pguiobj_each_value(&block)
|
130
|
+
@collection.each_value(&block)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class PMinHeap < Array
|
2
|
+
attr_reader :comparator
|
3
|
+
|
4
|
+
def initialize(&comparator)
|
5
|
+
if block_given?
|
6
|
+
@comparator = comparator
|
7
|
+
else
|
8
|
+
@comparator = proc { |a, b| a <=> b }
|
9
|
+
end
|
10
|
+
super()
|
11
|
+
end
|
12
|
+
|
13
|
+
def push(lm)
|
14
|
+
i = self.length
|
15
|
+
super(lm)
|
16
|
+
while i>0 && @comparator.call(self[parent_i=((i-1)>>1)], lm) > 0
|
17
|
+
self[i] = self[parent_i]
|
18
|
+
i = parent_i
|
19
|
+
end
|
20
|
+
self[i] = lm
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
alias_method :<<, :push
|
25
|
+
|
26
|
+
def pop
|
27
|
+
res = self.first
|
28
|
+
lm = super
|
29
|
+
return res if self.empty?
|
30
|
+
i = 0
|
31
|
+
len = self.length
|
32
|
+
while (chld_i = (i<<1) + 1) < len
|
33
|
+
l_chld_i = chld_i + 1
|
34
|
+
chld_i = l_chld_i if l_chld_i < len &&
|
35
|
+
@comparator.call(self[l_chld_i],self[chld_i])<0
|
36
|
+
if @comparator.call(lm, self[chld_i]) > 0
|
37
|
+
self[i] = self[chld_i]
|
38
|
+
i = chld_i
|
39
|
+
else
|
40
|
+
self[i] = lm
|
41
|
+
return res
|
42
|
+
end
|
43
|
+
end
|
44
|
+
self[i] = lm
|
45
|
+
res
|
46
|
+
end
|
47
|
+
|
48
|
+
alias_method :shift, :pop
|
49
|
+
|
50
|
+
def concat(arr)
|
51
|
+
arr.each { |lm| self.push(lm) }
|
52
|
+
self
|
53
|
+
end
|
54
|
+
end
|