Class: Array
Overview
Instance Method Summary
collapse
#<
#<=
#===, #old_triple_equal4Set
#to_bset
#**
Instance Method Details
1202
1203
1204
1205
1206
1207
|
# File 'lib/setfu.rb', line 1202
def &(item)
return old_and_method4set(item) if (item.type_of? Array)
a = BitSet.new(self)
b = BitSet.new(item)
return a & b
end
|
1196
1197
1198
1199
1200
1201
|
# File 'lib/setfu.rb', line 1196
def -(item)
return old_subtract_method4set(item) if (item.type_of? Array)
a = BitSet.new(self)
b = BitSet.new(item)
return a - b
end
|
1186
1187
1188
1189
1190
1191
1192
1193
1194
|
# File 'lib/setfu.rb', line 1186
def ^(item)
if item.type_of? Array
return (self | item) - (self & item)
else
a = BitSet.new(self)
b = BitSet.new(item)
return a ^ b
end
end
|
#ascending? ⇒ Boolean
additions to be used by other future gems:
50
51
52
53
54
55
56
57
58
|
# File 'lib/setfu.rb', line 50
def ascending?
return false unless count >=2
cnt = self.length - 1
cnt.times do |ii|
return false unless self[ii+1] >= self[ii]
end
return false if first==last true
end
|
#descending? ⇒ Boolean
59
60
61
62
63
64
65
66
67
|
# File 'lib/setfu.rb', line 59
def descending?
return false unless count >=2
cnt = self.length - 1
cnt.times do |ii|
return false unless self[ii+1] <= self[ii]
end
return false if first==last true
end
|
#members_to_bset ⇒ Object
375
376
377
378
|
# File 'lib/setfu.rb', line 375
def members_to_bset
Setfu::bset_elements(self)
self
end
|
#old_and_method4set ⇒ Object
1176
|
# File 'lib/setfu.rb', line 1176
alias_method :old_and_method4set, :&
|
#old_or_method4set ⇒ Object
1177
|
# File 'lib/setfu.rb', line 1177
alias_method :old_or_method4set, :|
|
#old_subtract_method4set ⇒ Object
1175
|
# File 'lib/setfu.rb', line 1175
alias_method :old_subtract_method4set, :-
|
#peek(n = 0) ⇒ Object
43
44
45
|
# File 'lib/setfu.rb', line 43
def peek(n=0)
return self[count-n-1]
end
|
38
39
40
41
42
|
# File 'lib/setfu.rb', line 38
def pop2
a = pop
b = pop
return [a,b]
end
|
#reduce_tuples(passes = 1) ⇒ Object
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
|
# File 'lib/setfu.rb', line 390
def reduce_tuples(passes = 1)
Setfu::bset_elements(self)
Setfu::untag_bset_elements(self)
total_count = 0
loop do
tc = Setfu::reduce(self)
if tc < 0
total_count = -1
break
end
break if tc == 0
total_count += tc
passes -= 1
break if passes <= 0
end
total_count
end
|
#sorted? ⇒ Boolean
68
69
70
71
72
73
74
|
# File 'lib/setfu.rb', line 68
def sorted?
return false unless count >=1
return true if (self & self).count == 1 return true if ascending?
return true if descending?
false
end
|
#stack_rot ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/setfu.rb', line 30
def stack_rot
a = pop
b = pop
c = pop
push a
push c
push b
end
|
#stack_swap ⇒ Object
24
25
26
27
28
29
|
# File 'lib/setfu.rb', line 24
def stack_swap
a = pop
b = pop
push a
push b
end
|
387
388
389
|
# File 'lib/setfu.rb', line 387
def tuple
Setfu::tuple(self)
end
|
#tuple? ⇒ Boolean
384
385
386
|
# File 'lib/setfu.rb', line 384
def tuple?
Setfu::tuple?(self)
end
|
379
380
381
382
383
|
# File 'lib/setfu.rb', line 379
def tuples
members_to_bset
rtn = Setfu::tuples(self)
rtn
end
|
1208
1209
1210
1211
1212
1213
|
# File 'lib/setfu.rb', line 1208
def |(item)
return old_or_method4set(item) if (item.type_of? Array)
a = BitSet.new(self)
b = BitSet.new(item)
return a | b
end
|