class LogicTools::HashCounter
Class for storing and counting occurences of objects.
Public Class Methods
new()
click to toggle source
Creates a new hash counter.
# File lib/logic_tools/minimal_column_covers.rb, line 53 def initialize self.default = 0 end
Public Instance Methods
dec(element)
click to toggle source
Decrements the number of element
.
# File lib/logic_tools/minimal_column_covers.rb, line 63 def dec(element) if (self[elem] -= 1) == 0 then # No more instance of the element, remove the entry. self.delete(elem) end end
inc(element)
click to toggle source
Increments the number of element
.
# File lib/logic_tools/minimal_column_covers.rb, line 58 def inc(element) self[elem] += 1 end