class Fathom::AdjacencyMatrix
Public Class Methods
new(default=0)
click to toggle source
# File lib/fathom/data/adjacency_matrix.rb, line 6 def initialize(default=0) @default = default @store = Hash.new(default) end
Public Instance Methods
[](parent, child)
click to toggle source
# File lib/fathom/data/adjacency_matrix.rb, line 11 def [](parent, child) @store[[parent, child]] end
[]=(parent, child, value)
click to toggle source
# File lib/fathom/data/adjacency_matrix.rb, line 15 def []=(parent, child, value) if value == @default @store.delete([parent, child]) # preserves a little memory else @store[[parent, child]] = value end end
each() { |k,v| ... }
click to toggle source
# File lib/fathom/data/adjacency_matrix.rb, line 23 def each @store.each {|k, v| yield(k,v)} end