Class: Node
- Inherits:
-
Object
- Object
- Node
- Includes:
- NodeExtensions
- Defined in:
- lib/support/node.rb,
lib/visitor/numbering_visitor.rb
Constant Summary collapse
- CURRENT_ENDING_OFFSET =
Leaf nodes use this due to Rule 1: once a leaf, always a leaf
-1
- UNSPECIFIED_OFFSET =
Root uses this, it has no incoming edge, yet as a Node has incoming edge offset properties
-2
- LEAF_DEPTH =
Leaf nodes get special depth, since they vary as characters get added
-3
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#incomingEdgeEndOffset ⇒ Object
Returns the value of attribute incomingEdgeEndOffset.
-
#incomingEdgeStartOffset ⇒ Object
Returns the value of attribute incomingEdgeStartOffset.
-
#nodeId ⇒ Object
readonly
Returns the value of attribute nodeId.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#suffixLink ⇒ Object
Returns the value of attribute suffixLink.
-
#suffixOffset ⇒ Object
Returns the value of attribute suffixOffset.
Attributes included from NodeExtensions
#binaryTreeHeight, #dfsNumber, #numberNodesInSubtree, #runBits, #runHead, #runTail
Instance Method Summary collapse
-
#createAccessor(name) ⇒ Object
some algorithms require additional accessors, allow these to be created dynamically.
-
#each_suffix ⇒ Object
suffix offset enumerator (not sure this belongs here).
- #incomingEdgeLength ⇒ Object
-
#initialize(nodeId, suffixOffset = UNSPECIFIED_OFFSET) ⇒ Node
constructor
A new instance of Node.
- #isInternal ⇒ Object
- #isLeaf ⇒ Object
- #isRoot ⇒ Object
Constructor Details
#initialize(nodeId, suffixOffset = UNSPECIFIED_OFFSET) ⇒ Node
Returns a new instance of Node.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/support/node.rb', line 15 def initialize(nodeId, suffixOffset = UNSPECIFIED_OFFSET) @nodeId = nodeId @incomingEdgeStartOffset = UNSPECIFIED_OFFSET @incomingEdgeEndOffset = UNSPECIFIED_OFFSET @suffixOffset = suffixOffset @parent = nil @suffixLink = nil @children = nil end |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
12 13 14 |
# File 'lib/support/node.rb', line 12 def children @children end |
#incomingEdgeEndOffset ⇒ Object
Returns the value of attribute incomingEdgeEndOffset.
11 12 13 |
# File 'lib/support/node.rb', line 11 def incomingEdgeEndOffset @incomingEdgeEndOffset end |
#incomingEdgeStartOffset ⇒ Object
Returns the value of attribute incomingEdgeStartOffset.
11 12 13 |
# File 'lib/support/node.rb', line 11 def incomingEdgeStartOffset @incomingEdgeStartOffset end |
#nodeId ⇒ Object (readonly)
Returns the value of attribute nodeId.
13 14 15 |
# File 'lib/support/node.rb', line 13 def nodeId @nodeId end |
#parent ⇒ Object
Returns the value of attribute parent.
12 13 14 |
# File 'lib/support/node.rb', line 12 def parent @parent end |
#suffixLink ⇒ Object
Returns the value of attribute suffixLink.
12 13 14 |
# File 'lib/support/node.rb', line 12 def suffixLink @suffixLink end |
#suffixOffset ⇒ Object
Returns the value of attribute suffixOffset.
11 12 13 |
# File 'lib/support/node.rb', line 11 def suffixOffset @suffixOffset end |
Instance Method Details
#createAccessor(name) ⇒ Object
some algorithms require additional accessors, allow these to be created dynamically
45 46 47 |
# File 'lib/support/node.rb', line 45 def createAccessor(name) self.class.send(:attr_accessor, name) end |
#each_suffix ⇒ Object
suffix offset enumerator (not sure this belongs here)
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/support/node.rb', line 52 def each_suffix if (self.isLeaf) then yield suffixOffset else children.keys.sort.each do |key| children[key].each_suffix do |suffixOffset| yield suffixOffset end end end end |
#incomingEdgeLength ⇒ Object
38 39 40 |
# File 'lib/support/node.rb', line 38 def incomingEdgeLength return @incomingEdgeEndOffset - @incomingEdgeStartOffset + 1 end |
#isInternal ⇒ Object
34 35 36 |
# File 'lib/support/node.rb', line 34 def isInternal return !isLeaf && !isRoot end |
#isLeaf ⇒ Object
30 31 32 |
# File 'lib/support/node.rb', line 30 def isLeaf return @incomingEdgeEndOffset == CURRENT_ENDING_OFFSET end |
#isRoot ⇒ Object
26 27 28 |
# File 'lib/support/node.rb', line 26 def isRoot return @parent == nil end |