Class: DancingLinks::SparseMatrix::SparseMatrixNode

Inherits:
Object
  • Object
show all
Defined in:
lib/dancing_links.rb

Overview

All nodes within the matrix are instances of this class.

Direct Known Subclasses

SparseMatrixHeader, SparseMatrixRoot

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row_num = -1,, header = self, left = self, right = self, up = self, down = self) ⇒ SparseMatrixNode

Returns a new instance of SparseMatrixNode.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/dancing_links.rb', line 45

def initialize row_num=-1, header=self, left=self, right=self, up=self, down=self
  @row_num = row_num
  @header = header
  @left = left
  @right = right
  @up = up
  @down = down
  
  #puts "row: #{row_num}"
  
  @header.count = (@header.count + 1) if @header
  @left.right = self if @left
  @right.left = self if @right
  @up.down = self if @up
  @down.up = self if @down
end

Instance Attribute Details

#downObject

Returns the value of attribute down.



62
63
64
# File 'lib/dancing_links.rb', line 62

def down
  @down
end

#headerObject

Returns the value of attribute header.



62
63
64
# File 'lib/dancing_links.rb', line 62

def header
  @header
end

#leftObject

Returns the value of attribute left.



62
63
64
# File 'lib/dancing_links.rb', line 62

def left
  @left
end

#rightObject

Returns the value of attribute right.



62
63
64
# File 'lib/dancing_links.rb', line 62

def right
  @right
end

#row_numObject

Returns the value of attribute row_num.



62
63
64
# File 'lib/dancing_links.rb', line 62

def row_num
  @row_num
end

#upObject

Returns the value of attribute up.



62
63
64
# File 'lib/dancing_links.rb', line 62

def up
  @up
end