Class: Rinda::TupleBag::DomainTupleBin Private
- Defined in:
- lib/pione/patch/rinda-patch.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
DomainTupleBin should take tuples that have domain.
DomainTupleBin is a domain based TupleBin class.
Instance Method Summary collapse
-
#add(tuple) ⇒ void
private
Add the tuple into the tuple space.
-
#delete(tuple) ⇒ void
private
Deletes the tuple.
-
#delete_if {|Array| ... } ⇒ void
private
Deletes tuples that match the block.
-
#each(*args) ⇒ Enumerator
private
Returns an iterator of the values.
- #elements ⇒ Object private
-
#find(template) {|Array| ... } ⇒ Array
private
Finds a tuple matched by the template.
-
#find_all(template) {|Array| ... } ⇒ Array<Array>
private
Finds all tuples matched by the template.
-
#initialize ⇒ DomainTupleBin
constructor
private
Creates a new bin.
Methods inherited from TupleBin
Constructor Details
#initialize ⇒ DomainTupleBin
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new bin.
126 127 128 |
# File 'lib/pione/patch/rinda-patch.rb', line 126 def initialize @bin = {} end |
Instance Method Details
#add(tuple) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Add the tuple into the tuple space.
135 136 137 138 139 140 141 |
# File 'lib/pione/patch/rinda-patch.rb', line 135 def add(tuple) if dom = domain(tuple) @bin[dom] = tuple else raise RuntimeError end end |
#delete(tuple) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Deletes the tuple.
147 148 149 |
# File 'lib/pione/patch/rinda-patch.rb', line 147 def delete(tuple) @bin.delete(domain(tuple)) end |
#delete_if {|Array| ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Deletes tuples that match the block.
155 156 157 158 |
# File 'lib/pione/patch/rinda-patch.rb', line 155 def delete_if return @bin unless block_given? @bin.delete_if {|key, val| yield(val)} end |
#each(*args) ⇒ Enumerator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an iterator of the values.
204 205 206 |
# File 'lib/pione/patch/rinda-patch.rb', line 204 def each(*args) @bin.values.each(*args) end |
#elements ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
160 161 162 |
# File 'lib/pione/patch/rinda-patch.rb', line 160 def elements @bin.values end |
#find(template) {|Array| ... } ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds a tuple matched by the template. This method searches by index when the template has the domain, otherwise by liner.
172 173 174 175 176 177 178 179 180 |
# File 'lib/pione/patch/rinda-patch.rb', line 172 def find(template, &b) if key = domain(template) # indexed search return @bin[key] else # liner search return @bin.values.find {|val| yield(val)} end end |
#find_all(template) {|Array| ... } ⇒ Array<Array>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Finds all tuples matched by the template. This method searches by index when the template has the domain, otherwise by liner.
190 191 192 193 194 195 196 197 198 199 |
# File 'lib/pione/patch/rinda-patch.rb', line 190 def find_all(template, &b) return @bin.values unless block_given? if key = domain(template) # indexed search return [@bin[key]] else # liner search return @bin.select{|_, val| yield(val)}.values end end |