Class: Rinda::TupleBag::HashTupleBin Private

Inherits:
Object
  • Object
show all
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.

HashTupleBin is a hash based bin class.

Instance Method Summary collapse

Constructor Details

#initializeHashTupleBin

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 a new instance of HashTupleBin.



321
322
323
# File 'lib/pione/patch/rinda-patch.rb', line 321

def initialize
  @bin = {}
end

Instance Method Details

#add(tuple) ⇒ 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.



329
330
331
332
333
334
335
# File 'lib/pione/patch/rinda-patch.rb', line 329

def add(tuple)
  unless @bin[key(tuple)]
    @bin[key(tuple)] = tuple
  else
    raise RedundantErrorTuple.new(tuple)
  end
end

#delete(tuple) ⇒ 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.



337
338
339
# File 'lib/pione/patch/rinda-patch.rb', line 337

def delete(tuple)
  @bin.delete(key(tuple))
end

#delete_ifObject

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.



341
342
343
344
345
346
# File 'lib/pione/patch/rinda-patch.rb', line 341

def delete_if
  if block_given?
    @bin.delete_if {|_, val| yield(val)}
  end
  return @bin
end

#each(*args) ⇒ 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.



371
372
373
# File 'lib/pione/patch/rinda-patch.rb', line 371

def each(*args)
  @bin.values.each(*args)
end

#elementsObject

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.



325
326
327
# File 'lib/pione/patch/rinda-patch.rb', line 325

def elements
  @bin.values
end

#find(template, &b) ⇒ 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.



348
349
350
351
352
353
354
355
356
357
358
# File 'lib/pione/patch/rinda-patch.rb', line 348

def find(template, &b)
  if key(template) && @bin.has_key?(key(template))
    tuple = @bin[key(template)]
    return tuple if yield(tuple)
  else
    @bin.values.each do |tuple|
      return tuple if yield(tuple)
    end
  end
  return nil
end

#find_all(template, &b) ⇒ 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.



360
361
362
363
364
365
366
367
368
369
# File 'lib/pione/patch/rinda-patch.rb', line 360

def find_all(template, &b)
  if key(template) && @bin.has_key?(key(template))
    tuple = @bin[key(template)]
    return tuple if yield(tuple)
  else
    return @bin.values.find_all {|tuple|
      yield(tuple)
    }
  end
end