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



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

def initialize
  @bin = []
end

Instance Method Details

#add(tuple) ⇒ Object



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

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

#delete(tuple) ⇒ Object



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

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

#findObject



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

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