Class | Rinda::TupleBag |
In: |
rinda/tuplespace.rb
|
Parent: | Object |
TupleBag is an unordered collection of tuples. It is the basis of Tuplespace.
Delete tuples which dead tuples from the TupleBag, returning the deleted tuples.
# File rinda/tuplespace.rb, line 355 def delete_unless_alive deleted = [] @hash.keys.each do |size| ary = [] @hash[size].each do |tuple| if tuple.alive? ary.push(tuple) else deleted.push(tuple) end end @hash[size] = ary end deleted end
Finds a live tuple that matches template.
# File rinda/tuplespace.rb, line 335 def find(template) @hash.fetch(template.size, []).find do |tuple| tuple.alive? && template.match(tuple) end end
Finds all live tuples that match template.
# File rinda/tuplespace.rb, line 326 def find_all(template) @hash.fetch(template.size, []).find_all do |tuple| tuple.alive? && template.match(tuple) end end