Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more
Object
TupleBag is an unordered collection of tuples. It is the basis of Tuplespace.
Removes tuple
from the TupleBag.
# File rinda/tuplespace.rb, line 342 def delete(tuple) key = bin_key(tuple) bin = @hash[key] return nil unless bin bin.delete(tuple) @hash.delete(key) if bin.empty? tuple end
Delete tuples which dead tuples from the TupleBag, returning the deleted tuples.
# File rinda/tuplespace.rb, line 382 def delete_unless_alive deleted = [] @hash.each do |key, bin| bin.delete_if do |tuple| if tuple.alive? false else deleted.push(tuple) true end end end deleted end
Finds a live tuple that matches template
.
# File rinda/tuplespace.rb, line 362 def find(template) bin_for_find(template).find do |tuple| tuple.alive? && template.match(tuple) end end
Finds all live tuples that match template
.
# File rinda/tuplespace.rb, line 353 def find_all(template) bin_for_find(template).find_all do |tuple| tuple.alive? && template.match(tuple) end end
Finds all tuples in the TupleBag which when
treated as templates, match tuple
and are alive.
# File rinda/tuplespace.rb, line 372 def find_all_template(tuple) @enum.find_all do |template| template.alive? && template.match(tuple) end end
true
if the TupleBag to see if it
has any expired entries.
# File rinda/tuplespace.rb, line 324 def has_expires? @enum.find do |tuple| tuple.expires end end
Add tuple
to the TupleBag.
# File rinda/tuplespace.rb, line 333 def push(tuple) key = bin_key(tuple) @hash[key] ||= TupleBin.new @hash[key].add(tuple) end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.