class FpGrowth::FpTree::HeaderTable

Attributes

count[RW]
nodes[RW]

Public Class Methods

build(item, header_table) click to toggle source
# 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
new() click to toggle source
# File lib/fpgrowth/fp_tree/header_table.rb, line 12
def initialize()
  @count = Hash.new 0
  @nodes = Hash.new { Set.new() }
end

Public Instance Methods

<<(row) click to toggle source

Append a Row @param row Array as [item, support, node]

# 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() click to toggle source
# File lib/fpgrowth/fp_tree/header_table.rb, line 19
def keys
  @nodes.keys
end