| Class | Rinda::TupleBag |
| In: |
lib/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 lib/rinda/tuplespace.rb, line 355
355: def delete_unless_alive
356: deleted = []
357: @hash.keys.each do |size|
358: ary = []
359: @hash[size].each do |tuple|
360: if tuple.alive?
361: ary.push(tuple)
362: else
363: deleted.push(tuple)
364: end
365: end
366: @hash[size] = ary
367: end
368: deleted
369: end
Finds a live tuple that matches template.
# File lib/rinda/tuplespace.rb, line 335
335: def find(template)
336: @hash.fetch(template.size, []).find do |tuple|
337: tuple.alive? && template.match(tuple)
338: end
339: end
Finds all live tuples that match template.
# File lib/rinda/tuplespace.rb, line 326
326: def find_all(template)
327: @hash.fetch(template.size, []).find_all do |tuple|
328: tuple.alive? && template.match(tuple)
329: end
330: end