Class: Rinda::TupleBag::TupleBin

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/rinda/tuplespace.rb

Instance Method Summary collapse

Constructor Details

#initializeTupleBin

Returns a new instance of TupleBin.



294
295
296
# File 'lib/rinda/tuplespace.rb', line 294

def initialize
  @bin = []
end

Instance Method Details

#add(tuple) ⇒ Object



298
299
300
# File 'lib/rinda/tuplespace.rb', line 298

def add(tuple)
  @bin.push(tuple)
end

#delete(tuple) ⇒ Object



302
303
304
305
# File 'lib/rinda/tuplespace.rb', line 302

def delete(tuple)
  idx = @bin.rindex(tuple)
  @bin.delete_at(idx) if idx
end

#findObject



307
308
309
310
311
312
# File 'lib/rinda/tuplespace.rb', line 307

def find
  @bin.reverse_each do |x|
    return x if yield(x)
  end
  nil
end