Class: FpGrowth::FpTree::HeaderTable
- Inherits:
-
Object
- Object
- FpGrowth::FpTree::HeaderTable
- Defined in:
- lib/fpgrowth/fp_tree/header_table.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Class Method Summary collapse
Instance Method Summary collapse
-
#<<(row) ⇒ Object
Append a Row.
-
#initialize ⇒ HeaderTable
constructor
A new instance of HeaderTable.
- #keys ⇒ Object
Constructor Details
#initialize ⇒ HeaderTable
Returns a new instance of HeaderTable.
12 13 14 15 |
# File 'lib/fpgrowth/fp_tree/header_table.rb', line 12 def initialize() @count = Hash.new 0 @nodes = Hash.new { Set.new() } end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
17 18 19 |
# File 'lib/fpgrowth/fp_tree/header_table.rb', line 17 def count @count end |
#nodes ⇒ Object
Returns the value of attribute nodes.
17 18 19 |
# File 'lib/fpgrowth/fp_tree/header_table.rb', line 17 def nodes @nodes end |
Class Method Details
.build(item, header_table) ⇒ Object
6 7 8 9 |
# File 'lib/fpgrowth/fp_tree/header_table.rb', line 6 def self.build(item, header_table) builder = Builder::HeaderTableBuilder.new(item, header_table) return builder.execute() end |
Instance Method Details
#<<(row) ⇒ Object
Append a Row
26 27 28 29 30 31 |
# File 'lib/fpgrowth/fp_tree/header_table.rb', line 26 def << (row) # Add a link for m in HeaderTable @nodes[row[0]] = @nodes[row[0]] << row[2] # Add support m = previous + n @count[row[0]] += row[1] end |
#keys ⇒ Object
19 20 21 |
# File 'lib/fpgrowth/fp_tree/header_table.rb', line 19 def keys @nodes.keys end |