TupleBag
is an unordered collection of tuples. It is the basis of Tuplespace.
Namespace
Methods
- D
-
- F
-
- H
-
- P
-
Instance Public methods
delete(tuple)
Link
Source:
show
| on GitHub
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_unless_alive()
Link
Delete tuples which dead tuples from the TupleBag
, returning the deleted tuples.
Source:
show
| on GitHub
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
find(template)
Link
Finds a live tuple that matches template
.
Source:
show
| on GitHub
def find(template)
bin_for_find(template).find do |tuple|
tuple.alive? && template.match(tuple)
end
end
find_all(template)
Link
Finds all live tuples that match template
.
Source:
show
| on GitHub
def find_all(template)
bin_for_find(template).find_all do |tuple|
tuple.alive? && template.match(tuple)
end
end
find_all_template(tuple)
Link
Finds all tuples in the TupleBag
which when treated as templates, match tuple
and are alive.
Source:
show
| on GitHub
def find_all_template(tuple)
@enum.find_all do |template|
template.alive? && template.match(tuple)
end
end
has_expires?()
Link
true
if the TupleBag
to see if it has any expired entries.
Source:
show
| on GitHub
def has_expires?
@enum.find do |tuple|
tuple.expires
end
end
push(tuple)
Link
Source:
show
| on GitHub
def push(tuple)
key = bin_key(tuple)
@hash[key] ||= TupleBin.new
@hash[key].add(tuple)
end